@arcgis/portal-components 5.2.0-next.135 → 5.2.0-next.136
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/dist/cdn/{7RVBLIFE.js → 23X56P4K.js} +1 -1
- package/dist/cdn/2I5SLQC5.js +2 -0
- package/dist/cdn/3R4PPD5N.js +2 -0
- package/dist/cdn/3SO52LKS.js +2 -0
- package/dist/cdn/{DOOROTIK.js → 456JKNCU.js} +1 -1
- package/dist/cdn/{6D5PKX2I.js → 4ZTWQN6Q.js} +1 -1
- package/dist/cdn/5FDUO7J4.js +2 -0
- package/dist/cdn/5FOWUL6I.js +2 -0
- package/dist/cdn/{ISJALOUO.js → 6BMWSGLA.js} +1 -1
- package/dist/cdn/{BQR4YDYX.js → 6EY5GHKE.js} +1 -1
- package/dist/cdn/6L564FRK.js +2 -0
- package/dist/cdn/6LST5YZY.js +2 -0
- package/dist/cdn/6MWSS5YF.js +2 -0
- package/dist/cdn/{HCVZKEPD.js → 7NK6UF47.js} +1 -1
- package/dist/cdn/{3GRYBMC6.js → 7NQY5QJK.js} +1 -1
- package/dist/cdn/ADZAKBOJ.js +2 -0
- package/dist/cdn/AE574B3G.js +2 -0
- package/dist/cdn/AIMQTMDU.js +2 -0
- package/dist/cdn/AWCYG2JJ.js +2 -0
- package/dist/cdn/B3NVWHCS.js +2 -0
- package/dist/cdn/BRJE3G3H.js +2 -0
- package/dist/cdn/{HHO6EQZB.js → C5U7YKVI.js} +1 -1
- package/dist/cdn/C5VUNN4M.js +2 -0
- package/dist/cdn/{GXGPSLRY.js → CVOWIH4J.js} +1 -1
- package/dist/cdn/CWSEBETE.js +4 -0
- package/dist/cdn/D6QHNXEH.js +2 -0
- package/dist/cdn/{MXM422M5.js → D7LRCAK4.js} +1 -1
- package/dist/cdn/DF5GVVDW.js +2 -0
- package/dist/cdn/{E5MBJ2OM.js → DIKRXF22.js} +1 -1
- package/dist/cdn/DPGQZ4NM.js +2 -0
- package/dist/cdn/{PJ4ISUWJ.js → E3FQ4QWE.js} +1 -1
- package/dist/cdn/EPEF6NGS.js +2 -0
- package/dist/cdn/FEBUVUR5.js +2 -0
- package/dist/cdn/{JI4MTBTR.js → FFLIAQOL.js} +1 -1
- package/dist/cdn/FQOOFBPI.js +2 -0
- package/dist/cdn/FQYC25GN.js +2 -0
- package/dist/cdn/FTKD53UG.js +209 -0
- package/dist/cdn/{A7HUDHZU.js → GEZH4D32.js} +1 -1
- package/dist/cdn/GTZ4LKEQ.js +2 -0
- package/dist/cdn/GYA7R4F6.js +2 -0
- package/dist/cdn/H2M5XZPJ.js +2 -0
- package/dist/cdn/HNA5PWNK.js +2 -0
- package/dist/cdn/{BFSOZIZT.js → HP5GK5ZF.js} +1 -1
- package/dist/cdn/{PWOYHZOU.js → J537SBGI.js} +1 -1
- package/dist/cdn/{CBL5PQQB.js → JUDF3TYJ.js} +1 -1
- package/dist/cdn/KC4FTTKP.js +2 -0
- package/dist/cdn/{PIAWVFRU.js → KIKEE2KY.js} +1 -1
- package/dist/cdn/{576MGJVB.js → LNWWUPFK.js} +1 -1
- package/dist/cdn/LP4IB3PV.js +2 -0
- package/dist/cdn/LRHPL6B5.js +2 -0
- package/dist/cdn/MCX22B23.js +2 -0
- package/dist/cdn/{Q6VNNX2L.js → MQISQ7P3.js} +1 -1
- package/dist/cdn/MSQLYJTO.js +2 -0
- package/dist/cdn/MY7AYBBR.js +2 -0
- package/dist/cdn/NDRCB2K3.js +2 -0
- package/dist/cdn/NEZSLCHJ.js +2 -0
- package/dist/cdn/NICTB76A.js +2 -0
- package/dist/cdn/{AUVW676U.js → NXFE6R2N.js} +1 -1
- package/dist/cdn/ODH2VAWC.js +2 -0
- package/dist/cdn/OJNU7H3F.js +2 -0
- package/dist/cdn/{MXSBJ4UL.js → OQGUCK3G.js} +1 -1
- package/dist/cdn/{47AEGGQB.js → OV5O7YP4.js} +1 -1
- package/dist/cdn/OYGYOH2E.js +2 -0
- package/dist/cdn/Q5J7GRWI.js +2 -0
- package/dist/cdn/QBV7VDQK.js +2 -0
- package/dist/cdn/QCOJMMT3.js +2 -0
- package/dist/cdn/QKK6N2AN.js +2 -0
- package/dist/cdn/QSAZVVVL.js +2 -0
- package/dist/cdn/{YWS3KTEP.js → R3QN5WF2.js} +1 -1
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/{636D2CQX.js → RBGARTND.js} +1 -1
- package/dist/cdn/SG7Z5VLB.js +2 -0
- package/dist/cdn/T2HQNZ36.js +2 -0
- package/dist/cdn/UGRFT75G.js +2 -0
- package/dist/cdn/UKHCSMA4.js +2 -0
- package/dist/cdn/UQKT5JQZ.js +2 -0
- package/dist/cdn/{BGZVQGWE.js → USGROSML.js} +1 -1
- package/dist/cdn/V5YXPHYD.js +2 -0
- package/dist/cdn/{HNE7TSIC.js → VLEOBWFC.js} +1 -1
- package/dist/cdn/{FN64OJAN.js → WDMNL6PJ.js} +1 -1
- package/dist/cdn/WZU4HO4T.js +2 -0
- package/dist/cdn/{4PQO4X4X.js → XKC6SPS4.js} +1 -1
- package/dist/cdn/XU3QHJD7.js +2 -0
- package/dist/cdn/{OJGDXUKZ.js → XUPYBBRI.js} +1 -1
- package/dist/cdn/Y3YIMI2Z.js +463 -0
- package/dist/cdn/YUQFNMEZ.js +2 -0
- package/dist/cdn/{E37TWXOS.js → YXGR4ETK.js} +1 -1
- package/dist/cdn/ZAIRH5DL.js +2 -0
- package/dist/cdn/ZSILF72K.js +2 -0
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-add-gps-metadata/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-browser/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/portal-entity-picker/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-group-badges/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-group-browser/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-group-card/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-item-badges/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-item-card/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-item-favorite/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-item-type/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-navigation/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-sublayer-type/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/portal-user-popup/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-portal-navigation/index.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +7 -7
- package/dist/cdn/2N267CQJ.js +0 -2
- package/dist/cdn/2WTWI376.js +0 -2
- package/dist/cdn/3HEKI54S.js +0 -2
- package/dist/cdn/5OLOB42V.js +0 -2
- package/dist/cdn/5QJFE2TZ.js +0 -2
- package/dist/cdn/5ZOQN2RD.js +0 -2
- package/dist/cdn/6OGBUPNX.js +0 -2
- package/dist/cdn/74ZBFN22.js +0 -2
- package/dist/cdn/A7XG2CGZ.js +0 -2
- package/dist/cdn/AROVW3UH.js +0 -2
- package/dist/cdn/BQPBJWMI.js +0 -2
- package/dist/cdn/D7MON5HR.js +0 -2
- package/dist/cdn/DP3RFREY.js +0 -2
- package/dist/cdn/DQJLTSBY.js +0 -2
- package/dist/cdn/FEXHSQ6Z.js +0 -2
- package/dist/cdn/FS5XBCHL.js +0 -2
- package/dist/cdn/GBFEHPAL.js +0 -2
- package/dist/cdn/GKBQITIV.js +0 -2
- package/dist/cdn/GX6RPWBL.js +0 -2
- package/dist/cdn/HNIPFKPI.js +0 -2
- package/dist/cdn/IAUHMY3T.js +0 -2
- package/dist/cdn/ID2H3IUI.js +0 -2
- package/dist/cdn/INRJRPFE.js +0 -2
- package/dist/cdn/IVQXK46W.js +0 -2
- package/dist/cdn/IYNMMRVZ.js +0 -2
- package/dist/cdn/JYORYNSD.js +0 -2
- package/dist/cdn/KFIQURH5.js +0 -2
- package/dist/cdn/L4JQV42D.js +0 -2
- package/dist/cdn/M6UW4NQ5.js +0 -2
- package/dist/cdn/MTUFZXUQ.js +0 -2
- package/dist/cdn/NDZYRGOO.js +0 -2
- package/dist/cdn/OT3GDLUB.js +0 -2
- package/dist/cdn/OTTQ54QN.js +0 -2
- package/dist/cdn/QABX5STK.js +0 -2
- package/dist/cdn/SG23BRS4.js +0 -2
- package/dist/cdn/T3B2IOBY.js +0 -2
- package/dist/cdn/TV3JAEAU.js +0 -2
- package/dist/cdn/UMKPSK3Y.js +0 -2
- package/dist/cdn/UXZTO272.js +0 -4
- package/dist/cdn/VLIJNVNM.js +0 -2
- package/dist/cdn/VOZJP55F.js +0 -2
- package/dist/cdn/VPAW5MZH.js +0 -2
- package/dist/cdn/WEKTI5QA.js +0 -2
- package/dist/cdn/WHX4LFPO.js +0 -670
- package/dist/cdn/WLSTJTHH.js +0 -2
- package/dist/cdn/WRXH4QIH.js +0 -2
- package/dist/cdn/YBYLRWDO.js +0 -2
- package/dist/cdn/YUV3L73F.js +0 -2
- package/dist/cdn/Z2K2TPTY.js +0 -2
- package/dist/cdn/ZDA2LVTP.js +0 -2
package/dist/cdn/WHX4LFPO.js
DELETED
|
@@ -1,670 +0,0 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import c from"./55FL7WQV.js";import b from"./T3RJKB2A.js";import"./QDWOQBO3.js";import{a as ZP,c as VP,e as WP,f as qP,g as KP}from"./UZCHLKLO.js";import"./25XJ66JO.js";import"./5YDITHQA.js";import a from"./F3ODJVJC.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import{a as Zp,b as UE,d as Jh}from"./2GBRZSEC.js";import{a as LE}from"./OJGDXUKZ.js";import"./HHO6EQZB.js";import"./ISJALOUO.js";import{K as Fp,L as Bp,M as jE,S as DE,h as RE,j as Oi,n as NE,w as ME,z as zE}from"./UXZTO272.js";import{$ as hP,$a as Kt,A as tP,Aa as tg,B as rP,Ba as er,C as Qh,Ca as rg,D as Wp,Da as ng,E as qp,Ea as AP,F as Vu,Fa as OP,G as nP,Ga as Va,H as iP,Ha as $P,I as oP,Ia as TP,J as Rt,Ja as ig,K as sP,Ka as EP,L as aP,La as ps,M as cP,Ma as G6,N as uP,Na as PP,O as lP,Oa as CP,P as Kp,Pa as bn,Q as dP,Qa as RP,R as St,Ra as og,S as ho,Sa as NP,T as pP,Ta as MP,U as eg,Ua as zP,V as qt,Va as Ku,W as Ua,Wa as mr,X as fP,Xa as _w,Y as Gp,Ya as ut,Z as mP,Za as jP,_ as Wu,_a as hr,a as F,aa as qu,ab as Ue,b as FE,ba as La,bb as ze,c as Da,ca as ds,cb as Or,d as Vp,da as gP,e as BE,ea as yP,f as ZE,fa as Re,g as ls,ga as go,h as VE,ha as Hp,i as WE,ia as ct,j as qE,ja as vn,k as KE,ka as Fa,l as GE,la as _P,m as HE,ma as vP,n as Ar,na as Jp,o as JE,oa as Ba,p as XE,pa as bP,q as Ct,qa as wP,r as YE,ra as Qt,s as Bu,sa as Za,t as nn,ta as xP,u as QE,ua as kP,v as yw,va as Gn,w as eP,wa as Hn,x as Zu,xa as $i,y as Xh,ya as IP,z as Yh,za as SP}from"./XOFCMJBQ.js";import{a as CE,b as Kn,c as gw}from"./UZLQALHY.js";export default $arcgis.t(([QF,e6,J7,X7,s6,a6,cY,,{a:FP,b:BP},{a:DP,b:UP,c:LP}])=>{var z1=CE(Jy=>{"use strict";Jy.byteLength=aW;Jy.toByteArray=uW;Jy.fromByteArray=pW;var qi=[],Tn=[],sW=typeof Uint8Array<"u"?Uint8Array:Array,zA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Tc=0,N1=zA.length;Tc<N1;++Tc)qi[Tc]=zA[Tc],Tn[zA.charCodeAt(Tc)]=Tc;var Tc,N1;Tn[45]=62;Tn[95]=63;function M1(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function aW(e){var t=M1(e),r=t[0],n=t[1];return(r+n)*3/4-n}function cW(e,t,r){return(t+r)*3/4-r}function uW(e){var t,r=M1(e),n=r[0],i=r[1],o=new sW(cW(e,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=Tn[e.charCodeAt(c)]<<18|Tn[e.charCodeAt(c+1)]<<12|Tn[e.charCodeAt(c+2)]<<6|Tn[e.charCodeAt(c+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Tn[e.charCodeAt(c)]<<2|Tn[e.charCodeAt(c+1)]>>4,o[s++]=t&255),i===1&&(t=Tn[e.charCodeAt(c)]<<10|Tn[e.charCodeAt(c+1)]<<4|Tn[e.charCodeAt(c+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function lW(e){return qi[e>>18&63]+qi[e>>12&63]+qi[e>>6&63]+qi[e&63]}function dW(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(lW(n));return i.join("")}function pW(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(dW(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(qi[t>>2]+qi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(qi[t>>10]+qi[t>>4&63]+qi[t<<2&63]+"=")),i.join("")}});var A4=CE((at,Yv)=>{"use strict";if(typeof Yv<"u"&&Yv!==globalThis.module&&typeof at<"u"&&Yv.exports===at){Object.defineProperty(at,"__esModule",{value:!0}),at.findX509Credential=at.rememberX509Credential=at.findX509OAuthError=at.rememberX509OAuthError=at.isApprovedX509Client=at.markApprovedX509Client=at.isRetryableX509IssuerError=at.markRetryableX509IssuerError=at.isTransientX509ConnectionError=at.markTransientX509ConnectionError=at.rememberRegisteredX509Transport=at.findRegisteredX509Transport=void 0;let e=new WeakMap,t=new WeakSet,r=new WeakSet,n=new WeakSet,i=new WeakMap,o=new WeakMap;at.findRegisteredX509Transport=WeakMap.prototype.get.bind(e),at.rememberRegisteredX509Transport=WeakMap.prototype.set.bind(e),at.markTransientX509ConnectionError=WeakSet.prototype.add.bind(t),at.isTransientX509ConnectionError=WeakSet.prototype.has.bind(t),at.markRetryableX509IssuerError=WeakSet.prototype.add.bind(r),at.isRetryableX509IssuerError=WeakSet.prototype.has.bind(r),at.markApprovedX509Client=WeakSet.prototype.add.bind(n),at.isApprovedX509Client=WeakSet.prototype.has.bind(n),at.rememberX509OAuthError=WeakMap.prototype.set.bind(i),at.findX509OAuthError=WeakMap.prototype.get.bind(i),at.rememberX509Credential=WeakMap.prototype.set.bind(o),at.findX509Credential=WeakMap.prototype.get.bind(o)}});function GP(e,t){if(e!=null){if(typeof e!="number"||Number.isNaN(e)||e<=0)throw new Error(`${t} must be greater than 0`);return e}}function Wa(e){if(e==null)return;let t=typeof e=="number"?{runTimeout:e}:e,r=t.refreshOn??"auto";if(r!=="auto"&&r!=="heartbeat")throw new Error('refreshOn must be "auto" or "heartbeat"');let n=GP(t.runTimeout,"runTimeout"),i=GP(t.idleTimeout,"idleTimeout");if(!(n===void 0&&i===void 0))return{runTimeout:n,idleTimeout:i,refreshOn:r}}var Ye="__start__",Ze="__end__",Ei="__input__";var fs="__error__",Yp="__error_source_node__",sg="__pregel_ns_writes";function HP(){let e=typeof process<"u"?process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT:void 0;if(e!==void 0&&e!==""){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>0)return t}return 5e3}var gr="__pregel_send",yo="__pregel_call",$r="__pregel_read",wn="__pregel_checkpointer",Ka="__pregel_resuming",Gu="__pregel_task_id",Qp="__pregel_stream",H6="__pregel_resume_value",Ga="__pregel_resume_map",Zr="__pregel_scratchpad",Ha="__pregel_previous",J6="__pregel_durability",ms="checkpoint_id",on="checkpoint_ns",JP="__pregel_node_finished",ef="__pregel_node_error",yr="checkpoint_map",ag="__pregel_replay_state",XP="__pregel_abort_signals",rt="__interrupt__",Tr="__resume__",tf="__no_writes__",hs="__return__",gs="__previous__",zt="langsmith:hidden";var bw="__self__",Pi="__pregel_tasks",Er="__pregel_push",cg="__pregel_pull",Pr="00000000-0000-0000-0000-000000000000",YP=[zt,Ei,rt,Tr,fs,Yp,tf,gr,$r,wn,J6,Qp,Ka,Gu,yo,H6,Zr,Ha,yr,on,ms,ag],vw=Symbol.for("langgraph.command"),QP=class{[vw];constructor(e){this[vw]=e}};function ug(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var qa=class{lg_name="Send";node;args;timeout;constructor(e,t,r){this.node=e,this.args=Xp(t),this.timeout=Wa(r?.timeout)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args,timeout:this.timeout}}};function Gt(e){return e instanceof qa}var Ti="__overwrite__",X6=class{lg_name="Overwrite";[Ti];constructor(e){this[Ti]=e}get value(){return this[Ti]}toJSON(){return{[Ti]:this[Ti]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function Jn(e){if(typeof e=="object"&&e!==null){if("__overwrite__"in e)return[!0,e[Ti]];let t=e;if(t.type==="__overwrite__"&&"value"in t)return[!0,t.value]}return[!1,void 0]}function Ja(e){return Jn(e)[0]}function Xa(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[rt])}var Br=class extends QP{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(e){super(e),this.resume=e.resume,this.graph=e.graph,this.update=e.update,e.goto&&(this.goto=Array.isArray(e.goto)?Xp(e.goto):[Xp(e.goto)])}_updateAsTuples(){return this.update&&typeof this.update=="object"&&!Array.isArray(this.update)?Object.entries(this.update):Array.isArray(this.update)&&this.update.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string")?this.update:[["__root__",this.update]]}toJSON(){let e;return typeof this.goto=="string"?e=this.goto:Gt(this.goto)?e=this.goto.toJSON():e=this.goto?.map(t=>typeof t=="string"?t:t.toJSON()),{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:e}}};function tr(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function Y6(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Xp(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let r;if(Array.isArray(e))r=[],t.set(e,r),e.forEach((n,i)=>{r[i]=Xp(n,t)});else if(e instanceof Br||e instanceof qa||!Y6(e))r=e,t.set(e,r);else if(tr(e))r=new Br(e),t.set(e,r);else if(ug(e))r=new qa(e.node,e.args,e.timeout!==void 0?{timeout:e.timeout}:void 0),t.set(e,r);else if("lc_serializable"in e&&e.lc_serializable)r=e,t.set(e,r);else{r={},t.set(e,r);for(let[n,i]of Object.entries(e))r[n]=Xp(i,t)}return r}return e}var Ci=class extends Error{lc_error_code;constructor(e,t){let r=e??"";t?.lc_error_code&&(r=`${r}
|
|
3
|
-
|
|
4
|
-
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
|
|
5
|
-
`),super(r),this.lc_error_code=t?.lc_error_code}},lg=class extends Ci{get is_bubble_up(){return!0}},ww=class extends Ci{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},Ya=class extends Ci{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},dg=class extends lg{reason;constructor(e="shutdown",t){super(`Graph drained: ${e}`,t),this.name="GraphDrained",this.reason=e}static get unminifiable_name(){return"GraphDrained"}};function pg(e){return e!==void 0&&e.name===dg.unminifiable_name}var _o=class extends lg{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},ys=class extends _o{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},xw=class{node;error;constructor(e,t){this.node=e,this.error=t}static get unminifiable_name(){return"NodeError"}};var fg=class extends lg{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function kw(e){return e!==void 0&&e.name===fg.unminifiable_name}function _s(e){return e!==void 0&&e.is_bubble_up===!0}function vo(e){return e!==void 0&&[_o.unminifiable_name,ys.unminifiable_name].includes(e.name)}var Iw=class extends Ci{node;kind;timeout;elapsed;runTimeout;idleTimeout;constructor(e,t){let{node:r,elapsed:n,kind:i,runTimeout:o,idleTimeout:s}=e,a,c;if(i==="idle"){if(s===void 0)throw new Error("idleTimeout is required when kind='idle'");c=s,a=`Node "${r}" exceeded its idle timeout of ${s}ms without making progress (elapsed: ${n}ms).`}else{if(o===void 0)throw new Error("runTimeout is required when kind='run'");c=o,a=`Node "${r}" exceeded its run timeout of ${o}ms (elapsed: ${n}ms).`}super(a,t),this.name="NodeTimeoutError",this.node=r,this.kind=i,this.timeout=c,this.elapsed=n,this.runTimeout=o,this.idleTimeout=s}static get unminifiable_name(){return"NodeTimeoutError"}};var mg=class extends Ci{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Je=class extends Ci{constructor(e,t){let r=Error.stackTraceLimit;Error.stackTraceLimit=0,super(e,t),Error.stackTraceLimit=r,this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},Ce=class extends Ci{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}};var Sw=class extends Ci{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}};var rf=class extends Ci{constructor(e,t){super(e,t),this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}};var Aw=0,nf=0;function of(e){let t=Date.now();return t<=Aw?(nf+=1,nf>=1e4&&(nf=0,t=Aw+1)):nf=0,Aw=t,BE({clockseq:e,msecs:t,nsecs:nf})}function Ri(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(n=>parseInt(n,16));return Vp(e,new Uint8Array(r))}var Ow="__error__",Qa="__scheduled__",$w="__interrupt__",Tw="__resume__",Hu=class{lg_name="DeltaSnapshot";value;constructor(e){this.value=e}};function Ew(e){return e!=null&&typeof e=="object"&&e.lg_name==="DeltaSnapshot"}var eC="[...]",Q6="[Circular]",hg=[],Ju=[];function eB(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function tC(e,t,r,n){typeof n>"u"&&(n=eB()),Cw(e,"",0,[],void 0,0,n);var i;try{Ju.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,tB(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;hg.length!==0;){var o=hg.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function Pw(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),hg.push([n,r,t,i])):Ju.push([t,r,e]):(n[r]=e,hg.push([n,r,t]))}function Cw(e,t,r,n,i,o,s){o+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<n.length;a++)if(n[a]===e){Pw(Q6,e,t,i);return}if(typeof s.depthLimit<"u"&&o>s.depthLimit){Pw(eC,e,t,i);return}if(typeof s.edgesLimit<"u"&&r+1>s.edgesLimit){Pw(eC,e,t,i);return}if(n.push(e),Array.isArray(e))for(a=0;a<e.length;a++)Cw(e[a],a,a,n,e,o,s);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var u=c[a];Cw(e[u],u,a,n,e,o,s)}}n.pop()}}function tB(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Ju.length>0)for(var n=0;n<Ju.length;n++){var i=Ju[n];if(i[1]===t&&i[0]===r){r=i[2],Ju.splice(n,1);break}}return e.call(this,t,r)}}var rC=[];var nC=F({});var iC=F({});var le="0123456789abcdef".split(""),rB=[-2147483648,8388608,32768,128],Xn=[24,16,8,0],gg=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],rr=[];function Yn(e,t){t?(rr[0]=rr[16]=rr[1]=rr[2]=rr[3]=rr[4]=rr[5]=rr[6]=rr[7]=rr[8]=rr[9]=rr[10]=rr[11]=rr[12]=rr[13]=rr[14]=rr[15]=0,this.blocks=rr):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}Yn.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var n,i=0,o,s=e.length,a=this.blocks;i<s;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,this.block=a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),t)for(o=this.start;i<s&&o<64;++i)a[o>>>2]|=e[i]<<Xn[o++&3];else for(o=this.start;i<s&&o<64;++i)n=e.charCodeAt(i),n<128?a[o>>>2]|=n<<Xn[o++&3]:n<2048?(a[o>>>2]|=(192|n>>>6)<<Xn[o++&3],a[o>>>2]|=(128|n&63)<<Xn[o++&3]):n<55296||n>=57344?(a[o>>>2]|=(224|n>>>12)<<Xn[o++&3],a[o>>>2]|=(128|n>>>6&63)<<Xn[o++&3],a[o>>>2]|=(128|n&63)<<Xn[o++&3]):(n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023),a[o>>>2]|=(240|n>>>18)<<Xn[o++&3],a[o>>>2]|=(128|n>>>12&63)<<Xn[o++&3],a[o>>>2]|=(128|n>>>6&63)<<Xn[o++&3],a[o>>>2]|=(128|n&63)<<Xn[o++&3]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=a[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Yn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=rB[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};Yn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,s=this.h6,a=this.h7,c=this.blocks,u,l,d,p,f,m,h,y,w,_,b;for(u=16;u<64;++u)f=c[u-15],l=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,f=c[u-2],d=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(b=t&r,u=0;u<64;u+=4)this.first?(this.is224?(y=300032,f=c[0]-1413257819,a=f-150054599<<0,n=f+24177077<<0):(y=704751109,f=c[0]-210244248,a=f-1521486534<<0,n=f+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),y=e&t,p=y^e&r^b,h=i&o^~i&s,f=a+d+h+gg[u]+c[u],m=l+p,a=n+f<<0,n=f+m<<0),l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),w=n&e,p=w^n&t^y,h=s&a^~s&i,f=o+d+h+gg[u+1]+c[u+1],m=l+p,s=r+f<<0,r=f+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),_=r&n,p=_^r&e^w,h=o&s^~o&a,f=i+d+h+gg[u+2]+c[u+2],m=l+p,o=t+f<<0,t=f+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),b=t&r,p=b^t&n^_,h=o&s^~o&a,f=i+d+h+gg[u+3]+c[u+3],m=l+p,i=e+f<<0,e=f+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0,this.h4=this.h4+i<<0,this.h5=this.h5+o<<0,this.h6=this.h6+s<<0,this.h7=this.h7+a<<0};Yn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,s=this.h6,a=this.h7,c=le[e>>>28&15]+le[e>>>24&15]+le[e>>>20&15]+le[e>>>16&15]+le[e>>>12&15]+le[e>>>8&15]+le[e>>>4&15]+le[e&15]+le[t>>>28&15]+le[t>>>24&15]+le[t>>>20&15]+le[t>>>16&15]+le[t>>>12&15]+le[t>>>8&15]+le[t>>>4&15]+le[t&15]+le[r>>>28&15]+le[r>>>24&15]+le[r>>>20&15]+le[r>>>16&15]+le[r>>>12&15]+le[r>>>8&15]+le[r>>>4&15]+le[r&15]+le[n>>>28&15]+le[n>>>24&15]+le[n>>>20&15]+le[n>>>16&15]+le[n>>>12&15]+le[n>>>8&15]+le[n>>>4&15]+le[n&15]+le[i>>>28&15]+le[i>>>24&15]+le[i>>>20&15]+le[i>>>16&15]+le[i>>>12&15]+le[i>>>8&15]+le[i>>>4&15]+le[i&15]+le[o>>>28&15]+le[o>>>24&15]+le[o>>>20&15]+le[o>>>16&15]+le[o>>>12&15]+le[o>>>8&15]+le[o>>>4&15]+le[o&15]+le[s>>>28&15]+le[s>>>24&15]+le[s>>>20&15]+le[s>>>16&15]+le[s>>>12&15]+le[s>>>8&15]+le[s>>>4&15]+le[s&15];return this.is224||(c+=le[a>>>28&15]+le[a>>>24&15]+le[a>>>20&15]+le[a>>>16&15]+le[a>>>12&15]+le[a>>>8&15]+le[a>>>4&15]+le[a&15]),c};Yn.prototype.toString=Yn.prototype.hex;Yn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,s=this.h6,a=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255];return this.is224||c.push(a>>>24&255,a>>>16&255,a>>>8&255,a&255),c};Yn.prototype.array=Yn.prototype.digest;Yn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};var Xu=(...e)=>new Yn(!1,!0).update(e.join("")).hex();var oC=F({sha256:()=>Xu});var sC=F({BaseCache:()=>cC,InMemoryCache:()=>Rw,defaultHashKeyEncoder:()=>aC,deserializeStoredGeneration:()=>nB,serializeGeneration:()=>iB}),aC=(...e)=>Xu(e.join("_"));function nB(e){return e.message!==void 0?{text:e.text,message:ng(e.message)}:{text:e.text}}function iB(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var cC=class{keyEncoder=aC;makeDefaultKeyEncoder(e){this.keyEncoder=e}},oB=new Map,Rw=class uC extends cC{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,n){this.cache.set(this.keyEncoder(t,r),n)}static global(){return new uC(oB)}};async function sn(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(n=>{if(!t?.aborted)throw n}),new Promise((n,i)=>{r=()=>{i(vs(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&i(vs(t))})]).finally(()=>t.removeEventListener("abort",r))}function vs(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var lC=F({AsyncGeneratorWithSetup:()=>bs,IterableReadableStream:()=>jt,atee:()=>yg,concat:()=>an,pipeGeneratorWithSetup:()=>Mw}),jt=class Nw extends ReadableStream{reader;ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{let t=await this.reader.read();return t.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:t.value}}catch(t){throw this.reader.releaseLock(),t}}async return(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),await t}return{done:!0,value:void 0}}async throw(t){if(this.ensureReader(),this.locked){let r=this.reader.cancel();this.reader.releaseLock(),await r}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let r=t.getReader();return new Nw({start(n){return i();function i(){return r.read().then(({done:o,value:s})=>{if(o){n.close();return}return n.enqueue(s),i()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Nw({async pull(r){let{value:n,done:i}=await t.next();i&&r.close(),r.enqueue(n)},async cancel(r){await t.return(r)}})}};function yg(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(i){for(;;)if(i.length===0){let o=await e.next();for(let s of r)s.push(o)}else{if(i[0].done)return;yield i.shift().value}})}function an(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string")return e+t;if(typeof e=="number"&&typeof t=="number")return e+t;if("concat"in e&&typeof e.concat=="function")return e.concat(t);if(typeof e=="object"&&typeof t=="object"){let r={...e};for(let[n,i]of Object.entries(t))n in r&&!Array.isArray(r[n])?r[n]=an(r[n],i):r[n]=i;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var bs=class{generator;setup;config;signal;firstResult;firstResultUsed=!1;constructor(e){this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{ut.runWithConfig(Or(e.config),async()=>{this.firstResult=this.signal?sn(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(n=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?ut.runWithConfig(Or(this.config),this.signal?async()=>sn(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}};async function Mw(e,t,r,n,...i){let o=new bs({generator:t,startSetup:r,signal:n}),s=await o.setup;return{output:e(o,s,...i),setup:s}}var sB=Object.prototype.hasOwnProperty;function vg(e,t){return sB.call(e,t)}function bg(e){if(Array.isArray(e)){let r=new Array(e.length);for(let n=0;n<r.length;n++)r[n]=""+n;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)vg(e,r)&&t.push(r);return t}function cn(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function wg(e){let t=0,r=e.length,n;for(;t<r;){if(n=e.charCodeAt(t),n>=48&&n<=57){t++;continue}return!1}return!0}function ec(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function pC(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function _g(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(_g(e[r]))return!0}else if(typeof e=="object"){let r=bg(e),n=r.length;for(var t=0;t<n;t++)if(_g(e[r[t]]))return!0}}return!1}function dC(e,t){let r=[e];for(let n in t){let i=typeof t[n]=="object"?JSON.stringify(t[n],null,2):t[n];typeof i<"u"&&r.push(`${n}: ${i}`)}return r.join(`
|
|
6
|
-
`)}var fC=class extends Error{name;index;operation;tree;constructor(e,t,r,n,i){super(dC(e,{name:t,index:r,operation:n,tree:i})),this.name=t,this.index=r,this.operation=n,this.tree=i,Object.setPrototypeOf(this,new.target.prototype),this.message=dC(e,{name:t,index:r,operation:n,tree:i})}};var mC=F({JsonPatchError:()=>At,_areEquals:()=>Qu,applyOperation:()=>ws,applyPatch:()=>bo,applyReducer:()=>hC,deepClone:()=>aB,getValueByPointer:()=>sf,validate:()=>zw,validator:()=>af});var At=fC,aB=cn,Yu={add:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var n=e[t];return delete e[t],{newDocument:r,removed:n}},replace:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){let n=sf(r,this.path);n&&(n=cn(n));let i=ws(r,{op:"remove",path:this.from}).removed;return ws(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){let n=sf(r,this.from);return ws(r,{op:"add",path:this.path,value:cn(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Qu(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},cB={add:function(e,t,r){return wg(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:Yu.move,copy:Yu.copy,test:Yu.test,_get:Yu._get};function sf(e,t){if(t=="")return e;var r={op:"_get",path:t};return ws(e,r),r.value}function ws(e,t,r=!1,n=!0,i=!0,o=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):af(t,0)),t.path===""){let s={newDocument:e};if(t.op==="add")return s.newDocument=t.value,s;if(t.op==="replace")return s.newDocument=t.value,s.removed=e,s;if(t.op==="move"||t.op==="copy")return s.newDocument=sf(e,t.from),t.op==="move"&&(s.removed=e),s;if(t.op==="test"){if(s.test=Qu(e,t.value),s.test===!1)throw new At("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return s.newDocument=e,s}else{if(t.op==="remove")return s.removed=e,s.newDocument=null,s;if(t.op==="_get")return t.value=e,s;if(r)throw new At("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,t,e);return s}}else{n||(e=cn(e));let s=(t.path||"").split("/"),a=e,c=1,u=s.length,l,d,p;for(typeof r=="function"?p=r:p=af;;){if(d=s[c],d&&d.indexOf("~")!=-1&&(d=pC(d)),i&&(d=="__proto__"||d=="prototype"&&c>0&&s[c-1]=="constructor"))throw new 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(r&&l===void 0&&(a[d]===void 0?l=s.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&p(t,0,e,l)),c++,Array.isArray(a)){if(d==="-")d=a.length;else{if(r&&!wg(d))throw new At("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",o,t,e);wg(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>a.length)throw new At("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);let f=cB[t.op].call(t,a,d,e);if(f.test===!1)throw new At("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return f}}else if(c>=u){let f=Yu[t.op].call(t,a,d,e);if(f.test===!1)throw new At("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return f}if(a=a[d],r&&c<u&&(!a||typeof a!="object"))throw new At("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,t,e)}}}function bo(e,t,r,n=!0,i=!0){if(r&&!Array.isArray(t))throw new At("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=cn(e));let o=new Array(t.length);for(let s=0,a=t.length;s<a;s++)o[s]=ws(e,t[s],r,!0,i,s),e=o[s].newDocument;return o.newDocument=e,o}function hC(e,t,r){let n=ws(e,t);if(n.test===!1)throw new At("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function af(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new At("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(Yu[e.op]){if(typeof e.path!="string")throw new At("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new At('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new At("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new At("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&_g(e.value))throw new At("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var i=e.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new At("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new At("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var s=zw([{op:"_get",path:e.from,value:void 0}],r);if(s&&s.name==="OPERATION_PATH_UNRESOLVABLE")throw new At("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new At("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function zw(e,t,r){try{if(!Array.isArray(e))throw new At("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)bo(cn(t),cn(e),r||!0);else{r=r||af;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(i){if(i instanceof At)return i;throw i}}function Qu(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),i,o,s;if(r&&n){if(o=e.length,o!=t.length)return!1;for(i=o;i--!==0;)if(!Qu(e[i],t[i]))return!1;return!0}if(r!=n)return!1;var a=Object.keys(e);if(o=a.length,o!==Object.keys(t).length)return!1;for(i=o;i--!==0;)if(!t.hasOwnProperty(a[i]))return!1;for(i=o;i--!==0;)if(s=a[i],!Qu(e[s],t[s]))return!1;return!0}return e!==e&&t!==t}function gC(e,t,r,n,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var o=bg(t),s=bg(e),a=!1,c=s.length-1;c>=0;c--){var u=s[c],l=e[u];if(vg(t,u)&&!(t[u]===void 0&&l!==void 0&&Array.isArray(t)===!1)){var d=t[u];typeof l=="object"&&l!=null&&typeof d=="object"&&d!=null&&Array.isArray(l)===Array.isArray(d)?gC(l,d,r,n+"/"+ec(u),i):l!==d&&(i&&r.push({op:"test",path:n+"/"+ec(u),value:cn(l)}),r.push({op:"replace",path:n+"/"+ec(u),value:cn(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:n+"/"+ec(u),value:cn(l)}),r.push({op:"remove",path:n+"/"+ec(u)}),a=!0):(i&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}))}if(!(!a&&o.length==s.length))for(var c=0;c<o.length;c++){var u=o[c];!vg(e,u)&&t[u]!==void 0&&r.push({op:"add",path:n+"/"+ec(u),value:cn(t[u])})}}}function wo(e,t,r=!1){var n=[];return gC(e,t,n,"",r),n}({...mC});var vC=F({LogStreamCallbackHandler:()=>kg,RunLog:()=>xg,RunLogPatch:()=>Ni,isLogStreamHandler:()=>Dw}),Ni=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=bo({},t);return new xg({ops:t,state:r[r.length-1].newDocument})}},xg=class jw extends Ni{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),n=bo(this.state,t.ops);return new jw({ops:r,state:n[n.length-1].newDocument})}static fromRunLogPatch(t){let r=bo({},t.ops);return new jw({ops:t.ops,state:r[r.length-1].newDocument})}},Dw=e=>e.name==="log_stream_tracer";async function yC(e,t){if(t==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:r}=e;if(["retriever","llm","prompt"].includes(e.run_type))return r;if(!(Object.keys(r).length===1&&r?.input===""))return r.input}async function _C(e,t){let{outputs:r}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?r:r!==void 0&&Object.keys(r).length===1&&r?.output!==void 0?r.output:r}function uB(e){return e!==void 0&&e.message!==void 0}var kg=class extends bn{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;_schemaFormat="original";rootId;keyMapByRunId={};counterMapByRunName={};transformStream;writer;receiveStream;name="log_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=jt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(n=>this.includeTags?.includes(n))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let n=this.keyMapByRunId[e];n&&await this.writer.write(new Ni({ops:[{op:"add",path:`/logs/${n}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new Ni({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await yC(e,this._schemaFormat)),await this.writer.write(new Ni({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await yC(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await _C(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let n=new Ni({ops:r});await this.writer.write(n)}finally{if(e.id===this.rootId){let t=new Ni({ops:[{op:"replace",path:"/final_output",value:await _C(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let n=this.keyMapByRunId[e.id];if(n===void 0)return;let i=e.inputs.messages!==void 0,o;i?uB(r?.chunk)?o=r?.chunk:o=new ct({id:`run-${e.id}`,content:t}):o=t;let s=new Ni({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:o}]});await this.writer.write(s)}};var bC=F({ChatGenerationChunk:()=>un,GenerationChunk:()=>Mi,RUN_KEY:()=>tc}),tc="__run",Mi=class wC{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new wC({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},un=class xC extends Mi{message;constructor(t){super(t),this.message=t.message}concat(t){return new xC({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var lB=Object.prototype.toString,dB=e=>lB.call(e)==="[object Error]",pB=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function kC(e){if(!(e&&dB(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:r}=e;return t==="Load failed"?r===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:pB.has(t)}function fB(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Ig(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var mB=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}};function hB(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function IC(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function gB({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof mB)throw o.originalError;let s=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,a=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:s,retriesConsumed:r});if(await i.onFailedAttempt(c),IC(n,a)<=0)throw o;let u=await i.shouldConsumeRetry(c),l=IC(n,a);if(l<=0||s<=0)throw o;if(o instanceof TypeError&&!kC(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;let d=hB(r,i),p=typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0?o.retryAfterMs:void 0;p!==void 0&&(d=Math.max(d,p));let f=Math.min(d,l);return f>0&&await new Promise((m,h)=>{let y=()=>{clearTimeout(w),i.signal?.removeEventListener("abort",y),h(i.signal.reason)},w=setTimeout(()=>{i.signal?.removeEventListener("abort",y),m()},f);i.unref&&w.unref?.(),i.signal?.addEventListener("abort",y,{once:!0})}),i.signal?.throwIfAborted(),!0}async function cf(e,t={}){if(t={...t},fB(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Ig("factor",t.factor,{min:0,allowInfinity:!1}),Ig("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ig("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ig("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await gB({error:o,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Sg=gw(G6(),1),AC=F({AsyncCaller:()=>xo,classifyRateLimitError:()=>PC,parseRetryAfterMs:()=>EC}),yB=[400,401,402,403,404,405,406,407,409,413],_B=6e4,vB=[/insufficient[_ -]?quota/i,/exceeded (?:your|the current|the available).+quota/i,/usage quota/i,/quota (?:has been )?exhausted/i,/billing/i,/credit balance/i,/out of credits/i,/will reset at/i],bB=/(?:try again in|retry after)\s+(\d+(?:\.\d+)?)\s*(milliseconds?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h)\b/i;function OC(e){return typeof e=="object"&&e!==null&&"response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0}function $C(e){if(!(typeof e!="object"||e===null)){if("status"in e&&typeof e.status=="number")return e.status;if("statusCode"in e&&typeof e.statusCode=="number")return e.statusCode}}function Lw(e){return typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:void 0}function TC(e){if(!(typeof e!="object"||e===null))return"code"in e&&typeof e.code=="string"?e.code:"error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0}function wB(e){if(e?.headers)return typeof e.headers.get=="function"?e.headers.get("retry-after"):e.headers["retry-after"]??e.headers["Retry-After"];if(e?.response?.headers)return typeof e.response.headers.get=="function"?e.response.headers.get("retry-after"):e.response.headers["retry-after"]??e.response.headers["Retry-After"]}function xB(e){if(e==null)return;let t=bB.exec(e);if(!t)return;let r=Number(t[1]),n=t[2]?.toLowerCase();if(!(Number.isNaN(r)||!n))return n==="ms"||n.startsWith("millisecond")?r:n==="m"||n.startsWith("min")?r*6e4:n==="h"||n.startsWith("hr")||n.startsWith("hour")?r*36e5:r*1e3}function SC(e,t){if(e instanceof Error)return e;let r=new Error(t);return typeof e=="object"&&e!==null&&Object.assign(r,e),r}function Uw(e,t){if(typeof e!="object"||e===null)return;let r=e;r.rateLimitType=t.action,r.rateLimitReason=t.reason,t.retryAfterMs!==void 0&&(r.retryAfterMs=t.retryAfterMs)}function EC(e){if(e==null)return;let t=e.trim();if(!t)return;let r=Number(t);if(!Number.isNaN(r)&&r>=0)return r*1e3;let n=Date.parse(t);if(!Number.isNaN(n)){let i=n-Date.now();return i>0?i:0}}function PC(e){if((OC(e)??$C(e))!==429)return;if(TC(e)==="insufficient_quota")return{action:"stop",reason:"insufficient_quota"};let t=Lw(e);if(t&&vB.some(n=>n.test(t)))return{action:"stop",reason:"quota_message"};let r=EC(wB(e))??xB(t);return r!==void 0?r<=_B?{action:"wait",retryAfterMs:r,reason:"retry_after_hint"}:{action:"capacity",retryAfterMs:r,reason:"retry_after_too_large"}:{action:"capacity",reason:"headerless_429"}}var kB=e=>{if(typeof e!="object"||e===null)return;if(QE(e)===!1)throw e;if("message"in e&&typeof e.message=="string"&&(e.message.startsWith("Cancel")||e.message.startsWith("AbortError"))||"name"in e&&typeof e.name=="string"&&e.name==="AbortError")throw nn(e,!1);if("code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t=OC(e)??$C(e);if(t&&yB.includes(+t))throw nn(e,!1);if(TC(e)==="insufficient_quota"){let n=SC(e,Lw(e)??"Insufficient quota");throw n.name="InsufficientQuotaError",Uw(n,{action:"stop",reason:"insufficient_quota"}),nn(n,!1)}let r=PC(e);if(r){if(r.action==="wait"){Uw(e,r),nn(e,!0);return}let n=SC(e,Lw(e)??"Rate limit exceeded");throw n.name==="Error"&&(n.name=r.action==="stop"?"RateLimitQuotaExhaustedError":"RateLimitCapacityError"),Uw(n,r),nn(n,r.action!=="stop")}},xo=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??kB;let t="default"in Sg.default?Sg.default.default:Sg.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.callWithRetries(this.maxRetries,e,t)}callWithRetries(e,t,r){return this.queue.add(()=>cf(()=>t(...r).catch(n=>{throw n instanceof Error?n:new Error(n)}),{onFailedAttempt:({error:n})=>this.onFailedAttempt?.(n),retries:e,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){let n=e.maxRetries??this.maxRetries;if(e.signal){let i;return Promise.race([this.callWithRetries(n,t,r),new Promise((o,s)=>{i=()=>{s(vs(e.signal))},e.signal?.addEventListener("abort",i,{once:!0})})]).finally(()=>{e.signal&&i&&e.signal.removeEventListener("abort",i)})}return this.callWithRetries(n,t,r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var CC=F({isSerializableSchema:()=>zi,isStandardJsonSchema:()=>Ag,isStandardSchema:()=>RC});function RC(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function Ag(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function zi(e){return RC(e)&&Ag(e)}var Ao={};Kn(Ao,{$ZodAny:()=>Ek,$ZodArray:()=>Rk,$ZodAsyncError:()=>Qn,$ZodBase64:()=>bk,$ZodBase64URL:()=>wk,$ZodBigInt:()=>qg,$ZodBigIntFormat:()=>Ak,$ZodBoolean:()=>wf,$ZodCIDRv4:()=>yk,$ZodCIDRv6:()=>_k,$ZodCUID:()=>ok,$ZodCUID2:()=>sk,$ZodCatch:()=>Xk,$ZodCheck:()=>lt,$ZodCheckBigIntFormat:()=>Mx,$ZodCheckEndsWith:()=>Kx,$ZodCheckGreaterThan:()=>Lg,$ZodCheckIncludes:()=>Wx,$ZodCheckLengthEquals:()=>Fx,$ZodCheckLessThan:()=>Ug,$ZodCheckLowerCase:()=>Zx,$ZodCheckMaxLength:()=>Ux,$ZodCheckMaxSize:()=>zx,$ZodCheckMimeType:()=>Hx,$ZodCheckMinLength:()=>Lx,$ZodCheckMinSize:()=>jx,$ZodCheckMultipleOf:()=>Rx,$ZodCheckNumberFormat:()=>Nx,$ZodCheckOverwrite:()=>Jx,$ZodCheckProperty:()=>Gx,$ZodCheckRegex:()=>Bx,$ZodCheckSizeEquals:()=>Dx,$ZodCheckStartsWith:()=>qx,$ZodCheckStringFormat:()=>al,$ZodCheckUpperCase:()=>Vx,$ZodCodec:()=>Sf,$ZodCustom:()=>oI,$ZodCustomStringFormat:()=>Ik,$ZodDate:()=>Ck,$ZodDefault:()=>Kk,$ZodDiscriminatedUnion:()=>zk,$ZodE164:()=>xk,$ZodEmail:()=>tk,$ZodEmoji:()=>nk,$ZodEncodeError:()=>xs,$ZodEnum:()=>Fk,$ZodError:()=>hf,$ZodExactOptional:()=>Wk,$ZodFile:()=>Zk,$ZodFunction:()=>rI,$ZodGUID:()=>Qx,$ZodIPv4:()=>mk,$ZodIPv6:()=>hk,$ZodISODate:()=>dk,$ZodISODateTime:()=>lk,$ZodISODuration:()=>fk,$ZodISOTime:()=>pk,$ZodIntersection:()=>jk,$ZodJWT:()=>kk,$ZodKSUID:()=>uk,$ZodLazy:()=>iI,$ZodLiteral:()=>Bk,$ZodMAC:()=>gk,$ZodMap:()=>Uk,$ZodNaN:()=>Yk,$ZodNanoID:()=>ik,$ZodNever:()=>kf,$ZodNonOptional:()=>Hk,$ZodNull:()=>Tk,$ZodNullable:()=>qk,$ZodNumber:()=>Wg,$ZodNumberFormat:()=>Sk,$ZodObject:()=>lR,$ZodObjectJIT:()=>Nk,$ZodOptional:()=>ac,$ZodPipe:()=>Gg,$ZodPrefault:()=>Gk,$ZodPreprocess:()=>Qk,$ZodPromise:()=>nI,$ZodReadonly:()=>eI,$ZodRealError:()=>Wr,$ZodRecord:()=>Dk,$ZodRegistry:()=>Yg,$ZodSet:()=>Lk,$ZodString:()=>sc,$ZodStringFormat:()=>nt,$ZodSuccess:()=>Jk,$ZodSymbol:()=>Ok,$ZodTemplateLiteral:()=>tI,$ZodTransform:()=>Vk,$ZodTuple:()=>Kg,$ZodType:()=>Ie,$ZodULID:()=>ak,$ZodURL:()=>rk,$ZodUUID:()=>ek,$ZodUndefined:()=>$k,$ZodUnion:()=>If,$ZodUnknown:()=>xf,$ZodVoid:()=>Pk,$ZodXID:()=>ck,$ZodXor:()=>Mk,$brand:()=>Bw,$constructor:()=>E,$input:()=>aI,$output:()=>sI,Doc:()=>bf,JSONSchema:()=>pN,JSONSchemaGenerator:()=>Oy,NEVER:()=>Fw,TimePrecision:()=>dI,_any:()=>CI,_array:()=>jI,_base64:()=>hy,_base64url:()=>gy,_bigint:()=>SI,_boolean:()=>kI,_catch:()=>q9,_check:()=>dN,_cidrv4:()=>fy,_cidrv6:()=>my,_coercedBigint:()=>AI,_coercedBoolean:()=>II,_coercedDate:()=>MI,_coercedNumber:()=>yI,_coercedString:()=>uI,_cuid:()=>sy,_cuid2:()=>ay,_custom:()=>UI,_date:()=>NI,_decode:()=>Eg,_decodeAsync:()=>Cg,_default:()=>Z9,_discriminatedUnion:()=>P9,_e164:()=>yy,_email:()=>Qg,_emoji:()=>iy,_encode:()=>Tg,_encodeAsync:()=>Pg,_endsWith:()=>hl,_enum:()=>j9,_file:()=>DI,_float32:()=>vI,_float64:()=>bI,_gt:()=>Ui,_gte:()=>Rr,_guid:()=>$f,_includes:()=>fl,_int:()=>_I,_int32:()=>wI,_int64:()=>OI,_intersection:()=>C9,_ipv4:()=>dy,_ipv6:()=>py,_isoDate:()=>fI,_isoDateTime:()=>pI,_isoDuration:()=>hI,_isoTime:()=>mI,_jwt:()=>_y,_ksuid:()=>ly,_lazy:()=>J9,_length:()=>lc,_literal:()=>U9,_lowercase:()=>dl,_lt:()=>Di,_lte:()=>dn,_mac:()=>lI,_map:()=>M9,_max:()=>dn,_maxLength:()=>uc,_maxSize:()=>$s,_mime:()=>gl,_min:()=>Rr,_minLength:()=>Io,_minSize:()=>Li,_multipleOf:()=>Os,_nan:()=>zI,_nanoid:()=>oy,_nativeEnum:()=>D9,_negative:()=>by,_never:()=>Pf,_nonnegative:()=>xy,_nonoptional:()=>V9,_nonpositive:()=>wy,_normalize:()=>yl,_null:()=>PI,_nullable:()=>B9,_number:()=>gI,_optional:()=>F9,_overwrite:()=>ei,_parse:()=>nl,_parseAsync:()=>il,_pipe:()=>K9,_positive:()=>vy,_promise:()=>X9,_property:()=>ky,_readonly:()=>G9,_record:()=>N9,_refine:()=>LI,_regex:()=>ll,_safeDecode:()=>Ng,_safeDecodeAsync:()=>zg,_safeEncode:()=>Rg,_safeEncodeAsync:()=>Mg,_safeParse:()=>ol,_safeParseAsync:()=>sl,_set:()=>z9,_size:()=>cc,_slugify:()=>wl,_startsWith:()=>ml,_string:()=>cI,_stringFormat:()=>xl,_stringbool:()=>VI,_success:()=>W9,_superRefine:()=>FI,_symbol:()=>TI,_templateLiteral:()=>H9,_toLowerCase:()=>vl,_toUpperCase:()=>bl,_transform:()=>L9,_trim:()=>_l,_tuple:()=>R9,_uint32:()=>xI,_uint64:()=>$I,_ulid:()=>cy,_undefined:()=>EI,_union:()=>T9,_unknown:()=>Ef,_uppercase:()=>pl,_url:()=>Tf,_uuid:()=>ey,_uuidv4:()=>ty,_uuidv6:()=>ry,_uuidv7:()=>ny,_void:()=>RI,_xid:()=>uy,_xor:()=>E9,clone:()=>ft,config:()=>Ot,createStandardJSONSchemaMethod:()=>kl,createToJSONSchemaMethod:()=>WI,decode:()=>XB,decodeAsync:()=>QB,describe:()=>BI,encode:()=>JB,encodeAsync:()=>YB,extractDefs:()=>Es,finalize:()=>Ps,flattenError:()=>gf,formatError:()=>yf,globalConfig:()=>rc,globalRegistry:()=>Qe,initializeContext:()=>Ts,isValidBase64:()=>vk,isValidBase64URL:()=>sR,isValidJWT:()=>aR,locales:()=>Of,meta:()=>ZI,parse:()=>ji,parseAsync:()=>ic,prettifyError:()=>tx,process:()=>et,regexes:()=>ln,registry:()=>ul,safeDecode:()=>tZ,safeDecodeAsync:()=>nZ,safeEncode:()=>eZ,safeEncodeAsync:()=>rZ,safeParse:()=>rx,safeParseAsync:()=>nx,toDotPath:()=>UC,toJSONSchema:()=>So,treeifyError:()=>ex,util:()=>W,version:()=>Xx});var NC,Fw=Object.freeze({status:"aborted"});function E(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(a){var c;let u=r?.Parent?new o:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Bw=Symbol("zod_brand"),Qn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},xs=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(NC=globalThis).__zod_globalConfig??(NC.__zod_globalConfig={});var rc=globalThis.__zod_globalConfig;function Ot(e){return e&&Object.assign(rc,e),rc}var W={};Kn(W,{BIGINT_FORMAT_RANGES:()=>Yw,Class:()=>Vw,NUMBER_FORMAT_RANGES:()=>Xw,aborted:()=>As,allowsEval:()=>Kw,assert:()=>$B,assertEqual:()=>IB,assertIs:()=>AB,assertNever:()=>OB,assertNotEqual:()=>SB,assignProp:()=>Is,base64ToUint8Array:()=>zC,base64urlToUint8Array:()=>WB,cached:()=>tl,captureStackTrace:()=>$g,cleanEnum:()=>VB,cleanRegex:()=>df,clone:()=>ft,cloneDef:()=>EB,createTransparentProxy:()=>zB,defineLazy:()=>je,esc:()=>Og,escapeRegex:()=>xn,explicitlyAborted:()=>Qw,extend:()=>UB,finalizeIssue:()=>Cr,floatSafeRemainder:()=>Ww,getElementAtPath:()=>PB,getEnumValues:()=>lf,getLengthableOrigin:()=>mf,getParsedType:()=>MB,getSizableOrigin:()=>ff,hexToUint8Array:()=>KB,isObject:()=>nc,isPlainObject:()=>Ss,issue:()=>rl,joinValues:()=>N,jsonStringifyReplacer:()=>el,merge:()=>FB,mergeDefs:()=>ko,normalizeParams:()=>G,nullish:()=>ks,numKeys:()=>NB,objectClone:()=>TB,omit:()=>DB,optionalKeys:()=>Jw,parsedType:()=>V,partial:()=>BB,pick:()=>jB,prefixIssues:()=>Vr,primitiveTypes:()=>Hw,promiseAllObject:()=>CB,propertyKeyTypes:()=>pf,randomString:()=>RB,required:()=>ZB,safeExtend:()=>LB,shallowClone:()=>Gw,slugify:()=>qw,stringifyPrimitive:()=>Z,uint8ArrayToBase64:()=>jC,uint8ArrayToBase64url:()=>qB,uint8ArrayToHex:()=>GB,unwrapMessage:()=>uf});function IB(e){return e}function SB(e){return e}function AB(e){}function OB(e){throw new Error("Unexpected value in exhaustive check")}function $B(e){}function lf(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function N(e,t="|"){return e.map(r=>Z(r)).join(t)}function el(e,t){return typeof t=="bigint"?t.toString():t}function tl(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ks(e){return e==null}function df(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ww(e,t){let r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}var MC=Symbol("evaluating");function je(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==MC)return n===void 0&&(n=MC,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function TB(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Is(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ko(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function EB(e){return ko(e._zod.def)}function PB(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function CB(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function RB(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Og(e){return JSON.stringify(e)}function qw(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var $g="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Kw=tl(()=>{if(rc.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ss(e){if(nc(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(nc(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Gw(e){return Ss(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function NB(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var MB=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pf=new Set(["string","number","symbol"]),Hw=new Set(["string","number","bigint","boolean","symbol","undefined"]);function xn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ft(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function G(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 new 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 zB(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function Z(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Jw(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Xw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yw={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function jB(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=ko(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=r.shape[a])}return Is(this,"shape",s),s},checks:[]});return ft(e,o)}function DB(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=ko(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Is(this,"shape",s),s},checks:[]});return ft(e,o)}function UB(e,t){if(!Ss(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=ko(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Is(this,"shape",o),o}});return ft(e,i)}function LB(e,t){if(!Ss(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ko(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Is(this,"shape",n),n}});return ft(e,r)}function FB(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=ko(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Is(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ft(e,r)}function BB(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=ko(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Is(this,"shape",c),c},checks:[]});return ft(t,s)}function ZB(e,t,r){let n=ko(t._zod.def,{get shape(){let i=t._zod.def.shape,o={...i};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new e({type:"nonoptional",innerType:i[s]}))}else for(let s in i)o[s]=new e({type:"nonoptional",innerType:i[s]});return Is(this,"shape",o),o}});return ft(t,n)}function As(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Qw(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Vr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function uf(e){return typeof e=="string"?e:e?.message}function Cr(e,t,r){let n=e.message?e.message:uf(e.inst?._zod.def?.error?.(e))??uf(t?.error?.(e))??uf(r.customError?.(e))??uf(r.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function ff(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function mf(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function V(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function rl(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function VB(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function zC(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jC(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function WB(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return zC(t+r)}function qB(e){return jC(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function KB(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function GB(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Vw=class{constructor(...t){}};var DC=(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,el,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},hf=E("$ZodError",DC),Wr=E("$ZodError",DC,{Parent:Error});function gf(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function yf(e,t=r=>r.message){let r={_errors:[]},n=(i,o=[])=>{for(let s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...o,...s.path]);else{let a=[...o,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(s))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(e),r}function ex(e,t=r=>r.message){let r={errors:[]},n=(i,o=[])=>{var s,a;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>n({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...o,...c.path]);else{let u=[...o,...c.path];if(u.length===0){r.errors.push(t(c));continue}let l=r,d=0;for(;d<u.length;){let p=u[d],f=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),(s=l.properties)[p]??(s[p]={errors:[]}),l=l.properties[p]):(l.items??(l.items=[]),(a=l.items)[p]??(a[p]={errors:[]}),l=l.items[p]),f&&l.errors.push(t(c)),d++}}};return n(e),r}function UC(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function tx(e){let t=[],r=[...e.issues].sort((n,i)=>(n.path??[]).length-(i.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${UC(n.path)}`);return t.join(`
|
|
7
|
-
`)}var nl=e=>(t,r,n,i)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Qn;if(s.issues.length){let a=new(i?.Err??e)(s.issues.map(c=>Cr(c,o,Ot())));throw $g(a,i?.callee),a}return s.value},ji=nl(Wr),il=e=>async(t,r,n,i)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??e)(s.issues.map(c=>Cr(c,o,Ot())));throw $g(a,i?.callee),a}return s.value},ic=il(Wr),ol=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Qn;return o.issues.length?{success:!1,error:new(e??hf)(o.issues.map(s=>Cr(s,i,Ot())))}:{success:!0,data:o.value}},rx=ol(Wr),sl=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>Cr(s,i,Ot())))}:{success:!0,data:o.value}},nx=sl(Wr),Tg=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return nl(e)(t,r,i)},JB=Tg(Wr),Eg=e=>(t,r,n)=>nl(e)(t,r,n),XB=Eg(Wr),Pg=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return il(e)(t,r,i)},YB=Pg(Wr),Cg=e=>async(t,r,n)=>il(e)(t,r,n),QB=Cg(Wr),Rg=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return ol(e)(t,r,i)},eZ=Rg(Wr),Ng=e=>(t,r,n)=>ol(e)(t,r,n),tZ=Ng(Wr),Mg=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return sl(e)(t,r,i)},rZ=Mg(Wr),zg=e=>async(t,r,n)=>sl(e)(t,r,n),nZ=zg(Wr);var ln={};Kn(ln,{base64:()=>vx,base64url:()=>jg,bigint:()=>Ax,boolean:()=>$x,browserEmail:()=>dZ,cidrv4:()=>yx,cidrv6:()=>_x,cuid:()=>ix,cuid2:()=>ox,date:()=>xx,datetime:()=>Ix,domain:()=>mZ,duration:()=>lx,e164:()=>wx,email:()=>px,emoji:()=>fx,extendedDuration:()=>iZ,guid:()=>dx,hex:()=>hZ,hostname:()=>fZ,html5Email:()=>cZ,httpProtocol:()=>bx,idnEmail:()=>lZ,integer:()=>Ox,ipv4:()=>mx,ipv6:()=>hx,ksuid:()=>cx,lowercase:()=>Px,mac:()=>gx,md5_base64:()=>yZ,md5_base64url:()=>_Z,md5_hex:()=>gZ,nanoid:()=>ux,null:()=>Tx,number:()=>Dg,rfc5322Email:()=>uZ,sha1_base64:()=>bZ,sha1_base64url:()=>wZ,sha1_hex:()=>vZ,sha256_base64:()=>kZ,sha256_base64url:()=>IZ,sha256_hex:()=>xZ,sha384_base64:()=>AZ,sha384_base64url:()=>OZ,sha384_hex:()=>SZ,sha512_base64:()=>TZ,sha512_base64url:()=>EZ,sha512_hex:()=>$Z,string:()=>Sx,time:()=>kx,ulid:()=>sx,undefined:()=>Ex,unicodeEmail:()=>LC,uppercase:()=>Cx,uuid:()=>oc,uuid4:()=>oZ,uuid6:()=>sZ,uuid7:()=>aZ,xid:()=>ax});var ix=/^[cC][0-9a-z]{6,}$/,ox=/^[0-9a-z]+$/,sx=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ax=/^[0-9a-vA-V]{20}$/,cx=/^[A-Za-z0-9]{27}$/,ux=/^[a-zA-Z0-9_-]{21}$/,lx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,iZ=/^[-+]?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)?)??$/,dx=/^([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})$/,oc=e=>e?new 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)$/,oZ=oc(4),sZ=oc(6),aZ=oc(7),px=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cZ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,uZ=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,LC=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,lZ=LC,dZ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,pZ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fx(){return new RegExp(pZ,"u")}var mx=/^(?:(?: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])$/,hx=/^(([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}|:))$/,gx=e=>{let t=xn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},yx=/^((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])$/,_x=/^(([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])$/,vx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jg=/^[A-Za-z0-9_-]*$/,fZ=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,mZ=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,bx=/^https?$/,wx=/^\+[1-9]\d{6,14}$/,FC="(?:(?:\\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])))",xx=new RegExp(`^${FC}$`);function BC(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 kx(e){return new RegExp(`^${BC(e)}$`)}function Ix(e){let t=BC({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${FC}T(?:${n})$`)}var Sx=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ax=/^-?\d+n?$/,Ox=/^-?\d+$/,Dg=/^-?\d+(?:\.\d+)?$/,$x=/^(?:true|false)$/i,Tx=/^null$/i;var Ex=/^undefined$/i;var Px=/^[^A-Z]*$/,Cx=/^[^a-z]*$/,hZ=/^[0-9a-fA-F]*$/;function _f(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function vf(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var gZ=/^[0-9a-fA-F]{32}$/,yZ=_f(22,"=="),_Z=vf(22),vZ=/^[0-9a-fA-F]{40}$/,bZ=_f(27,"="),wZ=vf(27),xZ=/^[0-9a-fA-F]{64}$/,kZ=_f(43,"="),IZ=vf(43),SZ=/^[0-9a-fA-F]{96}$/,AZ=_f(64,""),OZ=vf(64),$Z=/^[0-9a-fA-F]{128}$/,TZ=_f(86,"=="),EZ=vf(86);var lt=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),VC={number:"number",bigint:"bigint",object:"date"},Ug=E("$ZodCheckLessThan",(e,t)=>{lt.init(e,t);let r=VC[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lg=E("$ZodCheckGreaterThan",(e,t)=>{lt.init(e,t);let r=VC[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Rx=E("$ZodCheckMultipleOf",(e,t)=>{lt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Ww(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Nx=E("$ZodCheckNumberFormat",(e,t)=>{lt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Xw[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=i,a.maximum=o,r&&(a.pattern=Ox)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Mx=E("$ZodCheckBigIntFormat",(e,t)=>{lt.init(e,t);let[r,n]=Yw[t.format];e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,o.minimum=r,o.maximum=n}),e._zod.check=i=>{let o=i.value;o<r&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>n&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),zx=E("$ZodCheckMaxSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;i.size<=t.maximum||n.issues.push({origin:ff(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),jx=E("$ZodCheckMinSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;i.size>=t.minimum||n.issues.push({origin:ff(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Dx=E("$ZodCheckSizeEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=n=>{let i=n.value,o=i.size;if(o===t.size)return;let s=o>t.size;n.issues.push({origin:ff(i),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ux=E("$ZodCheckMaxLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let s=mf(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Lx=E("$ZodCheckMinLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let s=mf(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Fx=E("$ZodCheckLengthEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ks(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let s=mf(i),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),al=E("$ZodCheckStringFormat",(e,t)=>{var r,n;lt.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Bx=E("$ZodCheckRegex",(e,t)=>{al.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zx=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Px),al.init(e,t)}),Vx=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Cx),al.init(e,t)}),Wx=E("$ZodCheckIncludes",(e,t)=>{lt.init(e,t);let r=xn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),qx=E("$ZodCheckStartsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`^${xn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),Kx=E("$ZodCheckEndsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`.*${xn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}});function ZC(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues))}var Gx=E("$ZodCheckProperty",(e,t)=>{lt.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(i=>ZC(i,r,t.property));ZC(n,r,t.property)}}),Hx=E("$ZodCheckMimeType",(e,t)=>{lt.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),Jx=E("$ZodCheckOverwrite",(e,t)=>{lt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var bf=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
8
|
-
`).filter(s=>s),i=Math.min(...n.map(s=>s.length-s.trimStart().length)),o=n.map(s=>s.slice(i)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...r,i.join(`
|
|
9
|
-
`))}};var Xx={major:4,minor:4,patch:3};var Ie=E("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xx;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,a,c)=>{let u=As(s),l;for(let d of a){if(d._zod.def.when){if(Qw(s)||!d._zod.def.when(s))continue}else if(u)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&c?.async===!1)throw new Qn;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(u||(u=As(s,p)))});else{if(s.issues.length===p)continue;u||(u=As(s,p))}}return l?l.then(()=>s):s},o=(s,a,c)=>{if(As(s))return s.aborted=!0,s;let u=i(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new Qn;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>o(l,s,a)):o(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Qn;return c.then(u=>i(u,n,a))}return i(c,n,a)}}je(e,"~standard",()=>({validate:i=>{try{let o=rx(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return nx(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),sc=E("$ZodString",(e,t)=>{Ie.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Sx(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),nt=E("$ZodStringFormat",(e,t)=>{al.init(e,t),sc.init(e,t)}),Qx=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=dx),nt.init(e,t)}),ek=E("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=oc(n))}else t.pattern??(t.pattern=oc());nt.init(e,t)}),tk=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=px),nt.init(e,t)}),rk=E("$ZodURL",(e,t)=>{nt.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===bx.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.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)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),nk=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fx()),nt.init(e,t)}),ik=E("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ux),nt.init(e,t)}),ok=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ix),nt.init(e,t)}),sk=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ox),nt.init(e,t)}),ak=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=sx),nt.init(e,t)}),ck=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ax),nt.init(e,t)}),uk=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cx),nt.init(e,t)}),lk=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ix(t)),nt.init(e,t)}),dk=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xx),nt.init(e,t)}),pk=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kx(t)),nt.init(e,t)}),fk=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lx),nt.init(e,t)}),mk=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mx),nt.init(e,t),e._zod.bag.format="ipv4"}),hk=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hx),nt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),gk=E("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gx(t.delimiter)),nt.init(e,t),e._zod.bag.format="mac"}),yk=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=yx),nt.init(e,t)}),_k=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=_x),nt.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[i,o]=n;if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function vk(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var bk=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=vx),nt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{vk(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function sR(e){if(!jg.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return vk(r)}var wk=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jg),nt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{sR(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),xk=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wx),nt.init(e,t)});function aR(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var kk=E("$ZodJWT",(e,t)=>{nt.init(e,t),e._zod.check=r=>{aR(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ik=E("$ZodCustomStringFormat",(e,t)=>{nt.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Wg=E("$ZodNumber",(e,t)=>{Ie.init(e,t),e._zod.pattern=e._zod.bag.pattern??Dg,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Sk=E("$ZodNumberFormat",(e,t)=>{Nx.init(e,t),Wg.init(e,t)}),wf=E("$ZodBoolean",(e,t)=>{Ie.init(e,t),e._zod.pattern=$x,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),qg=E("$ZodBigInt",(e,t)=>{Ie.init(e,t),e._zod.pattern=Ax,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Ak=E("$ZodBigIntFormat",(e,t)=>{Mx.init(e,t),qg.init(e,t)}),Ok=E("$ZodSymbol",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),r}}),$k=E("$ZodUndefined",(e,t)=>{Ie.init(e,t),e._zod.pattern=Ex,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),r}}),Tk=E("$ZodNull",(e,t)=>{Ie.init(e,t),e._zod.pattern=Tx,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}}),Ek=E("$ZodAny",(e,t)=>{Ie.init(e,t),e._zod.parse=r=>r}),xf=E("$ZodUnknown",(e,t)=>{Ie.init(e,t),e._zod.parse=r=>r}),kf=E("$ZodNever",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Pk=E("$ZodVoid",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),Ck=E("$ZodDate",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function qC(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}var Rk=E("$ZodArray",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?o.push(c.then(u=>qC(u,r,s))):qC(c,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Vg(e,t,r,n,i,o){let s=r in n;if(e.issues.length){if(i&&o&&!s)return;t.issues.push(...Vr(r,e.issues))}if(!s&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function cR(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Jw(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function uR(e,t,r,n,i,o){let s=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let p in t){if(p==="__proto__"||a.has(p))continue;if(u==="never"){s.push(p);continue}let f=c.run({value:t[p],issues:[]},n);f instanceof Promise?e.push(f.then(m=>Vg(m,r,p,t,l,d))):Vg(f,r,p,t,l,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var lR=E("$ZodObject",(e,t)=>{if(Ie.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=tl(()=>cR(t));je(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let i=nc,o=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=n.value);let u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],d=s.shape;for(let p of s.keys){let f=d[p],m=f._zod.optin==="optional",h=f._zod.optout==="optional",y=f._zod.run({value:u[p],issues:[]},c);y instanceof Promise?l.push(y.then(w=>Vg(w,a,p,u,m,h))):Vg(y,a,p,u,m,h)}return o?uR(l,u,a,c,n.value,e):l.length?Promise.all(l).then(()=>a):a}}),Nk=E("$ZodObjectJIT",(e,t)=>{lR.init(e,t);let r=e._zod.parse,n=tl(()=>cR(t)),i=p=>{let f=new bf(["shape","payload","ctx"]),m=n.value,h=b=>{let I=Og(b);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};f.write("const input = payload.value;");let y=Object.create(null),w=0;for(let b of m.keys)y[b]=`key_${w++}`;f.write("const newResult = {};");for(let b of m.keys){let I=y[b],$=Og(b),P=p[b],C=P?._zod?.optin==="optional",x=P?._zod?.optout==="optional";f.write(`const ${I} = ${h(b)};`),C&&x?f.write(`
|
|
10
|
-
if (${I}.issues.length) {
|
|
11
|
-
if (${$} in input) {
|
|
12
|
-
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
13
|
-
...iss,
|
|
14
|
-
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
15
|
-
})));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (${I}.value === undefined) {
|
|
20
|
-
if (${$} in input) {
|
|
21
|
-
newResult[${$}] = undefined;
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
newResult[${$}] = ${I}.value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
`):C?f.write(`
|
|
28
|
-
if (${I}.issues.length) {
|
|
29
|
-
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
30
|
-
...iss,
|
|
31
|
-
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
32
|
-
})));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (${I}.value === undefined) {
|
|
36
|
-
if (${$} in input) {
|
|
37
|
-
newResult[${$}] = undefined;
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
newResult[${$}] = ${I}.value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
`):f.write(`
|
|
44
|
-
const ${I}_present = ${$} in input;
|
|
45
|
-
if (${I}.issues.length) {
|
|
46
|
-
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
47
|
-
...iss,
|
|
48
|
-
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
49
|
-
})));
|
|
50
|
-
}
|
|
51
|
-
if (!${I}_present && !${I}.issues.length) {
|
|
52
|
-
payload.issues.push({
|
|
53
|
-
code: "invalid_type",
|
|
54
|
-
expected: "nonoptional",
|
|
55
|
-
input: undefined,
|
|
56
|
-
path: [${$}]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (${I}_present) {
|
|
61
|
-
if (${I}.value === undefined) {
|
|
62
|
-
newResult[${$}] = undefined;
|
|
63
|
-
} else {
|
|
64
|
-
newResult[${$}] = ${I}.value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");let _=f.compile();return(b,I)=>_(p,b,I)},o,s=nc,a=!rc.jitless,u=a&&Kw.value,l=t.catchall,d;e._zod.parse=(p,f)=>{d??(d=n.value);let m=p.value;return s(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(o||(o=i(t.shape)),p=o(p,f),l?uR([],m,p,f,d,e):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function KC(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!As(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>Cr(s,n,Ot())))}),t)}var If=E("$ZodUnion",(e,t)=>{Ie.init(e,t),je(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),je(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),je(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),je(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>df(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,s=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>KC(a,n,e,i)):KC(s,n,e,i)}});function GC(e,t,r,n){let i=e.filter(o=>o.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>Cr(s,n,Ot())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Mk=E("$ZodXor",(e,t)=>{If.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,s=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},i);c instanceof Promise?(s.push(c),o=!0):s.push(c)}return o?Promise.all(s).then(a=>GC(a,n,e,i)):GC(s,n,e,i)}}),zk=E("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,If.init(e,t);let r=e._zod.parse;je(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,c]of Object.entries(s)){i[a]||(i[a]=new Set);for(let u of c)i[a].add(u)}}return i});let n=tl(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!nc(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback||o.direction==="backward"?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:s,path:[t.discriminator],inst:e}),i)}}),jk=E("$ZodIntersection",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([c,u])=>HC(r,c,u)):HC(r,o,s)}});function Yx(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ss(e)&&Ss(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=Yx(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=Yx(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function HC(e,t,r){let n=new Map,i;for(let a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);let o=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&i&&e.issues.push({...i,keys:o}),As(e))return e;let s=Yx(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Kg=E("$ZodTuple",(e,t)=>{Ie.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let s=[],a=JC(r,"optin"),c=JC(r,"optout");if(!t.rest){if(o.length<a)return n.issues.push({code:"too_small",minimum:a,inclusive:!0,input:o,inst:e,origin:"array"}),n;o.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=new Array(r.length);for(let l=0;l<r.length;l++){let d=r[l]._zod.run({value:o[l],issues:[]},i);d instanceof Promise?s.push(d.then(p=>{u[l]=p})):u[l]=d}if(t.rest){let l=r.length-1,d=o.slice(r.length);for(let p of d){l++;let f=t.rest._zod.run({value:p,issues:[]},i);f instanceof Promise?s.push(f.then(m=>XC(m,n,l))):XC(f,n,l)}}return s.length?Promise.all(s).then(()=>YC(u,n,r,o,c)):YC(u,n,r,o,c)}});function JC(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function XC(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}function YC(e,t,r,n,i){for(let o=0;o<r.length;o++){let s=e[o],a=o<n.length;if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...Vr(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=n.length&&(r[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}var Dk=E("$ZodRecord",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Ss(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>Cr(f,n,Ot())),input:u,path:[u],inst:e});continue}let d=l.value,p=t.valueType._zod.run({value:i[u],issues:[]},n);p instanceof Promise?o.push(p.then(f=>{f.issues.length&&r.issues.push(...Vr(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...Vr(u,p.issues)),r.value[d]=p.value)}let c;for(let u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(i)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Dg.test(a)&&c.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[a]=i[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Cr(d,n,Ot())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:i[a],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...Vr(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Vr(a,l.issues)),r.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Uk=E("$ZodMap",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let o=[];r.value=new Map;for(let[s,a]of i){let c=t.keyType._zod.run({value:s,issues:[]},n),u=t.valueType._zod.run({value:a,issues:[]},n);c instanceof Promise||u instanceof Promise?o.push(Promise.all([c,u]).then(([l,d])=>{QC(l,d,r,s,i,e,n)})):QC(c,u,r,s,i,e,n)}return o.length?Promise.all(o).then(()=>r):r}});function QC(e,t,r,n,i,o,s){e.issues.length&&(pf.has(typeof n)?r.issues.push(...Vr(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Cr(a,s,Ot()))})),t.issues.length&&(pf.has(typeof n)?r.issues.push(...Vr(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:t.issues.map(a=>Cr(a,s,Ot()))})),r.value.set(e.value,t.value)}var Lk=E("$ZodSet",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let s of i){let a=t.valueType._zod.run({value:s,issues:[]},n);a instanceof Promise?o.push(a.then(c=>eR(c,r))):eR(a,r)}return o.length?Promise.all(o).then(()=>r):r}});function eR(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Fk=E("$ZodEnum",(e,t)=>{Ie.init(e,t);let r=lf(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>pf.has(typeof i)).map(i=>typeof i=="string"?xn(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:e}),i}}),Bk=E("$ZodLiteral",(e,t)=>{if(Ie.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?xn(n):n?xn(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),Zk=E("$ZodFile",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),Vk=E("$ZodTransform",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xs(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r.fallback=!0,r));if(i instanceof Promise)throw new Qn;return r.value=i,r.fallback=!0,r}});function tR(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ac=E("$ZodOptional",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",e._zod.optout="optional",je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),je(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${df(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=r.value,o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>tR(s,i)):tR(o,i)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Wk=E("$ZodExactOptional",(e,t)=>{ac.init(e,t),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),qk=E("$ZodNullable",(e,t)=>{Ie.init(e,t),je(e._zod,"optin",()=>t.innerType._zod.optin),je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${df(r.source)}|null)$`):void 0}),je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Kk=E("$ZodDefault",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>rR(o,t)):rR(i,t)}});function rR(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Gk=E("$ZodPrefault",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Hk=E("$ZodNonOptional",(e,t)=>{Ie.init(e,t),je(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>nR(o,e)):nR(i,e)}});function nR(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 Jk=E("$ZodSuccess",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xs("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),Xk=E("$ZodCatch",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>Cr(s,n,Ot()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>Cr(o,n,Ot()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),Yk=E("$ZodNaN",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Gg=E("$ZodPipe",(e,t)=>{Ie.init(e,t),je(e._zod,"values",()=>t.in._zod.values),je(e._zod,"optin",()=>t.in._zod.optin),je(e._zod,"optout",()=>t.out._zod.optout),je(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Fg(s,t.in,n)):Fg(o,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Fg(o,t.out,n)):Fg(i,t.out,n)}});function Fg(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var Sf=E("$ZodCodec",(e,t)=>{Ie.init(e,t),je(e._zod,"values",()=>t.in._zod.values),je(e._zod,"optin",()=>t.in._zod.optin),je(e._zod,"optout",()=>t.out._zod.optout),je(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Bg(s,t,n)):Bg(o,t,n)}else{let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Bg(s,t,n)):Bg(o,t,n)}}});function Bg(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Zg(e,o,t.out,r)):Zg(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Zg(e,o,t.in,r)):Zg(e,i,t.in,r)}}function Zg(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var Qk=E("$ZodPreprocess",(e,t)=>{Gg.init(e,t)}),eI=E("$ZodReadonly",(e,t)=>{Ie.init(e,t),je(e._zod,"propValues",()=>t.innerType._zod.propValues),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"optin",()=>t.innerType?._zod?.optin),je(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(iR):iR(i)}});function iR(e){return e.value=Object.freeze(e.value),e}var tI=E("$ZodTemplateLiteral",(e,t)=>{Ie.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let o=i.startsWith("^")?1:0,s=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(o,s))}else if(n===null||Hw.has(typeof n))r.push(xn(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),rI=E("$ZodFunction",(e,t)=>(Ie.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let i=e._def.input?ji(e._def.input,n):n,o=Reflect.apply(r,this,i);return e._def.output?ji(e._def.output,o):o}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await ic(e._def.input,n):n,o=await Reflect.apply(r,this,i);return e._def.output?await ic(e._def.output,o):o}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Kg({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),nI=E("$ZodPromise",(e,t)=>{Ie.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),iI=E("$ZodLazy",(e,t)=>{Ie.init(e,t),je(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),je(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),je(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),je(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),je(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),oI=E("$ZodCustom",(e,t)=>{lt.init(e,t),Ie.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>oR(o,r,n,e));oR(i,r,n,e)}});function oR(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(rl(i))}}var Of={};Kn(Of,{ar:()=>dR,az:()=>pR,be:()=>mR,bg:()=>hR,ca:()=>gR,cs:()=>yR,da:()=>_R,de:()=>vR,el:()=>bR,en:()=>Hg,eo:()=>wR,es:()=>xR,fa:()=>kR,fi:()=>IR,fr:()=>SR,frCA:()=>AR,he:()=>OR,hr:()=>$R,hu:()=>TR,hy:()=>PR,id:()=>CR,is:()=>RR,it:()=>NR,ja:()=>MR,ka:()=>zR,kh:()=>jR,km:()=>Jg,ko:()=>DR,lt:()=>LR,mk:()=>FR,ms:()=>BR,nl:()=>ZR,no:()=>VR,ota:()=>WR,pl:()=>KR,ps:()=>qR,pt:()=>GR,ro:()=>HR,ru:()=>XR,sl:()=>YR,sv:()=>QR,ta:()=>eN,th:()=>tN,tr:()=>rN,ua:()=>nN,uk:()=>Xg,ur:()=>iN,uz:()=>oN,vi:()=>sN,yo:()=>uN,zhCN:()=>aN,zhTW:()=>cN});var CZ=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(i){return e[i]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${i.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return i.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${Z(i.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${i.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${r[o.format]??i.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${N(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function dR(){return{localeError:CZ()}}var RZ=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${Z(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function pR(){return{localeError:RZ()}}function fR(e,t,r,n){let i=Math.abs(e),o=i%10,s=i%100;return s>=11&&s<=19?n:o===1?t:o>=2&&o<=4?r:n}var NZ=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(i){return e[i]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${Z(i.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);if(s){let a=Number(i.maximum),c=fR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${i.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);if(s){let a=Number(i.minimum),c=fR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${i.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${N(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function mR(){return{localeError:NZ()}}var MZ=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${Z(i.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${N(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function hR(){return{localeError:MZ()}}var zZ=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(i){return e[i]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${Z(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${N(i.values," o ")}`;case"too_big":{let o=i.inclusive?"com a m\xE0xim":"menys de",s=t(i.origin);return s?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${o} ${i.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(i.origin);return s?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${o} ${i.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}};function gR(){return{localeError:zZ()}}var jZ=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(i){return e[i]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${Z(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${N(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}};function yR(){return{localeError:jZ()}}var DZ=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(i){return e[i]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${Z(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin),a=n[i.origin]??i.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${i.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin),a=n[i.origin]??i.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${i.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${N(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}};function _R(){return{localeError:DZ()}}var UZ=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(i){return e[i]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${Z(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ist`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ist`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${N(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}};function vR(){return{localeError:UZ()}}var LZ=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(i){return e[i]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return typeof i.expected=="string"&&/^[A-Z]/.test(i.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${i.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":return i.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${Z(i.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.minimum.toString()} ${s.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${o.prefix}"`:o.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${o.suffix}"`:o.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${o.includes}"`:o.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[o.format]??i.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${N(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function bR(){return{localeError:LZ()}}var FZ=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Z(i.values[0])}`:`Invalid option: expected one of ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Too big: expected ${i.origin??"value"} to have ${o}${i.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Too small: expected ${i.origin} to have ${o}${i.minimum.toString()} ${s.unit}`:`Too small: expected ${i.origin} to be ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(s=>`'${s}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Hg(){return{localeError:FZ()}}var BZ=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(i){return e[i]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${Z(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${o}${i.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}};function wR(){return{localeError:BZ()}}var ZZ=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(i){return e[i]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${Z(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin),a=n[i.origin]??i.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${i.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin),a=n[i.origin]??i.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${i.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function xR(){return{localeError:ZZ()}}var VZ=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(i){return e[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${Z(i.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${N(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??i.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${N(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function kR(){return{localeError:VZ()}}var WZ=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(i){return e[i]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${Z(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${i.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${i.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${N(i.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function IR(){return{localeError:WZ()}}var qZ=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${Z(i.values[0])} attendu`:`Option invalide : une valeur parmi ${N(i.values,"|")} attendue`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Trop grand : ${n[i.origin]??"valeur"} doit ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Trop petit : ${n[i.origin]??"valeur"} doit ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Trop petit : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${N(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function SR(){return{localeError:qZ()}}var KZ=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${Z(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u2264":"<",s=t(i.origin);return s?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${o}${i.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u2265":">",s=t(i.origin);return s?`Trop petit : attendu que ${i.origin} ait ${o}${i.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${i.origin} soit ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${N(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function AR(){return{localeError:KZ()}}var GZ=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=u=>u?e[u]:void 0,n=u=>{let l=r(u);return l?l.label:u??e.unknown.label},i=u=>`\u05D4${n(u)}`,o=u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=u=>u?t[u]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return u=>{switch(u.code){case"invalid_type":{let l=u.expected,d=c[l??""]??n(l),p=V(u.input),f=c[p]??e[p]?.label??p;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${Z(u.values[0])}`;let l=u.values.map(f=>Z(f));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=s(u.origin),d=i(u.origin??"value");if(u.origin==="string")return`${l?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=u.inclusive?`${u.maximum} ${l?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${l?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=u.inclusive?"<=":"<",f=o(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.maximum.toString()}`}case"too_small":{let l=s(u.origin),d=i(u.origin??"value");if(u.origin==="string")return`${l?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let y=(u.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`}let h=u.inclusive?`${u.minimum} ${l?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${l?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=u.inclusive?">=":">",f=o(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${l.pattern}`;let d=a[l.format],p=d?.label??l.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${N(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${i(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function OR(){return{localeError:GZ()}}var HZ=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(i){return e[i]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},n={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${a}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${a}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${Z(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin),a=n[i.origin]??i.origin;return s?`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${o}${i.maximum.toString()} ${s.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin),a=n[i.origin]??i.origin;return s?`Premalo: o\u010Dekivano da ${a} ima ${o}${i.minimum.toString()} ${s.unit}`:`Premalo: o\u010Dekivano da ${a} bude ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${r[o.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${N(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${n[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${n[i.origin]??i.origin}`;default:return"Neispravan unos"}}};function $R(){return{localeError:HZ()}}var JZ=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${Z(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${i.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${o}${i.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function TR(){return{localeError:JZ()}}function ER(e,t,r){return Math.abs(e)===1?t:r}function cl(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var XZ=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(i){return e[i]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${i.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return i.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${Z(i.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);if(s){let a=Number(i.maximum),c=ER(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cl(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cl(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);if(s){let a=Number(i.minimum),c=ER(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cl(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cl(i.origin)} \u056C\u056B\u0576\u056B ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??i.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${N(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${cl(i.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${cl(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function PR(){return{localeError:XZ()}}var YZ=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(i){return e[i]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${Z(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${o}${i.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Terlalu kecil: diharapkan ${i.origin} memiliki ${o}${i.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}};function CR(){return{localeError:YZ()}}var QZ=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(i){return e[i]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${Z(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${o}${i.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${o}${i.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${N(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}};function RR(){return{localeError:QZ()}}var e9=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(i){return e[i]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${Z(i.values[0])}`:`Opzione non valida: atteso uno tra ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Troppo grande: ${i.origin??"valore"} deve avere ${o}${i.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Troppo piccolo: ${i.origin} deve avere ${o}${i.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${i.origin} deve essere ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${r[o.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${N(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}};function NR(){return{localeError:e9()}}var t9=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(i){return e[i]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${Z(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${N(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(i.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(i.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${i.keys.length>1?"\u7FA4":""}: ${N(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function MR(){return{localeError:t9()}}var r9=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(i){return e[i]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},n={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${i.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return i.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${Z(i.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${N(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${i.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${N(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function zR(){return{localeError:r9()}}var n9=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(i){return e[i]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},n={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${i.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return i.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${Z(i.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${N(i.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Jg(){return{localeError:n9()}}function jR(){return Jg()}var i9=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${Z(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${N(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${o}${s}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${o}${s}`}case"too_small":{let o=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${o}${s}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${N(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function DR(){return{localeError:i9()}}var Af=e=>e.charAt(0).toUpperCase()+e.slice(1);function UR(e){let t=Math.abs(e),r=t%10,n=t%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}var o9=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(i,o,s,a){let c=e[i]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},n={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${Z(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${N(i.values,"|")} pasirinkim\u0173`;case"too_big":{let o=n[i.origin]??i.origin,s=t(i.origin,UR(Number(i.maximum)),i.inclusive??!1,"smaller");if(s?.verb)return`${Af(o??i.origin??"reik\u0161m\u0117")} ${s.verb} ${i.maximum.toString()} ${s.unit??"element\u0173"}`;let a=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Af(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.maximum.toString()} ${s?.unit}`}case"too_small":{let o=n[i.origin]??i.origin,s=t(i.origin,UR(Number(i.minimum)),i.inclusive??!1,"bigger");if(s?.verb)return`${Af(o??i.origin??"reik\u0161m\u0117")} ${s.verb} ${i.minimum.toString()} ${s.unit??"element\u0173"}`;let a=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Af(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${N(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=n[i.origin]??i.origin;return`${Af(o??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function LR(){return{localeError:o9()}}var s9=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(i){return e[i]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Z(i.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${N(i.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function FR(){return{localeError:s9()}}var a9=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(i){return e[i]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${Z(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Terlalu besar: dijangka ${i.origin??"nilai"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Terlalu kecil: dijangka ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${N(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}};function BR(){return{localeError:a9()}}var c9=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(i){return e[i]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${Z(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin),a=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} is`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin),a=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} is`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}};function ZR(){return{localeError:c9()}}var u9=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(i){return e[i]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${Z(i.values[0])}`:`Ugyldig valg: forventet en av ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${N(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}};function VR(){return{localeError:u9()}}var l9=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${Z(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=i;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function WR(){return{localeError:l9()}}var d9=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(i){return e[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${Z(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${N(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${N(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function qR(){return{localeError:d9()}}var p9=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(i){return e[i]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${Z(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function KR(){return{localeError:p9()}}var f9=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(i){return e[i]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${Z(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${o}${i.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Muito pequeno: esperado que ${i.origin} tivesse ${o}${i.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${N(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}};function GR(){return{localeError:f9()}}var m9=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(i){return e[i]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},n={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${a}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${Z(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Prea mic: a\u0219teptat ca ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${r[o.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${N(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}};function HR(){return{localeError:m9()}}function JR(e,t,r,n){let i=Math.abs(e),o=i%10,s=i%100;return s>=11&&s<=19?n:o===1?t:o>=2&&o<=4?r:n}var h9=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${Z(i.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);if(s){let a=Number(i.maximum),c=JR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);if(s){let a=Number(i.minimum),c=JR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${N(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function XR(){return{localeError:h9()}}var g9=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(i){return e[i]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${Z(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${o}${i.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${o}${i.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${N(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}};function YR(){return{localeError:g9()}}var y9=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(i){return e[i]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${Z(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${N(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function QR(){return{localeError:y9()}}var _9=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(i){return e[i]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${i.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return i.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${Z(i.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${N(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${o}${i.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${o}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function eN(){return{localeError:_9()}}var v9=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(i){return e[i]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},n={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${i.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${Z(i.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(i.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(i.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??i.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${i.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${N(i.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function tN(){return{localeError:v9()}}var b9=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(i){return e[i]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${Z(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function rN(){return{localeError:b9()}}var w9=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${i.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${Z(i.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${N(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${i.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function Xg(){return{localeError:w9()}}function nN(){return Xg()}var x9=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(i){return e[i]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${Z(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${N(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${i.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${o}${i.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${o}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${i.keys.length>1?"\u0632":""}: ${N(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function iN(){return{localeError:x9()}}var k9=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(i){return e[i]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${Z(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function oN(){return{localeError:k9()}}var I9=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(i){return e[i]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${Z(i.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${i.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${s.verb} ${o}${i.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??i.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${N(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function sN(){return{localeError:I9()}}var S9=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(i){return e[i]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${Z(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${N(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function aN(){return{localeError:S9()}}var A9=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(i){return e[i]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${Z(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${N(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function cN(){return{localeError:A9()}}var O9=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(i){return e[i]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,s=V(i.input),a=n[s]??s;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${Z(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${N(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",s=t(i.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${s.verb} ${o}${i.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.maximum}`}case"too_small":{let o=i.inclusive?">=":">",s=t(i.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${s.verb} ${o}${i.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.minimum}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??i.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${N(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function uN(){return{localeError:O9()}}var lN,sI=Symbol("ZodOutput"),aI=Symbol("ZodInput"),Yg=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function ul(){return new Yg}(lN=globalThis).__zod_globalRegistry??(lN.__zod_globalRegistry=ul());var Qe=globalThis.__zod_globalRegistry;function cI(e,t){return new e({type:"string",...G(t)})}function uI(e,t){return new e({type:"string",coerce:!0,...G(t)})}function Qg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function $f(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function ey(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function ty(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function ry(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function ny(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function Tf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function iy(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function oy(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function sy(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function ay(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function cy(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function uy(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function ly(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function dy(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function py(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function lI(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...G(t)})}function fy(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function my(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function hy(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function gy(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function yy(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function _y(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}var dI={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function pI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function fI(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function mI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function hI(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function gI(e,t){return new e({type:"number",checks:[],...G(t)})}function yI(e,t){return new e({type:"number",coerce:!0,checks:[],...G(t)})}function _I(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...G(t)})}function vI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...G(t)})}function bI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...G(t)})}function wI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...G(t)})}function xI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...G(t)})}function kI(e,t){return new e({type:"boolean",...G(t)})}function II(e,t){return new e({type:"boolean",coerce:!0,...G(t)})}function SI(e,t){return new e({type:"bigint",...G(t)})}function AI(e,t){return new e({type:"bigint",coerce:!0,...G(t)})}function OI(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...G(t)})}function $I(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...G(t)})}function TI(e,t){return new e({type:"symbol",...G(t)})}function EI(e,t){return new e({type:"undefined",...G(t)})}function PI(e,t){return new e({type:"null",...G(t)})}function CI(e){return new e({type:"any"})}function Ef(e){return new e({type:"unknown"})}function Pf(e,t){return new e({type:"never",...G(t)})}function RI(e,t){return new e({type:"void",...G(t)})}function NI(e,t){return new e({type:"date",...G(t)})}function MI(e,t){return new e({type:"date",coerce:!0,...G(t)})}function zI(e,t){return new e({type:"nan",...G(t)})}function Di(e,t){return new Ug({check:"less_than",...G(t),value:e,inclusive:!1})}function dn(e,t){return new Ug({check:"less_than",...G(t),value:e,inclusive:!0})}function Ui(e,t){return new Lg({check:"greater_than",...G(t),value:e,inclusive:!1})}function Rr(e,t){return new Lg({check:"greater_than",...G(t),value:e,inclusive:!0})}function vy(e){return Ui(0,e)}function by(e){return Di(0,e)}function wy(e){return dn(0,e)}function xy(e){return Rr(0,e)}function Os(e,t){return new Rx({check:"multiple_of",...G(t),value:e})}function $s(e,t){return new zx({check:"max_size",...G(t),maximum:e})}function Li(e,t){return new jx({check:"min_size",...G(t),minimum:e})}function cc(e,t){return new Dx({check:"size_equals",...G(t),size:e})}function uc(e,t){return new Ux({check:"max_length",...G(t),maximum:e})}function Io(e,t){return new Lx({check:"min_length",...G(t),minimum:e})}function lc(e,t){return new Fx({check:"length_equals",...G(t),length:e})}function ll(e,t){return new Bx({check:"string_format",format:"regex",...G(t),pattern:e})}function dl(e){return new Zx({check:"string_format",format:"lowercase",...G(e)})}function pl(e){return new Vx({check:"string_format",format:"uppercase",...G(e)})}function fl(e,t){return new Wx({check:"string_format",format:"includes",...G(t),includes:e})}function ml(e,t){return new qx({check:"string_format",format:"starts_with",...G(t),prefix:e})}function hl(e,t){return new Kx({check:"string_format",format:"ends_with",...G(t),suffix:e})}function ky(e,t,r){return new Gx({check:"property",property:e,schema:t,...G(r)})}function gl(e,t){return new Hx({check:"mime_type",mime:e,...G(t)})}function ei(e){return new Jx({check:"overwrite",tx:e})}function yl(e){return ei(t=>t.normalize(e))}function _l(){return ei(e=>e.trim())}function vl(){return ei(e=>e.toLowerCase())}function bl(){return ei(e=>e.toUpperCase())}function wl(){return ei(e=>qw(e))}function jI(e,t,r){return new e({type:"array",element:t,...G(r)})}function T9(e,t,r){return new e({type:"union",options:t,...G(r)})}function E9(e,t,r){return new e({type:"union",options:t,inclusive:!1,...G(r)})}function P9(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...G(n)})}function C9(e,t,r){return new e({type:"intersection",left:t,right:r})}function R9(e,t,r,n){let i=r instanceof Ie,o=i?n:r,s=i?r:null;return new e({type:"tuple",items:t,rest:s,...G(o)})}function N9(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...G(n)})}function M9(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...G(n)})}function z9(e,t,r){return new e({type:"set",valueType:t,...G(r)})}function j9(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:n,...G(r)})}function D9(e,t,r){return new e({type:"enum",entries:t,...G(r)})}function U9(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...G(r)})}function DI(e,t){return new e({type:"file",...G(t)})}function L9(e,t){return new e({type:"transform",transform:t})}function F9(e,t){return new e({type:"optional",innerType:t})}function B9(e,t){return new e({type:"nullable",innerType:t})}function Z9(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Gw(r)}})}function V9(e,t,r){return new e({type:"nonoptional",innerType:t,...G(r)})}function W9(e,t){return new e({type:"success",innerType:t})}function q9(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function K9(e,t,r){return new e({type:"pipe",in:t,out:r})}function G9(e,t){return new e({type:"readonly",innerType:t})}function H9(e,t,r){return new e({type:"template_literal",parts:t,...G(r)})}function J9(e,t){return new e({type:"lazy",getter:t})}function X9(e,t){return new e({type:"promise",innerType:t})}function UI(e,t,r){let n=G(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function LI(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}function FI(e,t){let r=dN(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(rl(i,n.value,r._zod.def));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(rl(o))}},e(n.value,n)),t);return r}function dN(e,t){let r=new lt({check:"custom",...G(t)});return r._zod.check=e,r}function BI(e){let t=new lt({check:"describe"});return t._zod.onattach=[r=>{let n=Qe.get(r)??{};Qe.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function ZI(e){let t=new lt({check:"meta"});return t._zod.onattach=[r=>{let n=Qe.get(r)??{};Qe.add(r,{...n,...e})}],t._zod.check=()=>{},t}function VI(e,t){let r=G(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(f=>typeof f=="string"?f.toLowerCase():f),i=i.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(n),s=new Set(i),a=e.Codec??Sf,c=e.Boolean??wf,u=e.String??sc,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),p=new a({type:"pipe",in:l,out:d,transform:((f,m)=>{let h=f;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:s.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:m.value,inst:p,continue:!1}),{})}),reverseTransform:((f,m)=>f===!0?n[0]||"true":i[0]||"false"),error:r.error});return p}function xl(e,t,r,n={}){let i=G(n),o={...G(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:a=>r.test(a),...i};return r instanceof RegExp&&(o.pattern=r),new e(o)}function Ts(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??Qe,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 et(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let p=s.schema,f=t.processors[i.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);f(e,t,p,l)}let d=e._zod.parent;d&&(s.ref||(s.ref=d),et(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&Nr(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Es(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}let i=s=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(s[1]===r)return{ref:"#"};let u=`#/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=i(s);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
69
|
-
|
|
70
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){o(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&e.reused==="ref"){o(s);continue}}}function Ps(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(m.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[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 a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}Object.assign(i,r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:kl(t,"input",e.processors),output:kl(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Nr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Nr(n.element,r);if(n.type==="set")return Nr(n.valueType,r);if(n.type==="lazy")return Nr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Nr(n.innerType,r);if(n.type==="intersection")return Nr(n.left,r)||Nr(n.right,r);if(n.type==="record"||n.type==="map")return Nr(n.keyType,r)||Nr(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Nr(n.in,r)||Nr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(Nr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(Nr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(Nr(i,r))return!0;return!!(n.rest&&Nr(n.rest,r))}return!1}var WI=(e,t={})=>r=>{let n=Ts({...r,processors:t});return et(e,n),Es(n,e),Ps(n,e)},kl=(e,t,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},s=Ts({...i??{},target:o,io:t,processors:r});return et(e,s),Es(s,e),Ps(s,e)};var Y9={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},qI=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=Y9[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},KI=(e,t,r,n)=>{let i=r,{minimum:o,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";let d=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";d?f?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof o=="number"&&(i.minimum=o),p?f?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof s=="number"&&(i.maximum=s),typeof c=="number"&&(i.multipleOf=c)},GI=(e,t,r,n)=>{r.type="boolean"},HI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},JI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},XI=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},YI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},QI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},eS=(e,t,r,n)=>{r.not={}},tS=(e,t,r,n)=>{},rS=(e,t,r,n)=>{},nS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},iS=(e,t,r,n)=>{let i=e._zod.def,o=lf(i.entries);o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},oS=(e,t,r,n)=>{let i=e._zod.def,o=[];for(let s of i.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),o.every(s=>typeof s=="boolean")&&(r.type="boolean"),o.every(s=>s===null)&&(r.type="null"),r.enum=o},sS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},aS=(e,t,r,n)=>{let i=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},cS=(e,t,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,o)},uS=(e,t,r,n)=>{r.type="boolean"},lS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},dS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},pS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},fS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},mS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},hS=(e,t,r,n)=>{let i=r,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=et(o.element,t,{...n,path:[...n.path,"items"]})},gS=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object",i.properties={};let s=o.shape;for(let u in s)i.properties[u]=et(s[u],t,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=et(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Sy=(e,t,r,n)=>{let i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>et(a,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},yS=(e,t,r,n)=>{let i=e._zod.def,o=et(i.left,t,{...n,path:[...n.path,"allOf",0]}),s=et(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c},_S=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((p,f)=>et(p,t,{...n,path:[...n.path,s,f]})),u=o.rest?et(o.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof d=="number"&&(i.maxItems=d)},vS=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object";let s=o.keyType,c=s._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=et(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=et(o.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=et(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=s._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l)}},bS=(e,t,r,n)=>{let i=e._zod.def,o=et(i.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},wS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},xS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},kS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},IS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},SS=(e,t,r,n)=>{let i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;et(s,t,n);let a=t.seen.get(e);a.ref=s},AS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},OS=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Ay=(e,t,r,n)=>{let i=e._zod.def;et(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},$S=(e,t,r,n)=>{let i=e._zod.innerType;et(i,t,n);let o=t.seen.get(e);o.ref=i},Iy={string:qI,number:KI,boolean:GI,bigint:HI,symbol:JI,null:XI,undefined:YI,void:QI,never:eS,any:tS,unknown:rS,date:nS,enum:iS,literal:oS,nan:sS,template_literal:aS,file:cS,success:uS,custom:lS,function:dS,transform:pS,map:fS,set:mS,array:hS,object:gS,union:Sy,intersection:yS,tuple:_S,record:vS,nullable:bS,nonoptional:wS,default:xS,prefault:kS,catch:IS,pipe:SS,readonly:AS,promise:OS,optional:Ay,lazy:$S};function So(e,t){if("_idmap"in e){let n=e,i=Ts({...t,processors:Iy}),o={};for(let c of n._idmap.entries()){let[u,l]=c;et(l,i)}let s={},a={registry:n,uri:t?.uri,defs:o};i.external=a;for(let c of n._idmap.entries()){let[u,l]=c;Es(i,l),s[u]=Ps(i,l)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=Ts({...t,processors:Iy});return et(e,r),Es(r,e),Ps(r,e)}var Oy=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Ts({processors:Iy,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return et(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Es(this.ctx,t);let n=Ps(this.ctx,t),{"~standard":i,...o}=n;return o}};var pN={};function it(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let r=t._zod;return typeof r=="object"&&r!==null&&"def"in r}function _t(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let r=t._def;return typeof r=="object"&&r!=null&&"typeName"in r}function fN(e){return it(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),_t(e)}function Ht(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(it(e)||_t(e))}function TS(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodLiteral"}function ES(e){return it(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="literal":!1}function mN(e){return!!(TS(e)||ES(e))}async function Ty(e,t){if(it(e))try{return{success:!0,data:await ic(e,t)}}catch(r){return{success:!1,error:r}}if(_t(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function Cs(e,t){if(it(e))return await ic(e,t);if(_t(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function hN(e,t){if(it(e))try{return{success:!0,data:ji(e,t)}}catch(r){return{success:!1,error:r}}if(_t(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Rs(e,t){if(it(e))return ji(e,t);if(_t(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function ti(e){if(it(e))return Qe.get(e)?.description;if(_t(e)||"description"in e&&typeof e.description=="string")return e.description}function gN(e){if(!Ht(e))return!1;if(_t(e)){let t=e._def;if(t.typeName==="ZodObject"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(it(e)){let t=e._zod.def;if(t.type==="object"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function Sl(e){return Ht(e)?_t(e)?e._def.typeName==="ZodString":it(e)?e._zod.def.type==="string":!1:!1}function Cf(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodObject"}function kn(e){return it(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="object":!1}function Rf(e){return it(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="array":!1}function PS(e){return it(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="optional":!1}function CS(e){return it(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="nullable":!1}function _r(e){return!!(Cf(e)||kn(e))}function Oo(e){if(_t(e))return e.shape;if(it(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ey(e,t){if(_t(e))return e.extend(t);if(it(e))return W.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ns(e){if(_t(e))return e.partial();if(it(e))return W.partial(ac,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Il(e,t=!1){if(Cf(e))return e.strict();if(kn(e)){let r=e._zod.def.shape;if(t)for(let[o,s]of Object.entries(e._zod.def.shape)){if(kn(s))r[o]=Il(s,t);else if(Rf(s)){let c=s._zod.def.element;kn(c)&&(c=Il(c,t)),r[o]=ft(s,{...s._zod.def,element:c})}else r[o]=s;let a=Qe.get(s);a&&Qe.add(r[o],a)}let n=ft(e,{...e._zod.def,shape:r,catchall:Pf(kf)}),i=Qe.get(e);return i&&Qe.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function $y(e,t=!1){if(Cf(e))return e.passthrough();if(kn(e)){let r=e._zod.def.shape;if(t)for(let[o,s]of Object.entries(e._zod.def.shape)){if(kn(s))r[o]=$y(s,t);else if(Rf(s)){let c=s._zod.def.element;kn(c)&&(c=$y(c,t)),r[o]=ft(s,{...s._zod.def,element:c})}else r[o]=s;let a=Qe.get(s);a&&Qe.add(r[o],a)}let n=ft(e,{...e._zod.def,shape:r,catchall:Ef(xf)}),i=Qe.get(e);return i&&Qe.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Py(e){if(_t(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(it(e))try{let t=ji(e,void 0);return()=>t}catch{return}}function eV(e){return _t(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function tV(e){return it(e)&&e._zod.def.type==="pipe"}function dc(e,t,r){let n=r.get(e);if(n!==void 0)return n;if(_t(e))return eV(e)?dc(e._def.schema,t,r):e;if(it(e)){let i=e;if(tV(e)&&(i=dc(e._zod.def.in,t,r)),t){if(kn(i)){let s={};for(let[a,c]of Object.entries(i._zod.def.shape))s[a]=dc(c,t,r);i=ft(i,{...i._zod.def,shape:s})}else if(Rf(i)){let s=dc(i._zod.def.element,t,r);i=ft(i,{...i._zod.def,element:s})}else if(PS(i)){let s=dc(i._zod.def.innerType,t,r);i=ft(i,{...i._zod.def,innerType:s})}else if(CS(i)){let s=dc(i._zod.def.innerType,t,r);i=ft(i,{...i._zod.def,innerType:s})}}let o=Qe.get(e);return o&&Qe.add(i,o),r.set(e,i),i}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Cy(e,t=!1){return dc(e,t,new WeakMap)}function yN(e,t){if(_t(e)){let r=Oo(e),n={};for(let[i,o]of Object.entries(r))t(i,o)?n[i]=o.optional():n[i]=o;return e.extend(n)}if(it(e)){let r=Oo(e),n={...e._zod.def.shape};for(let[s,a]of Object.entries(r))t(s,a)&&(n[s]=new ac({type:"optional",innerType:a}));let i=ft(e,{...e._zod.def,shape:n}),o=Qe.get(e);return o&&Qe.add(i,o),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ry(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var NS=Symbol("Let zodToJsonSchema decide on which parser to use"),RS={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"},MS=e=>typeof e=="string"?{...RS,name:e}:{...RS,...e};var zS=e=>{let t=MS(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};var Nf=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function mt(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Nf(t,e.currentPath):t.join("/")}}function Ny(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ve(e,t,r,n,i){e[t]=r,Ny(e,t,n,i)}var nr={};Kn(nr,{BRAND:()=>OV,DIRTY:()=>pc,EMPTY_PATH:()=>oV,INVALID:()=>ge,NEVER:()=>d5,OK:()=>vr,ParseStatus:()=>dr,Schema:()=>Ne,ZodAny:()=>js,ZodArray:()=>Po,ZodBigInt:()=>mc,ZodBoolean:()=>hc,ZodBranded:()=>zf,ZodCatch:()=>Ac,ZodDate:()=>gc,ZodDefault:()=>Sc,ZodDiscriminatedUnion:()=>jy,ZodEffects:()=>An,ZodEnum:()=>kc,ZodError:()=>qr,ZodFirstPartyTypeKind:()=>z,ZodFunction:()=>Uy,ZodIntersection:()=>bc,ZodIssueCode:()=>q,ZodLazy:()=>wc,ZodLiteral:()=>xc,ZodMap:()=>Pl,ZodNaN:()=>Rl,ZodNativeEnum:()=>Ic,ZodNever:()=>ri,ZodNull:()=>_c,ZodNullable:()=>Zi,ZodNumber:()=>fc,ZodObject:()=>Kr,ZodOptional:()=>In,ZodParsedType:()=>se,ZodPipeline:()=>jf,ZodPromise:()=>Ds,ZodReadonly:()=>Oc,ZodRecord:()=>Dy,ZodSchema:()=>Ne,ZodSet:()=>Cl,ZodString:()=>zs,ZodSymbol:()=>Tl,ZodTransformer:()=>An,ZodTuple:()=>Bi,ZodType:()=>Ne,ZodUndefined:()=>yc,ZodUnion:()=>vc,ZodUnknown:()=>Eo,ZodVoid:()=>El,addIssueToContext:()=>ee,any:()=>zV,array:()=>LV,bigint:()=>PV,boolean:()=>$N,coerce:()=>l5,custom:()=>SN,date:()=>CV,datetimeRegex:()=>kN,defaultErrorMap:()=>$o,discriminatedUnion:()=>VV,effect:()=>r5,enum:()=>QV,function:()=>JV,getErrorMap:()=>Al,getParsedType:()=>Fi,instanceof:()=>TV,intersection:()=>WV,isAborted:()=>My,isAsync:()=>Ol,isDirty:()=>zy,isValid:()=>Ms,late:()=>$V,lazy:()=>XV,literal:()=>YV,makeIssue:()=>Mf,map:()=>GV,nan:()=>EV,nativeEnum:()=>e5,never:()=>DV,null:()=>MV,nullable:()=>i5,number:()=>ON,object:()=>FV,objectUtil:()=>jS,oboolean:()=>u5,onumber:()=>c5,optional:()=>n5,ostring:()=>a5,pipeline:()=>s5,preprocess:()=>o5,promise:()=>t5,quotelessJson:()=>rV,record:()=>KV,set:()=>HV,setErrorMap:()=>iV,strictObject:()=>BV,string:()=>AN,symbol:()=>RV,transformer:()=>r5,tuple:()=>qV,undefined:()=>NV,union:()=>ZV,unknown:()=>jV,util:()=>Be,void:()=>UV});var Be;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},e.find=(i,o)=>{for(let s of i)if(o(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Be||(Be={}));var jS;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(jS||(jS={}));var se=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fi=e=>{switch(typeof e){case"undefined":return se.undefined;case"string":return se.string;case"number":return Number.isNaN(e)?se.nan:se.number;case"boolean":return se.boolean;case"function":return se.function;case"bigint":return se.bigint;case"symbol":return se.symbol;case"object":return Array.isArray(e)?se.array:e===null?se.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?se.promise:typeof Map<"u"&&e instanceof Map?se.map:typeof Set<"u"&&e instanceof Set?se.set:typeof Date<"u"&&e instanceof Date?se.date:se.object;default:return se.unknown}};var q=Be.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"]),rV=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),qr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,c=0;for(;c<s.path.length;){let u=s.path[c];c===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(s))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};qr.create=e=>new qr(e);var nV=(e,t)=>{let r;switch(e.code){case q.invalid_type:e.received===se.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case q.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Be.jsonStringifyReplacer)}`;break;case q.unrecognized_keys:r=`Unrecognized key(s) in object: ${Be.joinValues(e.keys,", ")}`;break;case q.invalid_union:r="Invalid input";break;case q.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Be.joinValues(e.options)}`;break;case q.invalid_enum_value:r=`Invalid enum value. Expected ${Be.joinValues(e.options)}, received '${e.received}'`;break;case q.invalid_arguments:r="Invalid function arguments";break;case q.invalid_return_type:r="Invalid function return type";break;case q.invalid_date:r="Invalid date";break;case q.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Be.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case q.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case q.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case q.custom:r="Invalid input";break;case q.invalid_intersection_types:r="Intersection results could not be merged";break;case q.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case q.not_finite:r="Number must be finite";break;default:r=t.defaultError,Be.assertNever(e)}return{message:r}},$o=nV;var _N=$o;function iV(e){_N=e}function Al(){return _N}var Mf=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:t,defaultError:a}).message;return{...i,path:o,message:a}},oV=[];function ee(e,t){let r=Al(),n=Mf({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===$o?void 0:$o].filter(i=>!!i)});e.common.issues.push(n)}var dr=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return ge;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return ge;o.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:t.value,value:n}}},ge=Object.freeze({status:"aborted"}),pc=e=>({status:"dirty",value:e}),vr=e=>({status:"valid",value:e}),My=e=>e.status==="aborted",zy=e=>e.status==="dirty",Ms=e=>e.status==="valid",Ol=e=>typeof Promise<"u"&&e instanceof Promise;var de;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(de||(de={}));var Sn=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},vN=(e,t)=>{if(Ms(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new qr(e.common.issues);return this._error=r,this._error}}};function Te(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(s,a)=>{let{message:c}=e;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:i}}var Ne=class{get description(){return this._def.description}_getType(t){return Fi(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Fi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new dr,ctx:{common:t.parent.common,data:t.data,parsedType:Fi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ol(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Fi(t)},i=this._parseSync({data:t,path:n.path,parent:n});return vN(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Fi(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Ms(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Ms(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Fi(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(Ol(i)?i:Promise.resolve(i));return vN(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=t(i),a=()=>o.addIssue({code:q.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new An({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)}}optional(){return In.create(this,this._def)}nullable(){return Zi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Po.create(this)}promise(){return Ds.create(this,this._def)}or(t){return vc.create([this,t],this._def)}and(t){return bc.create(this,t,this._def)}transform(t){return new An({...Te(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Sc({...Te(this._def),innerType:this,defaultValue:r,typeName:z.ZodDefault})}brand(){return new zf({typeName:z.ZodBranded,type:this,...Te(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Ac({...Te(this._def),innerType:this,catchValue:r,typeName:z.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return jf.create(this,t)}readonly(){return Oc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},sV=/^c[^\s-]{8,}$/i,aV=/^[0-9a-z]+$/,cV=/^[0-9A-HJKMNP-TV-Z]{26}$/i,uV=/^[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,lV=/^[a-z0-9_-]{21}$/i,dV=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pV=/^[-+]?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)?)??$/,fV=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mV="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",DS,hV=/^(?:(?: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])$/,gV=/^(?:(?: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])$/,yV=/^(([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]))$/,_V=/^(([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])$/,vV=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,bV=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wN="((\\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])))",wV=new RegExp(`^${wN}$`);function xN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function xV(e){return new RegExp(`^${xN(e)}$`)}function kN(e){let t=`${wN}T${xN(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function kV(e,t){return!!((t==="v4"||!t)&&hV.test(e)||(t==="v6"||!t)&&yV.test(e))}function IV(e,t){if(!dV.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function SV(e,t){return!!((t==="v4"||!t)&&gV.test(e)||(t==="v6"||!t)&&_V.test(e))}var zs=class e extends Ne{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==se.string){let o=this._getOrReturnCtx(t);return ee(o,{code:q.invalid_type,expected:se.string,received:o.parsedType}),ge}let n=new dr,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),ee(i,{code:q.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),ee(i,{code:q.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=t.data.length>o.value,a=t.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(t,i),s?ee(i,{code:q.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&ee(i,{code:q.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")fV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"email",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")DS||(DS=new RegExp(mV,"u")),DS.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"emoji",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")uV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"uuid",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")lV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"nanoid",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")sV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"cuid",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")aV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"cuid2",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")cV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"ulid",code:q.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),ee(i,{validation:"url",code:q.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"regex",code:q.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?kN(o).test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?wV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?xV(o).test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{code:q.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?pV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"duration",code:q.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?kV(t.data,o.version)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"ip",code:q.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?IV(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"jwt",code:q.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?SV(t.data,o.version)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"cidr",code:q.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?vV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"base64",code:q.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?bV.test(t.data)||(i=this._getOrReturnCtx(t,i),ee(i,{validation:"base64url",code:q.invalid_string,message:o.message}),n.dirty()):Be.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:q.invalid_string,...de.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...de.errToObj(t)})}url(t){return this._addCheck({kind:"url",...de.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...de.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...de.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...de.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...de.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...de.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...de.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...de.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...de.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...de.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...de.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...de.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...de.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...de.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...de.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...de.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...de.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...de.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...de.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...de.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...de.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...de.errToObj(r)})}nonempty(t){return this.min(1,de.errToObj(t))}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(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};zs.create=e=>new zs({checks:[],typeName:z.ZodString,coerce:e?.coerce??!1,...Te(e)});function AV(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}var fc=class e extends Ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==se.number){let o=this._getOrReturnCtx(t);return ee(o,{code:q.invalid_type,expected:se.number,received:o.parsedType}),ge}let n,i=new dr;for(let o of this._def.checks)o.kind==="int"?Be.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),ee(n,{code:q.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?AV(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),ee(n,{code:q.not_finite,message:o.message}),i.dirty()):Be.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,de.toString(r))}gt(t,r){return this.setLimit("min",t,!1,de.toString(r))}lte(t,r){return this.setLimit("max",t,!0,de.toString(r))}lt(t,r){return this.setLimit("max",t,!1,de.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:de.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:de.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:de.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:de.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:de.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:de.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:de.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:de.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:de.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:de.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Be.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};fc.create=e=>new fc({checks:[],typeName:z.ZodNumber,coerce:e?.coerce||!1,...Te(e)});var mc=class e extends Ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==se.bigint)return this._getInvalidInput(t);let n,i=new dr;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),ee(n,{code:q.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Be.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return ee(r,{code:q.invalid_type,expected:se.bigint,received:r.parsedType}),ge}gte(t,r){return this.setLimit("min",t,!0,de.toString(r))}gt(t,r){return this.setLimit("min",t,!1,de.toString(r))}lte(t,r){return this.setLimit("max",t,!0,de.toString(r))}lt(t,r){return this.setLimit("max",t,!1,de.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:de.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:de.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:de.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:de.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:de.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:de.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};mc.create=e=>new mc({checks:[],typeName:z.ZodBigInt,coerce:e?.coerce??!1,...Te(e)});var hc=class extends Ne{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==se.boolean){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.boolean,received:n.parsedType}),ge}return vr(t.data)}};hc.create=e=>new hc({typeName:z.ZodBoolean,coerce:e?.coerce||!1,...Te(e)});var gc=class e extends Ne{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==se.date){let o=this._getOrReturnCtx(t);return ee(o,{code:q.invalid_type,expected:se.date,received:o.parsedType}),ge}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return ee(o,{code:q.invalid_date}),ge}let n=new dr,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),ee(i,{code:q.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),ee(i,{code:q.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Be.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:de.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:de.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};gc.create=e=>new gc({checks:[],coerce:e?.coerce||!1,typeName:z.ZodDate,...Te(e)});var Tl=class extends Ne{_parse(t){if(this._getType(t)!==se.symbol){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.symbol,received:n.parsedType}),ge}return vr(t.data)}};Tl.create=e=>new Tl({typeName:z.ZodSymbol,...Te(e)});var yc=class extends Ne{_parse(t){if(this._getType(t)!==se.undefined){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.undefined,received:n.parsedType}),ge}return vr(t.data)}};yc.create=e=>new yc({typeName:z.ZodUndefined,...Te(e)});var _c=class extends Ne{_parse(t){if(this._getType(t)!==se.null){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.null,received:n.parsedType}),ge}return vr(t.data)}};_c.create=e=>new _c({typeName:z.ZodNull,...Te(e)});var js=class extends Ne{constructor(){super(...arguments),this._any=!0}_parse(t){return vr(t.data)}};js.create=e=>new js({typeName:z.ZodAny,...Te(e)});var Eo=class extends Ne{constructor(){super(...arguments),this._unknown=!0}_parse(t){return vr(t.data)}};Eo.create=e=>new Eo({typeName:z.ZodUnknown,...Te(e)});var ri=class extends Ne{_parse(t){let r=this._getOrReturnCtx(t);return ee(r,{code:q.invalid_type,expected:se.never,received:r.parsedType}),ge}};ri.create=e=>new ri({typeName:z.ZodNever,...Te(e)});var El=class extends Ne{_parse(t){if(this._getType(t)!==se.undefined){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.void,received:n.parsedType}),ge}return vr(t.data)}};El.create=e=>new El({typeName:z.ZodVoid,...Te(e)});var Po=class e extends Ne{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==se.array)return ee(r,{code:q.invalid_type,expected:se.array,received:r.parsedType}),ge;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(ee(r,{code:s?q.too_big:q.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(ee(r,{code:q.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(ee(r,{code:q.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new Sn(r,s,r.path,a)))).then(s=>dr.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new Sn(r,s,r.path,a)));return dr.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:de.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:de.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:de.toString(r)}})}nonempty(t){return this.min(1,t)}};Po.create=(e,t)=>new Po({type:e,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...Te(t)});function $l(e){if(e instanceof Kr){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=In.create($l(n))}return new Kr({...e._def,shape:()=>t})}else return e instanceof Po?new Po({...e._def,type:$l(e.element)}):e instanceof In?In.create($l(e.unwrap())):e instanceof Zi?Zi.create($l(e.unwrap())):e instanceof Bi?Bi.create(e.items.map(t=>$l(t))):e}var Kr=class e extends Ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Be.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==se.object){let u=this._getOrReturnCtx(t);return ee(u,{code:q.invalid_type,expected:se.object,received:u.parsedType}),ge}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof ri&&this._def.unknownKeys==="strip"))for(let u in i.data)s.includes(u)||a.push(u);let c=[];for(let u of s){let l=o[u],d=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Sn(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof ri){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(u==="strict")a.length>0&&(ee(i,{code:q.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Sn(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>dr.mergeObjectSync(n,u)):dr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return de.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:de.errToObj(t).message??i}:{message:i}}}:{}})}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:z.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of Be.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of Be.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return $l(this)}partial(t){let r={};for(let n of Be.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of Be.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof In;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return IN(Be.objectKeys(this.shape))}};Kr.create=(e,t)=>new Kr({shape:()=>e,unknownKeys:"strip",catchall:ri.create(),typeName:z.ZodObject,...Te(t)});Kr.strictCreate=(e,t)=>new Kr({shape:()=>e,unknownKeys:"strict",catchall:ri.create(),typeName:z.ZodObject,...Te(t)});Kr.lazycreate=(e,t)=>new Kr({shape:e,unknownKeys:"strip",catchall:ri.create(),typeName:z.ZodObject,...Te(t)});var vc=class extends Ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new qr(a.ctx.common.issues));return ee(r,{code:q.invalid_union,unionErrors:s}),ge}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(c=>new qr(c));return ee(r,{code:q.invalid_union,unionErrors:a}),ge}}get options(){return this._def.options}};vc.create=(e,t)=>new vc({options:e,typeName:z.ZodUnion,...Te(t)});var To=e=>e instanceof wc?To(e.schema):e instanceof An?To(e.innerType()):e instanceof xc?[e.value]:e instanceof kc?e.options:e instanceof Ic?Be.objectValues(e.enum):e instanceof Sc?To(e._def.innerType):e instanceof yc?[void 0]:e instanceof _c?[null]:e instanceof In?[void 0,...To(e.unwrap())]:e instanceof Zi?[null,...To(e.unwrap())]:e instanceof zf||e instanceof Oc?To(e.unwrap()):e instanceof Ac?To(e._def.innerType):[],jy=class e extends Ne{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==se.object)return ee(r,{code:q.invalid_type,expected:se.object,received:r.parsedType}),ge;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(ee(r,{code:q.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let s=To(o.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,o)}}return new e({typeName:z.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Te(n)})}};function US(e,t){let r=Fi(e),n=Fi(t);if(e===t)return{valid:!0,data:e};if(r===se.object&&n===se.object){let i=Be.objectKeys(t),o=Be.objectKeys(e).filter(a=>i.indexOf(a)!==-1),s={...e,...t};for(let a of o){let c=US(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===se.array&&n===se.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let s=e[o],a=t[o],c=US(s,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===se.date&&n===se.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var bc=class extends Ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,s)=>{if(My(o)||My(s))return ge;let a=US(o.value,s.value);return a.valid?((zy(o)||zy(s))&&r.dirty(),{status:r.value,value:a.data}):(ee(n,{code:q.invalid_intersection_types}),ge)};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(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};bc.create=(e,t,r)=>new bc({left:e,right:t,typeName:z.ZodIntersection,...Te(r)});var Bi=class e extends Ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==se.array)return ee(n,{code:q.invalid_type,expected:se.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return ee(n,{code:q.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(ee(n,{code:q.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Sn(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>dr.mergeArray(r,s)):dr.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Bi.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bi({items:e,typeName:z.ZodTuple,rest:null,...Te(t)})};var Dy=class e extends Ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==se.object)return ee(n,{code:q.invalid_type,expected:se.object,received:n.parsedType}),ge;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new Sn(n,a,n.path,a)),value:s._parse(new Sn(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?dr.mergeObjectAsync(r,i):dr.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Ne?new e({keyType:t,valueType:r,typeName:z.ZodRecord,...Te(n)}):new e({keyType:zs.create(),valueType:t,typeName:z.ZodRecord,...Te(r)})}},Pl=class extends Ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==se.map)return ee(n,{code:q.invalid_type,expected:se.map,received:n.parsedType}),ge;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,c],u)=>({key:i._parse(new Sn(n,a,n.path,[u,"key"])),value:o._parse(new Sn(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return ge;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return ge;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};Pl.create=(e,t,r)=>new Pl({valueType:t,keyType:e,typeName:z.ZodMap,...Te(r)});var Cl=class e extends Ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==se.set)return ee(n,{code:q.invalid_type,expected:se.set,received:n.parsedType}),ge;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ee(n,{code:q.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ee(n,{code:q.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(c){let u=new Set;for(let l of c){if(l.status==="aborted")return ge;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>o._parse(new Sn(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:de.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:de.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Cl.create=(e,t)=>new Cl({valueType:e,minSize:null,maxSize:null,typeName:z.ZodSet,...Te(t)});var Uy=class e extends Ne{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==se.function)return ee(r,{code:q.invalid_type,expected:se.function,received:r.parsedType}),ge;function n(a,c){return Mf({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Al(),$o].filter(u=>!!u),issueData:{code:q.invalid_arguments,argumentsError:c}})}function i(a,c){return Mf({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Al(),$o].filter(u=>!!u),issueData:{code:q.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Ds){let a=this;return vr(async function(...c){let u=new qr([]),l=await a._def.args.parseAsync(c,o).catch(f=>{throw u.addIssue(n(c,f)),u}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(f=>{throw u.addIssue(i(d,f)),u})})}else{let a=this;return vr(function(...c){let u=a._def.args.safeParse(c,o);if(!u.success)throw new qr([n(c,u.error)]);let l=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new qr([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Bi.create(t).rest(Eo.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Bi.create([]).rest(Eo.create()),returns:r||Eo.create(),typeName:z.ZodFunction,...Te(n)})}},wc=class extends Ne{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};wc.create=(e,t)=>new wc({getter:e,typeName:z.ZodLazy,...Te(t)});var xc=class extends Ne{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return ee(r,{received:r.data,code:q.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:t.data}}get value(){return this._def.value}};xc.create=(e,t)=>new xc({value:e,typeName:z.ZodLiteral,...Te(t)});function IN(e,t){return new kc({values:e,typeName:z.ZodEnum,...Te(t)})}var kc=class e extends Ne{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return ee(r,{expected:Be.joinValues(n),received:r.parsedType,code:q.invalid_type}),ge}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return ee(r,{received:r.data,code:q.invalid_enum_value,options:n}),ge}return vr(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};kc.create=IN;var Ic=class extends Ne{_parse(t){let r=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==se.string&&n.parsedType!==se.number){let i=Be.objectValues(r);return ee(n,{expected:Be.joinValues(i),received:n.parsedType,code:q.invalid_type}),ge}if(this._cache||(this._cache=new Set(Be.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Be.objectValues(r);return ee(n,{received:n.data,code:q.invalid_enum_value,options:i}),ge}return vr(t.data)}get enum(){return this._def.values}};Ic.create=(e,t)=>new Ic({values:e,typeName:z.ZodNativeEnum,...Te(t)});var Ds=class extends Ne{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==se.promise&&r.common.async===!1)return ee(r,{code:q.invalid_type,expected:se.promise,received:r.parsedType}),ge;let n=r.parsedType===se.promise?r.data:Promise.resolve(r.data);return vr(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ds.create=(e,t)=>new Ds({type:e,typeName:z.ZodPromise,...Te(t)});var An=class extends Ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:s=>{ee(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return ge;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"?pc(c.value):r.value==="dirty"?pc(c.value):c});{if(r.value==="aborted")return ge;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?ge:a.status==="dirty"?pc(a.value):r.value==="dirty"?pc(a.value):a}}if(i.type==="refinement"){let s=a=>{let c=i.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ge:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?ge:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ms(s))return ge;let a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Ms(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):ge);Be.assertNever(i)}};An.create=(e,t,r)=>new An({schema:e,typeName:z.ZodEffects,effect:t,...Te(r)});An.createWithPreprocess=(e,t,r)=>new An({schema:t,effect:{type:"preprocess",transform:e},typeName:z.ZodEffects,...Te(r)});var In=class extends Ne{_parse(t){return this._getType(t)===se.undefined?vr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};In.create=(e,t)=>new In({innerType:e,typeName:z.ZodOptional,...Te(t)});var Zi=class extends Ne{_parse(t){return this._getType(t)===se.null?vr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zi.create=(e,t)=>new Zi({innerType:e,typeName:z.ZodNullable,...Te(t)});var Sc=class extends Ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===se.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Sc.create=(e,t)=>new Sc({innerType:e,typeName:z.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Te(t)});var Ac=class extends Ne{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ol(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new qr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new qr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ac.create=(e,t)=>new Ac({innerType:e,typeName:z.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Te(t)});var Rl=class extends Ne{_parse(t){if(this._getType(t)!==se.nan){let n=this._getOrReturnCtx(t);return ee(n,{code:q.invalid_type,expected:se.nan,received:n.parsedType}),ge}return{status:"valid",value:t.data}}};Rl.create=e=>new Rl({typeName:z.ZodNaN,...Te(e)});var OV=Symbol("zod_brand"),zf=class extends Ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},jf=class e extends Ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"?(r.dirty(),pc(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:z.ZodPipeline})}},Oc=class extends Ne{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Ms(i)&&(i.value=Object.freeze(i.value)),i);return Ol(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Oc.create=(e,t)=>new Oc({innerType:e,typeName:z.ZodReadonly,...Te(t)});function bN(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function SN(e,t={},r){return e?js.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=bN(t,n),c=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!o){let s=bN(t,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):js.create()}var $V={object:Kr.lazycreate},z;(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"})(z||(z={}));var TV=(e,t={message:`Input not instance of ${e.name}`})=>SN(r=>r instanceof e,t),AN=zs.create,ON=fc.create,EV=Rl.create,PV=mc.create,$N=hc.create,CV=gc.create,RV=Tl.create,NV=yc.create,MV=_c.create,zV=js.create,jV=Eo.create,DV=ri.create,UV=El.create,LV=Po.create,FV=Kr.create,BV=Kr.strictCreate,ZV=vc.create,VV=jy.create,WV=bc.create,qV=Bi.create,KV=Dy.create,GV=Pl.create,HV=Cl.create,JV=Uy.create,XV=wc.create,YV=xc.create,QV=kc.create,e5=Ic.create,t5=Ds.create,r5=An.create,n5=In.create,i5=Zi.create,o5=An.createWithPreprocess,s5=jf.create,a5=()=>AN().optional(),c5=()=>ON().optional(),u5=()=>$N().optional(),l5={string:(e=>zs.create({...e,coerce:!0})),number:(e=>fc.create({...e,coerce:!0})),boolean:(e=>hc.create({...e,coerce:!0})),bigint:(e=>mc.create({...e,coerce:!0})),date:(e=>gc.create({...e,coerce:!0}))};var d5=ge;function LS(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==z.ZodAny&&(r.items=ye(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ve(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ve(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ve(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ve(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function FS(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?Ve(r,"minimum",n.value,n.message,t):Ve(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ve(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Ve(r,"maximum",n.value,n.message,t):Ve(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ve(r,"maximum",n.value,n.message,t));break;case"multipleOf":Ve(r,"multipleOf",n.value,n.message,t);break}return r}function BS(){return{type:"boolean"}}function Df(e,t){return ye(e.type._def,t)}var ZS=(e,t)=>ye(e.innerType._def,t);function Ly(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(i=>Ly(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return p5(e,t)}}var p5=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":Ve(r,"minimum",n.value,n.message,t);break;case"max":Ve(r,"maximum",n.value,n.message,t);break}return r};function VS(e,t){return{...ye(e.innerType._def,t),default:e.defaultValue()}}function WS(e,t){return t.effectStrategy==="input"?ye(e.schema._def,t):mt(t)}function qS(e){return{type:"string",enum:Array.from(e.values)}}var f5=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function KS(e,t){let r=[ye(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ye(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(f5(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;s=c}else n=void 0;i.push(s)}}),i.length?{allOf:i,...n}:void 0}function GS(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var HS,On={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:()=>(HS===void 0&&(HS=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),HS),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 Uf(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":Ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":Ve(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":ni(r,"email",n.message,t);break;case"format:idn-email":ni(r,"idn-email",n.message,t);break;case"pattern:zod":Mr(r,On.email,n.message,t);break}break;case"url":ni(r,"uri",n.message,t);break;case"uuid":ni(r,"uuid",n.message,t);break;case"regex":Mr(r,n.regex,n.message,t);break;case"cuid":Mr(r,On.cuid,n.message,t);break;case"cuid2":Mr(r,On.cuid2,n.message,t);break;case"startsWith":Mr(r,RegExp(`^${JS(n.value,t)}`),n.message,t);break;case"endsWith":Mr(r,RegExp(`${JS(n.value,t)}$`),n.message,t);break;case"datetime":ni(r,"date-time",n.message,t);break;case"date":ni(r,"date",n.message,t);break;case"time":ni(r,"time",n.message,t);break;case"duration":ni(r,"duration",n.message,t);break;case"length":Ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),Ve(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Mr(r,RegExp(JS(n.value,t)),n.message,t);break;case"ip":n.version!=="v6"&&ni(r,"ipv4",n.message,t),n.version!=="v4"&&ni(r,"ipv6",n.message,t);break;case"base64url":Mr(r,On.base64url,n.message,t);break;case"jwt":Mr(r,On.jwt,n.message,t);break;case"cidr":n.version!=="v6"&&Mr(r,On.ipv4Cidr,n.message,t),n.version!=="v4"&&Mr(r,On.ipv6Cidr,n.message,t);break;case"emoji":Mr(r,On.emoji(),n.message,t);break;case"ulid":Mr(r,On.ulid,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":ni(r,"binary",n.message,t);break;case"contentEncoding:base64":Ve(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Mr(r,On.base64,n.message,t);break}break;case"nanoid":Mr(r,On.nanoid,n.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function JS(e,t){return t.patternStrategy==="escape"?h5(e):e}var m5=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function h5(e){let t="";for(let r=0;r<e.length;r++)m5.has(e[r])||(t+="\\"),t+=e[r];return t}function ni(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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,...r&&n.errorMessages&&{errorMessage:{format:r}}})):Ve(e,"format",t,r,n)}function Mr(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:TN(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Ve(e,"pattern",TN(t,n),r,n)}function TN(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,s=!1,a=!1;for(let c=0;c<n.length;c++){if(o){i+=n[c],o=!1;continue}if(r.i){if(s){if(n[c].match(/[a-z]/)){a?(i+=n[c],i+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(i+=n[c],a=!0):i+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){i+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){i+=`(^|(?<=[\r
|
|
71
|
-
]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
|
|
72
|
-
]))`;continue}}if(r.s&&n[c]==="."){i+=s?`${n[c]}\r
|
|
73
|
-
`:`[${n[c]}\r
|
|
74
|
-
]`;continue}i+=n[c],n[c]==="\\"?o=!0:s&&n[c]==="]"?s=!1:!s&&n[c]==="["&&(s=!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 Lf(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===z.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:ye(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??mt(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:ye(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===z.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=Uf(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===z.ZodBranded&&e.keyType._def.type._def.typeName===z.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=Df(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function XS(e,t){return t.mapStrategy==="record"?Lf(e,t):{type:"array",maxItems:125,items:{type:"array",items:[ye(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||mt(t),ye(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||mt(t)],minItems:2,maxItems:2}}}function YS(e){let t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(r.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:r}}function QS(e){return e.target==="openAi"?void 0:{not:mt({...e,currentPath:[...e.currentPath,"not"]})}}function eA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Nl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function tA(e,t){if(t.target==="openApi3")return EN(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Nl&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let s=Nl[o._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":return o._def.value===null?[...i,"null"]:i;default:return i}},[]);if(n.length===r.length){let i=n.filter((o,s,a)=>a.indexOf(o)===s);return{type:i.length>1?i:i[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return EN(e,t)}var EN=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>ye(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function rA(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:Nl[e.innerType._def.typeName],nullable:!0}:{type:[Nl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=ye(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=ye(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function nA(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",Ny(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?Ve(r,"minimum",n.value,n.message,t):Ve(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ve(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Ve(r,"maximum",n.value,n.message,t):Ve(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ve(r,"maximum",n.value,n.message,t));break;case"multipleOf":Ve(r,"multipleOf",n.value,n.message,t);break}return r}function iA(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let u=y5(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=ye(c._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||i.push(a))}i.length&&(n.required=i);let s=g5(e,t);return s!==void 0&&(n.additionalProperties=s),n}function g5(e,t){if(e.catchall._def.typeName!=="ZodNever")return ye(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 y5(e){try{return e.isOptional()}catch{return!0}}var oA=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return ye(e.innerType._def,t);let r=ye(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:mt(t)},r]}:mt(t)};var sA=(e,t)=>{if(t.pipeStrategy==="input")return ye(e.in._def,t);if(t.pipeStrategy==="output")return ye(e.out._def,t);let r=ye(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,ye(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(n=>n!==void 0)}};function aA(e,t){return ye(e.type._def,t)}function cA(e,t){let r={type:"array",uniqueItems:!0,items:ye(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ve(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ve(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function uA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>ye(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:ye(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>ye(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function lA(e){return{not:mt(e)}}function dA(e){return mt(e)}var pA=(e,t)=>ye(e.innerType._def,t);var fA=(e,t,r)=>{switch(t){case z.ZodString:return Uf(e,r);case z.ZodNumber:return nA(e,r);case z.ZodObject:return iA(e,r);case z.ZodBigInt:return FS(e,r);case z.ZodBoolean:return BS();case z.ZodDate:return Ly(e,r);case z.ZodUndefined:return lA(r);case z.ZodNull:return eA(r);case z.ZodArray:return LS(e,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return tA(e,r);case z.ZodIntersection:return KS(e,r);case z.ZodTuple:return uA(e,r);case z.ZodRecord:return Lf(e,r);case z.ZodLiteral:return GS(e,r);case z.ZodEnum:return qS(e);case z.ZodNativeEnum:return YS(e);case z.ZodNullable:return rA(e,r);case z.ZodOptional:return oA(e,r);case z.ZodMap:return XS(e,r);case z.ZodSet:return cA(e,r);case z.ZodLazy:return()=>e.getter()._def;case z.ZodPromise:return aA(e,r);case z.ZodNaN:case z.ZodNever:return QS(r);case z.ZodEffects:return WS(e,r);case z.ZodAny:return mt(r);case z.ZodUnknown:return dA(r);case z.ZodDefault:return VS(e,r);case z.ZodBranded:return Df(e,r);case z.ZodReadonly:return pA(e,r);case z.ZodCatch:return ZS(e,r);case z.ZodPipeline:return sA(e,r);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(n=>{})(t)}};function ye(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==NS)return a}if(n&&!r){let a=_5(n,t);if(a!==void 0)return a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=fA(e,e.typeName,t),s=typeof o=="function"?ye(o(),t):o;if(s&&v5(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return i.jsonSchema=s,a}return i.jsonSchema=s,s}var _5=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Nf(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),mt(t)):t.$refStrategy==="seen"?mt(t):void 0}},v5=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var mA=(e,t)=>{let r=zS(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:ye(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??mt(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=ye(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??mt(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(o.title=s),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function Vi(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(!Vi(e[i],t[i]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let s of n)if(!Vi(e[s],t[s]))return!1;return!0}return e===t}function pn(e){return encodeURI(b5(e))}function b5(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var w5={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},x5={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},k5={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},I5=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function ii(e,t=Object.create(null),r=I5,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let o=e.$id||e.id;if(o){let s=new URL(o,r.href);s.hash.length>1?t[s.href]=e:(s.hash="",n===""?r=s:ii(e,t,r))}}else if(e!==!0&&e!==!1)return t;let i=r.href+(n?"#"+n:"");if(t[i]!==void 0)throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let o=new URL(e.$ref,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:o.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let o=new URL(e.$recursiveRef,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:o.href})}if(e.$anchor){let o=new URL("#"+e.$anchor,r.href);t[o.href]=e}for(let o in e){if(k5[o])continue;let s=`${n}/${pn(o)}`,a=e[o];if(Array.isArray(a)){if(w5[o]){let c=a.length;for(let u=0;u<c;u++)ii(a[u],t,r,`${s}/${u}`)}}else if(x5[o])for(let c in a)ii(a[c],t,r,`${s}/${pn(c)}`);else ii(a,t,r,s)}return t}var S5=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,A5=[0,31,28,31,30,31,30,31,31,30,31,30,31],O5=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,$5=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,T5=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,E5=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,P5=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,C5=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,R5=/^(?:\/(?:[^~/]|~0|~1)*)*$/,N5=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,M5=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,z5=e=>{if(e[0]==='"')return!1;let[t,r,...n]=e.split("@");return!t||!r||n.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},j5=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,D5=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,U5=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Wi(e){return e.test.bind(e)}var hA={date:PN,time:CN.bind(void 0,!1),"date-time":B5,duration:U5,uri:W5,"uri-reference":Wi(T5),"uri-template":Wi(E5),url:Wi(P5),email:z5,hostname:Wi($5),ipv4:Wi(j5),ipv6:Wi(D5),regex:K5,uuid:Wi(C5),"json-pointer":Wi(R5),"json-pointer-uri-fragment":Wi(N5),"relative-json-pointer":Wi(M5)};function L5(e){return e%4===0&&(e%100!==0||e%400===0)}function PN(e){let t=e.match(S5);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n==2&&L5(r)?29:A5[n])}function CN(e,t){let r=t.match(O5);if(!r)return!1;let n=+r[1],i=+r[2],o=+r[3],s=!!r[5];return(n<=23&&i<=59&&o<=59||n==23&&i==59&&o==60)&&(!e||s)}var F5=/t|\s/i;function B5(e){let t=e.split(F5);return t.length==2&&PN(t[0])&&CN(!0,t[1])}var Z5=/\/|:/,V5=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function W5(e){return Z5.test(e)&&V5.test(e)}var q5=/[^\\]\\Z/;function K5(e){if(q5.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var RN;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(RN||(RN={}));function NN(e){let t=0,r=e.length,n=0,i;for(;n<r;)t++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<r&&(i=e.charCodeAt(n),(i&64512)==56320&&n++);return t}function dt(e,t,r="2019-09",n=ii(t),i=!0,o=null,s="#",a="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let u=typeof e,l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":e===null?l="null":Array.isArray(e)?l="array":l="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:d,$recursiveRef:p,$recursiveAnchor:f,type:m,const:h,enum:y,required:w,not:_,anyOf:b,allOf:I,oneOf:$,if:P,then:C,else:x,format:D,properties:M,patternProperties:R,additionalProperties:B,unevaluatedProperties:K,minProperties:re,maxProperties:We,propertyNames:ne,dependentRequired:X,dependentSchemas:Q,dependencies:ae,prefixItems:ce,items:$e,additionalItems:bt,unevaluatedItems:yn,contains:Et,minContains:Xe,maxContains:k,minItems:v,maxItems:U,uniqueItems:T,minimum:xe,maximum:Pe,exclusiveMinimum:wt,exclusiveMaximum:He,multipleOf:fr,minLength:_n,maxLength:Pt,pattern:Ai,__absolute_ref__:Fu,__absolute_recursive_ref__:Hh}=t,oe=[];if(f===!0&&o===null&&(o=t),p==="#"){let be=o===null?n[Hh]:o,me=`${a}/$recursiveRef`,Ae=dt(e,o===null?t:o,r,n,i,be,s,me,c);Ae.valid||oe.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:me,error:"A subschema had errors."},...Ae.errors)}if(d!==void 0){let me=n[Fu||d];if(me===void 0){let ie=`Unresolved $ref "${d}".`;throw Fu&&Fu!==d&&(ie+=` Absolute URI "${Fu}".`),ie+=`
|
|
75
|
-
Known schemas:
|
|
76
|
-
- ${Object.keys(n).join(`
|
|
77
|
-
- `)}`,new Error(ie)}let Ae=`${a}/$ref`,ue=dt(e,me,r,n,i,o,s,Ae,c);if(ue.valid||oe.push({instanceLocation:s,keyword:"$ref",keywordLocation:Ae,error:"A subschema had errors."},...ue.errors),r==="4"||r==="7")return{valid:oe.length===0,errors:oe}}if(Array.isArray(m)){let be=m.length,me=!1;for(let Ae=0;Ae<be;Ae++)if(l===m[Ae]||m[Ae]==="integer"&&l==="number"&&e%1===0&&e===e){me=!0;break}me||oe.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&oe.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&oe.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(h!==void 0&&(l==="object"||l==="array"?Vi(e,h)||oe.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&oe.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),y!==void 0&&(l==="object"||l==="array"?y.some(be=>Vi(e,be))||oe.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(be=>e===be)||oe.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),_!==void 0){let be=`${a}/not`;dt(e,_,r,n,i,o,s,be).valid&&oe.push({instanceLocation:s,keyword:"not",keywordLocation:be,error:'Instance matched "not" schema.'})}let ja=[];if(b!==void 0){let be=`${a}/anyOf`,me=oe.length,Ae=!1;for(let ue=0;ue<b.length;ue++){let ie=b[ue],ke=Object.create(c),we=dt(e,ie,r,n,i,f===!0?o:null,s,`${be}/${ue}`,ke);oe.push(...we.errors),Ae=Ae||we.valid,we.valid&&ja.push(ke)}Ae?oe.length=me:oe.splice(me,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:be,error:"Instance does not match any subschemas."})}if(I!==void 0){let be=`${a}/allOf`,me=oe.length,Ae=!0;for(let ue=0;ue<I.length;ue++){let ie=I[ue],ke=Object.create(c),we=dt(e,ie,r,n,i,f===!0?o:null,s,`${be}/${ue}`,ke);oe.push(...we.errors),Ae=Ae&&we.valid,we.valid&&ja.push(ke)}Ae?oe.length=me:oe.splice(me,0,{instanceLocation:s,keyword:"allOf",keywordLocation:be,error:"Instance does not match every subschema."})}if($!==void 0){let be=`${a}/oneOf`,me=oe.length,Ae=$.filter((ue,ie)=>{let ke=Object.create(c),we=dt(e,ue,r,n,i,f===!0?o:null,s,`${be}/${ie}`,ke);return oe.push(...we.errors),we.valid&&ja.push(ke),we.valid}).length;Ae===1?oe.length=me:oe.splice(me,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:be,error:`Instance does not match exactly one subschema (${Ae} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...ja),P!==void 0){let be=`${a}/if`;if(dt(e,P,r,n,i,o,s,be,c).valid){if(C!==void 0){let Ae=dt(e,C,r,n,i,o,s,`${a}/then`,c);Ae.valid||oe.push({instanceLocation:s,keyword:"if",keywordLocation:be,error:'Instance does not match "then" schema.'},...Ae.errors)}}else if(x!==void 0){let Ae=dt(e,x,r,n,i,o,s,`${a}/else`,c);Ae.valid||oe.push({instanceLocation:s,keyword:"if",keywordLocation:be,error:'Instance does not match "else" schema.'},...Ae.errors)}}if(l==="object"){if(w!==void 0)for(let ue of w)ue in e||oe.push({instanceLocation:s,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${ue}".`});let be=Object.keys(e);if(re!==void 0&&be.length<re&&oe.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${re} properties.`}),We!==void 0&&be.length>We&&oe.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${We} properties.`}),ne!==void 0){let ue=`${a}/propertyNames`;for(let ie in e){let ke=`${s}/${pn(ie)}`,we=dt(ie,ne,r,n,i,o,ke,ue);we.valid||oe.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:ue,error:`Property name "${ie}" does not match schema.`},...we.errors)}}if(X!==void 0){let ue=`${a}/dependantRequired`;for(let ie in X)if(ie in e){let ke=X[ie];for(let we of ke)we in e||oe.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:ue,error:`Instance has "${ie}" but does not have "${we}".`})}}if(Q!==void 0)for(let ue in Q){let ie=`${a}/dependentSchemas`;if(ue in e){let ke=dt(e,Q[ue],r,n,i,o,s,`${ie}/${pn(ue)}`,c);ke.valid||oe.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:ie,error:`Instance has "${ue}" but does not match dependant schema.`},...ke.errors)}}if(ae!==void 0){let ue=`${a}/dependencies`;for(let ie in ae)if(ie in e){let ke=ae[ie];if(Array.isArray(ke))for(let we of ke)we in e||oe.push({instanceLocation:s,keyword:"dependencies",keywordLocation:ue,error:`Instance has "${ie}" but does not have "${we}".`});else{let we=dt(e,ke,r,n,i,o,s,`${ue}/${pn(ie)}`);we.valid||oe.push({instanceLocation:s,keyword:"dependencies",keywordLocation:ue,error:`Instance has "${ie}" but does not match dependant schema.`},...we.errors)}}}let me=Object.create(null),Ae=!1;if(M!==void 0){let ue=`${a}/properties`;for(let ie in M){if(!(ie in e))continue;let ke=`${s}/${pn(ie)}`,we=dt(e[ie],M[ie],r,n,i,o,ke,`${ue}/${pn(ie)}`);if(we.valid)c[ie]=me[ie]=!0;else if(Ae=i,oe.push({instanceLocation:s,keyword:"properties",keywordLocation:ue,error:`Property "${ie}" does not match schema.`},...we.errors),Ae)break}}if(!Ae&&R!==void 0){let ue=`${a}/patternProperties`;for(let ie in R){let ke=new RegExp(ie,"u"),we=R[ie];for(let Fr in e){if(!ke.test(Fr))continue;let EE=`${s}/${pn(Fr)}`,PE=dt(e[Fr],we,r,n,i,o,EE,`${ue}/${pn(ie)}`);PE.valid?c[Fr]=me[Fr]=!0:(Ae=i,oe.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:ue,error:`Property "${Fr}" matches pattern "${ie}" but does not match associated schema.`},...PE.errors))}}}if(!Ae&&B!==void 0){let ue=`${a}/additionalProperties`;for(let ie in e){if(me[ie])continue;let ke=`${s}/${pn(ie)}`,we=dt(e[ie],B,r,n,i,o,ke,ue);we.valid?c[ie]=!0:(Ae=i,oe.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:ue,error:`Property "${ie}" does not match additional properties schema.`},...we.errors))}}else if(!Ae&&K!==void 0){let ue=`${a}/unevaluatedProperties`;for(let ie in e)if(!c[ie]){let ke=`${s}/${pn(ie)}`,we=dt(e[ie],K,r,n,i,o,ke,ue);we.valid?c[ie]=!0:oe.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:ue,error:`Property "${ie}" does not match unevaluated properties schema.`},...we.errors)}}}else if(l==="array"){U!==void 0&&e.length>U&&oe.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${U}).`}),v!==void 0&&e.length<v&&oe.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${v}).`});let be=e.length,me=0,Ae=!1;if(ce!==void 0){let ue=`${a}/prefixItems`,ie=Math.min(ce.length,be);for(;me<ie;me++){let ke=dt(e[me],ce[me],r,n,i,o,`${s}/${me}`,`${ue}/${me}`);if(c[me]=!0,!ke.valid&&(Ae=i,oe.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:ue,error:"Items did not match schema."},...ke.errors),Ae))break}}if($e!==void 0){let ue=`${a}/items`;if(Array.isArray($e)){let ie=Math.min($e.length,be);for(;me<ie;me++){let ke=dt(e[me],$e[me],r,n,i,o,`${s}/${me}`,`${ue}/${me}`);if(c[me]=!0,!ke.valid&&(Ae=i,oe.push({instanceLocation:s,keyword:"items",keywordLocation:ue,error:"Items did not match schema."},...ke.errors),Ae))break}}else for(;me<be;me++){let ie=dt(e[me],$e,r,n,i,o,`${s}/${me}`,ue);if(c[me]=!0,!ie.valid&&(Ae=i,oe.push({instanceLocation:s,keyword:"items",keywordLocation:ue,error:"Items did not match schema."},...ie.errors),Ae))break}if(!Ae&&bt!==void 0){let ie=`${a}/additionalItems`;for(;me<be;me++){let ke=dt(e[me],bt,r,n,i,o,`${s}/${me}`,ie);c[me]=!0,ke.valid||(Ae=i,oe.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:ie,error:"Items did not match additional items schema."},...ke.errors))}}}if(Et!==void 0)if(be===0&&Xe===void 0)oe.push({instanceLocation:s,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Xe!==void 0&&be<Xe)oe.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${be}) than minContains (${Xe}).`});else{let ue=`${a}/contains`,ie=oe.length,ke=0;for(let we=0;we<be;we++){let Fr=dt(e[we],Et,r,n,i,o,`${s}/${we}`,ue);Fr.valid?(c[we]=!0,ke++):oe.push(...Fr.errors)}ke>=(Xe||0)&&(oe.length=ie),Xe===void 0&&k===void 0&&ke===0?oe.splice(ie,0,{instanceLocation:s,keyword:"contains",keywordLocation:ue,error:"Array does not contain item matching schema."}):Xe!==void 0&&ke<Xe?oe.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${Xe} items matching schema. Only ${ke} items were found.`}):k!==void 0&&ke>k&&oe.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${k} items matching schema. ${ke} items were found.`})}if(!Ae&&yn!==void 0){let ue=`${a}/unevaluatedItems`;for(me;me<be;me++){if(c[me])continue;let ie=dt(e[me],yn,r,n,i,o,`${s}/${me}`,ue);c[me]=!0,ie.valid||oe.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:ue,error:"Items did not match unevaluated items schema."},...ie.errors)}}if(T)for(let ue=0;ue<be;ue++){let ie=e[ue],ke=typeof ie=="object"&&ie!==null;for(let we=0;we<be;we++){if(ue===we)continue;let Fr=e[we];(ie===Fr||ke&&(typeof Fr=="object"&&Fr!==null)&&Vi(ie,Fr))&&(oe.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${ue} and ${we}.`}),ue=Number.MAX_SAFE_INTEGER,we=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(xe!==void 0&&(wt===!0&&e<=xe||e<xe)&&oe.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${wt?"or equal to ":""} ${xe}.`}),Pe!==void 0&&(He===!0&&e>=Pe||e>Pe)&&oe.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${He?"or equal to ":""} ${Pe}.`})):(xe!==void 0&&e<xe&&oe.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${xe}.`}),Pe!==void 0&&e>Pe&&oe.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${Pe}.`}),wt!==void 0&&e<=wt&&oe.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${wt}.`}),He!==void 0&&e>=He&&oe.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${He}.`})),fr!==void 0){let be=e%fr;Math.abs(0-be)>=11920929e-14&&Math.abs(fr-be)>=11920929e-14&&oe.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${fr}.`})}}else if(l==="string"){let be=_n===void 0&&Pt===void 0?0:NN(e);_n!==void 0&&be<_n&&oe.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${be} < ${_n}).`}),Pt!==void 0&&be>Pt&&oe.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${be} > ${Pt}).`}),Ai!==void 0&&!new RegExp(Ai,"u").test(e)&&oe.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."}),D!==void 0&&hA[D]&&!hA[D](e)&&oe.push({instanceLocation:s,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${D}".`})}return{valid:oe.length===0,errors:oe}}var Fy=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",n=!0){this.schema=t,this.draft=r,this.shortCircuit=n,this.lookup=ii(t)}validate(t){return dt(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),ii(t,this.lookup)}};var zN=F({Validator:()=>Fy,deepCompareStrict:()=>Vi,toJsonSchema:()=>ht,validatesOnlyStrings:()=>Ml}),MN=new WeakMap;function ht(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let i=MN.get(e);if(i)return i}let n;if(Ag(e)&&!it(e))n=e["~standard"].jsonSchema.input({target:"draft-07"});else if(it(e)){let i=Cy(e,!0);kn(i)?n=So(Il(i,!0),t):n=So(e,t)}else _t(e)?n=mA(e):n=e;return r&&n!=null&&typeof n=="object"&&MN.set(e,n),n}function Ml(e){if(!e||typeof e!="object"||Object.keys(e).length===0||Array.isArray(e))return!1;if("type"in e)return typeof e.type=="string"?e.type==="string":Array.isArray(e.type)?e.type.every(t=>t==="string"):!1;if("enum"in e)return Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every(t=>typeof t=="string");if("const"in e)return typeof e.const=="string";if("allOf"in e&&Array.isArray(e.allOf))return e.allOf.some(t=>Ml(t));if("anyOf"in e&&Array.isArray(e.anyOf)||"oneOf"in e&&Array.isArray(e.oneOf)){let t="anyOf"in e?e.anyOf:e.oneOf;return t.length>0&&t.every(r=>Ml(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=ii(e);return r[t]?Ml(r[t]):!1}return!1}function Ff(e){return e?e.lc_runnable:!1}var jN=class{includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;constructor(e){this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,n=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||n.some(i=>this.includeTags?.includes(i))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&n.every(i=>!this.excludeTags?.includes(i))),r}},DN=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function gA(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var G5=["*","_","`"];function H5(e){let t="";for(let[r,n]of Object.entries(e))t+=` classDef ${r} ${n};
|
|
78
|
-
`;return t}function UN(e,t,r){let{firstNode:n,lastNode:i,nodeColors:o,withStyles:s=!0,curveStyle:a="linear",wrapLabelNWords:c=9}=r??{},u=s?`%%{init: {'flowchart': {'curve': '${a}'}}}%%
|
|
79
|
-
graph TD;
|
|
80
|
-
`:`graph TD;
|
|
81
|
-
`;if(s){let m="default",h={[m]:"{0}({1})"};n!==void 0&&(h[n]="{0}([{1}]):::first"),i!==void 0&&(h[i]="{0}([{1}]):::last");for(let[y,w]of Object.entries(e)){let _=w.name.split(":").pop()??"",b=G5.some($=>_.startsWith($)&&_.endsWith($))?`<p>${_}</p>`:_;Object.keys(w.metadata??{}).length&&(b+=`<hr/><small><em>${Object.entries(w.metadata??{}).map(([$,P])=>`${$} = ${P}`).join(`
|
|
82
|
-
`)}</em></small>`);let I=(h[y]??h[m]).replace("{0}",gA(y)).replace("{1}",b);u+=` ${I}
|
|
83
|
-
`}}let l={};for(let m of t){let h=m.source.split(":"),y=m.target.split(":"),w=h.filter((_,b)=>_===y[b]).join(":");l[w]||(l[w]=[]),l[w].push(m)}let d=new Set;function p(m){return[...m].sort((h,y)=>h.split(":").length-y.split(":").length)}function f(m,h){let y=m.length===1&&m[0].source===m[0].target;if(h&&!y){let _=h.split(":").pop();if(d.has(h))throw new Error(`Found duplicate subgraph '${_}' at '${h} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(h),u+=` subgraph ${_}
|
|
84
|
-
`}let w=p(Object.keys(l).filter(_=>_.startsWith(`${h}:`)&&_!==h&&_.split(":").length===h.split(":").length+1));for(let _ of w)f(l[_],_);for(let _ of m){let{source:b,target:I,data:$,conditional:P}=_,C="";if($!==void 0){let x=$,D=x.split(" ");D.length>c&&(x=Array.from({length:Math.ceil(D.length/c)},(M,R)=>D.slice(R*c,(R+1)*c).join(" ")).join(" <br> ")),C=P?` -. ${x} .-> `:` -- ${x} --> `}else C=P?" -.-> ":" --> ";u+=` ${gA(b)}${C}${gA(I)};
|
|
85
|
-
`}h&&!y&&(u+=` end
|
|
86
|
-
`)}f(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&f(l[m],m);return s&&(u+=H5(o??{})),u}async function LN(e,t){let r=t?.backgroundColor??"white",n=t?.imageType??"png",i=DN(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let o=`https://mermaid.ink/img/${i}?bgColor=${r}&type=${n}`,s=await fetch(o);if(!s.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${s.status}`,`Status text: ${s.statusText}`].join(`
|
|
87
|
-
`));return await s.blob()}var ZN=F({Graph:()=>$c});function J5(e,t){if(e!==void 0&&!ls(e))return e;if(Ff(t))try{let r=t.getName();return r=r.startsWith("Runnable")?r.slice(8):r,r}catch{return t.getName()}else return t.name??"UnknownSchema"}function X5(e){return Ff(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...ht(e.data.schema),title:e.data.name}}}var $c=class VN{nodes={};edges=[];constructor(t){this.nodes=t?.nodes??this.nodes,this.edges=t?.edges??this.edges}toJSON(){let t={};return Object.values(this.nodes).forEach((r,n)=>{t[r.id]=ls(r.id)?n:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...X5(r)})),edges:this.edges.map(r=>{let n={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(n.data=r.data),typeof r.conditional<"u"&&(n.conditional=r.conditional),n})}}addNode(t,r,n){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let i=r??Da(),o={id:i,data:t,name:J5(r,t),metadata:n};return this.nodes[i]=o,o}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,n,i){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[r.id]===void 0)throw new Error(`Target node ${r.id} not in graph`);let o={source:t.id,target:r.id,data:n,conditional:i};return this.edges.push(o),o}firstNode(){return FN(this)}lastNode(){return BN(this)}extend(t,r=""){let n=r;Object.values(t.nodes).map(c=>c.id).every(ls)&&(n="");let i=c=>n?`${n}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[i(c)]={...u,id:i(c)}});let o=t.edges.map(c=>({...c,source:i(c.source),target:i(c.target)}));this.edges=[...this.edges,...o];let s=t.firstNode(),a=t.lastNode();return[s?{id:i(s.id),data:s.data}:void 0,a?{id:i(a.id),data:a.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&FN(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&BN(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),r=new Map;Object.values(t).forEach(i=>{r.set(i,(r.get(i)||0)+1)});let n=i=>{let o=t[i];return ls(i)&&r.get(o)===1?o:i};return new VN({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,o])=>[n(i),{...o,id:n(i)}])),edges:this.edges.map(i=>({...i,source:n(i.source),target:n(i.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:n,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:o}=t??{},s=this.reid(),a=s.firstNode(),c=s.lastNode();return UN(s.nodes,s.edges,{firstNode:a?.id,lastNode:c?.id,withStyles:r,curveStyle:n,nodeColors:i,wrapLabelNWords:o})}async drawMermaidPng(t){return LN(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function FN(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.source)).map(i=>i.target)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function BN(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.target)).map(i=>i.source)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function By({name:e,serialized:t}){return e!==void 0?e:t?.name!==void 0?t.name:t?.id!==void 0&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}var WN=e=>e.name==="event_stream_tracer",qN=class extends bn{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;runInfoMap=new Map;tappedPromises=new Map;transformStream;writer;receiveStream;readableStreamClosed=!1;name="event_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream({flush:()=>{this.readableStreamClosed=!0}}),this.writer=this.transformStream.writable.getWriter(),this.receiveStream=jt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(n=>this.includeTags?.includes(n))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let n=this.runInfoMap.get(e);if(n===void 0){yield r.value;return}function i(s,a){return s==="llm"&&typeof a=="string"?new Mi({text:a}):a}let o=this.tappedPromises.get(e);if(o===void 0){let s;o=new Promise(a=>{s=a}),this.tappedPromises.set(e,o);try{let a={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...a,data:{chunk:i(n.runType,r.value)}},n),yield r.value;for await(let c of t)n.runType!=="tool"&&n.runType!=="retriever"&&await this.send({...a,data:{chunk:i(n.runType,c)}},n),yield c}finally{s?.()}}else{yield r.value;for await(let s of t)yield s}}async send(e,t){this.readableStreamClosed||this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=By(e),r=e.inputs.messages!==void 0?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,n);let i=`on_${r}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,r){let n=this.runInfoMap.get(e.id),i,o;if(n===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(n.runType==="chat_model")o="on_chat_model_stream",r?.chunk===void 0?i=new ct({content:t,id:`run-${e.id}`}):i=r.chunk.message;else if(n.runType==="llm")o="on_llm_stream",r?.chunk===void 0?i=new Mi({text:t}):i=r.chunk;else throw new Error(`Unexpected run type ${n.runType}`);await this.send({event:o,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let n=e.outputs?.generations,i;if(t.runType==="chat_model"){for(let o of n??[]){if(i!==void 0)break;i=o[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")i={generations:n?.map(o=>o.map(s=>({text:s.text,generationInfo:s.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=By(e),r=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},i={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(i={},n.inputs={}):e.inputs.input!==void 0?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${r}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onChainEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&Object.keys(n).length===1&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:r,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=By(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onToolError(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);await this.sendEndEvent({event:"on_tool_error",data:{input:t.inputs,error:e.error},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){let t=By(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,r),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onRetrieverEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){let n=this.runInfoMap.get(r);if(n===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:n.tags,metadata:n.metadata,data:t},n)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var yA=class extends bn{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:n}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=n}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}};function KN(e){let t=new TextEncoder,r=new ReadableStream({async start(n){for await(let i of e)n.enqueue(t.encode(`event: data
|
|
88
|
-
data: ${JSON.stringify(i)}
|
|
89
|
-
|
|
90
|
-
`));n.enqueue(t.encode(`event: end
|
|
91
|
-
|
|
92
|
-
`)),n.close()}});return jt.fromReadableStream(r)}function _A(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var GN=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function Zy(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function vA(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function HN(e,t){try{let r=await e.next();for(;!r.done;)await t?.(r.value),r=await e.next();return r.value}finally{await e.return?.(void 0)}}function*bA(e,t){for(;;){let{value:r,done:n}=ut.runWithConfig(Or(e),t.next.bind(t),!0);if(n)break;yield r}}async function*Vy(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:n,done:i}=await ut.runWithConfig(Or(e),r.next.bind(t),!0);if(i)break;yield n}}function Dt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var he=class extends Ar{lc_runnable=!0;name;getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}withRetry(e){return new qy({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new $n({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new wA({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(Ue);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([n])=>n!=="runId"));return Array.from({length:t},(n,i)=>Ue(i===0?e:r))}return Array.from({length:t},()=>Ue(e))}async batch(e,t,r){let n=this._getOptionsList(t??{},e.length),i=new xo({maxConcurrency:n[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:s=>{throw s}}),o=e.map((s,a)=>i.call(async()=>{try{return await this.invoke(s,n[a])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=Ue(t),n=new bs({generator:this._streamIterator(e,r),config:r});return await n.setup,jt.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Ue(e):t=Ue({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){let n=Ue(r),i=await(await hr(n))?.handleChainStart(this.toJSON(),Dt(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName());delete n.runId;let o;try{o=await sn(e.call(this,t,n,i),n.signal)}catch(s){throw await i?.handleChainError(s),s}return await i?.handleChainEnd(Dt(o,"output")),o}async _batchWithConfig(e,t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(hr)),s=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),Dt(t[u],"input"),i[u].runId,i[u].runType,void 0,void 0,i[u].runName??this.getName());return delete i[u].runId,l})),a;try{a=await sn(e.call(this,t,i,s,n),i?.[0]?.signal)}catch(c){throw await Promise.all(s.map(u=>u?.handleChainError(c))),c}return await Promise.all(s.map(c=>c?.handleChainEnd(Dt(a,"output")))),a}_concatOutputChunks(e,t){return an(e,t)}async*_transformStreamWithConfig(e,t,r){let n,i=!0,o,s=!0,a=Ue(r),c=await hr(a),u=this;async function*l(){for await(let p of e){if(i)if(n===void 0)n=p;else try{n=u._concatOutputChunks(n,p)}catch{n=void 0,i=!1}yield p}}let d;try{let p=await Mw(t.bind(this),l(),async()=>c?.handleChainStart(this.toJSON(),{input:""},a.runId,a.runType,void 0,void 0,a.runName??this.getName(),void 0,{lc_defers_inputs:!0}),a.signal,a);delete a.runId,d=p.setup;let f=d?.handlers.find(WN),m=p.output;f!==void 0&&d!==void 0&&(m=f.tapOutputIterable(d.runId,m));let h=d?.handlers.find(Dw);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let y of m)if(yield y,s)if(o===void 0)o=y;else try{o=this._concatOutputChunks(o,y)}catch{o=void 0,s=!1}}catch(p){throw await d?.handleChainError(p,void 0,void 0,void 0,{inputs:Dt(n,"input")}),p}await d?.handleChainEnd(o??{},void 0,void 0,void 0,{inputs:Dt(n,"input")})}getGraph(e){let t=new $c,r=t.addNode({name:`${this.getName()}Input`,schema:nr.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:nr.any()});return t.addEdge(r,n),t.addEdge(n,i),t}pipe(e){return new fn({first:this,last:xt(e)})}pick(e){return this.pipe(new xA(e))}assign(e){return this.pipe(new Zf(new Us({steps:e})))}async*transform(e,t){let r;for await(let n of e)r===void 0?r=n:r=this._concatOutputChunks(r,n);yield*this._streamIterator(r,Ue(t))}async*streamLog(e,t,r){let n=new kg({...r,autoClose:!1,_schemaFormat:"original"}),i=Ue(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,r){let{callbacks:n}=r;if(n===void 0)r.callbacks=[t];else if(Array.isArray(n))r.callbacks=n.concat([t]);else{let a=n.copy();a.addHandler(t,!0),r.callbacks=a}let i=this.stream(e,r);async function o(){try{let a=await i;for await(let c of a){let u=new Ni({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let s=o();try{for await(let a of t)yield a}finally{await s}}streamEvents(e,t,r){let n;if(t.version==="v1")n=this._streamEventsV1(e,t,r);else if(t.version==="v2")n=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?KN(n):jt.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,r){let n=new qN({...r,autoClose:!1}),i=Ue(t),o=i.runId??ZE();i.runId=o;let s=i.callbacks;if(s===void 0)i.callbacks=[n];else if(Array.isArray(s))i.callbacks=s.concat(n);else{let f=s.copy();f.addHandler(n,!0),i.callbacks=f}let a=new AbortController,c=this;async function u(){let f;try{if(i.signal)if("any"in AbortSignal)f=AbortSignal.any([a.signal,i.signal]);else{let y=new AbortController;i.signal.addEventListener("abort",()=>y.abort(),{once:!0}),a.signal.addEventListener("abort",()=>y.abort(),{once:!0}),f=y.signal}else f=a.signal;let m=await c.stream(e,{...i,signal:f}),h=n.tapOutputIterable(o,m);for await(let y of h)if(a.signal.aborted)break}finally{await n.finish()}}let l=u(),d=!1,p;try{for await(let f of n){if(!d){f.data.input=e,d=!0,p=f.run_id,yield f;continue}f.run_id===p&&f.event.endsWith("_end")&&f.data?.input&&delete f.data.input,yield f}}finally{a.abort(),await l}}async*_streamEventsV1(e,t,r){let n,i=!1,o=Ue(t),s=o.tags??[],a=o.metadata??{},c=o.runName??this.getName(),u=new kg({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new jN({...r}),d=this._streamLog(e,u,o);for await(let f of d){if(n?n=n.concat(f):n=xg.fromRunLogPatch(f),n.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;let w={...n.state},_={run_id:w.id,event:`on_${w.type}_start`,name:c,tags:s,metadata:a,data:{input:e}};l.includeEvent(_,w.type)&&(yield _)}let m=f.ops.filter(w=>w.path.startsWith("/logs/")).map(w=>w.path.split("/")[2]),h=[...new Set(m)];for(let w of h){let _,b={},I=n.state.logs[w];if(I.end_time===void 0?I.streamed_output.length>0?_="stream":_="start":_="end",_==="start")I.inputs!==void 0&&(b.input=I.inputs);else if(_==="end")I.inputs!==void 0&&(b.input=I.inputs),b.output=I.final_output;else if(_==="stream"){let $=I.streamed_output.length;if($!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${$} instead. Encountered in: "${I.name}"`);b={chunk:I.streamed_output[0]},I.streamed_output=[]}yield{event:`on_${I.type}_${_}`,name:I.name,run_id:I.id,tags:I.tags,metadata:I.metadata,data:b}}let{state:y}=n;if(y.streamed_output.length>0){let w=y.streamed_output.length;if(w!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${w} instead. Encountered in: "${y.name}"`);let _={chunk:y.streamed_output[0]};y.streamed_output=[];let b={event:`on_${y.type}_stream`,run_id:y.id,tags:s,metadata:a,name:c,data:_};l.includeEvent(b,y.type)&&(yield b)}}let p=n?.state;if(p!==void 0){let f={event:`on_${p.type}_end`,name:c,run_id:p.id,tags:s,metadata:a,data:{output:p.final_output}};l.includeEvent(f,p.type)&&(yield f)}}static isRunnable(e){return Ff(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new $n({bound:this,config:{},configFactories:[n=>({callbacks:[new yA({config:n,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return eW(this,e)}},$n=class JN extends he{static lc_name(){return"RunnableBinding"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;bound;config;kwargs;configFactories;constructor(t){super(t),this.bound=t.bound,this.kwargs=t.kwargs,this.config=t.config,this.configFactories=t.configFactories}getName(t){return this.bound.getName(t)}async _mergeConfig(...t){let r=Kt(this.config,...t);return Kt(r,...this.configFactories?await Promise.all(this.configFactories.map(async n=>await n(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new qy({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,r){return this.bound.invoke(t,await this._mergeConfig(r,this.kwargs))}async batch(t,r,n){let i=Array.isArray(r)?await Promise.all(r.map(async o=>this._mergeConfig(Ue(o),this.kwargs))):await this._mergeConfig(Ue(r),this.kwargs);return this.bound.batch(t,i,n)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(Ue(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(Ue(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(Ue(r),this.kwargs))}streamEvents(t,r,n){let i=this,o=async function*(){yield*i.bound.streamEvents(t,{...await i._mergeConfig(Ue(r),i.kwargs),version:r.version},n)};return jt.fromAsyncGenerator(o())}static isRunnableBinding(t){return t.bound&&he.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:n}){return new JN({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new yA({config:i,onStart:t,onEnd:r,onError:n})]})]})}},XN=class YN extends he{static lc_name(){return"RunnableEach"}lc_serializable=!0;lc_namespace=["langchain_core","runnables"];bound;constructor(t){super(t),this.bound=t.bound}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async _invoke(t,r,n){return this.bound.batch(t,ze(r,{callbacks:n?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:n}){return new YN({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:n})})}},qy=class extends $n{static lc_name(){return"RunnableRetry"}lc_namespace=["langchain_core","runnables"];maxAttemptNumber=3;onFailedAttempt=()=>{};constructor(e){super(e),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let n=e>1?`retry:attempt:${e}`:void 0;return ze(t,{callbacks:r?.getChild(n)})}async _invoke(e,t,r){return cf(n=>super.invoke(e,this._patchConfigForRetry(n,t,r)),{onFailedAttempt:({error:n})=>this.onFailedAttempt(n,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,n){let i={};try{await cf(async o=>{let s=e.map((d,p)=>p).filter(d=>i[d.toString()]===void 0||i[d.toString()]instanceof Error),a=s.map(d=>e[d]),c=s.map(d=>this._patchConfigForRetry(o,t?.[d],r?.[d])),u=await super.batch(a,c,{...n,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let p=u[d],f=s[d];p instanceof Error&&l===void 0&&(l=p,l.input=a[d]),i[f.toString()]=p}if(l)throw l;return u},{onFailedAttempt:({error:o})=>this.onFailedAttempt(o,o.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(o){if(n?.returnExceptions!==!0)throw o}return Object.keys(i).sort((o,s)=>parseInt(o,10)-parseInt(s,10)).map(o=>i[parseInt(o,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},fn=class Bf extends he{static lc_name(){return"RunnableSequence"}first;middle=[];last;omitSequenceTags=!1;lc_serializable=!0;lc_namespace=["langchain_core","runnables"];constructor(t){super(t),this.first=t.first,this.middle=t.middle??this.middle,this.last=t.last,this.name=t.name,this.omitSequenceTags=t.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(t,r){let n=Ue(r),i=await(await hr(n))?.handleChainStart(this.toJSON(),Dt(t,"input"),n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o=t,s;try{let a=[this.first,...this.middle];for(let c=0;c<a.length;c+=1)o=await sn(a[c].invoke(o,ze(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),n.signal);if(n.signal?.aborted)throw vs(n.signal);s=await this.last.invoke(o,ze(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(Dt(s,"output")),s}async batch(t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(hr)),s=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),Dt(t[u],"input"),i[u].runId,void 0,void 0,void 0,i[u].runName);return delete i[u].runId,l})),a=t;try{for(let c=0;c<this.steps.length;c+=1)a=await sn(this.steps[c].batch(a,s.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return ze(i[l],{callbacks:d})}),n),i[0]?.signal)}catch(c){throw await Promise.all(s.map(u=>u?.handleChainError(c))),c}return await Promise.all(s.map(c=>c?.handleChainEnd(Dt(a,"output")))),a}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let n=await hr(r),{runId:i,...o}=r??{},s=await n?.handleChainStart(this.toJSON(),Dt(t,"input"),i,void 0,void 0,void 0,o?.runName),a=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=a[0].transform(l(),ze(o,{callbacks:s?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let p=1;p<a.length;p+=1)d=await a[p].transform(d,ze(o,{callbacks:s?.getChild(this.omitSequenceTags?void 0:`seq:step:${p+1}`)}));for await(let p of d)if(r?.signal?.throwIfAborted(),yield p,c)if(u===void 0)u=p;else try{u=this._concatOutputChunks(u,p)}catch{u=void 0,c=!1}}catch(d){throw await s?.handleChainError(d),d}await s?.handleChainEnd(Dt(u,"output"))}getGraph(t){let r=new $c,n=null;return this.steps.forEach((i,o)=>{let s=i.getGraph(t);o!==0&&s.trimFirstNode(),o!==this.steps.length-1&&s.trimLastNode(),r.extend(s);let a=s.firstNode();if(!a)throw new Error(`Runnable ${i} has no first node`);n&&r.addEdge(n,a),n=s.lastNode()}),r}pipe(t){return Bf.isRunnableSequence(t)?new Bf({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Bf({first:this.first,middle:[...this.middle,this.last],last:xt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&he.isRunnable(t)}static from([t,...r],n){let i={};return typeof n=="string"?i.name=n:n!==void 0&&(i=n),new Bf({...i,first:xt(t),middle:r.slice(0,-1).map(xt),last:xt(r[r.length-1])})}},Us=class QN extends he{static lc_name(){return"RunnableMap"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;steps;getStepsKeys(){return Object.keys(this.steps)}constructor(t){super(t),this.steps={};for(let[r,n]of Object.entries(t.steps))this.steps[r]=xt(n)}static from(t){return new QN({steps:t})}async invoke(t,r){let n=Ue(r),i=await(await hr(n))?.handleChainStart(this.toJSON(),{input:t},n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o={};try{let s=Object.entries(this.steps).map(async([a,c])=>{o[a]=await c.invoke(t,ze(n,{callbacks:i?.getChild(`map:key:${a}`)}))});await sn(Promise.all(s),n.signal)}catch(s){throw await i?.handleChainError(s),s}return await i?.handleChainEnd(o),o}async*_transform(t,r,n){let i={...this.steps},o=yg(t,Object.keys(i).length),s=new Map(Object.entries(i).map(([a,c],u)=>{let l=c.transform(o[u],ze(n,{callbacks:r?.getChild(`map:key:${a}`)}));return[a,l.next().then(d=>({key:a,gen:l,result:d}))]}));for(;s.size;){let{key:a,result:c,gen:u}=await sn(Promise.race(s.values()),n?.signal);s.delete(a),c.done||(yield{[a]:c.value},s.set(a,u.next().then(l=>({key:a,gen:u,result:l}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=Ue(r),o=new bs({generator:this.transform(n(),i),config:i});return await o.setup,jt.fromAsyncGenerator(o)}},Y5=class e1 extends he{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!og(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,r){let[n]=this._getOptionsList(r??{},1),i=await hr(n);return sn(this.func(ze(n,{callbacks:i}),t),n?.signal)}async*_streamIterator(t,r){let[n]=this._getOptionsList(r??{},1),i=await this.invoke(t,r);if(Zy(i)){for await(let o of i)n?.signal?.throwIfAborted(),yield o;return}if(GN(i)){for(;;){n?.signal?.throwIfAborted();let o=i.next();if(o.done)break;yield o.value}return}yield i}static from(t){return new e1({func:t})}};function Q5(e){if(og(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var ir=class t1 extends he{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(og(t.func))return Y5.from(t.func);super(t),Q5(t.func),this.func=t.func}static from(t){return new t1({func:t})}async _invoke(t,r,n){return new Promise((i,o)=>{let s=ze(r,{callbacks:n?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});ut.runWithConfig(Or(s),async()=>{try{let a=await this.func(t,{...s});if(a&&he.isRunnable(a)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");a=await a.invoke(t,{...s,recursionLimit:(s.recursionLimit??25)-1})}else if(Zy(a)){let c;for await(let u of Vy(s,a))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}a=c}else if(_A(a)){let c;for(let u of bA(s,a))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}a=c}i(a)}catch(a){o(a)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,n){let i;for await(let a of t)if(i===void 0)i=a;else try{i=this._concatOutputChunks(i,a)}catch{i=a}let o=ze(n,{callbacks:r?.getChild(),recursionLimit:(n?.recursionLimit??25)-1}),s=await new Promise((a,c)=>{ut.runWithConfig(Or(o),async()=>{try{a(await this.func(i,{...o,config:o}))}catch(u){c(u)}})});if(s&&he.isRunnable(s)){if(n?.recursionLimit===0)throw new Error("Recursion limit reached.");let a=await s.stream(i,o);for await(let c of a)yield c}else if(Zy(s))for await(let a of Vy(o,s))n?.signal?.throwIfAborted(),yield a;else if(_A(s))for(let a of bA(o,s))n?.signal?.throwIfAborted(),yield a;else yield s}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=Ue(r),o=new bs({generator:this.transform(n(),i),config:i});return await o.setup,jt.fromAsyncGenerator(o)}},r1=class extends Us{},wA=class extends he{static lc_name(){return"RunnableWithFallbacks"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnable;fallbacks;constructor(e){super(e),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}async invoke(e,t){let r=Ue(t),n=await hr(r),{runId:i,...o}=r,s=await n?.handleChainStart(this.toJSON(),Dt(e,"input"),i,void 0,void 0,void 0,o?.runName),a=ze(o,{callbacks:s?.getChild()});return await ut.runWithConfig(a,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,a);return await s?.handleChainEnd(Dt(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await s?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=Ue(t),n=await hr(r),{runId:i,...o}=r,s=await n?.handleChainStart(this.toJSON(),Dt(e,"input"),i,void 0,void 0,void 0,o?.runName),a,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=ze(o,{callbacks:s?.getChild()});try{c=Vy(d,await l.stream(e,d));break}catch(p){a===void 0&&(a=p)}}if(c===void 0){let l=a??new Error("No error stored at end of fallback.");throw await s?.handleChainError(l),l}let u;try{for await(let l of c){yield l;try{u=u===void 0?u:this._concatOutputChunks(u,l)}catch{u=void 0}}}catch(l){throw await s?.handleChainError(l),l}await s?.handleChainEnd(Dt(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(a=>hr(a))),o=await Promise.all(i.map(async(a,c)=>{let u=await a?.handleChainStart(this.toJSON(),Dt(e[c],"input"),n[c].runId,void 0,void 0,void 0,n[c].runName);return delete n[c].runId,u})),s;for(let a of this.runnables()){n[0].signal?.throwIfAborted();try{let c=await a.batch(e,o.map((u,l)=>ze(n[l],{callbacks:u?.getChild()})),r);return await Promise.all(o.map((u,l)=>u?.handleChainEnd(Dt(c[l],"output")))),c}catch(c){s===void 0&&(s=c)}}throw s?(await Promise.all(o.map(a=>a?.handleChainError(s))),s):new Error("No error stored at end of fallbacks.")}};function xt(e){if(typeof e=="function")return new ir({func:e});if(he.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=xt(n);return new Us({steps:t})}else throw new Error(`Expected a Runnable, function or object.
|
|
93
|
-
Instead got an unsupported type.`)}var Zf=class extends he{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof Us&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){let n=this.mapper.getStepsKeys(),[i,o]=yg(e),s=this.mapper.transform(o,ze(r,{callbacks:t?.getChild()})),a=s.next();for await(let c of i){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let u=Object.fromEntries(Object.entries(c).filter(([l])=>!n.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await a).value;for await(let c of s)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=Ue(t),i=new bs({generator:this.transform(r(),n),config:n});return await i.setup,jt.fromAsyncGenerator(i)}},xA=class extends he{static lc_name(){return"RunnablePick"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;keys;constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(let t of e){let r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=Ue(t),i=new bs({generator:this.transform(r(),n),config:n});return await i.setup,jt.fromAsyncGenerator(i)}},Wy=class extends $n{name;description;schema;constructor(e){let t=fn.from([ir.from(async r=>{let n;if(Wu(r))try{n=await Cs(this.schema,r.args)}catch{throw new qu("Received tool input did not match expected schema",JSON.stringify(r.args))}else n=r;return n}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function eW(e,t){let r=t.name??e.getName(),n=t.description??ti(t.schema);return Sl(t.schema)?new Wy({name:r,description:n,schema:nr.object({input:nr.string()}).transform(i=>i.input),bound:e}):new Wy({name:r,description:n,schema:t.schema,bound:e})}var Ky=(e,t)=>{let r=[...new Set(t?.map(i=>{if(typeof i=="string")return i;let o=new i({});if(!("getType"in o)||typeof o.getType!="function")throw new Error("Invalid type provided.");return o.getType()}))],n=e.getType();return r.some(i=>i===n)};function a1(e,t){return Array.isArray(e)?n1(e,t):ir.from(r=>n1(r,e))}function n1(e,t={}){let{includeNames:r,excludeNames:n,includeTypes:i,excludeTypes:o,includeIds:s,excludeIds:a}=t,c=[];for(let u of e)if(!(n&&u.name&&n.includes(u.name))){{if(o&&Ky(u,o))continue;if(a&&u.id&&a.includes(u.id))continue}i||s||r?(r&&u.name&&r.some(l=>l===u.name)||i&&Ky(u,i)||s&&u.id&&s.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function c1(e){return Array.isArray(e)?i1(e):ir.from(i1)}function i1(e){if(!e.length)return[];let t=[];for(let r of e){let n=r,i=t.pop();if(!i)t.push(n);else if(n.getType()==="tool"||n.getType()!==i.getType())t.push(i,n);else{let o=Va(i),s=Va(n),a=o.concat(s);typeof o.content=="string"&&typeof s.content=="string"&&(a.content=`${o.content}
|
|
94
|
-
${s.content}`),t.push(rW(a))}}return t}function u1(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return o1(r,t)}else{let r=e;return ir.from(n=>o1(n,r)).withConfig({runName:"trim_messages"})}}async function o1(e,t){let{maxTokens:r,tokenCounter:n,strategy:i="last",allowPartial:o=!1,endOn:s,startOn:a,includeSystem:c=!1,textSplitter:u}=t;if(a&&i==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&i==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in n?l=async p=>(await Promise.all(p.map(f=>n.getNumTokens(f.content)))).reduce((f,m)=>f+m,0):l=async p=>n(p);let d=IA;if(u&&("splitText"in u?d=u.splitText.bind(u):d=async p=>u(p)),i==="first")return l1(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:o?"first":void 0,endOn:s});if(i==="last")return tW(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:o,includeSystem:c,startOn:a,endOn:s});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function l1(e,t){let{maxTokens:r,tokenCounter:n,textSplitter:i,partialStrategy:o,endOn:s}=t,a=[...e],c=0;for(let u=0;u<a.length;u+=1)if(await n(u>0?a.slice(0,-u):a)<=r){c=a.length-u;break}if(c<a.length&&o){let u=!1;if(Array.isArray(a[c].content)){let l=a[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,p=o==="last"?[...l.content].reverse():l.content;for(let f=1;f<=d;f+=1){let m=o==="first"?p.slice(0,f):p.slice(-f),h=Object.fromEntries(Object.entries(l).filter(([_])=>_!=="type"&&!_.startsWith("lc_"))),y=kA(l.getType(),{...h,content:m}),w=[...a.slice(0,c),y];if(await n(w)<=r)a=w,c+=1,u=!0;else break}u&&o==="last"&&(l.content=[...p].reverse())}if(!u){let l=a[c],d;if(Array.isArray(l.content)&&l.content.some(p=>typeof p=="string"||p.type==="text")?d=l.content.find(p=>p.type==="text"&&p.text)?.text:typeof l.content=="string"&&(d=l.content),d){let p=await i(d),f=p.length;o==="last"&&p.reverse();for(let m=0;m<f-1;m+=1)if(p.pop(),l.content=p.join(""),await n([...a.slice(0,c),l])<=r){o==="last"&&(l.content=[...p].reverse().join("")),a=[...a.slice(0,c),l],c+=1;break}}}}if(s){let u=Array.isArray(s)?s:[s];for(;c>0&&!Ky(a[c-1],u);)c-=1}return a.slice(0,c)}async function tW(e,t){let{allowPartial:r=!1,includeSystem:n=!1,endOn:i,startOn:o,...s}=t,a=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([p])=>p!=="type"&&!p.startsWith("lc_")));return kA(l.getType(),d,ho(l))});if(i){let l=Array.isArray(i)?i:[i];for(;a.length>0&&!Ky(a[a.length-1],l);)a=a.slice(0,-1)}let c=n&&a[0]?.getType()==="system",u=c?a.slice(0,1).concat(a.slice(1).reverse()):a.reverse();return u=await l1(u,{...s,partialStrategy:r?"last":void 0,endOn:o}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var s1={human:{message:Qt,messageChunk:Za},ai:{message:Re,messageChunk:ct},system:{message:Hn,messageChunk:$i},developer:{message:Hn,messageChunk:$i},tool:{message:qt,messageChunk:Ua},function:{message:Jp,messageChunk:Ba},generic:{message:vn,messageChunk:Fa},remove:{message:Gn,messageChunk:Gn}};function kA(e,t,r){let n,i;switch(e){case"human":r?n=new Za(t):i=new Qt(t);break;case"ai":if(r){let o={...t};"tool_calls"in o&&(o={...o,tool_call_chunks:o.tool_calls?.map(s=>({...s,type:"tool_call_chunk",index:void 0,args:JSON.stringify(s.args)}))}),n=new ct(o)}else i=new Re(t);break;case"system":r?n=new $i(t):i=new Hn(t);break;case"developer":r?n=new $i({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):i=new Hn({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?n=new Ua(t):i=new qt(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)n=new Ba(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");i=new Jp(t)}break;case"generic":if("role"in t)r?n=new Fa(t):i=new vn(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(r&&n)return n;if(i)return i;throw new Error(`Unrecognized message type ${e}`)}function rW(e){let t=e.getType(),r,n=Object.fromEntries(Object.entries(e).filter(([i])=>!["type","tool_call_chunks"].includes(i)&&!i.startsWith("lc_")));if(t in s1&&(r=kA(t,n)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(s1)}`);return r}function IA(e){let t=e.split(`
|
|
95
|
-
`);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
|
|
96
|
-
`),t[t.length-1]])}var d1=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var p1=["image","video","audio","text-plain","file"];var f1=["text","reasoning",...d1,...p1];var m1=F({AIMessage:()=>Re,AIMessageChunk:()=>ct,BaseMessage:()=>Rt,BaseMessageChunk:()=>Kp,ChatMessage:()=>vn,ChatMessageChunk:()=>Fa,DEFAULT_MERGE_IGNORE_KEYS:()=>aP,FunctionMessage:()=>Jp,FunctionMessageChunk:()=>Ba,HumanMessage:()=>Qt,HumanMessageChunk:()=>Za,KNOWN_BLOCK_TYPES:()=>f1,RemoveMessage:()=>Gn,SystemMessage:()=>Hn,SystemMessageChunk:()=>$i,ToolMessage:()=>qt,ToolMessageChunk:()=>Ua,_isMessageFieldWithRole:()=>dP,_mergeDicts:()=>cP,_mergeLists:()=>uP,_mergeObj:()=>lP,_mergeStatus:()=>oP,coerceMessageLikeToMessage:()=>er,collapseToolCallChunks:()=>$P,convertToChunk:()=>Va,convertToOpenAIImageBlock:()=>Qh,convertToProviderContentBlock:()=>Vu,defaultTextSplitter:()=>IA,defaultToolCallParser:()=>fP,filterMessages:()=>a1,getBufferString:()=>rg,iife:()=>tg,isAIMessage:()=>go,isAIMessageChunk:()=>Hp,isBase64ContentBlock:()=>Yh,isBaseMessage:()=>St,isBaseMessageChunk:()=>ho,isChatMessage:()=>_P,isChatMessageChunk:()=>vP,isDataContentBlock:()=>Zu,isDirectToolOutput:()=>eg,isFunctionMessage:()=>bP,isFunctionMessageChunk:()=>wP,isHumanMessage:()=>xP,isHumanMessageChunk:()=>kP,isIDContentBlock:()=>rP,isMessage:()=>nP,isOpenAIToolCallArray:()=>sP,isPlainTextContentBlock:()=>tP,isSystemMessage:()=>IP,isSystemMessageChunk:()=>SP,isToolMessage:()=>Gp,isToolMessageChunk:()=>mP,isURLContentBlock:()=>Xh,mapChatMessagesToStoredMessages:()=>OP,mapStoredMessageToChatMessage:()=>ng,mapStoredMessagesToChatMessages:()=>AP,mergeContent:()=>iP,mergeMessageRuns:()=>c1,mergeResponseMetadata:()=>gP,mergeUsageMetadata:()=>yP,parseBase64DataUrl:()=>qp,parseMimeType:()=>Wp,trimMessages:()=>u1});var h1=F({BaseChatMessageHistory:()=>SA,BaseListChatMessageHistory:()=>Gy,InMemoryChatMessageHistory:()=>nW}),SA=class extends Ar{async addMessages(e){for(let t of e)await this.addMessage(t)}},Gy=class extends Ar{addUserMessage(e){return this.addMessage(new Qt(e))}addAIMessage(e){return this.addMessage(new Re(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},nW=class extends Gy{lc_namespace=["langchain","stores","message","in_memory"];messages=[];constructor(e){super(...arguments),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}};var mn=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var AA=class extends he{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},g1=class extends AA{async transformDocuments(e){let t=[];for(let r of e){let n=await this._transformDocument(r);t.push(n)}return t}};var y1=F({BaseDocumentTransformer:()=>AA,Document:()=>mn,MappingDocumentTransformer:()=>g1});var _1=F({BaseDocumentLoader:()=>OA}),OA=class{};var v1=F({LangSmithLoader:()=>iW}),iW=class extends OA{datasetId;datasetName;exampleIds;asOf;splits;inlineS3Urls;offset;limit;metadata;filter;contentKey;formatContent;client;constructor(e){if(super(),e.client&&e.clientConfig)throw new Error("client and clientConfig cannot both be provided.");this.client=e.client??new PP(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??oW,this.datasetId=e.datasetId,this.datasetName=e.datasetName,this.exampleIds=e.exampleIds,this.asOf=e.asOf,this.splits=e.splits,this.inlineS3Urls=e.inlineS3Urls,this.offset=e.offset,this.limit=e.limit,this.metadata=e.metadata,this.filter=e.filter}async load(){let e=[];for await(let t of this.client.listExamples({datasetId:this.datasetId,datasetName:this.datasetName,exampleIds:this.exampleIds,asOf:this.asOf,splits:this.splits,inlineS3Urls:this.inlineS3Urls,offset:this.offset,limit:this.limit,metadata:this.metadata,filter:this.filter})){let r=t.inputs;for(let o of this.contentKey)r=r[o];let n=this.formatContent(r),i=t;["created_at","modified_at"].forEach(o=>{o in i&&typeof i[o]=="object"&&(i[o]=i[o].toString())}),e.push({pageContent:n,metadata:i})}return e}};function oW(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var b1=F({Embeddings:()=>zl}),zl=class{caller;constructor(e){this.caller=new xo(e??{})}};var jl=class extends Ar{lc_namespace=["langchain_core","example_selectors","base"]};var $A=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},w1=class extends $A{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,r]of this.conditionals)if(t(e))return r;return this.defaultPrompt}};function x1(e){return e._modelType()==="base_llm"}function k1(e){return e._modelType()==="base_chat_model"}function I1(e){return e.split(/\n| /).length}var S1=class A1 extends jl{examples=[];examplePrompt;getTextLength=I1;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??I1}async addExample(t){this.examples.push(t);let r=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(r))}async calculateExampleTextLengths(t,r){if(t.length>0)return t;let{examples:n,examplePrompt:i}=r;return(await Promise.all(n.map(o=>i.format(o)))).map(o=>this.getTextLength(o))}async selectExamples(t){let r=Object.values(t).join(" "),n=this.maxLength-this.getTextLength(r),i=0,o=[];for(;n>0&&i<this.examples.length;){let s=n-this.exampleTextLengths[i];if(s<0)break;o.push(this.examples[i]),n=s,i+=1}return o}static async fromExamples(t,r){let n=new A1(r);return await Promise.all(t.map(i=>n.addExample(i))),n}};function TA(e){return Object.keys(e).sort().map(t=>e[t])}var O1=class $1 extends jl{vectorStoreRetriever;exampleKeys;inputKeys;constructor(t){if(super(t),this.exampleKeys=t.exampleKeys,this.inputKeys=t.inputKeys,t.vectorStore!==void 0)this.vectorStoreRetriever=t.vectorStore.asRetriever({k:t.k??4,filter:t.filter});else if(t.vectorStoreRetriever)this.vectorStoreRetriever=t.vectorStoreRetriever;else throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".')}async addExample(t){let r=TA((this.inputKeys??Object.keys(t)).reduce((n,i)=>({...n,[i]:t[i]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new mn({pageContent:r,metadata:t})])}async selectExamples(t){let r=TA((this.inputKeys??Object.keys(t)).reduce((i,o)=>({...i,[o]:t[o]}),{})).join(" "),n=(await this.vectorStoreRetriever.invoke(r)).map(i=>i.metadata);return this.exampleKeys?n.map(i=>this.exampleKeys.reduce((o,s)=>({...o,[s]:i[s]}),{})):n}static async fromExamples(t,r,n,i={}){let o=i.inputKeys??null,s=t.map(c=>TA(o?o.reduce((u,l)=>({...u,[l]:c[l]}),{}):c).join(" ")),a=await n.fromTexts(s,t,r,i);return new $1({vectorStore:a,k:i.k??4,exampleKeys:i.exampleKeys,inputKeys:i.inputKeys})}};var T1=F({BaseExampleSelector:()=>jl,BasePromptSelector:()=>$A,ConditionalPromptSelector:()=>w1,LengthBasedExampleSelector:()=>S1,SemanticSimilarityExampleSelector:()=>O1,isChatModel:()=>k1,isLLM:()=>x1});var Vf="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",E1=class extends Ar{lc_namespace=["langchain","recordmanagers"]};var EA=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Xu;constructor(e){this.uid=e.uid,this.pageContent=e.pageContent,this.metadata=e.metadata}makeDefaultKeyEncoder(e){this.keyEncoder=e}calculateHashes(){let e=["hash_","content_hash","metadata_hash"];for(let r of e)if(r in this.metadata)throw new Error(`Metadata cannot contain key ${r} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let r=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=r}catch(r){throw new Error(`Failed to hash metadata: ${r}. Please use a dict that can be serialized using json.`)}this.hash_=this._hashStringToUUID(this.contentHash+this.metadataHash),this.uid||(this.uid=this.hash_)}toDocument(){return new mn({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let r=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return r.calculateHashes(),r}_hashStringToUUID(e){return Vp(this.keyEncoder(e),Vf)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return Vp(this.keyEncoder(t),Vf)}};function PA(e,t){let r=[],n=[];return t.forEach(i=>{n.push(i),n.length>=e&&(r.push(n),n=[])}),n.length>0&&r.push(n),r}function CA(e){let t=new Set,r=[];for(let n of e){if(!n.hash_)throw new Error("Hashed document does not have a hash");t.has(n.hash_)||(t.add(n.hash_),r.push(n))}return r}function RA(e){if(e===null)return t=>null;if(typeof e=="string")return t=>t.metadata[e];if(typeof e=="function")return e;throw new Error(`sourceIdKey should be null, a string or a function, got ${typeof e}`)}var NA=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function P1(e){let{docsSource:t,recordManager:r,vectorStore:n,options:i}=e,{batchSize:o=100,cleanup:s,sourceIdKey:a,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=i??{};if(s==="incremental"&&!a)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=NA(t)?await t.load():t,d=RA(a??null),p=await r.getTime(),f=0,m=0,h=0,y=0,w=PA(o??100,l);for(let _ of w){let b=CA(_.map(M=>EA.fromDocument(M))),I=b.map(M=>d(M));s==="incremental"&&b.forEach((M,R)=>{if(I[R]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let $=await r.exists(b.map(M=>M.uid)),P=[],C=[],x=[],D=new Set;if(b.forEach((M,R)=>{if($[R])if(u)D.add(M.uid);else{x.push(M.uid);return}P.push(M.uid),C.push(M.toDocument())}),x.length>0&&(await r.update(x,{timeAtLeast:p}),y+=x.length),C.length>0&&(await n.addDocuments(C,{ids:P}),f+=C.length-D.size,h+=D.size),await r.update(b.map(M=>M.uid),{timeAtLeast:p,groupIds:I}),s==="incremental"){I.forEach(R=>{if(!R)throw new Error("Source id cannot be null")});let M=await r.listKeys({before:p,groupIds:I});M.length>0&&(await n.delete({ids:M}),await r.deleteKeys(M),m+=M.length)}}if(s==="full"){let _=await r.listKeys({before:p,limit:c});for(;_.length>0;)await n.delete({ids:_}),await r.deleteKeys(_),m+=_.length,_=await r.listKeys({before:p,limit:c})}return{numAdded:f,numDeleted:m,numUpdated:h,numSkipped:y}}var C1=F({RecordManager:()=>E1,UUIDV5_NAMESPACE:()=>Vf,_HashedDocument:()=>EA,_batch:()=>PA,_deduplicateInOrder:()=>CA,_getSourceIdAssigner:()=>RA,_isBaseDocumentLoader:()=>NA,index:()=>P1});var R1=F({BasePromptValue:()=>Hy,ChatPromptValue:()=>qf,ImagePromptValue:()=>MA,StringPromptValue:()=>Wf}),Hy=class extends Ar{},Wf=class extends Hy{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Qt(this.value)]}},qf=class extends Hy{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return rg(this.messages)}toChatMessages(){return this.messages}},MA=class extends Hy{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Qt({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var j1=gw(z1(),1),fW=Object.defineProperty,mW=(e,t,r)=>t in e?fW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hW=(e,t,r)=>(mW(e,typeof t!="symbol"?t+"":t,r),r);function gW(e,t){let r=Array.from({length:e.length},(n,i)=>({start:i,end:i+1}));for(;r.length>1;){let n=null;for(let i=0;i<r.length-1;i++){let o=e.slice(r[i].start,r[i+1].end),s=t.get(o.join(","));s!=null&&(n==null||s<n[0])&&(n=[s,i])}if(n!=null){let i=n[1];r[i]={start:r[i].start,end:r[i+1].end},r.splice(i+1,1)}else break}return r}function yW(e,t){return e.length===1?[t.get(e.join(","))]:gW(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function _W(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var jA=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,t){this.patStr=e.pat_str;let r=e.bpe_ranks.split(`
|
|
97
|
-
`).filter(Boolean).reduce((n,i)=>{let[o,s,...a]=i.split(" "),c=Number.parseInt(s,10);return a.forEach((u,l)=>n[u]=c+l),n},{});for(let[n,i]of Object.entries(r)){let o=j1.default.toByteArray(n);this.rankMap.set(o.join(","),i),this.textMap.set(i,o)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((n,[i,o])=>(n[o]=this.textEncoder.encode(i),n),{})}encode(e,t=[],r="all"){let n=new RegExp(this.patStr,"ug"),i=jA.specialTokenRegex(Object.keys(this.specialTokens)),o=[],s=new Set(t==="all"?Object.keys(this.specialTokens):t),a=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!s.has(u)):r);if(a.size>0){let u=jA.specialTokenRegex([...a]),l=e.match(u);if(l!=null)throw new Error(`The text contains a special token that is not allowed: ${l[0]}`)}let c=0;for(;;){let u=null,l=c;for(;i.lastIndex=l,u=i.exec(e),!(u==null||s.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let f of e.substring(c,d).matchAll(n)){let m=this.textEncoder.encode(f[0]),h=this.rankMap.get(m.join(","));if(h!=null){o.push(h);continue}o.push(...yW(m,this.rankMap))}if(u==null)break;let p=this.specialTokens[u[0]];o.push(p),c=u.index+u[0].length}return o}decode(e){let t=[],r=0;for(let o=0;o<e.length;++o){let s=e[o],a=this.textMap.get(s)??this.inverseSpecialTokens[s];a!=null&&(t.push(a),r+=a.length)}let n=new Uint8Array(r),i=0;for(let o of t)n.set(o,i),i+=o.length;return this.textDecoder.decode(n)}},Xy=jA;hW(Xy,"specialTokenRegex",e=>new RegExp(e.map(t=>_W(t)).join("|"),"g"));function DA(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var D1=F({encodingForModel:()=>Qy,getEncoding:()=>U1}),Yy={},vW=new xo({});async function U1(e){return e in Yy||(Yy[e]=vW.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Xy(t)).catch(t=>{throw delete Yy[e],t})),await Yy[e]}async function Qy(e){return U1(DA(e))}var L1=F({BaseLangChain:()=>t_,BaseLanguageModel:()=>Gf,calculateMaxTokens:()=>B1,getEmbeddingContextSize:()=>bW,getModelContextSize:()=>F1,getModelNameForTiktoken:()=>e_,isOpenAITool:()=>Kf}),e_=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,bW=e=>e==="text-embedding-ada-002"?8191:2046,F1=e=>{switch(e_(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function Kf(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}var B1=async({prompt:e,modelName:t})=>{let r;try{r=(await Qy(e_(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),r=Math.ceil(e.length/4)}return F1(t)-r},wW=()=>!1,t_=class extends he{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??wW(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.2.9")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Gf=class extends t_{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:n,...i}=r;super({callbacks:e??t,...i}),typeof n=="object"?this.cache=n:n?this.cache=Rw.global():this.cache=void 0,this.caller=new xo(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(n=>typeof n=="string"?n:n.type==="text"&&"text"in n?n.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await Qy("modelName"in this?e_(this.modelName):"gpt2")}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Wf(e):Array.isArray(e)?new qf(e.map(er)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([n,i])=>i!==void 0).map(([n,i])=>`${n}:${JSON.stringify(i)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}_filterInvocationParamsForTracing(e){let{tools:t,functions:r,messages:n,response_format:i,...o}=e;return o}};var Co=class extends he{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,t){let r=Ue(t);return this.func&&await this.func(e,r),this._callWithConfig(n=>Promise.resolve(n),e,r)}async*transform(e,t){let r=Ue(t),n,i=!0;for await(let o of this._transformStreamWithConfig(e,s=>s,r))if(yield o,i)if(n===void 0)n=o;else try{n=an(n,o)}catch{n=void 0,i=!1}this.func&&n!==void 0&&await this.func(n,r)}static assign(e){return new Zf(new Us({steps:e}))}};var Z1=class extends he{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.invoke(n,Ue(t))}async batch(e,t,r){let n=e.map(l=>l.key),i=e.map(l=>l.input);if(n.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let o=n.map(l=>this.runnables[l]),s=this._getOptionsList(t??{},e.length),a=s[0]?.maxConcurrency??r?.maxConcurrency,c=a&&a>0?a:e.length,u=[];for(let l=0;l<i.length;l+=c){let d=i.slice(l,l+c).map((f,m)=>o[m].invoke(f,s[m])),p=await Promise.all(d);u.push(p)}return u.flat()}async stream(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.stream(n,t)}};var V1=class extends he{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");let t=e.slice(0,-1).map(([n,i])=>[xt(n),xt(i)]),r=xt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let n;for(let i=0;i<this.branches.length;i+=1){let[o,s]=this.branches[i];if(await o.invoke(e,ze(t,{callbacks:r?.getChild(`condition:${i+1}`)}))){n=await s.invoke(e,ze(t,{callbacks:r?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,ze(t,{callbacks:r?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await hr(t))?.handleChainStart(this.toJSON(),Dt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),n,i=!0,o;try{for(let s=0;s<this.branches.length;s+=1){let[a,c]=this.branches[s];if(await a.invoke(e,ze(t,{callbacks:r?.getChild(`condition:${s+1}`)}))){o=await c.stream(e,ze(t,{callbacks:r?.getChild(`branch:${s+1}`)}));for await(let u of o)if(yield u,i)if(n===void 0)n=u;else try{n=an(n,u)}catch{n=void 0,i=!1}break}}if(o===void 0){o=await this.default.stream(e,ze(t,{callbacks:r?.getChild("branch:default")}));for await(let s of o)if(yield s,i)if(n===void 0)n=s;else try{n=an(n,s)}catch{n=void 0,i=!1}}}catch(s){throw await r?.handleChainError(s),s}await r?.handleChainEnd(n??{})}};var W1=class extends $n{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=ir.from((o,s)=>this._enterHistory(o,s??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=Co.assign({[r]:t}).withConfig({runName:"insertHistory"}));let n=t.pipe(e.runnable.withListeners({onEnd:(o,s)=>this._exitHistory(o,s??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if(typeof e=="object"&&!Array.isArray(e)&&!St(e)){let r;this.inputMessagesKey?r=this.inputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="input",Array.isArray(e[r])&&Array.isArray(e[r][0])?t=e[r][0]:t=e[r]}else t=e;if(typeof t=="string")return[new Qt(t)];if(Array.isArray(t))return t;if(St(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
98
|
-
Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!St(e)&&typeof e!="string"){let r;this.outputMessagesKey!==void 0?r=this.outputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[r]}else t=e;if(typeof t=="string")return[new Re(t)];if(Array.isArray(t))return t;if(St(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){let r=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,t){let r=t.configurable?.messageHistory,n;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?n=e.inputs[0]:n=e.inputs;let i=this._getInputMessages(n);if(this.historyMessagesKey===void 0){let a=await r.getMessages();i=i.slice(a.length)}let o=e.outputs;if(!o)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let s=this._getOutputMessages(o);await r.addMessages([...i,...s])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let n={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
99
|
-
eg. chain.invoke(${JSON.stringify(n)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var q1=F({RouterRunnable:()=>Z1,Runnable:()=>he,RunnableAssign:()=>Zf,RunnableBinding:()=>$n,RunnableBranch:()=>V1,RunnableEach:()=>XN,RunnableLambda:()=>ir,RunnableMap:()=>Us,RunnableParallel:()=>r1,RunnablePassthrough:()=>Co,RunnablePick:()=>xA,RunnableRetry:()=>qy,RunnableSequence:()=>fn,RunnableToolLike:()=>Wy,RunnableWithFallbacks:()=>wA,RunnableWithMessageHistory:()=>W1,_coerceToRunnable:()=>xt,ensureConfig:()=>Ue,getCallbackManagerForConfig:()=>hr,mergeConfigs:()=>Kt,patchConfig:()=>ze,pickRunnableConfigKeys:()=>Or,raceWithSignal:()=>sn});var K1=F({applyPatch:()=>bo,compare:()=>wo});var Dl=class extends he{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,n)=>this.parseResult([{text:r}],n?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,n)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],n?.callbacks),e,{...t,runType:"parser"})}},oi=class extends Dl{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}},br=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,n=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=n,n&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Bu(this,"OUTPUT_PARSING_FAILURE")}};var Ro=class extends oi{async*_transform(e){for await(let t of e)typeof t=="string"?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}},Ki=class extends Ro{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let n of e){if(typeof n!="string"&&typeof n.content!="string")throw new Error("Cannot handle non-string output.");let i;if(ho(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new un({message:n,text:n.content})}else if(St(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new un({message:Va(n),text:n.content})}else i=new Mi({text:n});r===void 0?r=i:r=r.concat(i);let o=await this.parsePartialResult([r]);o!=null&&!Vi(o,t)&&(this.diff?yield this._diff(t,o):yield o,t=o)}}getFormatInstructions(){return""}};var G1=class extends Ro{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}};var Ul=class extends Ro{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let n=[...t.matchAll(this.re)];if(n.length>1){let i=0;for(let o of n.slice(0,-1))yield[o[1]],i+=(o.index??0)+o[0].length;t=t.slice(i)}}else{let n=await this.parse(t);if(n.length>1){for(let i of n.slice(0,-1))yield[i];t=n[n.length-1]}}for(let r of await this.parse(t))yield[r]}},H1=class extends Ul{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(t=>t.trim())}catch{throw new br(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},J1=class extends Ul{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:t}){super(...arguments),this.length=e,this.separator=t||","}async parse(e){try{let t=e.trim().split(this.separator).map(r=>r.trim());if(this.length!==void 0&&t.length!==this.length)throw new br(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===br.prototype?t:new br(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},X1=class extends Ul{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
100
|
-
|
|
101
|
-
1. foo
|
|
102
|
-
|
|
103
|
-
2. bar
|
|
104
|
-
|
|
105
|
-
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},Y1=class extends Ul{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
106
|
-
|
|
107
|
-
1. foo
|
|
108
|
-
|
|
109
|
-
2. bar
|
|
110
|
-
|
|
111
|
-
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var Q1=class extends Ro{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;case"reasoning":case"thinking":case"redacted_thinking":return"";default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((t,r)=>t+this._messageContentToString(r),"")}};var Ll=class extends Ki{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,t){return this.diff?super._concatOutputChunks(e,t):t}_diff(e,t){if(t)return e?wo(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return La(e[0].text)}async parse(e){return La(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var r_=class extends oi{static lc_name(){return"StandardSchemaOutputParser"}lc_namespace=["langchain","output_parsers","standard_schema"];schema;constructor(e){super(),this.schema=e}static fromSerializableSchema(e){return new this(e)}async parse(e){try{let t=La(e,JSON.parse),r=await this.schema["~standard"].validate(t);if(r.issues)throw new Error(`Validation failed: ${JSON.stringify(r.issues)}`);return r.value}catch(t){throw new br(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var Hf=class extends oi{schema;static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=nr.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,nr.string().describe(n)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
112
|
-
|
|
113
|
-
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
114
|
-
|
|
115
|
-
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
116
|
-
would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
|
|
117
|
-
Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
|
|
118
|
-
|
|
119
|
-
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
120
|
-
|
|
121
|
-
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
122
|
-
\`\`\`json
|
|
123
|
-
${JSON.stringify(ht(this.schema))}
|
|
124
|
-
\`\`\`
|
|
125
|
-
`}async parse(e){try{let t=e.trim(),r=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(n,i)=>`"${i.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await Cs(this.schema,JSON.parse(r))}catch(t){throw new br(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},UA=class extends Hf{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){let t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
|
|
126
|
-
\`\`\`json
|
|
127
|
-
${this._schemaToInstruction(ht(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
|
|
128
|
-
\`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let n=!1,i;if(Array.isArray(r.type)){let a=r.type.findIndex(c=>c==="null");a!==-1&&(n=!0,r.type.splice(a,1)),i=r.type.join(" | ")}else i=r.type;if(r.type==="object"&&r.properties){let a=r.description?` // ${r.description}`:"";return`{
|
|
129
|
-
${Object.entries(r.properties).map(([c,u])=>{let l=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
|
|
130
|
-
`)}
|
|
131
|
-
${" ".repeat(t-2)}}${a}`}if(r.type==="array"&&r.items){let a=r.description?` // ${r.description}`:"";return`array[
|
|
132
|
-
${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
|
|
133
|
-
${" ".repeat(t-2)}] ${a}`}let o=n?" (nullable)":"",s=r.description?` // ${r.description}`:"";return`${i}${s}${o}`}if("anyOf"in r)return r.anyOf.map(n=>this._schemaToInstruction(n,t)).join(`
|
|
134
|
-
${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=nr.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,nr.string().describe(n)])));return new this(t)}},eM=class extends oi{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new UA(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new br(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var xW=function(){let e={};e.parser=function(k,v){return new r(k,v)},e.SAXParser=r,e.SAXStream=u,e.createStream=c,e.MAX_BUFFER_LENGTH=65536;let t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(k,v){if(!(this instanceof r))return new r(k,v);var U=this;i(U),U.q=U.c="",U.bufferCheckPosition=e.MAX_BUFFER_LENGTH,U.opt=v||{},U.opt.lowercase=U.opt.lowercase||U.opt.lowercasetags,U.looseCase=U.opt.lowercase?"toLowerCase":"toUpperCase",U.tags=[],U.closed=U.closedRoot=U.sawRoot=!1,U.tag=U.error=null,U.strict=!!k,U.noscript=!!(k||U.opt.noscript),U.state=x.BEGIN,U.strictEntities=U.opt.strictEntities,U.ENTITIES=U.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),U.attribList=[],U.opt.xmlns&&(U.ns=Object.create(m)),U.trackPosition=U.opt.position!==!1,U.trackPosition&&(U.position=U.line=U.column=0),M(U,"onready")}Object.create||(Object.create=function(k){function v(){}return v.prototype=k,new v}),Object.keys||(Object.keys=function(k){var v=[];for(var U in k)k.hasOwnProperty(U)&&v.push(U);return v});function n(k){for(var v=Math.max(e.MAX_BUFFER_LENGTH,10),U=0,T=0,xe=t.length;T<xe;T++){var Pe=k[t[T]].length;if(Pe>v)switch(t[T]){case"textNode":B(k);break;case"cdata":R(k,"oncdata",k.cdata),k.cdata="";break;case"script":R(k,"onscript",k.script),k.script="";break;default:re(k,"Max buffer length exceeded: "+t[T])}U=Math.max(U,Pe)}k.bufferCheckPosition=e.MAX_BUFFER_LENGTH-U+k.position}function i(k){for(var v=0,U=t.length;v<U;v++)k[t[v]]=""}function o(k){B(k),k.cdata!==""&&(R(k,"oncdata",k.cdata),k.cdata=""),k.script!==""&&(R(k,"onscript",k.script),k.script="")}r.prototype={end:function(){We(this)},write:Xe,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var s=ReadableStream;s||(s=function(){});var a=e.EVENTS.filter(function(k){return k!=="error"&&k!=="end"});function c(k,v){return new u(k,v)}function u(k,v){if(!(this instanceof u))return new u(k,v);s.apply(this),this._parser=new r(k,v),this.writable=!0,this.readable=!0;var U=this;this._parser.onend=function(){U.emit("end")},this._parser.onerror=function(T){U.emit("error",T),U._parser.error=null},this._decoder=null,a.forEach(function(T){Object.defineProperty(U,"on"+T,{get:function(){return U._parser["on"+T]},set:function(xe){if(!xe)return U.removeAllListeners(T),U._parser["on"+T]=xe,xe;U.on(T,xe)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(s.prototype,{constructor:{value:u}}),u.prototype.write=function(k){return this._parser.write(k.toString()),this.emit("data",k),!0},u.prototype.end=function(k){return k&&k.length&&this.write(k),this._parser.end(),!0},u.prototype.on=function(k,v){var U=this;return!U._parser["on"+k]&&a.indexOf(k)!==-1&&(U._parser["on"+k]=function(){var T=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);T.splice(0,0,k),U.emit.apply(U,T)}),s.prototype.on.call(U,k,v)};var l="[CDATA[",d="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",f="http://www.w3.org/2000/xmlns/",m={xml:p,xmlns:f},h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function b(k){return k===" "||k===`
|
|
135
|
-
`||k==="\r"||k===" "}function I(k){return k==='"'||k==="'"}function $(k){return k===">"||b(k)}function P(k,v){return k.test(v)}function C(k,v){return!P(k,v)}var x=0;e.STATE={BEGIN:x++,BEGIN_WHITESPACE:x++,TEXT:x++,TEXT_ENTITY:x++,OPEN_WAKA:x++,SGML_DECL:x++,SGML_DECL_QUOTED:x++,DOCTYPE:x++,DOCTYPE_QUOTED:x++,DOCTYPE_DTD:x++,DOCTYPE_DTD_QUOTED:x++,COMMENT_STARTING:x++,COMMENT:x++,COMMENT_ENDING:x++,COMMENT_ENDED:x++,CDATA:x++,CDATA_ENDING:x++,CDATA_ENDING_2:x++,PROC_INST:x++,PROC_INST_BODY:x++,PROC_INST_ENDING:x++,OPEN_TAG:x++,OPEN_TAG_SLASH:x++,ATTRIB:x++,ATTRIB_NAME:x++,ATTRIB_NAME_SAW_WHITE:x++,ATTRIB_VALUE:x++,ATTRIB_VALUE_QUOTED:x++,ATTRIB_VALUE_CLOSED:x++,ATTRIB_VALUE_UNQUOTED:x++,ATTRIB_VALUE_ENTITY_Q:x++,ATTRIB_VALUE_ENTITY_U:x++,CLOSE_TAG:x++,CLOSE_TAG_SAW_WHITE:x++,SCRIPT:x++,SCRIPT_ENDING:x++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(k){var v=e.ENTITIES[k],U=typeof v=="number"?String.fromCharCode(v):v;e.ENTITIES[k]=U});for(var D in e.STATE)e.STATE[e.STATE[D]]=D;x=e.STATE;function M(k,v,U){k[v]&&k[v](U)}function R(k,v,U){k.textNode&&B(k),M(k,v,U)}function B(k){k.textNode=K(k.opt,k.textNode),k.textNode&&M(k,"ontext",k.textNode),k.textNode=""}function K(k,v){return k.trim&&(v=v.trim()),k.normalize&&(v=v.replace(/\s+/g," ")),v}function re(k,v){return B(k),k.trackPosition&&(v+=`
|
|
136
|
-
Line: `+k.line+`
|
|
137
|
-
Column: `+k.column+`
|
|
138
|
-
Char: `+k.c),v=new Error(v),k.error=v,M(k,"onerror",v),k}function We(k){return k.sawRoot&&!k.closedRoot&&ne(k,"Unclosed root tag"),k.state!==x.BEGIN&&k.state!==x.BEGIN_WHITESPACE&&k.state!==x.TEXT&&re(k,"Unexpected end"),B(k),k.c="",k.closed=!0,M(k,"onend"),r.call(k,k.strict,k.opt),k}function ne(k,v){if(typeof k!="object"||!(k instanceof r))throw new Error("bad call to strictFail");k.strict&&re(k,v)}function X(k){k.strict||(k.tagName=k.tagName[k.looseCase]());var v=k.tags[k.tags.length-1]||k,U=k.tag={name:k.tagName,attributes:{}};k.opt.xmlns&&(U.ns=v.ns),k.attribList.length=0,R(k,"onopentagstart",U)}function Q(k,v){var U=k.indexOf(":")<0?["",k]:k.split(":"),T=U[0],xe=U[1];return v&&k==="xmlns"&&(T="xmlns",xe=""),{prefix:T,local:xe}}function ae(k){if(k.strict||(k.attribName=k.attribName[k.looseCase]()),k.attribList.indexOf(k.attribName)!==-1||k.tag.attributes.hasOwnProperty(k.attribName)){k.attribName=k.attribValue="";return}if(k.opt.xmlns){var v=Q(k.attribName,!0),U=v.prefix,T=v.local;if(U==="xmlns")if(T==="xml"&&k.attribValue!==p)ne(k,"xml: prefix must be bound to "+p+`
|
|
139
|
-
Actual: `+k.attribValue);else if(T==="xmlns"&&k.attribValue!==f)ne(k,"xmlns: prefix must be bound to "+f+`
|
|
140
|
-
Actual: `+k.attribValue);else{var xe=k.tag,Pe=k.tags[k.tags.length-1]||k;xe.ns===Pe.ns&&(xe.ns=Object.create(Pe.ns)),xe.ns[T]=k.attribValue}k.attribList.push([k.attribName,k.attribValue])}else k.tag.attributes[k.attribName]=k.attribValue,R(k,"onattribute",{name:k.attribName,value:k.attribValue});k.attribName=k.attribValue=""}function ce(k,v){if(k.opt.xmlns){var U=k.tag,T=Q(k.tagName);U.prefix=T.prefix,U.local=T.local,U.uri=U.ns[T.prefix]||"",U.prefix&&!U.uri&&(ne(k,"Unbound namespace prefix: "+JSON.stringify(k.tagName)),U.uri=T.prefix);var xe=k.tags[k.tags.length-1]||k;U.ns&&xe.ns!==U.ns&&Object.keys(U.ns).forEach(function(ja){R(k,"onopennamespace",{prefix:ja,uri:U.ns[ja]})});for(var Pe=0,wt=k.attribList.length;Pe<wt;Pe++){var He=k.attribList[Pe],fr=He[0],_n=He[1],Pt=Q(fr,!0),Ai=Pt.prefix,Fu=Pt.local,Hh=Ai===""?"":U.ns[Ai]||"",oe={name:fr,value:_n,prefix:Ai,local:Fu,uri:Hh};Ai&&Ai!=="xmlns"&&!Hh&&(ne(k,"Unbound namespace prefix: "+JSON.stringify(Ai)),oe.uri=Ai),k.tag.attributes[fr]=oe,R(k,"onattribute",oe)}k.attribList.length=0}k.tag.isSelfClosing=!!v,k.sawRoot=!0,k.tags.push(k.tag),R(k,"onopentag",k.tag),v||(!k.noscript&&k.tagName.toLowerCase()==="script"?k.state=x.SCRIPT:k.state=x.TEXT,k.tag=null,k.tagName=""),k.attribName=k.attribValue="",k.attribList.length=0}function $e(k){if(!k.tagName){ne(k,"Weird empty close tag."),k.textNode+="</>",k.state=x.TEXT;return}if(k.script){if(k.tagName!=="script"){k.script+="</"+k.tagName+">",k.tagName="",k.state=x.SCRIPT;return}R(k,"onscript",k.script),k.script=""}var v=k.tags.length,U=k.tagName;k.strict||(U=U[k.looseCase]());for(var T=U;v--&&k.tags[v].name!==T;)ne(k,"Unexpected close tag");if(v<0){ne(k,"Unmatched closing tag: "+k.tagName),k.textNode+="</"+k.tagName+">",k.state=x.TEXT;return}k.tagName=U;for(var xe=k.tags.length;xe-- >v;){var Pe=k.tag=k.tags.pop();k.tagName=k.tag.name,R(k,"onclosetag",k.tagName);var wt={};for(var He in Pe.ns)wt[He]=Pe.ns[He];var fr=k.tags[k.tags.length-1]||k;k.opt.xmlns&&Pe.ns!==fr.ns&&Object.keys(Pe.ns).forEach(function(_n){var Pt=Pe.ns[_n];R(k,"onclosenamespace",{prefix:_n,uri:Pt})})}v===0&&(k.closedRoot=!0),k.tagName=k.attribValue=k.attribName="",k.attribList.length=0,k.state=x.TEXT}function bt(k){var v=k.entity,U=v.toLowerCase(),T,xe="";return k.ENTITIES[v]?k.ENTITIES[v]:k.ENTITIES[U]?k.ENTITIES[U]:(v=U,v.charAt(0)==="#"&&(v.charAt(1)==="x"?(v=v.slice(2),T=parseInt(v,16),xe=T.toString(16)):(v=v.slice(1),T=parseInt(v,10),xe=T.toString(10))),v=v.replace(/^0+/,""),isNaN(T)||xe.toLowerCase()!==v?(ne(k,"Invalid character entity"),"&"+k.entity+";"):String.fromCodePoint(T))}function yn(k,v){v==="<"?(k.state=x.OPEN_WAKA,k.startTagPosition=k.position):b(v)||(ne(k,"Non-whitespace before first tag."),k.textNode=v,k.state=x.TEXT)}function Et(k,v){var U="";return v<k.length&&(U=k.charAt(v)),U}function Xe(k){var v=this;if(this.error)throw this.error;if(v.closed)return re(v,"Cannot write after close. Assign an onready handler.");if(k===null)return We(v);typeof k=="object"&&(k=k.toString());for(var U=0,T="";T=Et(k,U++),v.c=T,!!T;)switch(v.trackPosition&&(v.position++,T===`
|
|
141
|
-
`?(v.line++,v.column=0):v.column++),v.state){case x.BEGIN:if(v.state=x.BEGIN_WHITESPACE,T==="\uFEFF")continue;yn(v,T);continue;case x.BEGIN_WHITESPACE:yn(v,T);continue;case x.TEXT:if(v.sawRoot&&!v.closedRoot){for(var xe=U-1;T&&T!=="<"&&T!=="&";)T=Et(k,U++),T&&v.trackPosition&&(v.position++,T===`
|
|
142
|
-
`?(v.line++,v.column=0):v.column++);v.textNode+=k.substring(xe,U-1)}T==="<"&&!(v.sawRoot&&v.closedRoot&&!v.strict)?(v.state=x.OPEN_WAKA,v.startTagPosition=v.position):(!b(T)&&(!v.sawRoot||v.closedRoot)&&ne(v,"Text data outside of root node."),T==="&"?v.state=x.TEXT_ENTITY:v.textNode+=T);continue;case x.SCRIPT:T==="<"?v.state=x.SCRIPT_ENDING:v.script+=T;continue;case x.SCRIPT_ENDING:T==="/"?v.state=x.CLOSE_TAG:(v.script+="<"+T,v.state=x.SCRIPT);continue;case x.OPEN_WAKA:if(T==="!")v.state=x.SGML_DECL,v.sgmlDecl="";else if(!b(T))if(P(h,T))v.state=x.OPEN_TAG,v.tagName=T;else if(T==="/")v.state=x.CLOSE_TAG,v.tagName="";else if(T==="?")v.state=x.PROC_INST,v.procInstName=v.procInstBody="";else{if(ne(v,"Unencoded <"),v.startTagPosition+1<v.position){var Pe=v.position-v.startTagPosition;T=new Array(Pe).join(" ")+T}v.textNode+="<"+T,v.state=x.TEXT}continue;case x.SGML_DECL:(v.sgmlDecl+T).toUpperCase()===l?(R(v,"onopencdata"),v.state=x.CDATA,v.sgmlDecl="",v.cdata=""):v.sgmlDecl+T==="--"?(v.state=x.COMMENT,v.comment="",v.sgmlDecl=""):(v.sgmlDecl+T).toUpperCase()===d?(v.state=x.DOCTYPE,(v.doctype||v.sawRoot)&&ne(v,"Inappropriately located doctype declaration"),v.doctype="",v.sgmlDecl=""):T===">"?(R(v,"onsgmldeclaration",v.sgmlDecl),v.sgmlDecl="",v.state=x.TEXT):(I(T)&&(v.state=x.SGML_DECL_QUOTED),v.sgmlDecl+=T);continue;case x.SGML_DECL_QUOTED:T===v.q&&(v.state=x.SGML_DECL,v.q=""),v.sgmlDecl+=T;continue;case x.DOCTYPE:T===">"?(v.state=x.TEXT,R(v,"ondoctype",v.doctype),v.doctype=!0):(v.doctype+=T,T==="["?v.state=x.DOCTYPE_DTD:I(T)&&(v.state=x.DOCTYPE_QUOTED,v.q=T));continue;case x.DOCTYPE_QUOTED:v.doctype+=T,T===v.q&&(v.q="",v.state=x.DOCTYPE);continue;case x.DOCTYPE_DTD:v.doctype+=T,T==="]"?v.state=x.DOCTYPE:I(T)&&(v.state=x.DOCTYPE_DTD_QUOTED,v.q=T);continue;case x.DOCTYPE_DTD_QUOTED:v.doctype+=T,T===v.q&&(v.state=x.DOCTYPE_DTD,v.q="");continue;case x.COMMENT:T==="-"?v.state=x.COMMENT_ENDING:v.comment+=T;continue;case x.COMMENT_ENDING:T==="-"?(v.state=x.COMMENT_ENDED,v.comment=K(v.opt,v.comment),v.comment&&R(v,"oncomment",v.comment),v.comment=""):(v.comment+="-"+T,v.state=x.COMMENT);continue;case x.COMMENT_ENDED:T!==">"?(ne(v,"Malformed comment"),v.comment+="--"+T,v.state=x.COMMENT):v.state=x.TEXT;continue;case x.CDATA:T==="]"?v.state=x.CDATA_ENDING:v.cdata+=T;continue;case x.CDATA_ENDING:T==="]"?v.state=x.CDATA_ENDING_2:(v.cdata+="]"+T,v.state=x.CDATA);continue;case x.CDATA_ENDING_2:T===">"?(v.cdata&&R(v,"oncdata",v.cdata),R(v,"onclosecdata"),v.cdata="",v.state=x.TEXT):T==="]"?v.cdata+="]":(v.cdata+="]]"+T,v.state=x.CDATA);continue;case x.PROC_INST:T==="?"?v.state=x.PROC_INST_ENDING:b(T)?v.state=x.PROC_INST_BODY:v.procInstName+=T;continue;case x.PROC_INST_BODY:if(!v.procInstBody&&b(T))continue;T==="?"?v.state=x.PROC_INST_ENDING:v.procInstBody+=T;continue;case x.PROC_INST_ENDING:T===">"?(R(v,"onprocessinginstruction",{name:v.procInstName,body:v.procInstBody}),v.procInstName=v.procInstBody="",v.state=x.TEXT):(v.procInstBody+="?"+T,v.state=x.PROC_INST_BODY);continue;case x.OPEN_TAG:P(y,T)?v.tagName+=T:(X(v),T===">"?ce(v):T==="/"?v.state=x.OPEN_TAG_SLASH:(b(T)||ne(v,"Invalid character in tag name"),v.state=x.ATTRIB));continue;case x.OPEN_TAG_SLASH:T===">"?(ce(v,!0),$e(v)):(ne(v,"Forward-slash in opening tag not followed by >"),v.state=x.ATTRIB);continue;case x.ATTRIB:if(b(T))continue;T===">"?ce(v):T==="/"?v.state=x.OPEN_TAG_SLASH:P(h,T)?(v.attribName=T,v.attribValue="",v.state=x.ATTRIB_NAME):ne(v,"Invalid attribute name");continue;case x.ATTRIB_NAME:T==="="?v.state=x.ATTRIB_VALUE:T===">"?(ne(v,"Attribute without value"),v.attribValue=v.attribName,ae(v),ce(v)):b(T)?v.state=x.ATTRIB_NAME_SAW_WHITE:P(y,T)?v.attribName+=T:ne(v,"Invalid attribute name");continue;case x.ATTRIB_NAME_SAW_WHITE:if(T==="=")v.state=x.ATTRIB_VALUE;else{if(b(T))continue;ne(v,"Attribute without value"),v.tag.attributes[v.attribName]="",v.attribValue="",R(v,"onattribute",{name:v.attribName,value:""}),v.attribName="",T===">"?ce(v):P(h,T)?(v.attribName=T,v.state=x.ATTRIB_NAME):(ne(v,"Invalid attribute name"),v.state=x.ATTRIB)}continue;case x.ATTRIB_VALUE:if(b(T))continue;I(T)?(v.q=T,v.state=x.ATTRIB_VALUE_QUOTED):(ne(v,"Unquoted attribute value"),v.state=x.ATTRIB_VALUE_UNQUOTED,v.attribValue=T);continue;case x.ATTRIB_VALUE_QUOTED:if(T!==v.q){T==="&"?v.state=x.ATTRIB_VALUE_ENTITY_Q:v.attribValue+=T;continue}ae(v),v.q="",v.state=x.ATTRIB_VALUE_CLOSED;continue;case x.ATTRIB_VALUE_CLOSED:b(T)?v.state=x.ATTRIB:T===">"?ce(v):T==="/"?v.state=x.OPEN_TAG_SLASH:P(h,T)?(ne(v,"No whitespace between attributes"),v.attribName=T,v.attribValue="",v.state=x.ATTRIB_NAME):ne(v,"Invalid attribute name");continue;case x.ATTRIB_VALUE_UNQUOTED:if(!$(T)){T==="&"?v.state=x.ATTRIB_VALUE_ENTITY_U:v.attribValue+=T;continue}ae(v),T===">"?ce(v):v.state=x.ATTRIB;continue;case x.CLOSE_TAG:if(v.tagName)T===">"?$e(v):P(y,T)?v.tagName+=T:v.script?(v.script+="</"+v.tagName,v.tagName="",v.state=x.SCRIPT):(b(T)||ne(v,"Invalid tagname in closing tag"),v.state=x.CLOSE_TAG_SAW_WHITE);else{if(b(T))continue;C(h,T)?v.script?(v.script+="</"+T,v.state=x.SCRIPT):ne(v,"Invalid tagname in closing tag."):v.tagName=T}continue;case x.CLOSE_TAG_SAW_WHITE:if(b(T))continue;T===">"?$e(v):ne(v,"Invalid characters in closing tag");continue;case x.TEXT_ENTITY:case x.ATTRIB_VALUE_ENTITY_Q:case x.ATTRIB_VALUE_ENTITY_U:var wt,He;switch(v.state){case x.TEXT_ENTITY:wt=x.TEXT,He="textNode";break;case x.ATTRIB_VALUE_ENTITY_Q:wt=x.ATTRIB_VALUE_QUOTED,He="attribValue";break;case x.ATTRIB_VALUE_ENTITY_U:wt=x.ATTRIB_VALUE_UNQUOTED,He="attribValue";break}if(T===";")if(v.opt.unparsedEntities){var fr=bt(v);v.entity="",v.state=wt,v.write(fr)}else v[He]+=bt(v),v.entity="",v.state=wt;else P(v.entity.length?_:w,T)?v.entity+=T:(ne(v,"Invalid character in entity name"),v[He]+="&"+v.entity+T,v.entity="",v.state=wt);continue;default:throw new Error(v,"Unknown state: "+v.state)}return v.position>=v.bufferCheckPosition&&n(v),v}return String.fromCodePoint||(function(){var k=String.fromCharCode,v=Math.floor,U=function(){var T=16384,xe=[],Pe,wt,He=-1,fr=arguments.length;if(!fr)return"";for(var _n="";++He<fr;){var Pt=Number(arguments[He]);if(!isFinite(Pt)||Pt<0||Pt>1114111||v(Pt)!==Pt)throw RangeError("Invalid code point: "+Pt);Pt<=65535?xe.push(Pt):(Pt-=65536,Pe=(Pt>>10)+55296,wt=Pt%1024+56320,xe.push(Pe,wt)),(He+1===fr||xe.length>T)&&(_n+=k.apply(null,xe),xe.length=0)}return _n};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:U,configurable:!0,writable:!0}):String.fromCodePoint=U})(),e},tM=xW();var n_=`The output should be formatted as a XML file.
|
|
143
|
-
1. Output should conform to the tags below.
|
|
144
|
-
2. If tags are not given, make them on your own.
|
|
145
|
-
3. Remember to always open and close all the tags.
|
|
146
|
-
|
|
147
|
-
As an example, for the tags ["foo", "bar", "baz"]:
|
|
148
|
-
1. String "<foo>
|
|
149
|
-
<bar>
|
|
150
|
-
<baz></baz>
|
|
151
|
-
</bar>
|
|
152
|
-
</foo>" is a well-formatted instance of the schema.
|
|
153
|
-
2. String "<foo>
|
|
154
|
-
<bar>
|
|
155
|
-
</foo>" is a badly-formatted instance.
|
|
156
|
-
3. String "<foo>
|
|
157
|
-
<tag>
|
|
158
|
-
</tag>
|
|
159
|
-
</foo>" is a badly-formatted instance.
|
|
160
|
-
|
|
161
|
-
Here are the output tags:
|
|
162
|
-
\`\`\`
|
|
163
|
-
{tags}
|
|
164
|
-
\`\`\``,rM=class extends Ki{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,t){if(t)return e?wo(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return i_(e[0].text)}async parse(e){return i_(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?n_.replace("{tags}",this.tags?.join(", ")??""):n_}},kW=e=>e.split(`
|
|
165
|
-
`).map(t=>t.replace(/^\s+/,"")).join(`
|
|
166
|
-
`).trim(),nM=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(nM),t):(t[e.name]=e.text??void 0,t)};function i_(e){let t=kW(e),r=tM.parser(!0),n={},i=[];r.onopentag=a=>{let c={name:a.name,attributes:a.attributes,children:[],text:"",isSelfClosing:a.isSelfClosing};i.length>0?i[i.length-1].children.push(c):n=c,a.isSelfClosing||i.push(c)},r.onclosetag=()=>{if(i.length>0){let a=i.pop();i.length===0&&a&&(n=a)}},r.ontext=a=>{if(i.length>0){let c=i[i.length-1];c.text+=a}},r.onattribute=a=>{if(i.length>0){let c=i[i.length-1];c.attributes[a.name]=a.value}};let o=/```(xml)?(.*)```/s.exec(t),s=o?o[2]:t;return r.write(s).close(),n&&n.name==="?xml"&&(n=n.children[0]),nM(n)}var iM=F({AsymmetricStructuredOutputParser:()=>eM,BaseCumulativeTransformOutputParser:()=>Ki,BaseLLMOutputParser:()=>Dl,BaseOutputParser:()=>oi,BaseTransformOutputParser:()=>Ro,BytesOutputParser:()=>G1,CommaSeparatedListOutputParser:()=>H1,CustomListOutputParser:()=>J1,JsonMarkdownStructuredOutputParser:()=>UA,JsonOutputParser:()=>Ll,ListOutputParser:()=>Ul,MarkdownListOutputParser:()=>Y1,NumberedListOutputParser:()=>X1,OutputParserException:()=>br,StandardSchemaOutputParser:()=>r_,StringOutputParser:()=>Q1,StructuredOutputParser:()=>Hf,XMLOutputParser:()=>rM,XML_FORMAT_INSTRUCTIONS:()=>n_,parseJsonMarkdown:()=>La,parsePartialJson:()=>ds,parseXMLMarkdown:()=>i_});var oM=F({extendInteropZodObject:()=>Ey,getInteropZodDefaultGetter:()=>Py,getInteropZodObjectShape:()=>Oo,getSchemaDescription:()=>ti,interopParse:()=>Rs,interopParseAsync:()=>Cs,interopSafeParse:()=>hN,interopSafeParseAsync:()=>Ty,interopZodObjectMakeFieldsOptional:()=>yN,interopZodObjectPartial:()=>Ns,interopZodObjectPassthrough:()=>$y,interopZodObjectStrict:()=>Il,interopZodTransformInputSchema:()=>Cy,isInteropZodError:()=>Ry,isInteropZodLiteral:()=>mN,isInteropZodObject:()=>_r,isInteropZodSchema:()=>Ht,isShapelessZodSchema:()=>gN,isSimpleStringZodSchema:()=>Sl,isZodArrayV4:()=>Rf,isZodLiteralV3:()=>TS,isZodLiteralV4:()=>ES,isZodNullableV4:()=>CS,isZodObjectV3:()=>Cf,isZodObjectV4:()=>kn,isZodOptionalV4:()=>PS,isZodSchema:()=>fN,isZodSchemaV3:()=>_t,isZodSchemaV4:()=>it});function Ec(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=ds(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(i){throw new br([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${i.message}`].join(`
|
|
167
|
-
`))}let n={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(n.id=e.id),n}function Jf(e){if(e.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function Ls(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var LA=class extends Ki{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let r=e[0].message,n;if(go(r)&&r.tool_calls?.length?n=r.tool_calls.map(o=>{let{id:s,...a}=o;return this.returnId?{id:s,...a}:a}):r.additional_kwargs.tool_calls!==void 0&&(n=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(o=>Ec(o,{returnId:this.returnId,partial:t}))),!n)return[];let i=[];for(let o of n)if(o!==void 0){let s={type:o.name,args:o.args,id:o.id};i.push(s)}return i}},o_=class extends LA{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,"zodSchema"in e&&(this.zodSchema=e.zodSchema),"serializableSchema"in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let r=await this.serializableSchema["~standard"].validate(e);if(r.issues)throw new br(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(r.issues)}`,JSON.stringify(e,null,2));return r.value}if(this.zodSchema===void 0)return e;let t=await Ty(this.zodSchema,e);if(t.success)return t.data;throw new br(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(n=>this._validateResult(n)))}};var sM=F({assembleStructuredOutputPipeline:()=>Xf,createContentParser:()=>s_,createFunctionCallingParser:()=>FA});function s_(e){return Ht(e)?Hf.fromZodSchema(e):zi(e)?r_.fromSerializableSchema(e):new Ll}function FA(e,t,r){let n=r??o_;return Ht(e)?new n({returnSingle:!0,keyName:t,zodSchema:e}):zi(e)?new n({returnSingle:!0,keyName:t,serializableSchema:e}):new n({returnSingle:!0,keyName:t})}function Xf(e,t,r,n){if(!r){let c=e.pipe(t);return n?c.withConfig({runName:n}):c}let i=Co.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),o=Co.assign({parsed:()=>null}),s=i.withFallbacks({fallbacks:[o]}),a=fn.from([{raw:e},s]);return n?a.withConfig({runName:n}):a}var cM=F({ChatModelStream:()=>Fs,ReasoningContentStream:()=>dM,TextContentStream:()=>uM,ToolCallsStream:()=>lM,UsageMetadataStream:()=>pM}),IW=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let r of t)r()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let r of t)r()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function SW(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Yf(e){if(e.event!=="content-block-delta")return;if("delta"in e&&e.delta)return e.delta;let t=e.content;if(t==null||typeof t!="object")return;let r=t;if(r.type==="text"&&typeof r.text=="string")return{type:"text-delta",text:r.text};if(r.type==="reasoning"&&typeof r.reasoning=="string")return{type:"reasoning-delta",reasoning:r.reasoning};if(r.type==="thinking"&&typeof r.thinking=="string")return{type:"reasoning-delta",reasoning:r.thinking};if(typeof r.data=="string")return{type:"data-delta",data:r.data,encoding:"base64"};if(typeof r.type=="string")return{type:"block-delta",fields:{...r,type:r.type}}}function aM(e){if(e==null||typeof e!="object")return;let t=e;if(t.type==="reasoning"&&typeof t.reasoning=="string")return t.reasoning;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking}function a_(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function Fl(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function AW(e){if(e!=null&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function OW(e){let t=e;if(e.type==="tool_call"||e.type!=="tool_call_chunk"&&e.type!=="tool_use"&&e.type!=="input_json_delta")return e;let r=typeof t.name=="string"?t.name:void 0;if(r==null)return e;let n=t.args??t.input;return{...t,type:"tool_call",name:r,args:AW(n)}}var uM=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="";for await(let r of e.iterate()){let n=Yf(r);n?.type==="text-delta"&&(t+=n.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let n=Yf(r);n?.type==="text-delta"&&(yield n.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},lM=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(t.push(r.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(yield r.content)}return t()}then(e,t){return(async()=>{let r=[];for await(let n of this)r.push(n);return r})().then(e,t)}},dM=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!a_(n.content)){if(r)return;continue}r=!0;let i=aM(n.content);if(i==null||i.length===0)continue;t+=i,yield t}else if(n.event==="content-block-delta"){let i=Yf(n);if(i?.type!=="reasoning-delta")continue;r=!0;let o=i.reasoning;if(o==null||o.length===0)continue;t+=o,yield t}else{if(n.event==="content-block-finish"&&a_(n.content))return;if(n.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!a_(n.content)){if(r)return;continue}r=!0;let i=aM(n.content);i!=null&&i.length>0&&(yield i)}else if(n.event==="content-block-delta"){let i=Yf(n);if(i?.type!=="reasoning-delta")continue;r=!0;let o=i.reasoning;o!=null&&o.length>0&&(yield o)}else{if(n.event==="content-block-finish"&&a_(n.content))return;if(n.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},pM=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())if(r.event==="usage"){let n=Fl(r.usage);n&&(yield n)}else if(r.event==="message-start"&&r.usage){let n=Fl(r.usage);n&&(yield n)}else if(r.event==="message-finish"&&r.usage){let n=Fl(r.usage);n&&(yield n)}}return t()}then(e,t){return(async()=>{let r;for await(let n of this)r=n;return r})().then(e,t)}},Fs=class{_buffer;constructor(e){this._buffer=new IW,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(t){this._buffer.setError(t instanceof Error?t:new Error(String(t)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new uM(this._buffer)}get toolCalls(){return new lM(this._buffer)}get reasoning(){return new dM(this._buffer)}get usage(){return new pM(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,n={},i;for await(let s of this._buffer.iterate())switch(s.event){case"message-start":t=s.id??t,s.usage&&(r=Fl(s.usage));break;case"content-block-start":e[s.index]=s.content;break;case"content-block-delta":{let a=e[s.index],c=Yf(s);a&&c&&(e[s.index]=SW(a,c));break}case"content-block-finish":e[s.index]=s.content;break;case"usage":r=Fl(s.usage);break;case"message-finish":i=s.reason,s.usage&&(r=Fl(s.usage)),s.responseMetadata&&(n={...n,...s.responseMetadata});break;default:break}let o=e.filter(s=>s!=null).map(OW);return new Re({id:t,content:o,usage_metadata:r,response_metadata:{...n,...i?{finish_reason:i}:{},output_version:"v1"}})}};var mM=F({convertChunksToEvents:()=>BA,finalizeContentBlock:()=>Bl}),$W={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},TW={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function fM(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function hM(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function EW(e){let t=hM(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let n of t){if(n==null||typeof n!="object")continue;let i=n;if(i.type!=="image_generation_call")continue;let o=typeof i.result=="string"?i.result:void 0,s=typeof i.url=="string"?i.url:void 0;if(o==null&&s==null)continue;let a=typeof i.output_format=="string"?i.output_format.toLowerCase():void 0,c=(a!=null?TW[a]:void 0)??"image/png";r.push({type:"image",...typeof i.id=="string"?{id:i.id}:{},...s!=null?{url:s}:{},...o!=null?{data:o}:{},mimeType:c})}return r}function PW(e){let t=hM(e).audio;if(t==null||typeof t!="object")return;let r=t,n=typeof r.data=="string"?r.data:void 0,i=typeof r.url=="string"?r.url:void 0,o=typeof r.transcript=="string"?r.transcript:void 0;if(n==null&&i==null&&o==null)return;let s=typeof r.mime_type=="string"?r.mime_type:typeof r.mimeType=="string"?r.mimeType:void 0,a=typeof r.format=="string"?r.format.toLowerCase():void 0,c=s??(a!=null?$W[a]:void 0)??(n!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...n!=null?{data:n}:{},...i!=null?{url:i}:{},...o!=null?{transcript:o}:{},mimeType:c}}async function*BA(e,t){let r=new Map,n=!1,i,o,s=new Set;for await(let a of e){t?.signal?.throwIfAborted();let c=a.message,u=!1;if(!n){n=!0;let p={event:"message-start",id:c.id??void 0};ct.isInstance(c)&&c.usage_metadata&&(p.usage=c.usage_metadata,i={...c.usage_metadata},u=!0),yield p}let l=c.content;if(typeof l=="string"){if(l!==""){if(!r.has(0)){let m={type:"text",text:""};r.set(0,{type:"text",accumulated:m}),yield{event:"content-block-start",index:0,content:m}}let f=r.get(0);f.accumulated={...f.accumulated,text:(f.accumulated.text??"")+l},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:l}}}}else if(Array.isArray(l))for(let p of l){let f=typeof p.index=="number"?p.index:r.size;if(!r.has(f))r.set(f,{type:p.type,accumulated:{...p}}),yield{event:"content-block-start",index:f,content:{...p}};else{let m=r.get(f),h=RW(p);m.accumulated=CW(m.accumulated,h),yield{event:"content-block-delta",index:f,delta:h}}}if(ct.isInstance(c)&&c.tool_call_chunks&&c.tool_call_chunks.length>0)for(let p of c.tool_call_chunks){let f=typeof p.index=="number"?p.index:r.size;if(!r.has(f)){let h={type:"tool_call_chunk",id:p.id,name:p.name,args:"",index:f};r.set(f,{type:"tool_call_chunk",accumulated:h}),yield{event:"content-block-start",index:f,content:h}}let m=r.get(f).accumulated;p.id!=null&&(m.id=p.id),p.name!=null&&(m.name=p.name),m.args=(m.args??"")+(p.args??""),yield{event:"content-block-delta",index:f,delta:{type:"block-delta",fields:{type:"tool_call_chunk",..."id"in m&&m.id!=null?{id:m.id}:{},..."name"in m&&m.name!=null?{name:m.name}:{},args:m.args}}}}let d=PW(c);if(d!=null){if(o==null){let f=fM(r);o={index:f,id:d.id,mimeType:d.mimeType,transcript:""};let m={type:"audio",...d.id!=null?{id:d.id}:{},...d.url!=null?{url:d.url}:{},data:"",mimeType:d.mimeType};r.set(f,{type:"audio",accumulated:m}),yield{event:"content-block-start",index:f,content:m}}let p=r.get(o.index);if(p!=null){let f=p.accumulated;d.id!=null&&o.id==null&&(o.id=d.id,f.id=d.id),d.transcript!=null&&(o.transcript+=d.transcript,f.transcript=o.transcript,yield{event:"content-block-delta",index:o.index,delta:{type:"block-delta",fields:{type:"audio",transcript:o.transcript}}}),d.data!=null&&d.data.length>0&&(f.data=(f.data??"")+d.data,yield{event:"content-block-delta",index:o.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let p of EW(c)){let f=p,m=f.id??f.url??(f.data!=null?`${f.data.length}:${f.data.slice(0,32)}`:void 0);if(m!=null&&s.has(m))continue;m!=null&&s.add(m);let h=fM(r);r.set(h,{type:"image",accumulated:p}),yield{event:"content-block-start",index:h,content:p}}if(!u&&ct.isInstance(c)&&c.usage_metadata){let p=c.usage_metadata;i?i={input_tokens:i.input_tokens+p.input_tokens,output_tokens:i.output_tokens+p.output_tokens,total_tokens:i.total_tokens+p.total_tokens}:i={...p},yield{event:"usage",usage:{...i}}}}for(let[a,c]of r)yield{event:"content-block-finish",index:a,content:Bl(c.accumulated)};yield{event:"message-finish",reason:"stop",...i?{usage:i}:{}}}function CW(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function RW(e){if(e.type==="text")return{type:"text-delta",text:e.text};if(e.type==="reasoning")return{type:"reasoning-delta",reasoning:e.reasoning};if(e.type==="thinking"&&typeof e.thinking=="string")return{type:"reasoning-delta",reasoning:e.thinking};if(typeof e.data=="string")return{type:"data-delta",data:e.data,encoding:"base64"};if(typeof e.type=="string")return{type:"block-delta",fields:{...e}};throw new Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function Bl(e){if(e.type==="tool_call_chunk"){let t=e,r;try{r=JSON.parse(t.args??"{}")}catch{return{type:"invalid_tool_call",id:t.id,name:t.name,args:t.args,error:"Failed to parse tool call arguments as JSON"}}return{type:"tool_call",id:t.id,name:t.name,args:r}}return e}var gM=e=>e();function Qf(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var yM=F({BaseChatModel:()=>Hi,SimpleChatModel:()=>NW});function ZA(e){let t=[];for(let r of e){let n=r;if(Array.isArray(r.content))for(let i=0;i<r.content.length;i++){let o=r.content[i];(Xh(o)||Yh(o))&&n===r&&(n=new r.constructor({...n,content:[...r.content.slice(0,i),Qh(o),...r.content.slice(i+1)]}))}t.push(n)}return t}var Hi=class Gi extends Gf{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=gM(()=>{let r=t.outputVersion??Ct("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async invoke(t,r){let n=Gi._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,n){yield*BA(this._streamResponseChunks(t,r,n),{signal:r.signal})}streamEvents(t,r,n){if(r?.version==="v1"||r?.version==="v2")return super.streamEvents(t,r,n);let i=Gi._convertInputToPromptValue(t).toChatMessages(),[,o]=this._separateRunnableConfigFromCallOptionsCompat(r);return new Fs(this._streamChatModelEvents(i,o))}streamV2(t,r){return this.streamEvents(t,r)}async*_streamIterator(t,r){if(this._streamResponseChunks===Gi.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let n=Gi._convertInputToPromptValue(t).toChatMessages(),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),s={...i.metadata,...this.getLsParamsWithDefaults(o)},a=this._getInvocationParamsForTracing(o),c=await mr.configure(i.callbacks,this.callbacks,i.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(a)}),u={options:this._getCallOptionsForTracing(o,a),invocation_params:a,batch_size:1},l=o.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[ZA(n)],i.runId,void 0,u,void 0,void 0,i.runName),p,f;try{for await(let m of this._streamResponseChunks(n,o,d?.[0])){if(o.signal?.throwIfAborted(),m.message.id==null){let h=d?.at(0)?.runId;h!=null&&m.message._updateId(`run-${h}`)}m.message.response_metadata={...m.generationInfo,...m.message.response_metadata},l==="v1"?yield Qf(m.message):yield m.message,p?p=p.concat(m):p=m,Hp(m.message)&&m.message.usage_metadata!==void 0&&(f={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}o.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(h=>h?.handleLLMError(m))),m}await Promise.all((d??[]).map(m=>m?.handleLLMEnd({generations:[[p]],llmOutput:f})))}}getLsParams(t){let r=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:r}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,r,n,i){let o=t.map(f=>f.map(er)),s;if(i!==void 0&&i.length===o.length)s=i;else{let f={...n.metadata,...this.getLsParamsWithDefaults(r)},m=this._getInvocationParamsForTracing(r),h=await mr.configure(n.callbacks,this.callbacks,n.tags,this.tags,f,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),y={options:this._getCallOptionsForTracing(r,m),invocation_params:m,batch_size:1};s=await h?.handleChatModelStart(this.toJSON(),o.map(ZA),n.runId,void 0,y,void 0,void 0,n.runName)}let a=r.outputVersion??this.outputVersion,c=[],u=[],l=!!s?.[0].handlers.find(EP),d=!!s?.[0].handlers.find(ig);if(l&&!this.disableStreaming&&o.length===1&&(this._streamChatModelEvents!==Gi.prototype._streamChatModelEvents||this._streamResponseChunks!==Gi.prototype._streamResponseChunks))try{let f=!1,m=s?.[0],h=this._streamChatModelEvents(o[0],r),y=await new Fs({async*[Symbol.asyncIterator](){for await(let b of h){r.signal?.throwIfAborted(),f=!0;let I=b.event==="message-start"&&b.id==null&&m?.runId!=null?{...b,id:`run-${m.runId}`}:b;await m?.handleChatModelStreamEvent(I),yield I}}});if(r.signal?.throwIfAborted(),!f)throw new Error("Received empty response from chat model call.");if(y.id==null){let b=s?.at(0)?.runId;b!=null&&y._updateId(`run-${b}`)}let w={text:y.text,message:y};c.push([w]);let _=y.usage_metadata!==void 0?{tokenUsage:{promptTokens:y.usage_metadata.input_tokens,completionTokens:y.usage_metadata.output_tokens,totalTokens:y.usage_metadata.total_tokens}}:void 0;await s?.[0].handleLLMEnd({generations:c,llmOutput:_})}catch(f){throw await s?.[0].handleLLMError(f),f}else if(d&&!this.disableStreaming&&o.length===1&&this._streamResponseChunks!==Gi.prototype._streamResponseChunks)try{let f=await this._streamResponseChunks(o[0],r,s?.[0]),m,h;for await(let y of f){if(r.signal?.aborted){let w=m?.message;throw new yw("Model invocation was aborted.",w)}if(y.message.id==null){let w=s?.at(0)?.runId;w!=null&&y.message._updateId(`run-${w}`)}m===void 0?m=y:m=an(m,y),Hp(y.message)&&y.message.usage_metadata!==void 0&&(h={tokenUsage:{promptTokens:y.message.usage_metadata.input_tokens,completionTokens:y.message.usage_metadata.output_tokens,totalTokens:y.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let y=m?.message;throw new yw("Model invocation was aborted.",y)}if(m===void 0)throw new Error("Received empty response from chat model call.");a==="v1"&&(m.message=Qf(m.message)),c.push([m]),await s?.[0].handleLLMEnd({generations:c,llmOutput:h})}catch(f){throw await s?.[0].handleLLMError(f),f}else{let f=await Promise.allSettled(o.map(async(m,h)=>{let y=await this._generate(m,{...r,promptIndex:h},s?.[h]);if(a==="v1")for(let w of y.generations)w.message=Qf(w.message);return y}));await Promise.all(f.map(async(m,h)=>{if(m.status==="fulfilled"){let y=m.value;for(let w of y.generations){if(w.message.id==null){let _=s?.at(0)?.runId;_!=null&&w.message._updateId(`run-${_}`)}w.message.response_metadata={...w.generationInfo,...w.message.response_metadata}}return y.generations.length===1&&(y.generations[0].message.response_metadata={...y.llmOutput,...y.generations[0].message.response_metadata}),c[h]=y.generations,u[h]=y.llmOutput,s?.[h]?.handleLLMEnd({generations:[y.generations],llmOutput:y.llmOutput})}else return await s?.[h]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let p={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(p,tc,{value:s?{runIds:s?.map(f=>f.runId)}:void 0,configurable:!0}),p}async _generateCached({messages:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o}){let s=t.map(w=>w.map(er)),a={...o.metadata,...this.getLsParamsWithDefaults(i)},c=this._getInvocationParamsForTracing(i),u=await mr.configure(o.callbacks,this.callbacks,o.tags,this.tags,a,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),l={options:this._getCallOptionsForTracing(i,c),invocation_params:c,batch_size:1},d=await u?.handleChatModelStart(this.toJSON(),s.map(ZA),o.runId,void 0,l,void 0,void 0,o.runName),p=[],f=(await Promise.allSettled(s.map(async(w,_)=>{let b=Gi._convertInputToPromptValue(w).toString(),I=await r.lookup(b,n);return I==null&&p.push(_),I}))).map((w,_)=>({result:w,runManager:d?.[_]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),m=i.outputVersion??this.outputVersion,h=[];await Promise.all(f.map(async({result:w,runManager:_},b)=>{if(w.status==="fulfilled"){let I=w.value;return h[b]=I.map($=>("message"in $&&St($.message)&&go($.message)&&($.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&($.message=Qf($.message))),$.generationInfo={...$.generationInfo,tokenUsage:{}},$)),I.length&&await _?.handleLLMNewToken(I[0].text),_?.handleLLMEnd({generations:[I]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));let y={generations:h,missingPromptIndices:p,startedRunManagers:d};return Object.defineProperty(y,tc,{value:d?{runIds:d?.map(w=>w.runId)}:void 0,configurable:!0}),y}async generate(t,r,n){let i;Array.isArray(r)?i={stop:r}:i=r;let o=t.map(m=>m.map(er)),[s,a]=this._separateRunnableConfigFromCallOptionsCompat(i);if(s.callbacks=s.callbacks??n,!this.cache)return this._generateUncached(o,a,s);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(a),{generations:l,missingPromptIndices:d,startedRunManagers:p}=await this._generateCached({messages:o,cache:c,llmStringKey:u,parsedOptions:a,handledOptions:s}),f={};if(d.length>0){let m=await this._generateUncached(d.map(h=>o[h]),a,s,p!==void 0?d.map(h=>p?.[h]):void 0);await Promise.all(m.generations.map(async(h,y)=>{let w=d[y];l[w]=h;let _=Gi._convertInputToPromptValue(o[w]).toString();return c.update(_,u,h)})),f=m.llmOutput??{}}return{generations:l,llmOutput:f}}_getInvocationParamsForTracing(t){return this.invocationParams(t)}_getCallOptionsForTracing(t,r){return t}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,n){let i=t.map(o=>o.toChatMessages());return this.generate(i,r,n)}withStructuredOutput(t,r){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(r?.strict)throw new Error('"strict" mode is not supported for this model by default.');let n=t,i=r?.name,o=ti(n)??"A function available to call.",s=r?.method,a=r?.includeRaw;if(s==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=i??"extract";!Ht(n)&&!zi(n)&&"name"in n&&(c=n.name);let u=Ht(n)||zi(n)?ht(n):n,l=[{type:"function",function:{name:c,description:o,parameters:u}}];return Xf(this.bindTools(l),ir.from(d=>{if(!ct.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let p=d.tool_calls.find(f=>f.name===c);if(!p)throw new Error(`No tool call found with name ${c}.`);return p.args}),a,a?"StructuredOutputRunnable":"StructuredOutput")}},NW=class extends Hi{async _generate(e,t,r){let n=new Re(await this._call(e,t,r));if(typeof n.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:n.content,message:n}]}}};var _M=F({convertOpenAICompletionsStream:()=>em});async function*em(e,t={}){let r=t.streamUsage??!0,n=t.provider??"openai",i=t.mapChunk,o=new Map,s=new Map,a=0,c=!1,u,l,d,p=!1,f=(m,h)=>{let y=s.get(m);if(y!==void 0)return{index:y,isNew:!1};let w=a++;return s.set(m,w),o.set(w,{...h}),{index:w,isNew:!0}};for await(let m of e){i&&(m=i(m)),c||(c=!0,yield{event:"message-start",id:m.id}),!p&&(m.model||m.service_tier)&&(p=!0,yield{event:"provider",provider:n,name:"stream_metadata",payload:{model:m.model,service_tier:m.service_tier}}),m.usage&&r&&(u=DW(m.usage),yield{event:"usage",usage:u});let h=m.x_groq?.usage;h&&r&&(u=zW(h),yield{event:"usage",usage:u});let y=m.choices?.[0];if(!y)continue;y.finish_reason!=null&&(l=jW(y.finish_reason),d=UW(m,y));let{delta:w}=y;if(!w)continue;let _=MW(w);if(_){let{index:b,isNew:I}=f("reasoning",{type:"reasoning",reasoning:""});I&&(yield{event:"content-block-start",index:b,content:{type:"reasoning",reasoning:""}});let $=o.get(b);$.reasoning=($.reasoning??"")+_,yield{event:"content-block-delta",index:b,delta:{type:"reasoning-delta",reasoning:_}}}if(w.content){let{index:b,isNew:I}=f("text",{type:"text",text:""});I&&(yield{event:"content-block-start",index:b,content:{type:"text",text:""}});let $=o.get(b);$.text=($.text??"")+w.content,yield{event:"content-block-delta",index:b,delta:{type:"text-delta",text:w.content}}}if(Array.isArray(w.tool_calls))for(let b of w.tool_calls){let I=b.index??0,{index:$,isNew:P}=f(`tool:${I}`,{type:"tool_call_chunk",id:b.id,name:b.function?.name,args:"",index:I});P&&(yield{event:"content-block-start",index:$,content:{type:"tool_call_chunk",id:b.id,name:b.function?.name,args:"",index:I}});let C=o.get($);b.id!=null&&(C.id=b.id),b.function?.name!=null&&(C.name=b.function.name);let x=b.function?.arguments??"";C.args=(C.args??"")+x,yield{event:"content-block-delta",index:$,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...C.id!=null?{id:C.id}:{},...C.name!=null?{name:C.name}:{},args:C.args}}}}if(w.audio){let{index:b,isNew:I}=f("audio",{type:"audio",id:w.audio.id,data:"",mimeType:"audio/pcm",transcript:w.audio.transcript??""});I&&(yield{event:"content-block-start",index:b,content:{type:"audio",id:w.audio.id,data:"",mimeType:"audio/pcm",transcript:w.audio.transcript??""}});let $=o.get(b);w.audio.transcript&&($.transcript=($.transcript??"")+w.audio.transcript,yield{event:"content-block-delta",index:b,delta:{type:"block-delta",fields:{type:"audio",transcript:$.transcript}}}),w.audio.data&&($.data=($.data??"")+w.audio.data,yield{event:"content-block-delta",index:b,delta:{type:"data-delta",data:w.audio.data,encoding:"base64"}})}w.function_call&&(yield{event:"provider",provider:n,name:"function_call",payload:w.function_call}),y.logprobs&&(yield{event:"provider",provider:n,name:"logprobs",payload:y.logprobs})}for(let[m,h]of o)yield{event:"content-block-finish",index:m,content:Bl(h)};yield{event:"message-finish",reason:l,...u?{usage:u}:{},...d?{responseMetadata:d}:{}}}function MW(e){let t=e.reasoning_content??e.reasoning;return typeof t=="string"&&t.length>0?t:void 0}function zW(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function jW(e){switch(e){case"stop":return"stop";case"length":case"max_tokens":return"length";case"tool_calls":case"function_call":return"tool_use";case"content_filter":return"content_filter";default:return"stop"}}function DW(e){let t={...e.prompt_tokens_details?.audio_tokens!=null&&{audio:e.prompt_tokens_details.audio_tokens},...e.prompt_tokens_details?.cached_tokens!=null&&{cache_read:e.prompt_tokens_details.cached_tokens}},r={...e.completion_tokens_details?.audio_tokens!=null&&{audio:e.completion_tokens_details.audio_tokens},...e.completion_tokens_details?.reasoning_tokens!=null&&{reasoning:e.completion_tokens_details.reasoning_tokens}};return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0,...Object.keys(t).length>0&&{input_token_details:t},...Object.keys(r).length>0&&{output_token_details:r}}}function UW(e,t){return{model_provider:"openai",model_name:e.model,system_fingerprint:e.system_fingerprint,service_tier:e.service_tier,finish_reason:t.finish_reason,...e.usage?{usage:e.usage}:{}}}var vM=F({});var bM=F({BaseLLM:()=>VA,LLM:()=>c_}),VA=class tm extends Gf{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let n=tm._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async*_streamIterator(t,r){if(this._streamResponseChunks===tm.prototype._streamResponseChunks)yield this.invoke(t,r);else{let n=tm._convertInputToPromptValue(t),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),s=this.invocationParams(o),a=await mr.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),c={options:o,invocation_params:s,batch_size:1},u=await a?.handleLLMStart(this.toJSON(),[n.toString()],i.runId,void 0,c,void 0,void 0,i.runName),l=new Mi({text:""});try{for await(let d of this._streamResponseChunks(n.toString(),o,u?.[0]))l?l=l.concat(d):l=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((u??[]).map(p=>p?.handleLLMError(d))),d}await Promise.all((u??[]).map(d=>d?.handleLLMEnd({generations:[[l]]})))}}async generatePrompt(t,r,n){let i=t.map(o=>o.toString());return this.generate(i,r,n)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let n=0;n<t.generations.length;n+=1){let i=t.generations[n];if(n===0)r.push({generations:[i],llmOutput:t.llmOutput});else{let o=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[i],llmOutput:o})}}return r}async _generateUncached(t,r,n,i){let o;if(i!==void 0&&i.length===t.length)o=i;else{let u=this.invocationParams(r),l=await mr.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(u)}),d={options:r,invocation_params:u,batch_size:t.length};o=await l?.handleLLMStart(this.toJSON(),t,n.runId,void 0,d,void 0,void 0,n?.runName)}let s=!!o?.[0].handlers.find(ig),a;if(s&&t.length===1&&this._streamResponseChunks!==tm.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,o?.[0]),l;for await(let d of u)l===void 0?l=d:l=an(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");a={generations:[[l]],llmOutput:{}},await o?.[0].handleLLMEnd(a)}catch(u){throw await o?.[0].handleLLMError(u),u}else{try{a=await this._generate(t,r,o?.[0])}catch(l){throw await Promise.all((o??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(a);await Promise.all((o??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=o?.map(u=>u.runId)||void 0;return Object.defineProperty(a,tc,{value:c?{runIds:c}:void 0,configurable:!0}),a}async _generateCached({prompts:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o,runId:s}){let a=this.invocationParams(i),c=await mr.configure(o.callbacks,this.callbacks,o.tags,this.tags,o.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(a)}),u={options:i,invocation_params:a,batch_size:t.length},l=await c?.handleLLMStart(this.toJSON(),t,s,void 0,u,void 0,void 0,o?.runName),d=[],p=(await Promise.allSettled(t.map(async(h,y)=>{let w=await r.lookup(h,n);return w==null&&d.push(y),w}))).map((h,y)=>({result:h,runManager:l?.[y]})).filter(({result:h})=>h.status==="fulfilled"&&h.value!=null||h.status==="rejected"),f=[];await Promise.all(p.map(async({result:h,runManager:y},w)=>{if(h.status==="fulfilled"){let _=h.value;return f[w]=_.map(b=>(b.generationInfo={...b.generationInfo,tokenUsage:{}},b)),_.length&&await y?.handleLLMNewToken(_[0].text),y?.handleLLMEnd({generations:[_]},void 0,void 0,void 0,{cached:!0})}else return await y?.handleLLMError(h.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(h.reason)}));let m={generations:f,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(m,tc,{value:l?{runIds:l?.map(h=>h.runId)}:void 0,configurable:!0}),m}async generate(t,r,n){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let i;Array.isArray(r)?i={stop:r}:i=r;let[o,s]=this._separateRunnableConfigFromCallOptionsCompat(i);if(o.callbacks=o.callbacks??n,!this.cache)return this._generateUncached(t,s,o);let{cache:a}=this,c=this._getSerializedCacheKeyParametersForCall(s),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:a,llmStringKey:c,parsedOptions:s,handledOptions:o,runId:o.runId}),p={};if(l.length>0){let f=await this._generateUncached(l.map(m=>t[m]),s,o,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(f.generations.map(async(m,h)=>{let y=l[h];return u[y]=m,a.update(t[y],c,m)})),p=f.llmOutput??{}}return{generations:u,llmOutput:p}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},c_=class extends VA{async _generate(e,t,r){return{generations:await Promise.all(e.map((n,i)=>this._call(n,{...t,promptIndex:i},r).then(o=>[{text:o}])))}}};var wM=F({});var xM=F({BaseMemory:()=>LW,getInputValue:()=>FW,getOutputValue:()=>BW,getPromptInputKey:()=>ZW}),LW=class{},kM=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},FW=(e,t)=>{let r=kM(e,t);if(!r){let n=Object.keys(e);throw new Error(`input values have ${n.length} keys, you must specify an input key or pass only 1 key as input`)}return r},BW=(e,t)=>{let r=kM(e,t);if(!r&&r!==""){let n=Object.keys(e);throw new Error(`output values have ${n.length} keys, you must specify an output key or pass only 1 key as output`)}return r};function ZW(e,t){let r=Object.keys(e).filter(n=>!t.includes(n)&&n!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var WA=class extends Dl{static lc_name(){return"OutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;argsOnly=!0;constructor(e){super(),this.argsOnly=e?.argsOnly??this.argsOnly}async parseResult(e){if("message"in e[0]){let t=e[0].message.additional_kwargs.function_call;if(!t)throw new Error(`No function_call in message ${JSON.stringify(e)}`);if(!t.arguments)throw new Error(`No arguments in function_call ${JSON.stringify(e)}`);return this.argsOnly?t.arguments:JSON.stringify(t)}else throw new Error(`No message in generations ${JSON.stringify(e)}`)}},qA=class extends Ki{static lc_name(){return"JsonOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser;argsOnly=!0;constructor(e){super(e),this.argsOnly=e?.argsOnly??this.argsOnly,this.outputParser=new WA(e)}_diff(e,t){if(t)return wo(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,n=r.additional_kwargs.function_call;if(n)return this.argsOnly?ds(n.arguments):{...n,arguments:ds(n.arguments)}}async parseResult(e){let t=await this.outputParser.parseResult(e);if(!t)throw new Error(`No result from "OutputFunctionsParser" ${JSON.stringify(e)}`);return this.parse(t)}async parse(e){let t=JSON.parse(e);return this.argsOnly||(t.arguments=JSON.parse(t.arguments)),t}getFormatInstructions(){return""}},IM=class extends Dl{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new qA;attrName;get lc_aliases(){return{attrName:"key_name"}}constructor(e){super(e),this.attrName=e.attrName}async parseResult(e){return(await this.outputParser.parseResult(e))[this.attrName]}};var SM=F({JsonKeyOutputFunctionsParser:()=>IM,JsonOutputFunctionsParser:()=>qA,OutputFunctionsParser:()=>WA});var AM=F({JsonOutputKeyToolsParser:()=>o_,JsonOutputToolsParser:()=>LA,convertLangChainToolCallToOpenAI:()=>Jf,makeInvalidToolCall:()=>Ls,parseToolCall:()=>Ec});var Ji=class extends he{lc_serializable=!0;lc_namespace=["langchain_core","prompts",this._getPromptType()];get lc_attributes(){return{partialVariables:void 0}}inputVariables;outputParser;partialVariables;metadata;tags;constructor(e){super(e);let{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){let t=this.partialVariables??{},r={};for(let[n,i]of Object.entries(t))typeof i=="string"?r[n]=i:r[n]=await i();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},n=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(i=>this.formatPromptValue(i),e,{...t,tags:n,metadata:r,runType:"prompt"})}};var No=class extends Ji{async formatPromptValue(e){return new Wf(await this.format(e))}};var VW=Object.prototype.toString,Vl=Array.isArray||function(t){return VW.call(t)==="[object Array]"};function GA(e){return typeof e=="function"}function WW(e){return Vl(e)?"array":typeof e}function KA(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function OM(e,t){return e!=null&&typeof e=="object"&&t in e}function qW(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var KW=RegExp.prototype.test;function GW(e,t){return KW.call(e,t)}var HW=/\S/;function JW(e){return!GW(HW,e)}var XW={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function YW(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return XW[r]})}var QW=/\s*/,eq=/\s+/,$M=/\s*=/,tq=/\s*\}/,rq=/#|\^|\/|>|\{|&|=|!/;function nq(e,t){if(!e)return[];var r=!1,n=[],i=[],o=[],s=!1,a=!1,c="",u=0;function l(){if(s&&!a)for(;o.length;)delete i[o.pop()];else o=[];s=!1,a=!1}var d,p,f;function m(x){if(typeof x=="string"&&(x=x.split(eq,2)),!Vl(x)||x.length!==2)throw new Error("Invalid tags: "+x);d=new RegExp(KA(x[0])+"\\s*"),p=new RegExp("\\s*"+KA(x[1])),f=new RegExp("\\s*"+KA("}"+x[1]))}m(t||En.tags);for(var h=new nm(e),y,w,_,b,I,$;!h.eos();){if(y=h.pos,_=h.scanUntil(d),_)for(var P=0,C=_.length;P<C;++P)b=_.charAt(P),JW(b)?(o.push(i.length),c+=b):(a=!0,r=!0,c+=" "),i.push(["text",b,y,y+1]),y+=1,b===`
|
|
168
|
-
`&&(l(),c="",u=0,r=!1);if(!h.scan(d))break;if(s=!0,w=h.scan(rq)||"name",h.scan(QW),w==="="?(_=h.scanUntil($M),h.scan($M),h.scanUntil(p)):w==="{"?(_=h.scanUntil(f),h.scan(tq),h.scanUntil(p),w="&"):_=h.scanUntil(p),!h.scan(p))throw new Error("Unclosed tag at "+h.pos);if(w==">"?I=[w,_,y,h.pos,c,u,r]:I=[w,_,y,h.pos],u++,i.push(I),w==="#"||w==="^")n.push(I);else if(w==="/"){if($=n.pop(),!$)throw new Error('Unopened section "'+_+'" at '+y);if($[1]!==_)throw new Error('Unclosed section "'+$[1]+'" at '+y)}else w==="name"||w==="{"||w==="&"?a=!0:w==="="&&m(_)}if(l(),$=n.pop(),$)throw new Error('Unclosed section "'+$[1]+'" at '+h.pos);return oq(iq(i))}function iq(e){for(var t=[],r,n,i=0,o=e.length;i<o;++i)r=e[i],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function oq(e){for(var t=[],r=t,n=[],i,o,s=0,a=e.length;s<a;++s)switch(i=e[s],i[0]){case"#":case"^":r.push(i),n.push(i),r=i[4]=[];break;case"/":o=n.pop(),o[5]=i[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(i)}return t}function nm(e){this.string=e,this.tail=e,this.pos=0}nm.prototype.eos=function(){return this.tail===""};nm.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};nm.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function Zl(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Zl.prototype.push=function(t){return new Zl(t,this)};Zl.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var i=this,o,s,a,c=!1;i;){if(t.indexOf(".")>0)for(o=i.view,s=t.split("."),a=0;o!=null&&a<s.length;)a===s.length-1&&(c=OM(o,s[a])||qW(o,s[a])),o=o[s[a++]];else o=i.view[t],c=OM(i.view,t);if(c){n=o;break}i=i.parent}r[t]=n}return GA(n)&&(n=n.call(this.view)),n};function zr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}zr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};zr.prototype.parse=function(t,r){var n=this.templateCache,i=t+":"+(r||En.tags).join(":"),o=typeof n<"u",s=o?n.get(i):void 0;return s==null&&(s=nq(t,r),o&&n.set(i,s)),s};zr.prototype.render=function(t,r,n,i){var o=this.getConfigTags(i),s=this.parse(t,o),a=r instanceof Zl?r:new Zl(r,void 0);return this.renderTokens(s,a,n,t,i)};zr.prototype.renderTokens=function(t,r,n,i,o){for(var s="",a,c,u,l=0,d=t.length;l<d;++l)u=void 0,a=t[l],c=a[0],c==="#"?u=this.renderSection(a,r,n,i,o):c==="^"?u=this.renderInverted(a,r,n,i,o):c===">"?u=this.renderPartial(a,r,n,o):c==="&"?u=this.unescapedValue(a,r):c==="name"?u=this.escapedValue(a,r,o):c==="text"&&(u=this.rawValue(a)),u!==void 0&&(s+=u);return s};zr.prototype.renderSection=function(t,r,n,i,o){var s=this,a="",c=r.lookup(t[1]);function u(p){return s.render(p,r,n,o)}if(c){if(Vl(c))for(var l=0,d=c.length;l<d;++l)a+=this.renderTokens(t[4],r.push(c[l]),n,i,o);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")a+=this.renderTokens(t[4],r.push(c),n,i,o);else if(GA(c)){if(typeof i!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,i.slice(t[3],t[5]),u),c!=null&&(a+=c)}else a+=this.renderTokens(t[4],r,n,i,o);return a}};zr.prototype.renderInverted=function(t,r,n,i,o){var s=r.lookup(t[1]);if(!s||Vl(s)&&s.length===0)return this.renderTokens(t[4],r,n,i,o)};zr.prototype.indentPartial=function(t,r,n){for(var i=r.replace(/[^ \t]/g,""),o=t.split(`
|
|
169
|
-
`),s=0;s<o.length;s++)o[s].length&&(s>0||!n)&&(o[s]=i+o[s]);return o.join(`
|
|
170
|
-
`)};zr.prototype.renderPartial=function(t,r,n,i){if(n){var o=this.getConfigTags(i),s=GA(n)?n(t[1]):n[t[1]];if(s!=null){var a=t[6],c=t[5],u=t[4],l=s;c==0&&u&&(l=this.indentPartial(s,u,a));var d=this.parse(l,o);return this.renderTokens(d,r,n,l,i)}}};zr.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};zr.prototype.escapedValue=function(t,r,n){var i=this.getConfigEscape(n)||En.escape,o=r.lookup(t[1]);if(o!=null)return typeof o=="number"&&i===En.escape?String(o):i(o)};zr.prototype.rawValue=function(t){return t[1]};zr.prototype.getConfigTags=function(t){return Vl(t)?t:t&&typeof t=="object"?t.tags:void 0};zr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Vl(t))return t.escape};var En={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){rm.templateCache=e},get templateCache(){return rm.templateCache}},rm=new zr;En.clearCache=function(){return rm.clearCache()};En.parse=function(t,r){return rm.parse(t,r)};En.render=function(t,r,n,i){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+WW(t)+'" was given as the first argument for mustache#render(template, view, partials)');return rm.render(t,r,n,i)};En.escape=YW;En.Scanner=nm;En.Context=Zl;En.Writer=zr;var HA=En;var sq={escape:e=>e},Pc=e=>{let t=e.split(""),r=[],n=(o,s)=>{for(let a=s;a<t.length;a+=1)if(o.includes(t[a]))return a;return-1},i=0;for(;i<t.length;)if(t[i]==="{"&&i+1<t.length&&t[i+1]==="{")r.push({type:"literal",text:"{"}),i+=2;else if(t[i]==="}"&&i+1<t.length&&t[i+1]==="}")r.push({type:"literal",text:"}"}),i+=2;else if(t[i]==="{"){let o=n("}",i);if(o<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(i+1,o).join("")}),i=o+1}else{if(t[i]==="}")throw new Error("Single '}' in template.");{let o=n("{}",i),s=(o<0?t.slice(i):t.slice(i,o)).join("");r.push({type:"literal",text:s}),i=o<0?t.length:o}}return r},TM=(e,t=[])=>{let r=[];for(let n of e)if(n[0]==="name"){let i=n[1].includes(".")?n[1].split(".")[0]:n[1];r.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(n[0])){if(r.push({type:"variable",name:n[1]}),n[0]==="#"&&n.length>4&&Array.isArray(n[4])){let i=[...t,n[1]],o=TM(n[4],i);r.push(...o)}}else r.push({type:"literal",text:n[1]});return r},Wl=e=>{let t=HA.parse(e);return TM(t)},JA=(e,t)=>Pc(e).reduce((r,n)=>{if(n.type==="variable"){if(n.name in t)return r+(typeof t[n.name]=="string"?t[n.name]:JSON.stringify(t[n.name]));throw new Error(`(f-string) Missing value for input ${n.name}`)}return r+n.text},""),XA=(e,t)=>HA.render(e,t,void 0,sq),im={"f-string":JA,mustache:XA},YA={"f-string":Pc,mustache:Wl},wr=(e,t,r)=>{try{return im[t](e,r)}catch(n){throw Bu(n,"INVALID_PROMPT_INPUT")}},Cc=(e,t)=>YA[t](e),Mo=(e,t,r)=>{if(!(t in im)){let n=Object.keys(im);throw new Error(`Invalid template format. Got \`${t}\`;
|
|
171
|
-
should be one of ${n}`)}try{let n=Object.fromEntries(r.map(i=>[i,"foo"]));Array.isArray(e)?e.forEach(i=>{if(i.type==="text"&&"text"in i&&typeof i.text=="string")wr(i.text,t,n);else if(i.type==="image_url"){if(typeof i.image_url=="string")wr(i.image_url,t,n);else if(typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"){let o=i.image_url.url;wr(o,t,n)}}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):wr(e,t,n)}catch(n){throw new Error(`Invalid prompt schema: ${n.message}`)}};var si=class om extends No{static lc_name(){return"PromptTemplate"}template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Mo(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return wr(this.template,this.templateFormat,r)}static fromExamples(t,r,n,i=`
|
|
172
|
-
|
|
173
|
-
`,o=""){let s=[o,...t,r].join(i);return new om({inputVariables:n,template:s})}static fromTemplate(t,r){let{templateFormat:n="f-string",...i}=r??{},o=new Set;return Cc(t,n).forEach(s=>{s.type==="variable"&&o.add(s.name)}),new om({inputVariables:[...o],templateFormat:n,template:t,...i})}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),n={...this.partialVariables??{},...t},i={...this,inputVariables:r,partialVariables:n};return new om(i)}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(t){if(!t.template)throw new Error("Prompt template must have a template");return new om({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var ql=class EM extends Ji{static lc_name(){return"ImagePromptTemplate"}lc_namespace=["langchain_core","prompts","image"];template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),this.template=t.template,this.templateFormat=t.templateFormat??this.templateFormat,this.validateTemplate=t.validateTemplate??this.validateTemplate,this.additionalContentFields=t.additionalContentFields,this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Mo([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),n={...this.partialVariables??{},...t},i={...this,inputVariables:r,partialVariables:n};return new EM(i)}async format(t){let r={};for(let[s,a]of Object.entries(this.template))typeof a=="string"?r[s]=wr(a,this.templateFormat,t):r[s]=a;let n=t.url||r.url,i=t.detail||r.detail;if(!n)throw new Error("Must provide either an image URL.");if(typeof n!="string")throw new Error("url must be a string.");let o={url:n};return i&&(o.detail=i),o}async formatPromptValue(t){return new MA(await this.format(t))}};var sm=class extends he{lc_namespace=["langchain_core","prompts","dict"];lc_serializable=!0;template;templateFormat;inputVariables;static lc_name(){return"DictPromptTemplate"}constructor(e){let t=e.templateFormat??"f-string",r=QA(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return e0(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function QA(e,t){let r=[];for(let n of Object.values(e))if(typeof n=="string")Cc(n,t).forEach(i=>{i.type==="variable"&&r.push(i.name)});else if(Array.isArray(n))for(let i of n)typeof i=="string"?Cc(i,t).forEach(o=>{o.type==="variable"&&r.push(o.name)}):typeof i=="object"&&r.push(...QA(i,t));else typeof n=="object"&&n!==null&&r.push(...QA(n,t));return Array.from(new Set(r))}function e0(e,t,r){let n={};for(let[i,o]of Object.entries(e))if(typeof o=="string")n[i]=wr(o,r,t);else if(Array.isArray(o)){let s=[];for(let a of o)typeof a=="string"?s.push(wr(a,r,t)):typeof a=="object"&&s.push(e0(a,t,r));n[i]=s}else typeof o=="object"&&o!==null?n[i]=e0(o,t,r):n[i]=o;return n}var am=class extends he{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},l_=class extends am{static lc_name(){return"MessagesPlaceholder"}variableName;optional;constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){let t=e[this.variableName];if(this.optional&&!t)return[];if(!t){let n=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw n.name="InputFormatError",n}let r;try{Array.isArray(t)?r=t.map(er):r=[er(t)]}catch(n){let i=typeof t=="string"?t:JSON.stringify(t,null,2),o=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${i}`,`Additional message: ${n.message}`].join(`
|
|
174
|
-
|
|
175
|
-
`));throw o.name="InputFormatError",o.lc_error_code=n.lc_error_code,o}return r}},t0=class extends am{prompt;constructor(e){"prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}},cm=class extends Ji{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new qf(await this.formatMessages(e))}},r0=class extends t0{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new vn(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(si.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function aq(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function cq(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:"image_url"in e&&(typeof e.image_url=="string"||typeof e.image_url=="object"&&e.image_url!==null&&"url"in e.image_url&&typeof e.image_url.url=="string")}var n0=class extends am{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;inputVariables=[];additionalOptions={};prompt;messageClass;static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}chatMessageClass;constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(n=>{"inputVariables"in n&&(r=r.concat(n.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){let t=this.constructor;if(t._messageClass())return new(t._messageClass())({content:e});if(t.chatMessageClass){let r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(si.fromTemplate(e,t));let r=[];for(let n of e)if(typeof n=="string")r.push(si.fromTemplate(n,t));else if(n!==null)if(aq(n)){let i="";typeof n.text=="string"&&(i=n.text??"");let o={...t,additionalContentFields:n};r.push(si.fromTemplate(i,o))}else if(cq(n)){let i=n.image_url??"",o,s=[];if(typeof i=="string"){let a;t?.templateFormat==="mustache"?a=Wl(i):a=Pc(i);let c=a.flatMap(u=>u.type==="variable"?[u.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
|
|
176
|
-
Got: ${c}
|
|
177
|
-
From: ${i}`);s=[c[0]]}else s=[];i={url:i},o=new ql({template:i,inputVariables:s,templateFormat:t?.templateFormat,additionalContentFields:n})}else if(typeof i=="object"){if("url"in i){let a;t?.templateFormat==="mustache"?a=Wl(i.url):a=Pc(i.url),s=a.flatMap(c=>c.type==="variable"?[c.name]:[])}else s=[];o=new ql({template:i,inputVariables:s,templateFormat:t?.templateFormat,additionalContentFields:n})}else throw new Error("Invalid image template");r.push(o)}else typeof n=="object"&&r.push(new sm({template:n,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof No){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let n={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let i of r.inputVariables)n||(n={[i]:e[i]}),n={...n,[i]:e[i]};if(r instanceof No){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),i!==""&&t.push({...o,type:"text",text:i})}else if(r instanceof ql){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,type:"image_url",image_url:i})}else if(r instanceof sm){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,...i})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},d_=class extends n0{static _messageClass(){return Qt}static lc_name(){return"HumanMessagePromptTemplate"}},i0=class extends n0{static _messageClass(){return Re}static lc_name(){return"AIMessagePromptTemplate"}},um=class extends n0{static _messageClass(){return Hn}static lc_name(){return"SystemMessagePromptTemplate"}};function uq(e){return typeof e.formatMessages=="function"}function lq(e,t){if(uq(e)||St(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let i=e[1];if(t?.templateFormat==="mustache"&&typeof i=="string"&&i.slice(0,2)==="{{"&&i.slice(-2)==="}}")return new l_({variableName:i.slice(2,-2),optional:!0});if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}")return new l_({variableName:i.slice(1,-1),optional:!0});throw new Error(`Invalid placeholder template for format ${t?.templateFormat??'"f-string"'}: "${e[1]}". Expected a variable name surrounded by ${t?.templateFormat==="mustache"?"double":"single"} curly braces.`)}let r=er(e),n;if(typeof r.content=="string"?n=r.content:n=r.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),r._getType()==="human")return d_.fromTemplate(n,t);if(r._getType()==="ai")return i0.fromTemplate(n,t);if(r._getType()==="system")return um.fromTemplate(n,t);if(vn.isInstance(r))return r0.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function dq(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Pn=class u_ extends cm{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}promptMessages;validateTemplate=!0;templateFormat="f-string";constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){let r=new Set;for(let a of this.promptMessages)if(!(a instanceof Rt))for(let c of a.inputVariables)r.add(c);let n=this.inputVariables,i=new Set(this.partialVariables?n.concat(Object.keys(this.partialVariables)):n),o=new Set([...i].filter(a=>!r.has(a)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are not used in any of the prompt messages.`);let s=new Set([...r].filter(a=>!i.has(a)));if(s.size>0)throw new Error(`Input variables \`${[...s]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(t,r){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async n=>{if(n.type!=="image_url")return n;let i="";typeof n.image_url=="string"?i=n.image_url:typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"&&(i=n.image_url.url);let o=await si.fromTemplate(i,{templateFormat:this.templateFormat}).format(r);return typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url?n.image_url.url=o:n.image_url=o,n}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=[];for(let i of this.promptMessages)if(i instanceof Rt)n.push(await this._parseImagePrompts(i,r));else{let o;this.templateFormat==="mustache"?o={...r}:o=i.inputVariables.reduce((a,c)=>{if(!(c in r)&&!(dq(i)&&i.optional))throw Bu(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return a[c]=r[c],a},{});let s=await i.formatMessages(o);n=n.concat(s)}return n}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),n={...this.partialVariables??{},...t},i={...this,inputVariables:r,partialVariables:n};return new u_(i)}static fromTemplate(t,r){let n=new d_({prompt:si.fromTemplate(t,r)});return this.fromMessages([n])}static fromMessages(t,r){let n=t.reduce((s,a)=>s.concat(a instanceof u_?a.promptMessages:[lq(a,r)]),[]),i=t.reduce((s,a)=>a instanceof u_?Object.assign(s,a.partialVariables):s,Object.create(null)),o=new Set;for(let s of n)if(!(s instanceof Rt))for(let a of s.inputVariables)a in i||o.add(a);return new this({...r,inputVariables:[...o],promptMessages:n,partialVariables:i,templateFormat:r?.templateFormat})}};var PM=class o0 extends No{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
178
|
-
|
|
179
|
-
`;prefix="";templateFormat="f-string";validateTemplate=!0;constructor(t){if(super(t),Object.assign(this,t),this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Mo(this.prefix+this.suffix,this.templateFormat,r)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),n={...this.partialVariables??{},...t},i={...this,inputVariables:r,partialVariables:n};return new o0(i)}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=await Promise.all(n.map(o=>this.examplePrompt.format(o)));return wr([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(this.outputParser!==void 0)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(t){let{example_prompt:r}=t;if(!r)throw new Error("Missing example prompt");let n=await si.deserialize(r),i;if(Array.isArray(t.examples))i=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new o0({inputVariables:t.input_variables,examplePrompt:n,examples:i,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},CM=class RM extends cm{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
180
|
-
|
|
181
|
-
`;prefix="";templateFormat="f-string";validateTemplate=!0;_getPromptType(){return"few_shot_chat"}static lc_name(){return"FewShotChatMessagePromptTemplate"}constructor(t){if(super(t),this.examples=t.examples,this.examplePrompt=t.examplePrompt,this.exampleSeparator=t.exampleSeparator??`
|
|
182
|
-
|
|
183
|
-
`,this.exampleSelector=t.exampleSelector,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.templateFormat=t.templateFormat??"f-string",this.validateTemplate=t.validateTemplate??!0,this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Mo(this.prefix+this.suffix,this.templateFormat,r)}}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r);n=n.map(o=>{let s={};return this.examplePrompt.inputVariables.forEach(a=>{s[a]=o[a]}),s});let i=[];for(let o of n){let s=await this.examplePrompt.formatMessages(o);i.push(...s)}return i}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=(await Promise.all(n.map(o=>this.examplePrompt.formatMessages(o)))).flat().map(o=>o.content);return wr([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),n={...this.partialVariables??{},...t},i={...this,inputVariables:r,partialVariables:n};return new RM(i)}};var NM=class p_ extends Ji{static lc_name(){return"PipelinePromptTemplate"}pipelinePrompts;finalPrompt;constructor(t){super({...t,inputVariables:[]}),this.pipelinePrompts=t.pipelinePrompts,this.finalPrompt=t.finalPrompt,this.inputVariables=this.computeInputValues()}computeInputValues(){let t=this.pipelinePrompts.map(n=>n.name),r=this.pipelinePrompts.map(n=>n.prompt.inputVariables.filter(i=>!t.includes(i))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((n,i)=>(n[i]=t[i],n),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:n,prompt:i}of this.pipelinePrompts){let o=p_.extractRequiredInputValues(r,i.inputVariables);i instanceof Pn?r[n]=await i.formatMessages(o):r[n]=await i.format(o)}return p_.extractRequiredInputValues(r,this.finalPrompt.inputVariables)}async formatPromptValue(t){return this.finalPrompt.formatPromptValue(await this.formatPipelinePrompts(t))}async format(t){return this.finalPrompt.format(await this.formatPipelinePrompts(t))}async partial(t){let r={...this};return r.inputVariables=this.inputVariables.filter(n=>!(n in t)),r.partialVariables={...this.partialVariables??{},...t},new p_(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function MM(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function pq(e){return typeof e=="object"&&e!=null&&"lc_id"in e&&Array.isArray(e.lc_id)&&e.lc_id.join("/")==="langchain_core/runnables/RunnableBinding"}var zM=class jM extends Pn{schema;method;lc_namespace=["langchain_core","prompts","structured"];get lc_aliases(){return{...super.lc_aliases,schema:"schema_"}}constructor(t){super(t),this.schema=t.schema,this.method=t.method}pipe(t){if(MM(t))return super.pipe(t.withStructuredOutput(this.schema));if(pq(t)&&MM(t.bound))return super.pipe(new $n({bound:t.bound.withStructuredOutput(this.schema,...this.method?[{method:this.method}]:[]),kwargs:t.kwargs??{},config:t.config,configFactories:t.configFactories}));throw new Error('Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.')}static fromMessagesAndSchema(t,r,n){return jM.fromMessages(t,{schema:r,method:n})}};var DM=F({AIMessagePromptTemplate:()=>i0,BaseChatPromptTemplate:()=>cm,BaseMessagePromptTemplate:()=>am,BaseMessageStringPromptTemplate:()=>t0,BasePromptTemplate:()=>Ji,BaseStringPromptTemplate:()=>No,ChatMessagePromptTemplate:()=>r0,ChatPromptTemplate:()=>Pn,DEFAULT_FORMATTER_MAPPING:()=>im,DEFAULT_PARSER_MAPPING:()=>YA,DictPromptTemplate:()=>sm,FewShotChatMessagePromptTemplate:()=>CM,FewShotPromptTemplate:()=>PM,HumanMessagePromptTemplate:()=>d_,ImagePromptTemplate:()=>ql,MessagesPlaceholder:()=>l_,PipelinePromptTemplate:()=>NM,PromptTemplate:()=>si,StructuredPrompt:()=>zM,SystemMessagePromptTemplate:()=>um,checkValidTemplate:()=>Mo,interpolateFString:()=>JA,interpolateMustache:()=>XA,parseFString:()=>Pc,parseMustache:()=>Wl,parseTemplate:()=>Cc,renderTemplate:()=>wr});var UM=F({BaseDocumentCompressor:()=>fq}),fq=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var LM=F({BaseRetriever:()=>lm}),lm=class extends he{callbacks;tags;metadata;verbose;constructor(e){super(e),this.callbacks=e?.callbacks,this.tags=e?.tags??[],this.metadata=e?.metadata??{},this.verbose=e?.verbose??!1}_getRelevantDocuments(e,t){throw new Error("Not implemented!")}async invoke(e,t){let r=Ue(Ku(t)),n=await(await mr.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,r.runId,void 0,void 0,void 0,r.runName);try{let i=await this._getRelevantDocuments(e,n);return await n?.handleRetrieverEnd(i),i}catch(i){throw await n?.handleRetrieverError(i),i}}};var FM=F({BaseStore:()=>BM,InMemoryStore:()=>mq}),BM=class extends Ar{},mq=class extends BM{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,r]of e)this.store[t]=r}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let r of t)(e===void 0||r.startsWith(e))&&(yield r)}};var ai={and:"and",or:"or",not:"not"},Le={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},f_=class{},m_=class{accept(e){if(this.exprName==="Operation")return e.visitOperation(this);if(this.exprName==="Comparison")return e.visitComparison(this);if(this.exprName==="StructuredQuery")return e.visitStructuredQuery(this);throw new Error("Unknown Expression type")}},h_=class extends m_{},ZM=class extends h_{comparator;attribute;value;exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},VM=class extends h_{operator;args;exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},WM=class extends m_{query;filter;exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function s0(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Gr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:s0(e)&&Object.keys(e).length===0:!0}function a0(e){if(typeof e=="number")return e%1===0;if(typeof e=="string"){let t=parseInt(e,10);return!Number.isNaN(t)&&t%1===0&&t.toString()===e}return!1}function c0(e){if(typeof e=="number")return e%1!==0;if(typeof e=="string"){let t=parseFloat(e);return!Number.isNaN(t)&&t%1!==0&&t.toString()===e}return!1}function u0(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function l0(e){return typeof e=="boolean"}function Kl(e){let t;if(u0(e))t=e;else if(a0(e))t=parseInt(e,10);else if(c0(e))t=parseFloat(e);else if(l0(e))t=!!e;else throw new Error("Unsupported value type");return t}var dm=class extends f_{},qM=class extends dm{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[ai.and,ai.or],this.allowedComparators=e?.allowedComparators??[Le.eq,Le.ne,Le.gt,Le.gte,Le.lt,Le.lte]}formatFunction(e){if(e in Le){if(this.allowedComparators.length>0&&this.allowedComparators.indexOf(e)===-1)throw new Error(`Comparator ${e} not allowed. Allowed comparators: ${this.allowedComparators.join(", ")}`)}else if(e in ai){if(this.allowedOperators.length>0&&this.allowedOperators.indexOf(e)===-1)throw new Error(`Operator ${e} not allowed. Allowed operators: ${this.allowedOperators.join(", ")}`)}else throw new Error("Unknown comparator or operator");return`$${e}`}visitOperation(e){let t=e.args?.map(r=>r.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:Kl(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",n=!1){if(!(Gr(e)&&Gr(t))){if(Gr(e)||r==="replace")return Gr(t)?void 0:t;if(Gr(t))return n?e:r==="and"?void 0:e;if(r==="and")return{$and:[e,t]};if(r==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}};var KM=class extends dm{allowedOperators=[ai.and,ai.or];allowedComparators=[Le.eq,Le.ne,Le.gt,Le.gte,Le.lt,Le.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Le.eq,Le.ne,Le.gt,Le.gte,Le.lt,Le.lte];case"number":return[Le.eq,Le.ne,Le.gt,Le.gte,Le.lt,Le.lte];case"boolean":return[Le.eq,Le.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Le.eq:return(t,r)=>t===r;case Le.ne:return(t,r)=>t!==r;case Le.gt:return(t,r)=>t>r;case Le.gte:return(t,r)=>t>=r;case Le.lt:return(t,r)=>t<r;case Le.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case ai.and:return(t,r)=>t&&r;case ai.or:return(t,r)=>t||r;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:r}=e;if(this.allowedOperators.includes(t)){let n=this.getOperatorFunction(t);return i=>r?r.reduce((o,s)=>{let a=s.accept(this);if(typeof a=="function")return n(o,a(i));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:r,value:n}=e,i=[Le.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof n).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof n}`);let o=this.getComparatorFunction(t);return s=>{let a=s.metadata[r];return a===void 0?!!i.includes(t):o(a,Kl(n))}}else throw new Error("Comparator not allowed")}visitStructuredQuery(e){if(!e.filter)return{};let t=e.filter?.accept(this);if(typeof t!="function")throw new Error("Structured query filter is not a function");return{filter:t}}mergeFilters(e,t,r="and"){if(!(Gr(e)&&Gr(t))){if(Gr(e)||r==="replace")return Gr(t)?void 0:t;if(Gr(t))return r==="and"?void 0:e;if(r==="and")return n=>e(n)&&t(n);if(r==="or")return n=>e(n)||t(n);throw new Error("Unknown merge type")}}};var GM=F({BaseTranslator:()=>dm,BasicTranslator:()=>qM,Comparators:()=>Le,Comparison:()=>ZM,Expression:()=>m_,FilterDirective:()=>h_,FunctionalTranslator:()=>KM,Operation:()=>VM,Operators:()=>ai,StructuredQuery:()=>WM,Visitor:()=>f_,castValue:()=>Kl,isBoolean:()=>l0,isFilterEmpty:()=>Gr,isFloat:()=>c0,isInt:()=>a0,isObject:()=>s0,isString:()=>u0});function pm(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.text<"u"&&typeof t.toolCalls<"u"&&typeof t.reasoning<"u"&&typeof t.usage<"u"&&typeof t.output<"u"&&typeof t[Symbol.asyncIterator]=="function"}function HM(e,t,r){return e==null?!1:Object.entries(t).every(([n,i])=>r(e[n],i))}function JM(e,t,r){return e==null?!1:HM(e,t,r)}function XM(e){return e.content.find(t=>t.type==="text")?.text}function hq(e,t,r){if(t.id!==void 0&&e.id!==t.id||t.text!==void 0&&XM(e)!==t.text)return!1;if(t.toolCalls!==void 0){let n=e.tool_calls??[];if(n.length!==t.toolCalls.length)return!1;for(let i=0;i<t.toolCalls.length;i++){let o=n[i],s=t.toolCalls[i];if(o?.name!==s.name||!r(o.args,s.args))return!1}}return!(t.usage!==void 0&&!JM(e.usage_metadata,t.usage,r)||t.responseMetadata!==void 0&&!HM(e.response_metadata,t.responseMetadata,r))}function fm(e,t,r){return{pass:!1,message:()=>`${r.matcherHint(t)}
|
|
184
|
-
|
|
185
|
-
Expected: ChatModelStream (return value of model.streamEvents("Hello"))
|
|
186
|
-
Received: ${r.printReceived(e)}`,actual:e,expected:"ChatModelStream"}}function mm(e,t){return t?!e:e}async function gq(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamText";if(!pm(e))return fm(e,i,n);let o=await e.text;return{pass:mm(o===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
|
|
187
|
-
|
|
188
|
-
Expected stream text: ${r?"not ":""}${n.printExpected(t)}
|
|
189
|
-
Received stream text: ${n.printReceived(o)}`,actual:o,expected:t}}async function yq(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamReasoning";if(!pm(e))return fm(e,i,n);let o=await e.reasoning;return{pass:mm(o===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
|
|
190
|
-
|
|
191
|
-
Expected stream reasoning: ${r?"not ":""}${n.printExpected(t)}
|
|
192
|
-
Received stream reasoning: ${n.printReceived(o)}`,actual:o,expected:t}}async function _q(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamToolCalls";if(!pm(e))return fm(e,i,n);let o=await e.toolCalls,s=o.length===t.length&&t.every((a,c)=>{let u=o[c];return u?.name===a.name&&this.equals(u.args,a.args)});return s=mm(s,r),{pass:s,message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
|
|
193
|
-
|
|
194
|
-
Expected stream tool calls: ${n.printExpected(t)}
|
|
195
|
-
Received stream tool calls: ${n.printReceived(o.map(a=>({name:a.name,args:a.args})))}`,actual:o.map(a=>({name:a.name,args:a.args})),expected:t}}async function vq(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamUsage";if(!pm(e))return fm(e,i,n);let o=await e.usage;return{pass:mm(JM(o,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
|
|
196
|
-
|
|
197
|
-
Expected stream usage: ${n.printExpected(t)}
|
|
198
|
-
Received stream usage: ${n.printReceived(o)}`,actual:o,expected:t}}async function bq(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamOutput";if(!pm(e))return fm(e,i,n);let o=await e.output;return{pass:mm(hq(o,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
|
|
199
|
-
|
|
200
|
-
Expected stream output: ${n.printExpected(t)}
|
|
201
|
-
Received stream output: ${n.printReceived({id:o.id,text:XM(o),tool_calls:o.tool_calls?.map(s=>({name:s.name,args:s.args})),usage_metadata:o.usage_metadata,response_metadata:o.response_metadata})}`,actual:o,expected:t}}var Gl={toHaveStreamText:gq,toHaveStreamReasoning:yq,toHaveStreamToolCalls:_q,toHaveStreamUsage:vq,toHaveStreamOutput:bq};function hm(e){return Rt.isInstance(e)?e.constructor.name||e.type:typeof e}function g_(e,t){return function(r,n){let{isNot:i,utils:o}=this;if(!t(r))return{pass:!1,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
202
|
-
|
|
203
|
-
Expected: ${i?"not ":""}${e}
|
|
204
|
-
Received: ${hm(r)}`,actual:hm(r),expected:e};if(n===void 0)return{pass:!0,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
205
|
-
|
|
206
|
-
Expected: not ${e}
|
|
207
|
-
Received: ${e}`};let s=r;return typeof n=="string"?{pass:s.content===n,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
208
|
-
|
|
209
|
-
Expected: ${e} with content ${o.printExpected(n)}
|
|
210
|
-
Received: ${e} with content ${o.printReceived(s.content)}`,actual:s.content,expected:n}:{pass:Object.entries(n).every(([a,c])=>this.equals(s[a],c)),message:()=>{let a={};for(let c of Object.keys(n))a[c]=s[c];return`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
211
|
-
|
|
212
|
-
Expected: ${e} matching ${o.printExpected(n)}
|
|
213
|
-
Received: ${e} with ${o.printReceived(a)}`},actual:(()=>{let a={};for(let c of Object.keys(n))a[c]=s[c];return a})(),expected:n}}}var d0=g_("HumanMessage",Qt.isInstance),p0=g_("AIMessage",Re.isInstance),f0=g_("SystemMessage",Hn.isInstance),m0=g_("ToolMessage",qt.isInstance);function h0(e,t){let{isNot:r,utils:n}=this;if(!Re.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
214
|
-
|
|
215
|
-
Expected: AIMessage
|
|
216
|
-
Received: ${hm(e)}`};let i=e.tool_calls??[];if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
217
|
-
|
|
218
|
-
Expected ${r?"not ":""}${t.length} tool call(s), received ${i.length}`,actual:i.length,expected:t.length};let o=t.filter(s=>!i.some(a=>Object.entries(s).every(([c,u])=>this.equals(a[c],u))));return o.length>0?{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
219
|
-
|
|
220
|
-
Could not find matching tool call(s) for:
|
|
221
|
-
${n.printExpected(o)}
|
|
222
|
-
Received tool calls: ${n.printReceived(i.map(s=>({name:s.name,id:s.id,args:s.args})))}`,actual:i.map(s=>({name:s.name,id:s.id,args:s.args})),expected:t}:{pass:!0,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
223
|
-
|
|
224
|
-
Expected AIMessage not to have matching tool calls`}}function g0(e,t){let{isNot:r,utils:n}=this;if(!Re.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCallCount")}
|
|
225
|
-
|
|
226
|
-
Expected: AIMessage
|
|
227
|
-
Received: ${hm(e)}`};let i=e.tool_calls?.length??0;return{pass:i===t,message:()=>`${n.matcherHint("toHaveToolCallCount")}
|
|
228
|
-
|
|
229
|
-
Expected ${r?"not ":""}${t} tool call(s)
|
|
230
|
-
Received: ${i}`,actual:i,expected:t}}function y0(e,t){let{isNot:r,utils:n}=this;if(!Re.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toContainToolCall")}
|
|
231
|
-
|
|
232
|
-
Expected: AIMessage
|
|
233
|
-
Received: ${hm(e)}`};let i=e.tool_calls??[];return{pass:i.some(o=>Object.entries(t).every(([s,a])=>this.equals(o[s],a))),message:()=>`${n.matcherHint("toContainToolCall")}
|
|
234
|
-
|
|
235
|
-
Expected AIMessage ${r?"not ":""}to contain a tool call matching ${n.printExpected(t)}
|
|
236
|
-
Received tool calls: ${n.printReceived(i.map(o=>({name:o.name,id:o.id})))}`,actual:i.map(o=>({name:o.name,id:o.id})),expected:t}}function _0(e,t){let{isNot:r,utils:n}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
237
|
-
|
|
238
|
-
Expected an array of messages
|
|
239
|
-
Received: ${typeof e}`};let i=e.filter(qt.isInstance);if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
240
|
-
|
|
241
|
-
Expected ${r?"not ":""}${t.length} tool message(s), found ${i.length}`,actual:i.length,expected:t.length};for(let o=0;o<t.length;o++)if(!Object.entries(t[o]).every(([s,a])=>this.equals(i[o][s],a)))return{pass:!1,message:()=>{let s={};for(let a of Object.keys(t[o]))s[a]=i[o][a];return`${n.matcherHint("toHaveToolMessages")}
|
|
242
|
-
|
|
243
|
-
Tool message at index ${o} did not match:
|
|
244
|
-
Expected: ${n.printExpected(t[o])}
|
|
245
|
-
Received: ${n.printReceived(s)}`},actual:i[o],expected:t[o]};return{pass:!0,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
246
|
-
|
|
247
|
-
Expected messages not to contain matching tool messages`}}function v0(e,t){let{isNot:r,utils:n}=this,i=e?.__interrupt__;if(!(Array.isArray(i)&&i.length>0))return{pass:!1,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
248
|
-
|
|
249
|
-
Expected result ${r?"not ":""}to have been interrupted
|
|
250
|
-
Received __interrupt__: ${n.printReceived(i)}`};if(t===void 0)return{pass:!0,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
251
|
-
|
|
252
|
-
Expected result not to have been interrupted
|
|
253
|
-
Received ${i.length} interrupt(s)`};let o=i[0]?.value;return{pass:this.equals(o,t),message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
254
|
-
|
|
255
|
-
Expected interrupt value: ${n.printExpected(t)}
|
|
256
|
-
Received interrupt value: ${n.printReceived(o)}`,actual:o,expected:t}}function b0(e,t){let{isNot:r,utils:n}=this,i=e?.structuredResponse;return i===void 0?{pass:!1,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
257
|
-
|
|
258
|
-
Expected result ${r?"not ":""}to have a structured response
|
|
259
|
-
Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
260
|
-
|
|
261
|
-
Expected result not to have a structured response`}:{pass:Object.entries(t).every(([o,s])=>this.equals(i[o],s)),message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
262
|
-
|
|
263
|
-
Expected structured response: ${n.printExpected(t)}
|
|
264
|
-
Received structured response: ${n.printReceived(i)}`,actual:i,expected:t}}var YM={toBeHumanMessage:d0,toBeAIMessage:p0,toBeSystemMessage:f0,toBeToolMessage:m0,toHaveToolCalls:h0,toHaveToolCallCount:g0,toContainToolCall:y0,toHaveToolMessages:_0,toHaveBeenInterrupted:v0,toHaveStructuredResponse:b0,...Gl};function wq(e){return e.map(t=>t.text).filter(Boolean).join("-")}var QM=0;function xq(){return QM+=1,`fake_tc_${QM}`}var w0=class ez extends Hi{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_state={callIndex:0,calls:[]};get calls(){return this._state.calls}get callCount(){return this._state.calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Rt.isInstance(t)?this.queue.push({kind:"message",message:t}):this.queue.push({kind:"error",error:t}),this}respondWithTools(t){return this.queue.push({kind:"toolCalls",toolCalls:t.map(r=>({name:r.name,args:r.args,id:r.id??xq(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let r=[...this._tools,...t],n=new ez;return n.queue=this.queue,n._alwaysThrowError=this._alwaysThrowError,n._structuredResponseValue=this._structuredResponseValue,n._tools=r,n._state=this._state,n.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:n}=this;return ir.from(async()=>n)}async _generate(t,r,n){this._state.calls.push({messages:[...t],options:r});let i=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let o=this.queue[i];if(!o)throw new Error(`FakeModel: no response queued for invocation ${i} (${this.queue.length} total queued).`);if(o.kind==="error")throw o.error;if(o.kind==="factory"){let a=o.factory(t);if(!Rt.isInstance(a))throw a;return{generations:[{text:"",message:a}]}}if(o.kind==="message")return{generations:[{text:"",message:o.message}]};let s=wq(t);return{generations:[{text:s,message:new Re({content:s,id:i.toString(),tool_calls:o.toolCalls.length>0?o.toolCalls.map(a=>({...a,type:"tool_call"})):void 0})}],llmOutput:{}}}};function tz(){return new w0}function y_(e){return{async*[Symbol.asyncIterator](){for(let t of e)yield t}}}function __(e="test-model"){let t=gm(e),r=t[t.length-1];return t[t.length-1]={...r,usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}},t}function gm(e="test-model"){return[{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{role:"assistant",content:"Hello"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{content:" world"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function v_(e="test-model"){return[{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{role:"assistant",reasoning_content:"Let me reason..."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{content:"Answer."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function b_(e="test-model"){return[{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{role:"assistant",content:"Let me search."},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,id:"call_abc",type:"function",function:{name:"web_search",arguments:'{"query"'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,function:{arguments:':"weather"}'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{},finish_reason:"tool_calls"}]}]}function w_(e){let t=new TextEncoder;return new Response(new ReadableStream({start(r){for(let n of e)r.enqueue(t.encode(`data: ${JSON.stringify(n)}
|
|
265
|
-
|
|
266
|
-
`));r.close()}}),{status:200,headers:{"Content-Type":"text/event-stream"}})}var rz=F({FakeBuiltModel:()=>w0,asAsyncIterable:()=>y_,fakeModel:()=>tz,langchainMatchers:()=>YM,openAIReasoningTextChunks:()=>v_,openAITextOnlyChunks:()=>gm,openAITextOnlyChunksWithUsage:()=>__,openAIToolCallChunks:()=>b_,sseResponseFromOpenAIChunks:()=>w_,streamMatchers:()=>Gl,toBeAIMessage:()=>p0,toBeHumanMessage:()=>d0,toBeSystemMessage:()=>f0,toBeToolMessage:()=>m0,toContainToolCall:()=>y0,toHaveBeenInterrupted:()=>v0,toHaveStructuredResponse:()=>b0,toHaveToolCallCount:()=>g0,toHaveToolCalls:()=>h0,toHaveToolMessages:()=>_0});function ym(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function _m(e){return e!==void 0&&he.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function vm(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ht(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function zo(e){return vm(e)||_m(e)||ym(e)}var Y={};Kn(Y,{$brand:()=>Bw,$input:()=>aI,$output:()=>sI,NEVER:()=>Fw,TimePrecision:()=>dI,ZodAny:()=>V0,ZodArray:()=>G0,ZodBase64:()=>B_,ZodBase64URL:()=>Z_,ZodBigInt:()=>rd,ZodBigIntFormat:()=>q_,ZodBoolean:()=>td,ZodCIDRv4:()=>L_,ZodCIDRv6:()=>F_,ZodCUID:()=>R_,ZodCUID2:()=>N_,ZodCatch:()=>gO,ZodCodec:()=>Rm,ZodCustom:()=>Nm,ZodCustomStringFormat:()=>Ql,ZodDate:()=>$m,ZodDefault:()=>lO,ZodDiscriminatedUnion:()=>J0,ZodE164:()=>V_,ZodEmail:()=>E_,ZodEmoji:()=>P_,ZodEnum:()=>Xl,ZodError:()=>kq,ZodExactOptional:()=>aO,ZodFile:()=>oO,ZodFirstPartyTypeKind:()=>TO,ZodFunction:()=>AO,ZodGUID:()=>km,ZodIPv4:()=>D_,ZodIPv6:()=>U_,ZodISODate:()=>I_,ZodISODateTime:()=>k_,ZodISODuration:()=>A_,ZodISOTime:()=>S_,ZodIntersection:()=>X0,ZodIssueCode:()=>Sq,ZodJWT:()=>W_,ZodKSUID:()=>j_,ZodLazy:()=>kO,ZodLiteral:()=>iO,ZodMAC:()=>j0,ZodMap:()=>rO,ZodNaN:()=>_O,ZodNanoID:()=>C_,ZodNever:()=>q0,ZodNonOptional:()=>Y_,ZodNull:()=>B0,ZodNullable:()=>uO,ZodNumber:()=>ed,ZodNumberFormat:()=>Nc,ZodObject:()=>Em,ZodOptional:()=>X_,ZodPipe:()=>Cm,ZodPrefault:()=>pO,ZodPreprocess:()=>vO,ZodPromise:()=>SO,ZodReadonly:()=>bO,ZodRealError:()=>Hr,ZodRecord:()=>Jl,ZodSet:()=>nO,ZodString:()=>Yl,ZodStringFormat:()=>ot,ZodSuccess:()=>hO,ZodSymbol:()=>L0,ZodTemplateLiteral:()=>xO,ZodTransform:()=>sO,ZodTuple:()=>Q0,ZodType:()=>Ee,ZodULID:()=>M_,ZodURL:()=>Om,ZodUUID:()=>Xi,ZodUndefined:()=>F0,ZodUnion:()=>Pm,ZodUnknown:()=>W0,ZodVoid:()=>K0,ZodXID:()=>z_,ZodXor:()=>H0,_ZodString:()=>T_,_default:()=>dO,_function:()=>dj,any:()=>Bz,array:()=>Tm,base64:()=>Sz,base64url:()=>Az,bigint:()=>jz,boolean:()=>U0,catch:()=>yO,check:()=>pj,cidrv4:()=>kz,cidrv6:()=>Iz,clone:()=>ft,codec:()=>aj,coerce:()=>EO,config:()=>Ot,core:()=>Ao,cuid:()=>hz,cuid2:()=>gz,custom:()=>fj,date:()=>Vz,decode:()=>E0,decodeAsync:()=>C0,describe:()=>mj,discriminatedUnion:()=>Jz,e164:()=>Oz,email:()=>oz,emoji:()=>fz,encode:()=>T0,encodeAsync:()=>P0,endsWith:()=>hl,enum:()=>H_,exactOptional:()=>cO,file:()=>nj,flattenError:()=>gf,float32:()=>Rz,float64:()=>Nz,formatError:()=>yf,fromJSONSchema:()=>wj,function:()=>dj,getErrorMap:()=>Oq,globalRegistry:()=>Qe,gt:()=>Ui,gte:()=>Rr,guid:()=>sz,hash:()=>Cz,hex:()=>Pz,hostname:()=>Ez,httpUrl:()=>pz,includes:()=>fl,instanceof:()=>gj,int:()=>O_,int32:()=>Mz,int64:()=>Dz,intersection:()=>Y0,invertCodec:()=>cj,ipv4:()=>bz,ipv6:()=>xz,iso:()=>Hl,json:()=>_j,jwt:()=>$z,keyof:()=>Wz,ksuid:()=>vz,lazy:()=>IO,length:()=>lc,literal:()=>rj,locales:()=>Of,looseObject:()=>Gz,looseRecord:()=>Yz,lowercase:()=>dl,lt:()=>Di,lte:()=>dn,mac:()=>wz,map:()=>Qz,maxLength:()=>uc,maxSize:()=>$s,meta:()=>hj,mime:()=>gl,minLength:()=>Io,minSize:()=>Li,multipleOf:()=>Os,nan:()=>sj,nanoid:()=>mz,nativeEnum:()=>tj,negative:()=>by,never:()=>K_,nonnegative:()=>xy,nonoptional:()=>mO,nonpositive:()=>wy,normalize:()=>yl,null:()=>Z0,nullable:()=>Sm,nullish:()=>ij,number:()=>D0,object:()=>qz,optional:()=>Im,overwrite:()=>ei,parse:()=>wm,parseAsync:()=>A0,partialRecord:()=>Xz,pipe:()=>$_,positive:()=>vy,prefault:()=>fO,preprocess:()=>vj,prettifyError:()=>tx,promise:()=>lj,property:()=>ky,readonly:()=>wO,record:()=>tO,refine:()=>OO,regex:()=>ll,regexes:()=>ln,registry:()=>ul,safeDecode:()=>N0,safeDecodeAsync:()=>z0,safeEncode:()=>R0,safeEncodeAsync:()=>M0,safeParse:()=>O0,safeParseAsync:()=>$0,set:()=>ej,setErrorMap:()=>Aq,size:()=>cc,slugify:()=>wl,startsWith:()=>ml,strictObject:()=>Kz,string:()=>xm,stringFormat:()=>Tz,stringbool:()=>yj,success:()=>oj,superRefine:()=>$O,symbol:()=>Lz,templateLiteral:()=>uj,toJSONSchema:()=>So,toLowerCase:()=>vl,toUpperCase:()=>bl,transform:()=>J_,treeifyError:()=>ex,trim:()=>_l,tuple:()=>eO,uint32:()=>zz,uint64:()=>Uz,ulid:()=>yz,undefined:()=>Fz,union:()=>G_,unknown:()=>Rc,uppercase:()=>pl,url:()=>dz,util:()=>W,uuid:()=>az,uuidv4:()=>cz,uuidv6:()=>uz,uuidv7:()=>lz,void:()=>Zz,xid:()=>_z,xor:()=>Hz});var bm={};Kn(bm,{ZodAny:()=>V0,ZodArray:()=>G0,ZodBase64:()=>B_,ZodBase64URL:()=>Z_,ZodBigInt:()=>rd,ZodBigIntFormat:()=>q_,ZodBoolean:()=>td,ZodCIDRv4:()=>L_,ZodCIDRv6:()=>F_,ZodCUID:()=>R_,ZodCUID2:()=>N_,ZodCatch:()=>gO,ZodCodec:()=>Rm,ZodCustom:()=>Nm,ZodCustomStringFormat:()=>Ql,ZodDate:()=>$m,ZodDefault:()=>lO,ZodDiscriminatedUnion:()=>J0,ZodE164:()=>V_,ZodEmail:()=>E_,ZodEmoji:()=>P_,ZodEnum:()=>Xl,ZodExactOptional:()=>aO,ZodFile:()=>oO,ZodFunction:()=>AO,ZodGUID:()=>km,ZodIPv4:()=>D_,ZodIPv6:()=>U_,ZodIntersection:()=>X0,ZodJWT:()=>W_,ZodKSUID:()=>j_,ZodLazy:()=>kO,ZodLiteral:()=>iO,ZodMAC:()=>j0,ZodMap:()=>rO,ZodNaN:()=>_O,ZodNanoID:()=>C_,ZodNever:()=>q0,ZodNonOptional:()=>Y_,ZodNull:()=>B0,ZodNullable:()=>uO,ZodNumber:()=>ed,ZodNumberFormat:()=>Nc,ZodObject:()=>Em,ZodOptional:()=>X_,ZodPipe:()=>Cm,ZodPrefault:()=>pO,ZodPreprocess:()=>vO,ZodPromise:()=>SO,ZodReadonly:()=>bO,ZodRecord:()=>Jl,ZodSet:()=>nO,ZodString:()=>Yl,ZodStringFormat:()=>ot,ZodSuccess:()=>hO,ZodSymbol:()=>L0,ZodTemplateLiteral:()=>xO,ZodTransform:()=>sO,ZodTuple:()=>Q0,ZodType:()=>Ee,ZodULID:()=>M_,ZodURL:()=>Om,ZodUUID:()=>Xi,ZodUndefined:()=>F0,ZodUnion:()=>Pm,ZodUnknown:()=>W0,ZodVoid:()=>K0,ZodXID:()=>z_,ZodXor:()=>H0,_ZodString:()=>T_,_default:()=>dO,_function:()=>dj,any:()=>Bz,array:()=>Tm,base64:()=>Sz,base64url:()=>Az,bigint:()=>jz,boolean:()=>U0,catch:()=>yO,check:()=>pj,cidrv4:()=>kz,cidrv6:()=>Iz,codec:()=>aj,cuid:()=>hz,cuid2:()=>gz,custom:()=>fj,date:()=>Vz,describe:()=>mj,discriminatedUnion:()=>Jz,e164:()=>Oz,email:()=>oz,emoji:()=>fz,enum:()=>H_,exactOptional:()=>cO,file:()=>nj,float32:()=>Rz,float64:()=>Nz,function:()=>dj,guid:()=>sz,hash:()=>Cz,hex:()=>Pz,hostname:()=>Ez,httpUrl:()=>pz,instanceof:()=>gj,int:()=>O_,int32:()=>Mz,int64:()=>Dz,intersection:()=>Y0,invertCodec:()=>cj,ipv4:()=>bz,ipv6:()=>xz,json:()=>_j,jwt:()=>$z,keyof:()=>Wz,ksuid:()=>vz,lazy:()=>IO,literal:()=>rj,looseObject:()=>Gz,looseRecord:()=>Yz,mac:()=>wz,map:()=>Qz,meta:()=>hj,nan:()=>sj,nanoid:()=>mz,nativeEnum:()=>tj,never:()=>K_,nonoptional:()=>mO,null:()=>Z0,nullable:()=>Sm,nullish:()=>ij,number:()=>D0,object:()=>qz,optional:()=>Im,partialRecord:()=>Xz,pipe:()=>$_,prefault:()=>fO,preprocess:()=>vj,promise:()=>lj,readonly:()=>wO,record:()=>tO,refine:()=>OO,set:()=>ej,strictObject:()=>Kz,string:()=>xm,stringFormat:()=>Tz,stringbool:()=>yj,success:()=>oj,superRefine:()=>$O,symbol:()=>Lz,templateLiteral:()=>uj,transform:()=>J_,tuple:()=>eO,uint32:()=>zz,uint64:()=>Uz,ulid:()=>yz,undefined:()=>Fz,union:()=>G_,unknown:()=>Rc,url:()=>dz,uuid:()=>az,uuidv4:()=>cz,uuidv6:()=>uz,uuidv7:()=>lz,void:()=>Zz,xid:()=>_z,xor:()=>Hz});var x_={};Kn(x_,{endsWith:()=>hl,gt:()=>Ui,gte:()=>Rr,includes:()=>fl,length:()=>lc,lowercase:()=>dl,lt:()=>Di,lte:()=>dn,maxLength:()=>uc,maxSize:()=>$s,mime:()=>gl,minLength:()=>Io,minSize:()=>Li,multipleOf:()=>Os,negative:()=>by,nonnegative:()=>xy,nonpositive:()=>wy,normalize:()=>yl,overwrite:()=>ei,positive:()=>vy,property:()=>ky,regex:()=>ll,size:()=>cc,slugify:()=>wl,startsWith:()=>ml,toLowerCase:()=>vl,toUpperCase:()=>bl,trim:()=>_l,uppercase:()=>pl});var Hl={};Kn(Hl,{ZodISODate:()=>I_,ZodISODateTime:()=>k_,ZodISODuration:()=>A_,ZodISOTime:()=>S_,date:()=>k0,datetime:()=>x0,duration:()=>S0,time:()=>I0});var k_=E("ZodISODateTime",(e,t)=>{lk.init(e,t),ot.init(e,t)});function x0(e){return pI(k_,e)}var I_=E("ZodISODate",(e,t)=>{dk.init(e,t),ot.init(e,t)});function k0(e){return fI(I_,e)}var S_=E("ZodISOTime",(e,t)=>{pk.init(e,t),ot.init(e,t)});function I0(e){return mI(S_,e)}var A_=E("ZodISODuration",(e,t)=>{fk.init(e,t),ot.init(e,t)});function S0(e){return hI(A_,e)}var nz=(e,t)=>{hf.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yf(e,r)},flatten:{value:r=>gf(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,el,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,el,2)}},isEmpty:{get(){return e.issues.length===0}}})},kq=E("ZodError",nz),Hr=E("ZodError",nz,{Parent:Error});var wm=nl(Hr),A0=il(Hr),O0=ol(Hr),$0=sl(Hr),T0=Tg(Hr),E0=Eg(Hr),P0=Pg(Hr),C0=Cg(Hr),R0=Rg(Hr),N0=Ng(Hr),M0=Mg(Hr),z0=zg(Hr);var iz=new WeakMap;function Am(e,t,r){let n=Object.getPrototypeOf(e),i=iz.get(n);if(i||(i=new Set,iz.set(n,i)),!i.has(t)){i.add(t);for(let o in r){let s=r[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var Ee=E("ZodType",(e,t)=>(Ie.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:kl(e,"input"),output:kl(e,"output")}}),e.toJSONSchema=WI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>wm(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>O0(e,r,n),e.parseAsync=async(r,n)=>A0(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>$0(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>T0(e,r,n),e.decode=(r,n)=>E0(e,r,n),e.encodeAsync=async(r,n)=>P0(e,r,n),e.decodeAsync=async(r,n)=>C0(e,r,n),e.safeEncode=(r,n)=>R0(e,r,n),e.safeDecode=(r,n)=>N0(e,r,n),e.safeEncodeAsync=async(r,n)=>M0(e,r,n),e.safeDecodeAsync=async(r,n)=>z0(e,r,n),Am(e,"ZodType",{check(...r){let n=this.def;return this.clone(W.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ft(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(OO(r,n))},superRefine(r,n){return this.check($O(r,n))},overwrite(r){return this.check(ei(r))},optional(){return Im(this)},exactOptional(){return cO(this)},nullable(){return Sm(this)},nullish(){return Im(Sm(this))},nonoptional(r){return mO(this,r)},array(){return Tm(this)},or(r){return G_([this,r])},and(r){return Y0(this,r)},transform(r){return $_(this,J_(r))},default(r){return dO(this,r)},prefault(r){return fO(this,r)},catch(r){return yO(this,r)},pipe(r){return $_(this,r)},readonly(){return wO(this)},describe(r){let n=this.clone();return Qe.add(n,{description:r}),n},meta(...r){if(r.length===0)return Qe.get(this);let n=this.clone();return Qe.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Qe.get(e)?.description},configurable:!0}),e)),T_=E("_ZodString",(e,t)=>{sc.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(n,i,o)=>qI(e,n,i,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Am(e,"_ZodString",{regex(...n){return this.check(ll(...n))},includes(...n){return this.check(fl(...n))},startsWith(...n){return this.check(ml(...n))},endsWith(...n){return this.check(hl(...n))},min(...n){return this.check(Io(...n))},max(...n){return this.check(uc(...n))},length(...n){return this.check(lc(...n))},nonempty(...n){return this.check(Io(1,...n))},lowercase(n){return this.check(dl(n))},uppercase(n){return this.check(pl(n))},trim(){return this.check(_l())},normalize(...n){return this.check(yl(...n))},toLowerCase(){return this.check(vl())},toUpperCase(){return this.check(bl())},slugify(){return this.check(wl())}})}),Yl=E("ZodString",(e,t)=>{sc.init(e,t),T_.init(e,t),e.email=r=>e.check(Qg(E_,r)),e.url=r=>e.check(Tf(Om,r)),e.jwt=r=>e.check(_y(W_,r)),e.emoji=r=>e.check(iy(P_,r)),e.guid=r=>e.check($f(km,r)),e.uuid=r=>e.check(ey(Xi,r)),e.uuidv4=r=>e.check(ty(Xi,r)),e.uuidv6=r=>e.check(ry(Xi,r)),e.uuidv7=r=>e.check(ny(Xi,r)),e.nanoid=r=>e.check(oy(C_,r)),e.guid=r=>e.check($f(km,r)),e.cuid=r=>e.check(sy(R_,r)),e.cuid2=r=>e.check(ay(N_,r)),e.ulid=r=>e.check(cy(M_,r)),e.base64=r=>e.check(hy(B_,r)),e.base64url=r=>e.check(gy(Z_,r)),e.xid=r=>e.check(uy(z_,r)),e.ksuid=r=>e.check(ly(j_,r)),e.ipv4=r=>e.check(dy(D_,r)),e.ipv6=r=>e.check(py(U_,r)),e.cidrv4=r=>e.check(fy(L_,r)),e.cidrv6=r=>e.check(my(F_,r)),e.e164=r=>e.check(yy(V_,r)),e.datetime=r=>e.check(x0(r)),e.date=r=>e.check(k0(r)),e.time=r=>e.check(I0(r)),e.duration=r=>e.check(S0(r))});function xm(e){return cI(Yl,e)}var ot=E("ZodStringFormat",(e,t)=>{nt.init(e,t),T_.init(e,t)}),E_=E("ZodEmail",(e,t)=>{tk.init(e,t),ot.init(e,t)});function oz(e){return Qg(E_,e)}var km=E("ZodGUID",(e,t)=>{Qx.init(e,t),ot.init(e,t)});function sz(e){return $f(km,e)}var Xi=E("ZodUUID",(e,t)=>{ek.init(e,t),ot.init(e,t)});function az(e){return ey(Xi,e)}function cz(e){return ty(Xi,e)}function uz(e){return ry(Xi,e)}function lz(e){return ny(Xi,e)}var Om=E("ZodURL",(e,t)=>{rk.init(e,t),ot.init(e,t)});function dz(e){return Tf(Om,e)}function pz(e){return Tf(Om,{protocol:ln.httpProtocol,hostname:ln.domain,...W.normalizeParams(e)})}var P_=E("ZodEmoji",(e,t)=>{nk.init(e,t),ot.init(e,t)});function fz(e){return iy(P_,e)}var C_=E("ZodNanoID",(e,t)=>{ik.init(e,t),ot.init(e,t)});function mz(e){return oy(C_,e)}var R_=E("ZodCUID",(e,t)=>{ok.init(e,t),ot.init(e,t)});function hz(e){return sy(R_,e)}var N_=E("ZodCUID2",(e,t)=>{sk.init(e,t),ot.init(e,t)});function gz(e){return ay(N_,e)}var M_=E("ZodULID",(e,t)=>{ak.init(e,t),ot.init(e,t)});function yz(e){return cy(M_,e)}var z_=E("ZodXID",(e,t)=>{ck.init(e,t),ot.init(e,t)});function _z(e){return uy(z_,e)}var j_=E("ZodKSUID",(e,t)=>{uk.init(e,t),ot.init(e,t)});function vz(e){return ly(j_,e)}var D_=E("ZodIPv4",(e,t)=>{mk.init(e,t),ot.init(e,t)});function bz(e){return dy(D_,e)}var j0=E("ZodMAC",(e,t)=>{gk.init(e,t),ot.init(e,t)});function wz(e){return lI(j0,e)}var U_=E("ZodIPv6",(e,t)=>{hk.init(e,t),ot.init(e,t)});function xz(e){return py(U_,e)}var L_=E("ZodCIDRv4",(e,t)=>{yk.init(e,t),ot.init(e,t)});function kz(e){return fy(L_,e)}var F_=E("ZodCIDRv6",(e,t)=>{_k.init(e,t),ot.init(e,t)});function Iz(e){return my(F_,e)}var B_=E("ZodBase64",(e,t)=>{bk.init(e,t),ot.init(e,t)});function Sz(e){return hy(B_,e)}var Z_=E("ZodBase64URL",(e,t)=>{wk.init(e,t),ot.init(e,t)});function Az(e){return gy(Z_,e)}var V_=E("ZodE164",(e,t)=>{xk.init(e,t),ot.init(e,t)});function Oz(e){return yy(V_,e)}var W_=E("ZodJWT",(e,t)=>{kk.init(e,t),ot.init(e,t)});function $z(e){return _y(W_,e)}var Ql=E("ZodCustomStringFormat",(e,t)=>{Ik.init(e,t),ot.init(e,t)});function Tz(e,t,r={}){return xl(Ql,e,t,r)}function Ez(e){return xl(Ql,"hostname",ln.hostname,e)}function Pz(e){return xl(Ql,"hex",ln.hex,e)}function Cz(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=ln[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return xl(Ql,n,i,t)}var ed=E("ZodNumber",(e,t)=>{Wg.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(n,i,o)=>KI(e,n,i,o),Am(e,"ZodNumber",{gt(n,i){return this.check(Ui(n,i))},gte(n,i){return this.check(Rr(n,i))},min(n,i){return this.check(Rr(n,i))},lt(n,i){return this.check(Di(n,i))},lte(n,i){return this.check(dn(n,i))},max(n,i){return this.check(dn(n,i))},int(n){return this.check(O_(n))},safe(n){return this.check(O_(n))},positive(n){return this.check(Ui(0,n))},nonnegative(n){return this.check(Rr(0,n))},negative(n){return this.check(Di(0,n))},nonpositive(n){return this.check(dn(0,n))},multipleOf(n,i){return this.check(Os(n,i))},step(n,i){return this.check(Os(n,i))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function D0(e){return gI(ed,e)}var Nc=E("ZodNumberFormat",(e,t)=>{Sk.init(e,t),ed.init(e,t)});function O_(e){return _I(Nc,e)}function Rz(e){return vI(Nc,e)}function Nz(e){return bI(Nc,e)}function Mz(e){return wI(Nc,e)}function zz(e){return xI(Nc,e)}var td=E("ZodBoolean",(e,t)=>{wf.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>GI(e,r,n,i)});function U0(e){return kI(td,e)}var rd=E("ZodBigInt",(e,t)=>{qg.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(n,i,o)=>HI(e,n,i,o),e.gte=(n,i)=>e.check(Rr(n,i)),e.min=(n,i)=>e.check(Rr(n,i)),e.gt=(n,i)=>e.check(Ui(n,i)),e.gte=(n,i)=>e.check(Rr(n,i)),e.min=(n,i)=>e.check(Rr(n,i)),e.lt=(n,i)=>e.check(Di(n,i)),e.lte=(n,i)=>e.check(dn(n,i)),e.max=(n,i)=>e.check(dn(n,i)),e.positive=n=>e.check(Ui(BigInt(0),n)),e.negative=n=>e.check(Di(BigInt(0),n)),e.nonpositive=n=>e.check(dn(BigInt(0),n)),e.nonnegative=n=>e.check(Rr(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Os(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function jz(e){return SI(rd,e)}var q_=E("ZodBigIntFormat",(e,t)=>{Ak.init(e,t),rd.init(e,t)});function Dz(e){return OI(q_,e)}function Uz(e){return $I(q_,e)}var L0=E("ZodSymbol",(e,t)=>{Ok.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>JI(e,r,n,i)});function Lz(e){return TI(L0,e)}var F0=E("ZodUndefined",(e,t)=>{$k.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>YI(e,r,n,i)});function Fz(e){return EI(F0,e)}var B0=E("ZodNull",(e,t)=>{Tk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>XI(e,r,n,i)});function Z0(e){return PI(B0,e)}var V0=E("ZodAny",(e,t)=>{Ek.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tS(e,r,n,i)});function Bz(){return CI(V0)}var W0=E("ZodUnknown",(e,t)=>{xf.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rS(e,r,n,i)});function Rc(){return Ef(W0)}var q0=E("ZodNever",(e,t)=>{kf.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eS(e,r,n,i)});function K_(e){return Pf(q0,e)}var K0=E("ZodVoid",(e,t)=>{Pk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>QI(e,r,n,i)});function Zz(e){return RI(K0,e)}var $m=E("ZodDate",(e,t)=>{Ck.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(n,i,o)=>nS(e,n,i,o),e.min=(n,i)=>e.check(Rr(n,i)),e.max=(n,i)=>e.check(dn(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Vz(e){return NI($m,e)}var G0=E("ZodArray",(e,t)=>{Rk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hS(e,r,n,i),e.element=t.element,Am(e,"ZodArray",{min(r,n){return this.check(Io(r,n))},nonempty(r){return this.check(Io(1,r))},max(r,n){return this.check(uc(r,n))},length(r,n){return this.check(lc(r,n))},unwrap(){return this.element}})});function Tm(e,t){return jI(G0,e,t)}function Wz(e){let t=e._zod.def.shape;return H_(Object.keys(t))}var Em=E("ZodObject",(e,t)=>{Nk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gS(e,r,n,i),W.defineLazy(e,"shape",()=>t.shape),Am(e,"ZodObject",{keyof(){return H_(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},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:K_()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return W.extend(this,r)},safeExtend(r){return W.safeExtend(this,r)},merge(r){return W.merge(this,r)},pick(r){return W.pick(this,r)},omit(r){return W.omit(this,r)},partial(...r){return W.partial(X_,this,r[0])},required(...r){return W.required(Y_,this,r[0])}})});function qz(e,t){let r={type:"object",shape:e??{},...W.normalizeParams(t)};return new Em(r)}function Kz(e,t){return new Em({type:"object",shape:e,catchall:K_(),...W.normalizeParams(t)})}function Gz(e,t){return new Em({type:"object",shape:e,catchall:Rc(),...W.normalizeParams(t)})}var Pm=E("ZodUnion",(e,t)=>{If.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sy(e,r,n,i),e.options=t.options});function G_(e,t){return new Pm({type:"union",options:e,...W.normalizeParams(t)})}var H0=E("ZodXor",(e,t)=>{Pm.init(e,t),Mk.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sy(e,r,n,i),e.options=t.options});function Hz(e,t){return new H0({type:"union",options:e,inclusive:!1,...W.normalizeParams(t)})}var J0=E("ZodDiscriminatedUnion",(e,t)=>{Pm.init(e,t),zk.init(e,t)});function Jz(e,t,r){return new J0({type:"union",options:t,discriminator:e,...W.normalizeParams(r)})}var X0=E("ZodIntersection",(e,t)=>{jk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yS(e,r,n,i)});function Y0(e,t){return new X0({type:"intersection",left:e,right:t})}var Q0=E("ZodTuple",(e,t)=>{Kg.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_S(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function eO(e,t,r){let n=t instanceof Ie,i=n?r:t,o=n?t:null;return new Q0({type:"tuple",items:e,rest:o,...W.normalizeParams(i)})}var Jl=E("ZodRecord",(e,t)=>{Dk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vS(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function tO(e,t,r){return!t||!t._zod?new Jl({type:"record",keyType:xm(),valueType:e,...W.normalizeParams(t)}):new Jl({type:"record",keyType:e,valueType:t,...W.normalizeParams(r)})}function Xz(e,t,r){let n=ft(e);return n._zod.values=void 0,new Jl({type:"record",keyType:n,valueType:t,...W.normalizeParams(r)})}function Yz(e,t,r){return new Jl({type:"record",keyType:e,valueType:t,mode:"loose",...W.normalizeParams(r)})}var rO=E("ZodMap",(e,t)=>{Uk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fS(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Li(...r)),e.nonempty=r=>e.check(Li(1,r)),e.max=(...r)=>e.check($s(...r)),e.size=(...r)=>e.check(cc(...r))});function Qz(e,t,r){return new rO({type:"map",keyType:e,valueType:t,...W.normalizeParams(r)})}var nO=E("ZodSet",(e,t)=>{Lk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mS(e,r,n,i),e.min=(...r)=>e.check(Li(...r)),e.nonempty=r=>e.check(Li(1,r)),e.max=(...r)=>e.check($s(...r)),e.size=(...r)=>e.check(cc(...r))});function ej(e,t){return new nO({type:"set",valueType:e,...W.normalizeParams(t)})}var Xl=E("ZodEnum",(e,t)=>{Fk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(n,i,o)=>iS(e,n,i,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Xl({...t,checks:[],...W.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Xl({...t,checks:[],...W.normalizeParams(i),entries:o})}});function H_(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Xl({type:"enum",entries:r,...W.normalizeParams(t)})}function tj(e,t){return new Xl({type:"enum",entries:e,...W.normalizeParams(t)})}var iO=E("ZodLiteral",(e,t)=>{Bk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>oS(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function rj(e,t){return new iO({type:"literal",values:Array.isArray(e)?e:[e],...W.normalizeParams(t)})}var oO=E("ZodFile",(e,t)=>{Zk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cS(e,r,n,i),e.min=(r,n)=>e.check(Li(r,n)),e.max=(r,n)=>e.check($s(r,n)),e.mime=(r,n)=>e.check(gl(Array.isArray(r)?r:[r],n))});function nj(e){return DI(oO,e)}var sO=E("ZodTransform",(e,t)=>{Vk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pS(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xs(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(W.issue(o,r.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(W.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function J_(e){return new sO({type:"transform",transform:e})}var X_=E("ZodOptional",(e,t)=>{ac.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ay(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Im(e){return new X_({type:"optional",innerType:e})}var aO=E("ZodExactOptional",(e,t)=>{Wk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ay(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function cO(e){return new aO({type:"optional",innerType:e})}var uO=E("ZodNullable",(e,t)=>{qk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Sm(e){return new uO({type:"nullable",innerType:e})}function ij(e){return Im(Sm(e))}var lO=E("ZodDefault",(e,t)=>{Kk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dO(e,t){return new lO({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():W.shallowClone(t)}})}var pO=E("ZodPrefault",(e,t)=>{Gk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>kS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function fO(e,t){return new pO({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():W.shallowClone(t)}})}var Y_=E("ZodNonOptional",(e,t)=>{Hk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function mO(e,t){return new Y_({type:"nonoptional",innerType:e,...W.normalizeParams(t)})}var hO=E("ZodSuccess",(e,t)=>{Jk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function oj(e){return new hO({type:"success",innerType:e})}var gO=E("ZodCatch",(e,t)=>{Xk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>IS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yO(e,t){return new gO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var _O=E("ZodNaN",(e,t)=>{Yk.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sS(e,r,n,i)});function sj(e){return zI(_O,e)}var Cm=E("ZodPipe",(e,t)=>{Gg.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>SS(e,r,n,i),e.in=t.in,e.out=t.out});function $_(e,t){return new Cm({type:"pipe",in:e,out:t})}var Rm=E("ZodCodec",(e,t)=>{Cm.init(e,t),Sf.init(e,t)});function aj(e,t,r){return new Rm({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function cj(e){let t=e._zod.def;return new Rm({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var vO=E("ZodPreprocess",(e,t)=>{Cm.init(e,t),Qk.init(e,t)}),bO=E("ZodReadonly",(e,t)=>{eI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>AS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function wO(e){return new bO({type:"readonly",innerType:e})}var xO=E("ZodTemplateLiteral",(e,t)=>{tI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>aS(e,r,n,i)});function uj(e,t){return new xO({type:"template_literal",parts:e,...W.normalizeParams(t)})}var kO=E("ZodLazy",(e,t)=>{iI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$S(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function IO(e){return new kO({type:"lazy",getter:e})}var SO=E("ZodPromise",(e,t)=>{nI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>OS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function lj(e){return new SO({type:"promise",innerType:e})}var AO=E("ZodFunction",(e,t)=>{rI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dS(e,r,n,i)});function dj(e){return new AO({type:"function",input:Array.isArray(e?.input)?eO(e?.input):e?.input??Tm(Rc()),output:e?.output??Rc()})}var Nm=E("ZodCustom",(e,t)=>{oI.init(e,t),Ee.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lS(e,r,n,i)});function pj(e){let t=new lt({check:"custom"});return t._zod.check=e,t}function fj(e,t){return UI(Nm,e??(()=>!0),t)}function OO(e,t={}){return LI(Nm,e,t)}function $O(e,t){return FI(e,t)}var mj=BI,hj=ZI;function gj(e,t={}){let r=new Nm({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...W.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var yj=(...e)=>VI({Codec:Rm,Boolean:td,String:Yl},...e);function _j(e){let t=IO(()=>G_([xm(e),D0(),U0(),Z0(),Tm(t),tO(xm(),t)]));return t}function vj(e,t){return new vO({type:"pipe",in:J_(e),out:t})}var Sq={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Aq(e){Ot({customError:e})}function Oq(){return Ot().customError}var TO;TO||(TO={});var te={...bm,...x_,iso:Hl},$q=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Tq(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Eq(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function bj(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return te.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return te.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let o=Eq(i,t),s=xr(o,t);return t.refs.set(i,s),t.processing.delete(i),s}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return te.null();if(i.length===0)return te.never();if(i.length===1)return te.literal(i[0]);if(i.every(s=>typeof s=="string"))return te.enum(i);let o=i.map(s=>te.literal(s));return o.length<2?o[0]:te.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return te.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(o=>{let s={...e,type:o};return bj(s,t)});return i.length===0?te.never():i.length===1?i[0]:te.union(i)}if(!r)return te.any();let n;switch(r){case"string":{let i=te.string();if(e.format){let o=e.format;o==="email"?i=i.check(te.email()):o==="uri"||o==="uri-reference"?i=i.check(te.url()):o==="uuid"||o==="guid"?i=i.check(te.uuid()):o==="date-time"?i=i.check(te.iso.datetime()):o==="date"?i=i.check(te.iso.date()):o==="time"?i=i.check(te.iso.time()):o==="duration"?i=i.check(te.iso.duration()):o==="ipv4"?i=i.check(te.ipv4()):o==="ipv6"?i=i.check(te.ipv6()):o==="mac"?i=i.check(te.mac()):o==="cidr"?i=i.check(te.cidrv4()):o==="cidr-v6"?i=i.check(te.cidrv6()):o==="base64"?i=i.check(te.base64()):o==="base64url"?i=i.check(te.base64url()):o==="e164"?i=i.check(te.e164()):o==="jwt"?i=i.check(te.jwt()):o==="emoji"?i=i.check(te.emoji()):o==="nanoid"?i=i.check(te.nanoid()):o==="cuid"?i=i.check(te.cuid()):o==="cuid2"?i=i.check(te.cuid2()):o==="ulid"?i=i.check(te.ulid()):o==="xid"?i=i.check(te.xid()):o==="ksuid"&&(i=i.check(te.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?te.number().int():te.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=te.boolean();break}case"null":{n=te.null();break}case"object":{let i={},o=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(o)){let l=xr(u,t);i[c]=s.has(c)?l:l.optional()}if(e.propertyNames){let c=xr(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?xr(e.additionalProperties,t):te.any();if(Object.keys(i).length===0){n=te.record(c,u);break}let l=te.object(i).passthrough(),d=te.looseRecord(c,u);n=te.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let f=xr(c[p],t),m=te.string().regex(new RegExp(p));l.push(te.looseRecord(m,f))}let d=[];if(Object.keys(i).length>0&&d.push(te.object(i).passthrough()),d.push(...l),d.length===0)n=te.object({}).passthrough();else if(d.length===1)n=d[0];else{let p=te.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=te.intersection(p,d[f]);n=p}break}let a=te.object(i);e.additionalProperties===!1?n=a.strict():typeof e.additionalProperties=="object"?n=a.catchall(xr(e.additionalProperties,t)):n=a.passthrough();break}case"array":{let i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){let s=i.map(c=>xr(c,t)),a=o&&typeof o=="object"&&!Array.isArray(o)?xr(o,t):void 0;a?n=te.tuple(s).rest(a):n=te.tuple(s),typeof e.minItems=="number"&&(n=n.check(te.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(te.maxLength(e.maxItems)))}else if(Array.isArray(o)){let s=o.map(c=>xr(c,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?xr(e.additionalItems,t):void 0;a?n=te.tuple(s).rest(a):n=te.tuple(s),typeof e.minItems=="number"&&(n=n.check(te.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(te.maxLength(e.maxItems)))}else if(o!==void 0){let s=xr(o,t),a=te.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=te.array(te.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function xr(e,t){if(typeof e=="boolean")return e?te.any():te.never();let r=bj(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>xr(u,t)),c=te.union(a);r=n?te.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>xr(u,t)),c=te.xor(a);r=n?te.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:te.any();else{let a=n?r:xr(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)a=te.intersection(a,xr(e.allOf[u],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=te.nullable(r)),e.readOnly===!0&&(r=te.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in e&&(i[a]=e[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in e&&(i[a]=e[a]);for(let a of Object.keys(e))$q.has(a)||(i[a]=e[a]);return Object.keys(i).length>0&&t.registry.add(r,i),e.description&&(r=r.describe(e.description)),r}function wj(e,t){if(typeof e=="boolean")return e?te.any():te.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=Tq(r,t?.defaultTarget),i=r.$defs||r.definitions||{},o={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Qe};return xr(r,o)}var EO={};Kn(EO,{bigint:()=>Nq,boolean:()=>Rq,date:()=>Mq,number:()=>Cq,string:()=>Pq});function Pq(e){return uI(Yl,e)}function Cq(e){return yI(ed,e)}function Rq(e){return II(td,e)}function Nq(e){return AI(rd,e)}function Mq(e){return MI($m,e)}Ot(Hg());var xj=F({BaseToolkit:()=>zq,DynamicStructuredTool:()=>kj,DynamicTool:()=>CO,StructuredTool:()=>Mm,Tool:()=>PO,ToolInputParsingException:()=>qu,isLangChainTool:()=>zo,isRunnableToolLike:()=>_m,isStructuredTool:()=>ym,isStructuredToolParams:()=>vm,tool:()=>Bs}),Mm=class extends t_{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let r,n=Ue(Kt(this.defaultConfig,t));return Wu(e)?(r=e.args,n={...n,toolCall:e}):r=e,this.call(r,n)}async call(e,t,r){let n=Wu(e)?e.args:e,i;if(Ht(this.schema))try{i=await Cs(this.schema,n)}catch(f){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
267
|
-
Details: ${f.message}`),Ry(f)&&(m=`${m}
|
|
268
|
-
|
|
269
|
-
${Y.prettifyError(f)}`),new qu(m,JSON.stringify(e))}else{let f=dt(n,this.schema);if(!f.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
270
|
-
Details: ${f.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
|
|
271
|
-
`)}`),new qu(m,JSON.stringify(e))}i=n}let o=Ku(t),s=mr.configure(o.callbacks,this.callbacks,o.tags||r,this.tags,o.metadata,this.metadata,{verbose:this.verbose}),a;Wu(e)&&(a=e.id),!a&&hP(o)&&(a=o.toolCall.id);let c=await s?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),o.runId,void 0,void 0,void 0,o.runName,a);delete o.runId;let u;try{let f=await this._call(i,c,o);u=vA(f)?await HN(f,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):f}catch(f){throw await c?.handleToolError(f),f}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
|
|
272
|
-
Result: ${JSON.stringify(u)}`);else l=u;let p=Dq({content:l,artifact:d,toolCallId:a,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(p),p}},PO=class extends Mm{schema=nr.object({input:nr.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},CO=class extends PO{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=Ku(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},kj=class extends Mm{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let n=Ku(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},zq=class{getTools(){return this.tools}};function Bs(e,t){let r=Sl(t.schema),n=Ml(t.schema);if(!t.schema||r||n)return new CO({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(s,a,c)=>new Promise((u,l)=>{let d=ze(c,{callbacks:a?.getChild()});ut.runWithConfig(Or(d),async()=>{try{u(e(s,d))}catch(p){l(p)}})})});let i=t.schema,o=t.description??t.schema.description??`${t.name} tool`;return new kj({...t,description:o,schema:i,func:async(s,a,c)=>new Promise((u,l)=>{let d,p=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{p(),l(vs(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let f=ze(c,{callbacks:a?.getChild()});ut.runWithConfig(Or(f),async()=>{try{let m=await e(s,f);if(vA(m)){u(m);return}if(c?.signal?.aborted){p();return}p(),u(m)}catch(m){p(),l(m)}})})})}function jq(e){return typeof e=="object"&&e!==null&&"type"in e}function Dq(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!eg(t)?typeof t=="string"||Array.isArray(t)&&t.every(jq)?new qt({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new qt({status:"success",content:Uq(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function Uq(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var Ij=F({RunCollectorCallbackHandler:()=>Lq}),Lq=class extends bn{name="run_collector";exampleId;tracedRuns;constructor({exampleId:e}={}){super({_awaitHandler:!0}),this.exampleId=e,this.tracedRuns=[]}async persistRun(e){let t={...e};t.reference_example_id=this.exampleId,this.tracedRuns.push(t)}};var Sj=F({});var Aj=F({chunkArray:()=>Q_}),Q_=(e,t)=>e.reduce((r,n,i)=>{let o=Math.floor(i/t);return r[o]=(r[o]||[]).concat([n]),r},[]);var Oj=F({context:()=>Fq});function Fq(e,...t){let r=e.raw,n="";for(let i=0;i<r.length;i++){let o=r[i].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(n+=o,i<t.length){let s=Bq(t[i],n);n+=typeof s=="string"?s:JSON.stringify(s)}}return n=Zq(n),n=n.trim(),n=n.replace(/\\n/g,`
|
|
273
|
-
`),n}function Bq(e,t){if(typeof e!="string"||!e.includes(`
|
|
274
|
-
`))return e;let r=t.slice(t.lastIndexOf(`
|
|
275
|
-
`)+1).match(/^(\s+)/);if(r){let n=r[1];return e.replace(/\n/g,`
|
|
276
|
-
${n}`)}return e}function Zq(e){let t=e.split(`
|
|
277
|
-
`),r=null;for(let n of t){let i=n.match(/^(\s+)\S+/);if(i){let o=i[1].length;r===null?r=o:r=Math.min(r,o)}}return r===null?e:t.map(n=>n[0]===" "||n[0]===" "?n.slice(r):n).join(`
|
|
278
|
-
`)}var $j=F({EventStreamContentType:()=>Vq,convertEventStreamToIterableReadableDataStream:()=>qq,getBytes:()=>Tj,getLines:()=>Ej,getMessages:()=>Pj}),Vq="text/event-stream";async function Tj(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let n=await r.read();if(n.done){t(new Uint8Array,!0);break}t(n.value)}}else try{for await(let r of e)t(new Uint8Array(r));t(new Uint8Array,!0)}catch(r){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${r.message}`].join(`
|
|
279
|
-
`))}}function Ej(e){let t,r,n,i=!1;return function(s,a){if(a){e(s,0,!0);return}t===void 0?(t=s,r=0,n=-1):t=Wq(t,s);let c=t.length,u=0;for(;r<c;){i&&(t[r]===10&&(u=++r),i=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case 58:n===-1&&(n=r-u);break;case 13:i=!0;case 10:l=r;break}if(l===-1)break;e(t.subarray(u,l),n),u=r,n=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function Pj(e,t,r){let n=RO(),i=new TextDecoder;return function(s,a,c){if(c){Kq(n)||(e?.(n),n=RO());return}if(s.length===0)e?.(n),n=RO();else if(a>0){let u=i.decode(s.subarray(0,a)),l=a+(s[a+1]===32?2:1),d=i.decode(s.subarray(l));switch(u){case"data":n.data=n.data?n.data+`
|
|
280
|
-
`+d:d;break;case"event":n.event=d;break;case"id":t?.(n.id=d);break;case"retry":{let p=parseInt(d,10);Number.isNaN(p)||r?.(n.retry=p);break}}}}}function Wq(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function RO(){return{data:"",event:"",id:"",retry:void 0}}function qq(e,t){let r=new ReadableStream({async start(n){let i=Pj(s=>{if(s.event==="error")throw new Error(s.data??"Unspecified event streaming error.");s.event==="metadata"?t?.(s):s.data&&n.enqueue(s.data)});await Tj(e,Ej((s,a,c)=>{i(s,a,c),c&&n.close()}))}});return jt.fromReadableStream(r)}function Kq(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var Cj=F({});var Rj=F({convertToOpenAIFunction:()=>Nj,convertToOpenAITool:()=>NO,isLangChainTool:()=>zo,isRunnableToolLike:()=>_m,isStructuredTool:()=>ym,isStructuredToolParams:()=>vm});function Nj(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:ht(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function NO(e,t){let r=typeof t=="number"?void 0:t,n;return zo(e)?n={type:"function",function:Nj(e)}:n=e,r?.strict!==void 0&&(n.function.strict=r.strict),n}var Mj=F({DEFAULT_LANGSMITH_GATEWAY:()=>zj,resolveLangSmithGatewayConfig:()=>MO}),Gq="LANGSMITH_GATEWAY",Hq="LANGSMITH_GATEWAY_API_KEY",Jq="LANGSMITH_API_KEY",zj="https://gateway.smith.langchain.com",Xq=["true","1","yes"],Yq=["false","0","no"];function Qq(e){let t=Ct(Gq);if(!(!t||Yq.includes(t.toLowerCase())))return`${Xq.includes(t.toLowerCase())?zj:t.replace(/\/+$/,"")}/${e}`}function MO({baseURL:e,providerPath:t}){if(e!==void 0)return{baseURL:e};let r=Qq(t);return r===void 0?{}:{baseURL:r,apiKey:Ct(Hq)||Ct(Jq)}}function ev(e,t){let r=0,n=0,i=0;for(let o=0;o<e.length;o++)r+=e[o]*t[o],n+=e[o]*e[o],i+=t[o]*t[o];return r/(Math.sqrt(n)*Math.sqrt(i))}function jj(e,t){let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}function eK(e,t){let r=0;for(let n=0;n<e.length;n++)r+=(e[n]-t[n])*(e[n]-t[n]);return r}function Dj(e,t){return Math.sqrt(eK(e,t))}var Uj=F({cosineSimilarity:()=>zO,euclideanDistance:()=>nK,innerProduct:()=>rK,matrixFunc:()=>tv,maximalMarginalRelevance:()=>iK,normalize:()=>tK});function tv(e,t,r){if(e.length===0||e[0].length===0||t.length===0||t[0].length===0)return[[]];if(e[0].length!==t[0].length)throw new Error(`Number of columns in X and Y must be the same. X has shape ${[e.length,e[0].length]} and Y has shape ${[t.length,t[0].length]}.`);return e.map(n=>t.map(i=>r(n,i)).map(i=>Number.isNaN(i)?0:i))}function tK(e,t=!1){let r=oK(e);return e.map(n=>n.map(i=>t?1-i/r:i/r))}function zO(e,t){return tv(e,t,ev)}function rK(e,t){return tv(e,t,jj)}function nK(e,t){return tv(e,t,Dj)}function iK(e,t,r=.5,n=4){if(Math.min(n,t.length)<=0)return[];let i=zO(Array.isArray(e[0])?e:[e],t)[0],o=Lj(i).maxIndex,s=[t[o]],a=[o];for(;a.length<Math.min(n,t.length);){let c=-1/0,u=-1,l=zO(t,s);i.forEach((d,p)=>{if(a.includes(p))return;let f=Math.max(...l[p]),m=r*d-(1-r)*f;m>c&&(c=m,u=p)}),s.push(t[u]),a.push(u)}return a}function Lj(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let n=1;n<e.length;n+=1)e[n]>t&&(r=n,t=e[n]);return{maxIndex:r,maxValue:t}}function oK(e){return e.reduce((t,r)=>Math.max(t,Lj(r).maxValue),0)}var Fj=F({isCloudMetadata:()=>jO,isLocalhost:()=>DO,isPrivateIp:()=>qj,isSafeUrl:()=>fK,isSameOrigin:()=>mK,validateSafeUrl:()=>Kj}),sK=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8","169.254.0.0/16","0.0.0.0/8","::1/128","fc00::/7","fe80::/10","ff00::/8"],aK=["169.254.169.254","169.254.170.2","100.100.100.200"],cK=["metadata.google.internal","metadata","instance-data"],uK=["localhost","localhost.localdomain"],lK=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function Bj(e){return lK.test(e)}function rv(e){return Wj(e)!==null}function Zj(e){return Bj(e)||rv(e)}function Vj(e){if(Bj(e))return e.split(".").map(t=>parseInt(t,10));if(rv(e)){let t=Wj(e);if(!t)return null;let r=t.split(":"),n=[];for(let i of r)n.push(parseInt(i,16));return n}return null}function Wj(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let n=t.split("::");if(n.length>2)return null;let[i,o]=n,s=i?i.split(":"):[],a=o?o.split(":"):[],c=8-(s.length+a.length);if(c<0)return null;let u=Array(c).fill("0");t=[...s,...u,...a].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let n of r)if(n.length===0||n.length>4||!/^[0-9a-fA-F]+$/.test(n))return null;return r.map(n=>n.padStart(4,"0").toLowerCase()).join(":")}function dK(e){let[t,r]=e.split("/");if(!t||!r)return null;let n=Vj(t);if(!n)return null;let i=parseInt(r,10);if(isNaN(i))return null;let o=rv(t);return o&&i>128||!o&&i>32?null:{addr:n,prefixLen:i,isIpv6:o}}function pK(e,t){let r=Vj(e);if(!r)return!1;let n=dK(t);if(!n)return!1;let i=rv(e);if(i!==n.isIpv6)return!1;let{addr:o,prefixLen:s}=n;if(i)for(let a=0;a<Math.ceil(s/16);a++){let c=65535<<16-Math.min(16,s-a*16)&65535;if((r[a]&c)!==(o[a]&c))return!1}else for(let a=0;a<Math.ceil(s/8);a++){let c=255<<8-Math.min(8,s-a*8)&255;if((r[a]&c)!==(o[a]&c))return!1}return!0}function qj(e){if(!Zj(e))return!1;for(let t of sK)if(pK(e,t))return!0;return!1}function jO(e,t){if(aK.includes(t||""))return!0;let r=e.toLowerCase();return!!cK.includes(r)}function DO(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let r=e.toLowerCase();return!!uK.includes(r)}function Kj(e,t){let r=t?.allowPrivate??!1,n=t?.allowHttp??!1;try{let i;try{i=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let o=i.hostname;if(!o)throw new Error("URL missing hostname.");if(jO(o))throw new Error(`URL points to cloud metadata endpoint: ${o}`);if(DO(o)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}let s=i.protocol;if(s!=="http:"&&s!=="https:")throw new Error(`Invalid URL scheme: ${s}. Only http and https are allowed.`);if(s==="http:"&&!n)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(Zj(o)){let a=o;if(DO(o,a)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}if(jO(o,a))throw new Error(`URL resolves to cloud metadata IP: ${a} (${o})`);if(qj(a)&&!r)throw new Error(`URL resolves to private IP: ${a} (${o}). Set allowPrivate: true to allow.`);return e}return e}catch(i){throw i&&typeof i=="object"&&"message"in i?i:new Error(`URL validation failed: ${i}`)}}function fK(e,t){try{return Kj(e,t),!0}catch{return!1}}function mK(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var Gj=F({SaveableVectorStore:()=>hK,VectorStore:()=>iv,VectorStoreRetriever:()=>nv}),nv=class extends lm{static lc_name(){return"VectorStoreRetriever"}get lc_namespace(){return["langchain_core","vectorstores"]}vectorStore;k=4;searchType="similarity";searchKwargs;filter;_vectorstoreType(){return this.vectorStore._vectorstoreType()}constructor(e){super(e),this.vectorStore=e.vectorStore,this.k=e.k??this.k,this.searchType=e.searchType??this.searchType,this.filter=e.filter,e.searchType==="mmr"&&(this.searchKwargs=e.searchKwargs)}async _getRelevantDocuments(e,t){if(this.searchType==="mmr"){if(typeof this.vectorStore.maxMarginalRelevanceSearch!="function")throw new Error(`The vector store backing this retriever, ${this._vectorstoreType()} does not support max marginal relevance search.`);return this.vectorStore.maxMarginalRelevanceSearch(e,{k:this.k,filter:this.filter,...this.searchKwargs},t?.getChild("vectorstore"))}return this.vectorStore.similaritySearch(e,this.k,this.filter,t?.getChild("vectorstore"))}async addDocuments(e,t){return this.vectorStore.addDocuments(e,t)}},iv=class extends Ar{lc_namespace=["langchain","vectorstores",this._vectorstoreType()];embeddings;constructor(e,t){super(t),this.embeddings=e}async delete(e){throw new Error("Not implemented.")}async similaritySearch(e,t=4,r=void 0,n=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(i=>i[0])}async similaritySearchWithScore(e,t=4,r=void 0,n=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,n){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,r,n,i,o){if(typeof e=="number")return new nv({vectorStore:this,k:e,filter:t,tags:[...n??[],this._vectorstoreType()],metadata:i,verbose:o,callbacks:r});{let s={vectorStore:this,k:e?.k,filter:e?.filter,tags:[...e?.tags??[],this._vectorstoreType()],metadata:e?.metadata,verbose:e?.verbose,callbacks:e?.callbacks,searchType:e?.searchType};return e?.searchType==="mmr"?new nv({...s,searchKwargs:e.searchKwargs}):new nv({...s})}}},hK=class extends iv{static load(e,t){throw new Error("Not implemented")}};var Hj=class extends Hi{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Re(t.stop[0]),text:t.stop[0]}]};let n=e.map(i=>typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2)).join(`
|
|
281
|
-
`);return await r?.handleLLMNewToken(n),{generations:[{message:new Re(n),text:n}],llmOutput:{}}}},Jj=class Xj extends Hi{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:n=[],toolStyle:i="openai",thrownErrorString:o,...s}){super(s),this.sleep=t,this.responses=r,this.chunks=n,this.toolStyle=i,this.thrownErrorString=o}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],n=r.map(s=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:s.name,description:s.description,parameters:ht(s.schema)}};case"anthropic":return{name:s.name,description:s.description,input_schema:ht(s.schema)};case"bedrock":return{toolSpec:{name:s.name,description:s.description,inputSchema:ht(s.schema)}};case"google":return{name:s.name,description:s.description,parameters:ht(s.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new Xj({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return o.tools=r,o.withConfig({tools:i})}async _generate(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Re({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let s of this.chunks){let a=new un({message:new ct({content:s.content,tool_calls:s.tool_calls,additional_kwargs:s.additional_kwargs??{}}),text:s.content?.toString()??""});if(r.signal?.aborted)break;yield a,await n?.handleLLMNewToken(s.content,void 0,void 0,void 0,void 0,{chunk:a})}return}let i=this.responses?.[0]??new Re(typeof t[0].content=="string"?t[0].content:""),o=typeof i.content=="string"?i.content:"";for(let s of o){await new Promise(c=>setTimeout(c,this.sleep));let a=new un({message:new ct({content:s}),text:s});if(r.signal?.aborted)break;yield a,await n?.handleLLMNewToken(s,void 0,void 0,void 0,void 0,{chunk:a})}}},Yj=class Qj extends Hi{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:r,sleep:n,emitCustomEvent:i,generationInfo:o}=t;this.responses=r,this.sleep=n,this.emitCustomEvent=i??this.emitCustomEvent,this.generationInfo=o}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,n){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let i=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(i)],llmOutput:{}}}}_formatGeneration(t){return{message:new Re(t),text:t}}async*_streamResponseChunks(t,r,n){let i=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0});let o=[...i];for(let s=0;s<o.length;s++){let a=o[s],c=s===o.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let u=this._createResponseChunk(a,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield u,n?.handleLLMNewToken(a)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,r){return new un({message:new ct({content:t}),text:t,generationInfo:r})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let r=[...this.tools,...t],n=r.map(s=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:s.name,description:s.description,parameters:ht(s.schema)}};case"anthropic":return{name:s.name,description:s.description,input_schema:ht(s.schema)};case"bedrock":return{toolSpec:{name:s.name,description:s.description,inputSchema:ht(s.schema)}};case"google":return{name:s.name,description:s.description,parameters:ht(s.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new Qj({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return o.tools=r,o.toolStyle=this.toolStyle,o.i=this.i,o.withConfig({tools:i})}withStructuredOutput(t,r){return ir.from(async n=>{let i=await this.invoke(n);if(i.tool_calls?.[0]?.args)return i.tool_calls[0].args;if(typeof i.content=="string")return JSON.parse(i.content);throw new Error("No structured output found")})}};var eD=class extends zl{vectorSize;constructor(e){super(e??{}),this.vectorSize=e?.vectorSize??4}async embedDocuments(e){return Promise.all(e.map(t=>this.embedQuery(t)))}async embedQuery(e){let t=e;t=t.toLowerCase().replaceAll(/[^a-z ]/g,"");let r=t.length%this.vectorSize,n=r===0?0:this.vectorSize-r,i=t.length+n;t=t.padEnd(i," ");let o=t.length/this.vectorSize,s=[];for(let a=0;a<t.length;a+=o)s.push(t.slice(a,a+o));return s.map(a=>{let c=0;for(let u=0;u<a.length;u+=1)c+=a===" "?0:a.charCodeAt(u);return c%26/26})}},tD=class extends zl{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}};var rD=class extends c_{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let n=this.response??e;return await r?.handleLLMNewToken(n),n}},nD=class extends c_{sleep=50;responses;thrownErrorString;constructor(e){super(e),this.sleep=e.sleep??this.sleep,this.responses=e.responses,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let t=this.responses?.[0];return this.responses=this.responses?.slice(1),t??e}async*_streamResponseChunks(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let n=this.responses?.[0];this.responses=this.responses?.slice(1);for(let i of n??e)await new Promise(o=>setTimeout(o,this.sleep)),yield{text:i,generationInfo:{}},await r?.handleLLMNewToken(i)}};var iD=class extends SA{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async addUserMessage(e){this.messages.push(new Qt(e))}async addAIMessage(e){this.messages.push(new Re(e))}async clear(){this.messages=[]}},oD=class extends Gy{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},sD=class extends bn{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var aD=class extends oi{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var cD=class extends lm{lc_namespace=["test","fake"];output=[new mn({pageContent:"foo"}),new mn({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var uD=class extends he{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var lD=class extends Mm{name;description;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.schema=e.schema}async _call(e,t){return JSON.stringify(e)}};var dD=class extends bn{runPromiseResolver;runPromise;name="single_run_extractor";constructor(){super(),this.runPromise=new Promise(e=>{this.runPromiseResolver=e})}async persistRun(e){this.runPromiseResolver(e)}async extract(){return this.runPromise}};var pD=class fD extends iv{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...n}={}){super(t,n),this.similarity=r??ev}async addDocuments(t){let r=t.map(({pageContent:n})=>n);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let n=t.map((i,o)=>({content:r[o].pageContent,embedding:i,metadata:r[o].metadata}));this.memoryVectors=this.memoryVectors.concat(n)}async similaritySearchVectorWithScore(t,r,n){let i=s=>n?n(new mn({metadata:s.metadata,pageContent:s.content})):!0,o=this.memoryVectors.filter(i);return o.map((s,a)=>({similarity:this.similarity(t,s.embedding),index:a})).sort((s,a)=>s.similarity>a.similarity?-1:0).slice(0,r).map(s=>[new mn({metadata:o[s.index].metadata,pageContent:o[s.index].content}),s.similarity])}static async fromTexts(t,r,n,i){let o=[];for(let s=0;s<t.length;s+=1){let a=Array.isArray(r)?r[s]:r,c=new mn({pageContent:t[s],metadata:a});o.push(c)}return fD.fromDocuments(o,n,i)}static async fromDocuments(t,r,n){let i=new this(r,n);return await i.addDocuments(t),i}static async fromExistingIndex(t,r){return new this(t,r)}};var mD=F({FakeChatMessageHistory:()=>iD,FakeChatModel:()=>Hj,FakeEmbeddings:()=>tD,FakeLLM:()=>rD,FakeListChatMessageHistory:()=>oD,FakeListChatModel:()=>Yj,FakeRetriever:()=>cD,FakeRunnable:()=>uD,FakeSplitIntoListParser:()=>aD,FakeStreamingChatModel:()=>Jj,FakeStreamingLLM:()=>nD,FakeTool:()=>lD,FakeTracer:()=>sD,FakeVectorStore:()=>pD,SingleRunExtractor:()=>dD,SyntheticEmbeddings:()=>eD,asAsyncIterable:()=>y_,openAIReasoningTextChunks:()=>v_,openAITextOnlyChunks:()=>gm,openAITextOnlyChunksWithUsage:()=>__,openAIToolCallChunks:()=>b_,sseResponseFromOpenAIChunks:()=>w_,streamMatchers:()=>Gl});var hD=F({agents:()=>iC,caches:()=>sC,callbacks__base:()=>TP,callbacks__manager:()=>zP,callbacks__promises:()=>MP,chat_history:()=>h1,document_loaders__base:()=>_1,document_loaders__langsmith:()=>v1,documents:()=>y1,embeddings:()=>b1,errors:()=>YE,example_selectors:()=>T1,index:()=>nC,indexing:()=>C1,language_models__base:()=>L1,language_models__chat_models:()=>yM,language_models__compat:()=>mM,language_models__event:()=>vM,language_models__llms:()=>bM,language_models__openai_completions_stream:()=>_M,language_models__profile:()=>wM,language_models__stream:()=>cM,language_models__structured_output:()=>sM,load__serializable:()=>GE,memory:()=>xM,messages:()=>m1,messages__tool:()=>pP,output_parsers:()=>iM,output_parsers__openai_functions:()=>SM,output_parsers__openai_tools:()=>AM,outputs:()=>bC,prompt_values:()=>R1,prompts:()=>DM,retrievers:()=>LM,retrievers__document_compressors:()=>UM,runnables:()=>q1,runnables__graph:()=>ZN,singletons:()=>jP,stores:()=>FM,structured_query:()=>GM,testing:()=>rz,tools:()=>xj,tracers__base:()=>CP,tracers__console:()=>RP,tracers__log_stream:()=>vC,tracers__run_collector:()=>Ij,tracers__tracer_langchain:()=>NP,types__stream:()=>Sj,utils__async_caller:()=>AC,utils__chunk_array:()=>Aj,utils__context:()=>Oj,utils__env:()=>JE,utils__event_source_parse:()=>$j,utils__format:()=>Cj,utils__function_calling:()=>Rj,utils__gateway:()=>Mj,utils__hash:()=>oC,utils__json_patch:()=>K1,utils__json_schema:()=>zN,utils__math:()=>Uj,utils__ssrf:()=>Fj,utils__standard_schema:()=>CC,utils__stream:()=>lC,utils__testing:()=>mD,utils__tiktoken:()=>D1,utils__types:()=>oM,utils__uuid:()=>FE,vectorstores:()=>Gj});var gK=50;function yK(e){let t={};for(let r=e;r&&r.prototype;r=Object.getPrototypeOf(r))Object.assign(t,Reflect.get(r.prototype,"lc_aliases"));return Object.entries(t).reduce((r,[n,i])=>(r[i]=n,r),{})}async function ov(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:n,secretsMap:i,secretsFromEnv:o,path:s,depth:a,maxDepth:c}=this,u=s.join(".");if(a>c)throw new Error(`Maximum recursion depth (${c}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);if(typeof e!="object"||e==null)return e;if(Array.isArray(e))return Promise.all(e.map((p,f)=>ov.call({...this,path:[...s,`${f}`],depth:a+1},p)));let l=e;if(qE(l))return KE(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[p]=l.id;if(p in i)return i[p];if(o){let f=Ct(p);if(f)return f}throw new Error(`Missing secret "${p}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let p=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${p}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let p=l,f=JSON.stringify(p),[m,...h]=p.id.slice().reverse(),y=h.reverse(),w={langchain_core:hD,langchain:n},_=null,b=[y.join("/")];y[0]==="langchain_community"&&b.push(["langchain",...y.slice(1)].join("/"));let I=b.find(C=>C in t);if(rC.concat(r).includes(y.join("/"))||I)if(I!==void 0)_=await t[I];else throw new Error(`Missing key "${y.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let C;if(y[0]==="langchain"||y[0]==="langchain_core")C=w[y[0]],y.shift();else throw new Error(`Invalid namespace: ${u} -> ${f}`);if(y.length===0)throw new Error(`Invalid namespace: ${u} -> ${f}`);let x;do{if(x=y.join("__"),x in C)break;y.pop()}while(y.length>0);x in C&&(_=C[x])}if(typeof _!="object"||_===null)throw new Error(`Invalid namespace: ${u} -> ${f}`);let $=_[m]??Object.values(_).find(C=>typeof C=="function"&&HE(C)===m);if(typeof $!="function")throw new Error(`Invalid identifer: ${u} -> ${f}`);let P=new $(WE(await ov.call({...this,path:[...s,"kwargs"],depth:a+1},p.kwargs),VE,yK($)));return Object.defineProperty(P.constructor,"name",{value:m}),P}let d={};for(let[p,f]of Object.entries(l))d[p]=await ov.call({...this,path:[...s,p],depth:a+1},f);return d}async function gD(e,t){let r=JSON.parse(e),n={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??gK};return ov.call(n,r)}function _K(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}function vK(e){return e.lc===2&&e.type==="undefined"}function bK(e){return e.lc===2&&e.type==="delta_snapshot"&&Object.prototype.hasOwnProperty.call(e,"value")}function wK(e){return e.lc===2&&e.type==="constructor"}function zm(e,t){return Array.isArray(e.id)&&e.id.length===1&&e.id[0]===t}function jm(e){return e.method===void 0||e.method===null}function UO(e){return Array.isArray(e.args)&&e.args.length===1&&Array.isArray(e.args[0])}function xK(e){return e.every(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=255)}function kK(e){if(zm(e,"Set")&&jm(e))return UO(e)?new Set(e.args[0]):void 0;if(zm(e,"Map")&&jm(e))return!UO(e)||!e.args[0].every(t=>Array.isArray(t)&&t.length===2)?void 0:new Map(e.args[0]);if(zm(e,"RegExp")&&jm(e)){if(!Array.isArray(e.args)||e.args.length!==2||typeof e.args[0]!="string"||typeof e.args[1]!="string")return;try{return new RegExp(e.args[0],e.args[1])}catch{return}}if(zm(e,"Error")&&jm(e))return!Array.isArray(e.args)||e.args.length!==1||typeof e.args[0]!="string"?void 0:new Error(e.args[0]);if(zm(e,"Uint8Array")&&(jm(e)||e.method==="from"))return!UO(e)||!xK(e.args[0])?void 0:new Uint8Array(e.args[0])}async function LO(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>LO(t)));{let t={};for(let[r,n]of Object.entries(e))t[r]=await LO(n);return vK(t)?void 0:bK(t)?new Hu(t.value):wK(t)?kK(t)??t:_K(t)?gD(JSON.stringify(t)):t}}return e}function sv(e,t,r,n){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:n??{}}}function IK(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Hu?{lc:2,type:"delta_snapshot",value:e.value}:e instanceof Set||e instanceof Map?sv(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?sv(RegExp,void 0,[e.source,e.flags]):e instanceof Error?sv(Error,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args,...e.timeout!==void 0?{timeout:e.timeout}:{}}:e instanceof Uint8Array?sv(Uint8Array,"from",[Array.from(e)]):e}var FO=class{_dumps(e){return new TextEncoder().encode(tC(e,(t,r)=>IK(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return LO(JSON.parse(e))}async loadsTyped(e,t){if(e==="bytes")return typeof t=="string"?new TextEncoder().encode(t):t;if(e==="json")return this._loads(typeof t=="string"?t:new TextDecoder().decode(t));throw new Error(`Unknown serialization type: ${e}`)}};function BO(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=BO(e[r]));return t}function Mc(){return{v:4,id:of(0),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function Yi(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values??{}},channel_versions:{...e.channel_versions??{}},versions_seen:BO(e.versions_seen??{})}}function av(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function cv(...e){return e.reduce((t,r,n)=>n===0?r:av(t,r)>=0?t:r)}var uv={[Ow]:-1,[Qa]:-2,[$w]:-3,[Tw]:-4},ZO=new Set(["thread_id","checkpoint_id","checkpoint_ns","checkpoint_map","langgraph_step","langgraph_node","langgraph_triggers","langgraph_path","langgraph_checkpoint_ns"]);var nd=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function OK(e){if(e.length===0)throw new nd("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new nd(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new nd(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new nd(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new nd(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var Dm=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:n=10,offset:i=0,query:o}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:n,offset:i,query:o}]))[0]}async put(e,t,r,n){OK(e),await this.batch([{namespace:e,key:t,value:r,index:n}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:n,limit:i=100,offset:o=0}=e,s=[];return t&&s.push({matchType:"prefix",path:t}),r&&s.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:s.length?s:void 0,maxDepth:n,limit:i,offset:o}]))[0]}start(){}stop(){}};var $K=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,lv=class extends Dm{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=$K(e)}get isRunning(){return this.running}async batch(e){throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.")}async get(e,t){return this.enqueueOperation({namespace:e,key:t})}async search(e,t){let{filter:r,limit:n=10,offset:i=0,query:o}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:n,offset:i,query:o})}async put(e,t,r){return this.enqueueOperation({namespace:e,key:t,value:r})}async delete(e,t){return this.enqueueOperation({namespace:e,key:t,value:null})}start(){this.running||(this.running=!0,this.processingTask=this.processBatchQueue())}async stop(){this.running=!1,this.processingTask&&await this.processingTask}enqueueOperation(e){return new Promise((t,r)=>{let n=this.nextKey;this.nextKey+=1,this.queue.set(n,{operation:e,resolve:t,reject:r})})}async processBatchQueue(){for(;this.running;){if(await new Promise(t=>{setTimeout(t,0)}),this.queue.size===0)continue;let e=new Map(this.queue);this.queue.clear();try{let t=Array.from(e.values()).map(({operation:n})=>n),r=await this.store.batch(t);e.forEach(({resolve:n},i)=>{n(r[Array.from(e.keys()).indexOf(i)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};var dv=class{serde=new FO;constructor(e){this.serde=e||this.serde}};var PK=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Cn(e){return e!=null&&e.lc_graph_name==="DeltaChannel"}function WO(e){return e!=null&&e.lg_is_channel===!0}var Ut=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Je.unminifiable_name)return!1;throw e}}equals(e){return this===e}},VO=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function id(e){if(e[VO]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=e[r];WO(n)&&(t[r]=n)}return Object.assign(t,{[VO]:!0}),t}function pv(e,t){let r=id(e),n={};for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let o=t.channel_values[i];n[i]=r[i].fromCheckpoint(o)}return Object.assign(n,{[VO]:!0}),n}function qO(e,t){if(!PK.test(t))throw new TypeError(`Invalid task id for exit delta: ${t}`);let r=t.toLowerCase().split("-");return`${String(e).padStart(8,"0")}-${r[1]}-${r[2]}-${r[3]}-${r[4]}`}function fv(e,t){let r=new Set,n=HP();for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let o=e[i];if(!Cn(o)||!o.isAvailable())continue;let[s,a]=t[i]??[0,0];(s>=o.snapshotFrequency||a>=n)&&r.add(i)}return r}function ci(e,t,r,n){let i=n?.channelsToSnapshot??new Set,{updatedChannels:o,getNextVersion:s}=n??{},a,c=e.channel_versions;if(t===void 0)a=e.channel_values;else{a={},c={...e.channel_versions};for(let u in t){if(!Object.prototype.hasOwnProperty.call(t,u))continue;let l=t[u];if(i.has(u)){s!==void 0&&(o===void 0||!o.has(u))&&(c[u]=s(c[u])),a[u]=new Hu(l.get());continue}if(!Cn(l))try{a[u]=l.checkpoint()}catch(d){if(d.name!==Je.unminifiable_name)throw d}}}return{v:4,id:n?.id??of(r),ts:new Date().toISOString(),channel_values:a,channel_versions:c,versions_seen:e.versions_seen}}async function od(e,t,r){let n=pv(e,t),{saver:i,config:o}=r??{},s=id(e),a=[];for(let u in s)Object.prototype.hasOwnProperty.call(s,u)&&Cn(s[u])&&!Object.prototype.hasOwnProperty.call(t.channel_values,u)&&a.push(u);if(a.length===0||i===void 0||o===void 0)return n;let c=await i.getDeltaChannelHistory({config:o,channels:a});for(let u of a){let l=c[u];if(l===void 0)continue;let d=s[u].fromCheckpoint(l.seed);d.replayWrites(l.writes),n[u]=d}return n}var CK=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",jo=class _D extends Ut{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,r){super(),this.operator=t,this.initialValueFactory=r,this.value=r?.()}fromCheckpoint(t){let r=new _D(this.operator,this.initialValueFactory);return typeof t<"u"&&(r.value=t),r}update(t){let r=t;if(!r.length)return!1;if(this.value===void 0){let i=r[0],[o,s]=Jn(i);o?this.value=s:this.value=i,r=r.slice(1)}let n=!1;for(let i of r)if(Ja(i)){if(n)throw new Ce("Can receive only one Overwrite value per step.");let[,o]=Jn(i);this.value=o,n=!0;continue}else!n&&this.value!==void 0&&(this.value=this.operator(this.value,i));return!0}get(){if(this.value===void 0)throw new Je;return this.value}checkpoint(){if(this.value===void 0)throw new Je;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:CK(t)?this.operator===t.operator:!1}};var ui=class vD extends Ut{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new vD(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new Ce("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Je;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Je;return this.value[0]}isAvailable(){return this.value.length!==0}},KO=class bD extends Ut{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new bD;if(typeof t<"u"){let[n,i]=t;r.value=[n],r.finished=i}return r}update(t){return t.length===0?!1:(this.finished=!1,this.value=[t[t.length-1]],!0)}get(){if(this.value.length===0||!this.finished)throw new Je;return this.value[0]}checkpoint(){if(this.value.length!==0)return[this.value[0],this.finished]}consume(){return this.finished?(this.finished=!1,this.value=[],!0):!1}finish(){return!this.finished&&this.value.length>0?(this.finished=!0,!0):!1}isAvailable(){return this.value.length!==0&&this.finished}};var mv=class{lc_graph_name="AnnotationRoot";spec;constructor(e){this.spec=e}static isInstance(e){return typeof e=="object"&&e!==null&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"}},tt=function(e){return e?hv(e):new ui};tt.Root=e=>new mv(e);function hv(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new jo(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new jo(e.value,e.default):new ui}var RK=["tags","metadata","callbacks","configurable"],NK=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","heartbeat","executionInfo","serverInfo","control"],MK=25,zK=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function jK(e,t){if(!e)return t;let r=t??{};for(let n of zK){if(n in r)continue;let i=e[n];i!==void 0&&(r[n]=i)}return r}function wD(e){if(e==null||e.length===0)return;let t=e.filter(r=>!r.startsWith("seq:step"));return t.length>0?t:void 0}function DK(e,t){if(t===void 0)return e;if(e===void 0)return Array.isArray(t)?[...t]:t.copy();if(Array.isArray(t)){if(Array.isArray(e))return e.concat(t);let n=e.copy();for(let i of t)n.addHandler(_w(i),!0);return n}if(Array.isArray(e)){let n=t.copy();for(let i of e)n.addHandler(_w(i),!0);return n}let r=n=>n.filter((i,o)=>n.findIndex(s=>s===i||s.name==="StreamMessagesHandler"&&i.name==="StreamMessagesHandler")===o);return new mr(t._parentRunId,{handlers:r(e.handlers.concat(t.handlers)),inheritableHandlers:r(e.inheritableHandlers.concat(t.inheritableHandlers)),tags:Array.from(new Set(e.tags.concat(t.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(t.inheritableTags))),metadata:{...e.metadata,...t.metadata},inheritableMetadata:{...e.inheritableMetadata,...t.inheritableMetadata}})}function UK(e){let t;for(let o=e.length-1;o>=0;o-=1)if(e[o]!==void 0){t=e[o];break}let r=t?.configurable?.thread_id!==void 0,n=e.some(o=>o?.configurable?.[$r]!==void 0),i=ut.getRunnableConfig()?.configurable?.[$r]!==void 0;return r&&!n&&!i}function Um(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:MK,configurable:{}},r=UK(e),n=ut.getRunnableConfig();if(n!==void 0){for(let[i,o]of Object.entries(n))if(o!==void 0){if(i==="configurable"&&r)continue;if(RK.includes(i)){let s;Array.isArray(o)?s=[...o]:typeof o=="object"?i==="callbacks"&&"copy"in o&&typeof o.copy=="function"?s=o.copy():s={...o}:s=o,t[i]=s}else t[i]=o}}for(let i of e)if(i!==void 0)for(let[o,s]of Object.entries(i))s===void 0||!NK.includes(o)||(o==="configurable"?t.configurable={...t.configurable,...s}:o==="metadata"?t.metadata={...t.metadata,...s}:o==="tags"?t.tags=[...t.tags??[],...s]:o==="callbacks"?t.callbacks=DK(t.callbacks,s):t[o]=s);return t.metadata=jK(t.configurable,t.metadata)??{},t}function gv(){return ut.getRunnableConfig()}function yv(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function xD(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var GO=class{#e=void 0;requestDrain(e="shutdown"){this.#e=e}get drainRequested(){return this.#e!==void 0}get drainReason(){return this.#e}};var HO=["values","updates","messages","tools","custom","tasks"];function sd(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.id=="string"&&("source"in t||typeof t.step=="number")&&!("values"in t)&&!("config"in t)}function LK(e){if(!Array.isArray(e)||e.length!==2)return{data:e};let[t,r]=e;if(r==null||typeof r!="object")return{data:e};let n=r,i=typeof n.langgraph_node=="string"?n.langgraph_node:void 0,o=typeof n.run_id=="string"?n.run_id:void 0;return{data:o!=null&&t!=null&&typeof t=="object"?{...t,run_id:o}:t,node:i}}function JO({namespace:e,mode:t,payload:r,seq:n}){let i=Date.now(),o={type:"event"};switch(t){case"messages":{let{data:s,node:a}=LK(r);return[{...o,seq:n,method:"messages",params:{namespace:e,timestamp:i,...a?{node:a}:{},data:s}}]}case"tools":return[{...o,seq:n,method:"tools",params:{namespace:e,timestamp:i,data:FK(r)}}];case"checkpoints":return sd(r)?[{...o,seq:n,method:"checkpoints",params:{namespace:e,timestamp:i,data:r}}]:[];case"values":return[{...o,seq:n,method:"values",params:{namespace:e,timestamp:i,data:r}}];case"updates":{let s=BK(r);return[{...o,seq:n,method:"updates",params:{namespace:e,timestamp:i,...typeof s.node=="string"?{node:s.node}:{},data:s}}]}case"custom":{let s=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...o,seq:n,method:"custom",params:{namespace:e,timestamp:i,data:s}}]}case"tasks":return[{...o,seq:n,method:"tasks",params:{namespace:e,timestamp:i,data:r}}];default:return[]}}function FK(e){if(typeof e!="object"||e===null)return{event:"tool-error",tool_call_id:"",message:"Unexpected tools payload shape"};let t=e,r=String(t.toolCallId??"");switch(t.event){case"on_tool_start":return{event:"tool-started",tool_call_id:r,tool_name:String(t.name??"unknown"),input:t.input};case"on_tool_event":return{event:"tool-output-delta",tool_call_id:r,delta:typeof t.data=="string"?t.data:JSON.stringify(t.data??"")};case"on_tool_end":return{event:"tool-finished",tool_call_id:r,output:t.output};case"on_tool_error":{let n=t.error;return{event:"tool-error",tool_call_id:r,message:typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"?n.message:String(n??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function BK(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,n]=t[0];return{node:r,values:typeof n=="object"&&n!==null?n:{value:n}}}var XO=Symbol.for("langgraph.stream_channel"),Rn=class YO{[XO]=!0;channelName;#e=[];#t=[];#n=!1;#o;#i;constructor(t){this.channelName=t}static local(){return new YO}static remote(t){return new YO(t)}static isInstance(t){return typeof t=="object"&&t!==null&&XO in t&&t[XO]===!0}push(t){this.#e.push(t),this.#r(),this.#i?.(t)}iterate(t=0){let r=t;return{next:async()=>{for(;;){if(r<this.#e.length)return{value:this.#e[r++],done:!1};if(this.#n){if(this.#o)throw this.#o;return{value:void 0,done:!0}}await new Promise(n=>this.#t.push(n))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,n=this.iterate(t.startAt),i=t.event??this.channelName,o=t.serialize??(s=>JSON.stringify(s)??"null");return new ReadableStream({async pull(s){try{let a=await n.next();if(a.done){s.close();return}let c=[];i!=null&&c.push(`event: ${i}`);for(let u of o(a.value).split(/\r\n|\r|\n/))c.push(`data: ${u}`);s.enqueue(r.encode(`${c.join(`
|
|
282
|
-
`)}
|
|
283
|
-
|
|
284
|
-
`))}catch(a){s.error(a)}},async cancel(){await n.return?.()}})}get(t){if(t<0||t>=this.#e.length)throw new RangeError(`StreamChannel index ${t} out of bounds (size=${this.#e.length})`);return this.#e[t]}get size(){return this.#e.length}get done(){return this.#n}close(){this.#n=!0,this.#r()}fail(t){this.#o=t,this.#n=!0,this.#r()}_wire(t){this.#i=t}_close(){this.close()}_fail(t){this.fail(t)}[Symbol.asyncIterator](){return this.iterate()}#r(){let t=this.#t.splice(0);for(let r of t)r()}};function kD(e){return Rn.isInstance(e)}var ZK="custom:";function VK(e){return`${ZK}${e}`}function WK(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var _v=Symbol("resolveValues"),QO=Symbol("rejectValues"),ID=class{_events=Rn.local();_discoveries=Rn.local();#e=0;#t=!1;#n;#o=!1;#i=[];#r=[];#a=[];#s=new Map;#u=new Map;#c=[];#l=[];register(e,t){this.#s.set(Lt(e),t)}addTransformer(e){let t=this._events.size;this.#r.push(e),e.onRegister&&e.onRegister({push:(r,n)=>this.push(r,n)});for(let r=0;r<t;r+=1)e.process(this._events.get(r));this.#t&&(this.#n!==void 0?e.fail?.(this.#n):e.finalize?.())}wireChannels(e){for(let[t,r]of Object.entries(e)){if(kD(r)){if(this.#a.push(r),typeof r.channelName!="string")continue;let n=VK(r.channelName);r._wire(i=>{this._events.push({type:"event",seq:this.#e++,method:n,params:{namespace:this.#i,timestamp:Date.now(),data:i}})});continue}WK(r)&&this.#l.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#u.set(Lt(e),t.params.data);let r=this.#i;this.#i=e;let n=!0;for(let i of this.#r)i.process(t)||(n=!1);this.#i=r,n&&this._events.push({...t,seq:this.#e++})}close(){this.#t=!0;for(let[r,n]of this.#u.entries()){let i=r?r.split("\0"):[];this.#s.get(Lt(i))?.[_v](n)}let e=[];for(let r of this.#r){let n=r.finalize?.();n!=null&&typeof n.then=="function"&&e.push(n)}for(let r of this.#a)r._close();let t=this.#l;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:n})=>{try{let i=await n;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:i}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#s.values())r[_v](void 0)}fail(e){this.#t=!0,this.#n=e;for(let t of this.#r)t.fail?.(e);for(let t of this.#a)t._fail(e);this._events.fail(e),this._discoveries.fail(e);for(let t of this.#s.values())t[QO](e)}markInterrupted(e){this.#o=!0,this.#c.push(...e)}get interrupted(){return this.#o}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let n=await r.next();if(n.done||Qi(n.value.params.namespace,e))return n}}}}};async function SD(e,t){let r=0;try{for await(let n of e){let[i,o,s]=n;if(o==="values"&&Xa(s)){let c=s[rt];t.markInterrupted(c.map(u=>({interruptId:u.id??"",payload:u.value})))}let a=JO({namespace:i,mode:o,payload:s,seq:r});r+=a.length;for(let c of a)t.push(i,c)}}catch(n){t.fail(n);return}t.close()}function Lt(e){return e.join("\0")}function Qi(e,t){if(t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(e[r]!==t[r])return!1;return!0}function vv(e,t,r=0){return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let i=await n.next();if(i.done)return{value:void 0,done:!0};if(Qi(i.value.namespace,t))return{value:i.value,done:!1}}}}}}}var AD="root";function qK(e){if(e.length===0)return AD;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function KK(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function eo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function GK(e){if(!eo(e)||e.event!=="started")return;let t=e.cause;if(eo(t)&&typeof t.type=="string")return t}function HK(e){if(eo(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function e$(e={}){let t=e.rootGraphName??AD,r=e.initialStatus??"running",n=e.emitRootOnRegister??!0,i=e.getGraphName??qK,o=e.serializeError??KK,s=e.getTerminalStatusOverride,a=Rn.local(),c=new Map,u=new Map,l=new Map,d=new Map,p=new Set,f=[],m,h=0,y=!1,w=X=>{if(X.length===0)return t;let Q=l.get(Lt(X));return typeof Q=="string"&&Q.length>0?Q:i(X)},_=(X,Q)=>{let ae=Lt(X);if(l.has(ae))return;let ce=(eo(Q)&&eo(Q.metadata)?Q.metadata:void 0)?.lc_agent_name;l.set(ae,typeof ce=="string"?ce:void 0)},b=X=>{if(!eo(X))return;let Q=X.id;if(typeof Q!="string")return;let ae=X.input,ce;if(eo(ae)&&eo(ae.tool_call)){let $e=ae.tool_call.id;typeof $e=="string"&&(ce=$e)}else if(Array.isArray(ae)){for(let $e of ae)if(eo($e)&&typeof $e.id=="string"){ce=$e.id;break}}ce!=null&&d.set(Q,ce)},I=X=>{if(X.length===0)return;let Q=l.get(Lt(X));if(typeof Q!="string"||Q.length===0)return;let ae=X[X.length-1],ce=ae.indexOf(":");if(ce===-1)return;let $e=ae.slice(ce+1);if($e.length===0)return;let bt=d.get($e);if(!(typeof bt!="string"||bt.length===0))return{type:"toolCall",tool_call_id:bt}},$=X=>u.get(Lt(X))??I(X),P=(X,Q,ae)=>{let ce=Lt(X),$e=c.get(ce),bt=$e?.graphName??w(X);if($e!=null&&$e.status===Q&&$e.graphName===bt&&ae?.error==null)return;$e==null?($e={namespace:X,graphName:bt,status:Q},c.set(ce,$e)):$e.status=Q;let yn={event:Q,graph_name:bt,...ae?.cause!=null?{cause:ae.cause}:{},...ae?.error!=null?{error:ae.error}:{}},Et=Date.now();if(a.push({namespace:X,timestamp:Et,...yn}),!(X.length===0&&!n)&&m!=null){h+=1;try{m.push(X,{type:"event",seq:0,method:"lifecycle",params:{namespace:X,timestamp:Et,data:yn}})}finally{h-=1}}},C=X=>{let Q=Lt(X),ae=c.get(Q);return ae==null&&(ae={namespace:X,graphName:w(X),status:void 0},c.set(Q,ae)),ae},x=()=>{if(f.length===0)return;let X=f.splice(0,f.length);for(let Q of X){let ae=Lt(Q.namespace),ce=c.get(ae);ce==null||ce.status!=="started"||P(Q.namespace,"completed")}},D=X=>{let Q=Lt(X.namespace),ae=c.get(Q);ae==null||ae.status!=="started"||f.some(ce=>Lt(ce.namespace)===Q)||f.push(X)},M=(X,Q)=>{for(let ae=f.length-1;ae>=0;ae-=1){let ce=f[ae];ce.source.type==="node"&&ce.source.node===Q&&Lt(ce.source.parent)===Lt(X)&&f.splice(ae,1)}},R=X=>{for(let Q=1;Q<=X.length;Q+=1){let ae=X.slice(0,Q),ce=Lt(ae);if(c.has(ce))continue;C(ae);let $e=$(ae);P(ae,"started",$e!=null?{cause:$e}:void 0)}},B=()=>p.size>0?"interrupted":"completed",K=X=>{for(let Q of c.values())Q.namespace.length!==0&&Q.status==="started"&&P(Q.namespace,X);P([],X),a.close()},re=async()=>{if(s==null)return B();try{return await s()??B()}catch{return B()}},We=(X,Q)=>{let ae=`${Q}:`;for(let ce of c.values()){if(ce.namespace.length!==X.length+1||ce.status!=="started"||!Qi(ce.namespace,X))continue;let $e=ce.namespace[ce.namespace.length-1];if($e===Q||$e.startsWith(ae))return ce.namespace}},ne=(X,Q)=>{let ae=[...X,`${Q.name}:${Q.id}`];return c.get(Lt(ae))?.status==="started"?ae:void 0};return{__native:!0,init(){return{_lifecycleLog:a,lifecycle:vv(a,[],0)}},onRegister(X){m=X,C([]),n&&P([],r)},process(X){let Q=X.params.namespace;if(h>0)return!0;let ae=X.method==="tasks"?HK(X.params.data):void 0;if(ae!=null?M(Q,ae.name):X.method==="tasks"&&(_(Q,X.params.data),b(X.params.data)),x(),X.method==="lifecycle"){let ce=GK(X.params.data);return ce!=null&&u.set(Lt(Q),ce),R(Q),!1}if(R(Q),X.method==="input"&&eo(X.params.data)&&X.params.data.event==="requested"){let ce=X.params.data.id;typeof ce=="string"&&p.add(ce)}if(ae!=null){let ce=ne(Q,ae);ce!=null&&D({namespace:ce,source:{type:"task"}})}if(X.method==="updates"){let ce=X.params.node;if(typeof ce=="string"&&!ce.startsWith("__")){let $e=We(Q,ce);$e!=null&&D({namespace:$e,source:{type:"node",parent:Q,node:ce}})}}return!0},finalize(){if(!y){if(y=!0,x(),s==null){K(B());return}return re().then(K).catch(X=>{a.fail(X)})}},fail(X){if(y)return;y=!0;let Q=o(X);for(let ae of c.values())ae.namespace.length!==0&&ae.status==="started"&&P(ae.namespace,"failed");P([],"failed",{error:Q}),a.fail(X)}}}function ad(e){let t=e;return typeof t.run_id=="string"?`run:${t.run_id}`:e.event==="message-start"&&typeof t.id=="string"?`message:${t.id}`:"__default__"}function Lm(e,t){let r=Rn.local(),n=new Map,i=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(o){if(o.method!=="messages"||!Qi(o.params.namespace,e)||o.params.namespace.length!==e.length+1||t!==void 0&&o.params.node!==t)return!0;let s=o.params.data;switch(s.event){case"message-start":{let a=ad(s);if(s.role==="tool"){i.add(a);break}let c=Rn.local(),u=Object.assign(new Fs(c.toAsyncIterable()),{namespace:o.params.namespace,node:o.params.node});n.set(a,{source:c,stream:u}),c.push(s),r.push(u);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(i.has(ad(s)))break;n.get(ad(s))?.source.push(s);break;case"message-finish":{let a=ad(s);if(i.delete(a))break;let c=n.get(a);c&&(c.source.push(s),c.source.close(),n.delete(a));break}case"error":if(i.has(ad(s)))break;n.get(ad(s))?.source.push(s);break}return!0},finalize(){for(let[o,s]of n)s.source.push({event:"message-finish"}),s.source.close(),n.delete(o);i.clear(),r.close()},fail(o){for(let[s,a]of n)a.source.fail(o),n.delete(s);i.clear(),r.fail(o)}}}function Fm(e,t,r=0){let n=t.length+1;return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let o=await i.next();if(o.done)return{value:void 0,done:!0};let{ns:s,stream:a}=o.value;if(s.length===n&&Qi(s,t))return{value:a,done:!1}}}}}}}function t$(e,t){let{createStream:r}=t,n=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:Fm(e._discoveries,[],0)}},process(i){let o=i.params.namespace;if(o.length===0)return!0;let s=o.slice(0,1),a=Lt(s);if(n.has(a))return!0;n.add(a);let c=r(s,e._discoveries.size,e._events.size);return e.register(s,c),e._discoveries.push({ns:s,stream:c}),!0}}}function r$(e){let t=Rn.local();return{init:()=>({_valuesLog:t}),process(r){return r.method!=="values"||r.params.namespace.length!==e.length||!Qi(r.params.namespace,e)||t.push(r.params.data),!0},finalize(){t.close()},fail(r){t.fail(r)}}}function bv(e){return"__native"in e&&e.__native===!0}var OD=Symbol("setValuesLog"),$D=Symbol("setMessagesIterable"),n$=Symbol("setLifecycleIterable"),i$=Symbol("setSubgraphsIterable"),JK={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},o$=class{path;extensions;_mux;#e;#t;#n;#o;#i;#r;#a;#s;#u;#c;constructor(e,t,r=0,n=0,i,o){this.path=e,this._mux=t,this.#t=r,this.#e=n,this.extensions=i??{},this.#n=o??new AbortController,this.#r=new Promise((s,a)=>{this.#o=s,this.#i=a}),this.#r.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:Fm(this._mux._discoveries,this.path,this.#t)}get values(){let e=this.#a,t=this.#r,r=this._mux,n=this.#e,i=this.path,o=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let s=r.subscribeEvents(i,n);return{async next(){for(;;){let a=await s.next();if(a.done)return{value:void 0,done:!0};if(a.value.method==="values"&&a.value.params.namespace.length===i.length)return{value:a.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>o[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#s)return this.#s;let e=Lm(this.path),t=e.init();return this._mux.addTransformer(e),this.#s=t.messages,this.#s}get lifecycle(){return this.#u??JK}messagesFrom(e){let t=Lm(this.path,e),r=t.init();return this._mux.addTransformer(t),r.messages}get output(){return this.#r}get interrupted(){return this._mux.interrupted}get interrupts(){return this._mux.interrupts}abort(e){this.#n.abort(e)}get signal(){return this.#n.signal}[_v](e){this.#o?.(e),this.#o=void 0}[QO](e){this.#i?.(e),this.#i=void 0}[OD](e){this.#a=e}[$D](e){this.#s=e}[n$](e){this.#u=e}[i$](e){this.#c=e}},TD=class extends o${name;index;constructor(e,t,r=0,n=0,i,o){super(e,t,r,n,i,o);let s=e[e.length-1]??"",a=s.lastIndexOf(":");if(a>=0){this.name=s.slice(0,a);let c=s.slice(a+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=s,this.index=0}};function s$(e,t=[],r){let{abortController:n}=r instanceof AbortController?{abortController:r}:r??{},i=new ID,o=e$(),s=o.init(),a=s._lifecycleLog,c=t$(i,{createStream:(w,_,b)=>{let I=new TD(w,i,_,b);return I[i$](Fm(i._discoveries,w,_)),I[n$](vv(a,w,a.size)),I}}),u=c.init();i.addTransformer(c),i.addTransformer(o);let l=r$([]),d=Lm([]);i.addTransformer(l),i.addTransformer(d);let p={},f=[];for(let w of t){let _=w();i.addTransformer(_);let b=_.init();bv(_)?f.push(b):Object.assign(p,b),typeof b=="object"&&b!==null&&!bv(_)&&i.wireChannels(b)}let m=new o$([],i,0,0,p,n);for(let w of f)Object.assign(m,w);let h=l.init();m[OD](h._valuesLog);let y=d.init();return m[$D](y.messages),m[n$](s.lifecycle),m[i$](u.subgraphs),i.register([],m),SD(e,i).catch(w=>{}),m}var J=e=>BigInt(e),st=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),RD=J("0x9E3779B1"),ND=J("0x85EBCA77"),XK=J("0xC2B2AE3D"),Zs=J("0x9E3779B185EBCA87"),zc=J("0xC2B2AE3D27D4EB4F"),MD=J("0x165667B19E3779F9"),u$=J("0x85EBCA77C2B2AE63"),YK=J("0x27D4EB2F165667C5"),QK=J("0x165667919E3779F9"),e3=J("0x9FB21C651E98DF25"),t3=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,n=new Uint8Array(r),i=0,o=0;for(;o<r;){let s=e.slice(i,i+=2);n[o]=Number.parseInt(s,16),o+=1}return st(n)},to=t3("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),cd=(J(1)<<J(128))-J(1),Me=(J(1)<<J(64))-J(1),Iv=(J(1)<<J(32))-J(1),Do=64,zD=Do/8,r3=8,wv=4;function ud(e){if(!e)throw new Error("Assert failed")}function n3(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function i3(e){let t=e;return t=(t&J(65535))<<J(16)|(t&J(4294901760))>>J(16),t=(t&J(16711935))<<J(8)|(t&J(4278255360))>>J(8),t}function o3(e,t){return(e&Iv)*(t&Iv)&Me}function s3(e,t){return(e<<t|e>>J(32)-t)&Iv}function jD(e,t,r){for(let n=0;n<zD;n+=1){let i=t.getBigUint64(n*8,!0),o=i^r.getBigUint64(n*8,!0);e[n^1]+=i,e[n]+=o3(o,o>>J(32))}return e}function ED(e,t,r,n){for(let i=0;i<n;i+=1)jD(e,st(t,i*Do),st(r,i*8));return e}function a3(e,t){for(let r=0;r<zD;r+=1){let n=t.getBigUint64(r*8,!0),i=e[r];i=a$(i,J(47)),i^=n,i*=RD,e[r]=i&Me}return e}function xv(e,t){return DD(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(r3,!0))}function PD(e,t,r){let n=r;return n+=xv(e.slice(0),st(t,0*wv)),n+=xv(e.slice(2),st(t,4*wv)),n+=xv(e.slice(4),st(t,8*wv)),n+=xv(e.slice(6),st(t,12*wv)),ro(n&Me)}function c3(e,t,r,n,i){let o=e,s=Math.floor((r.byteLength-Do)/8),a=Do*s,c=Math.floor((t.byteLength-1)/a);for(let u=0;u<c;u+=1)o=ED(o,st(t,u*a),r,s),o=i(o,st(r,r.byteLength-Do));{let u=Math.floor((t.byteLength-1-a*c)/Do);o=ED(o,st(t,c*a),r,u),o=n(o,st(t,t.byteLength-Do),st(r,r.byteLength-Do-7))}return o}function u3(e,t){let r=new BigUint64Array([XK,Zs,zc,MD,u$,ND,YK,RD]);ud(e.byteLength>128),r=c3(r,e,t,jD,a3),ud(r.length*8===64);{let n=PD(r,st(t,11),J(e.byteLength)*Zs&Me);return PD(r,st(t,t.byteLength-Do-11),~(J(e.byteLength)*zc)&Me)<<J(64)|n}}function DD(e,t){let r=e*t&cd;return r&Me^r>>J(64)}function CD(e,t,r){return DD((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&Me,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&Me)}function kv(e,t,r,n,i){let o=e&Me,s=e>>J(64)&Me;return o+=CD(t,n,i),o^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),o&=Me,s+=CD(r,st(n,16),i),s^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),s&=Me,s<<J(64)|o}function ro(e){let t=e;return t^=t>>J(37),t*=QK,t&=Me,t^=t>>J(32),t}function Sv(e){let t=e;return t^=t>>J(33),t*=zc,t&=Me,t^=t>>J(29),t*=MD,t&=Me,t^=t>>J(32),t}function l3(e,t,r){let n=e.byteLength;ud(n>0&&n<=3);let i=J(e.getUint8(n-1))|J(n<<8)|J(e.getUint8(0)<<16)|J(e.getUint8(n>>1)<<24),o=(i^(J(t.getUint32(0,!0))^J(t.getUint32(4,!0)))+r)&Me,s=(J(t.getUint32(8,!0))^J(t.getUint32(12,!0)))-r;return(Sv((s3(i3(i),J(13))^s)&Me)&Me)<<J(64)|Sv(o)}function a$(e,t){return e^e>>t}function d3(e,t,r){let n=e.byteLength;ud(n>=4&&n<=8);{let i=e.getUint32(0,!0),o=e.getUint32(n-4,!0),s=((J(i)|J(o)<<J(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&Me)*(Zs+(J(n)<<J(2)))&cd;return s+=(s&Me)<<J(65),s&=cd,s^=s>>J(67),a$(a$(s&Me,J(35))*e3&Me,J(28))|ro(s>>J(64))<<J(64)}}function p3(e,t,r){let n=e.byteLength;ud(n>=9&&n<=16);{let i=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&Me,o=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&Me,s=e.getBigUint64(0,!0),a=e.getBigUint64(n-8,!0),c=(s^a^i)*Zs,u=(c&Me)+(J(n-1)<<J(54));c=c&(cd^Me)|u,a^=o,c+=a+(a&Iv)*(ND-J(1))<<J(64),c&=cd,c^=n3(c>>J(64));let l=(c&Me)*zc;return l+=(c>>J(64))*zc<<J(64),l&=cd,ro(l&Me)|ro(l>>J(64))<<J(64)}}function f3(e,t){let r=e.byteLength;return ud(r<=16),r>8?p3(e,to,t):r>=4?d3(e,to,t):r>0?l3(e,to,t):Sv(t^to.getBigUint64(64,!0)^to.getBigUint64(72,!0))|Sv(t^to.getBigUint64(80,!0)^to.getBigUint64(88,!0))<<J(64)}function c$(e){return~e+J(1)&Me}function m3(e,t,r){let n=J(e.byteLength)*Zs&Me,i=J(e.byteLength-1)/J(32);for(;i>=0;){let a=Number(i);n=kv(n,st(e,16*a),st(e,e.byteLength-16*(a+1)),st(t,32*a),r),i-=J(1)}let o=n+(n>>J(64))&Me;o=ro(o);let s=(n&Me)*Zs+(n>>J(64))*u$+(J(e.byteLength)-r&Me)*zc;return s&=Me,s=c$(ro(s)),o|s<<J(64)}function h3(e,t,r){let n=J(e.byteLength)*Zs&Me;for(let s=32;s<160;s+=32)n=kv(n,st(e,s-32),st(e,s-16),st(t,s-32),r);n=ro(n&Me)|ro(n>>J(64))<<J(64);for(let s=160;s<=e.byteLength;s+=32)n=kv(n,st(e,s-32),st(e,s-16),st(t,3+s-160),r);n=kv(n,st(e,e.byteLength-16),st(e,e.byteLength-32),st(t,103),c$(r));let i=n+(n>>J(64))&Me;i=ro(i);let o=(n&Me)*Zs+(n>>J(64))*u$+(J(e.byteLength)-r&Me)*zc;return o&=Me,o=c$(ro(o)),i|o<<J(64)}function no(e,t=J(0)){let r=new TextEncoder,n=st(typeof e=="string"?r.encode(e):e),i=n.byteLength,o=s=>s.toString(16).padStart(32,"0");return i<=16?o(f3(n,t)):i<=128?o(m3(n,to,t)):i<=240?o(h3(n,to,t)):o(u3(n,to))}function Av(e){return/^[0-9a-f]{32}$/.test(e)}function l$(e){let t=ut.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");if(!r.__pregel_checkpointer)throw new Ya("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=r[Zr];n.interruptCounter+=1;let i=n.interruptCounter;if(n.resume.length>0&&i<n.resume.length)return r[gr]?.([[Tr,n.resume]]),n.resume[i];if(n.nullResume!==void 0){if(n.resume.length!==i)throw new Error(`Resume length mismatch: ${n.resume.length} !== ${i}`);let s=n.consumeNullResume();return n.resume.push(s),r[gr]?.([[Tr,n.resume]]),s}let o=r[on]?.split("|");throw new _o([{id:o?no(o.join("|")):void 0,value:e}])}var or=class extends he{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.trace=e.trace??this.trace,this.recurse=e.recurse??this.recurse}async _tracedInvoke(e,t,r){return new Promise((n,i)=>{let o=ze(t,{callbacks:r?.getChild()});ut.runWithConfig(o,async()=>{try{n(await this.func(e,o))}catch(s){i(s)}})})}async invoke(e,t){let r,n=Um(t),i=Kt(this.config,n);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,i):r=await ut.runWithConfig(i,async()=>this.func(e,i)),he.isRunnable(r)&&this.recurse?await ut.runWithConfig(i,async()=>r.invoke(e,i)):r}};function*io(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function li(e){let t=[];for await(let r of await e)t.push(r);return t}function Vs(e){let t=[];for(let r of e)t.push(r);return t}function jc(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function UD(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function LD(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function g3(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var Jr={[Symbol.for("LG_PASSTHROUGH")]:!0};function Ov(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var d$=Symbol("IS_WRITER"),$t=class f$ extends or{writes;constructor(t,r){let n=`ChannelWrite<${t.map(i=>Gt(i)?i.node:"channel"in i?i.channel:"...").join(",")}>`;super({writes:t,name:n,tags:r,trace:!1,func:async(i,o)=>this._write(i,o??{})}),this.writes=t}async _write(t,r){let n=this.writes.map(i=>p$(i)&&Ov(i.value)?{mapper:i.mapper,value:t}:$v(i)&&Ov(i.value)?{channel:i.channel,value:t,skipNone:i.skipNone,mapper:i.mapper}:i);return await f$.doWrite(r,n),t}static async doWrite(t,r){for(let o of r){if($v(o)){if(o.channel==="__pregel_tasks")throw new Ce("Cannot write to the reserved channel TASKS");if(Ov(o.value))throw new Ce("PASSTHROUGH value must be replaced")}if(p$(o)&&Ov(o.value))throw new Ce("PASSTHROUGH value must be replaced")}let n=[];for(let o of r)if(Gt(o))n.push([Pi,o]);else if(p$(o)){let s=await o.mapper.invoke(o.value,t);s!=null&&s.length>0&&n.push(...s)}else if($v(o)){let s=o.mapper!==void 0?await o.mapper.invoke(o.value,t):o.value;if(g3(s)||o.skipNone&&s===void 0)continue;n.push([o.channel,s])}else throw new Error(`Invalid write entry: ${JSON.stringify(o)}`);let i=t.configurable?.[gr];i(n)}static isWriter(t){return t instanceof f$||d$ in t&&!!t[d$]}static registerWriter(t){return Object.defineProperty(t,d$,{value:!0})}};function $v(e){return e!==void 0&&typeof e.channel=="string"}function p$(e){return e!==void 0&&!$v(e)&&he.isRunnable(e.mapper)}var FD=class BD extends or{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,n=!1){super({trace:!1,func:(i,o)=>BD.doRead(o,this.channel,this.fresh,this.mapper)}),this.fresh=n,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,n,i){let o=t.configurable?.[$r];if(!o)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return i?i(o(r,n)):o(r,n)}},ld=new Co,di=class Bm extends $n{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=ld;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;timeout;subgraphs;ends;isErrorHandler;errorHandlerNode;constructor(t){let{channels:r,triggers:n,mapper:i,writers:o,bound:s,kwargs:a,metadata:c,retryPolicy:u,cachePolicy:l,timeout:d,tags:p,subgraphs:f,ends:m,isErrorHandler:h,errorHandlerNode:y}=t,w=[...t.config?.tags?t.config.tags:[],...p??[]];super({...t,bound:t.bound??ld,config:{...t.config?t.config:{},tags:w}}),this.channels=r,this.triggers=n,this.mapper=i,this.writers=o??this.writers,this.bound=s??this.bound,this.kwargs=a??this.kwargs,this.metadata=c??this.metadata,this.tags=w,this.retryPolicy=u,this.cachePolicy=l,this.timeout=d,this.subgraphs=f,this.ends=m,this.isErrorHandler=h,this.errorHandlerNode=y}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof $t&&t[t.length-2]instanceof $t;){let r=t.slice(-2),n=r[0].writes.concat(r[1].writes);t[t.length-2]=new $t(n,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===ld&&t.length===0))return this.bound===ld&&t.length===1?t[0]:this.bound===ld?new fn({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new fn({first:this.bound,middle:t.slice(0,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):this.bound}join(t){if(!Array.isArray(t))throw new Error("channels must be a list");if(typeof this.channels!="object")throw new Error("all channels must be named when using .join()");return new Bm({channels:{...this.channels,...Object.fromEntries(t.map(r=>[r,r]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}pipe(t){return $t.isWriter(t)?new Bm({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,t],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):this.bound===ld?new Bm({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:xt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):new Bm({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}};function y3(e){return"steps"in e&&Array.isArray(e.steps)}function Zm(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function Tv(e){let t=[e];for(let r of t){if(Zm(r))return r;y3(r)&&t.push(...r.steps)}}function Dc(e,t,r=!0,n=!1){try{return e[t].get()}catch(i){if(i.name===Je.unminifiable_name){if(n)return i;if(r)return null}throw i}}function pi(e,t,r=!0){if(Array.isArray(t)){let n={};for(let i of t)try{n[i]=Dc(e,i,!r)}catch(o){if(o.name===Je.unminifiable_name)continue}return n}else return Dc(e,t)}function*ZD(e,t){if(e.graph===Br.PARENT)throw new Ce("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let n of r)if(Gt(n))yield[Pr,Pi,n];else if(typeof n=="string")yield[Pr,`branch:to:${n}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof n}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(Av))for(let[r,n]of Object.entries(e.resume)){let i=t.filter(o=>o[0]===r&&o[1]==="__resume__").map(o=>o[2]).slice(0,1)??[];i.push(n),yield[r,Tr,i]}else yield[Pr,Tr,e.resume];if(e.update){if(typeof e.update!="object"||!e.update)throw new Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(e.update))for(let[r,n]of e.update)yield[Pr,r,n];else for(let[r,n]of Object.entries(e.update))yield[Pr,r,n]}}function*Ev(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let r in t)e.includes(r)&&(yield[r,t[r]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*Pv(e,t,r){Array.isArray(e)?(t===!0||t.find(([n,i])=>e.includes(n)))&&(yield pi(r,e)):(t===!0||t.some(([n,i])=>n===e))&&(yield Dc(r,e))}function*VD(e,t,r){let n=t.filter(([a,c])=>(a.config===void 0||!a.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!n.length)return;let i;n.some(([a])=>a.writes.some(([c,u])=>c==="__return__"))?i=n.flatMap(([a])=>a.writes.filter(([c,u])=>c===hs).map(([c,u])=>[a.name,u])):Array.isArray(e)?i=n.flatMap(([a])=>{let{writes:c}=a,u={};for(let[l]of c)e.includes(l)&&(u[l]=(u[l]||0)+1);return Object.values(u).some(l=>l>1)?c.filter(([l])=>e.includes(l)).map(([l,d])=>[a.name,{[l]:d}]):[[a.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):i=n.flatMap(([a])=>a.writes.filter(([c,u])=>c===e).map(([c,u])=>[a.name,u]));let o={};for(let[a,c]of i)a in o||(o[a]=[]),o[a].push(c);let s={};for(let a in o)if(o[a].length===1){let[c]=o[a];s[a]=c}else s[a]=o[a];r&&(s.__metadata__={cached:r}),yield s}function Cv(e){let t=typeof e[Ye];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=typeof e[r];if(n==="number")return 0;if(n==="string")return"";break}}function dd(e,t){if(Object.keys(e).length>0){let r=Cv(t);return Object.fromEntries(Object.entries(t).filter(([n,i])=>i>(e[n]??r)))}else return t}function WD(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function Jt(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function Ws(e,t){let r=t?.parents??{};return Object.keys(r).length>0?Jt(e,{[yr]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function qs(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let r=new AbortController,n=()=>{let o=t.find(s=>s.aborted)?.reason;r.abort(o),t.forEach(s=>s.removeEventListener("abort",n))};t.forEach(o=>o.addEventListener("abort",n,{once:!0}));let i=t.find(o=>o.aborted);return i&&r.abort(i.reason),{signal:r.signal,dispose:()=>{t.forEach(o=>o.removeEventListener("abort",n))}}}var qD=class{func;name;input;retry;cache;timeout;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:n,cache:i,timeout:o,callbacks:s}){this.func=e,this.name=t,this.input=r,this.retry=n,this.cache=i,this.timeout=o,this.callbacks=s}};function KD(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function GD(e,t){return new fn({name:e,first:new or({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new $t([{channel:hs,value:Jr}],[zt])})}function HD(e,t){return new or({func:(r,n)=>t(r,n),name:e,trace:!1,recurse:!1})}var JD=e=>e!==void 0?e+1:1;function _3(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function v3(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=cv(t,e[r]));return t}function Vm(e,t,r){let n=Cv(e.channel_versions),i=e.versions_seen.__interrupt__??{},o=!1;if((e.channel_versions.__start__??n)>(i.__start__??n))o=!0;else for(let a in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,a)&&e.channel_versions[a]>(i[a]??n)){o=!0;break}let s=r.some(a=>t==="*"?!a.config?.tags?.includes(zt):t.includes(a.name));return o&&s}function pd(e,t,r,n,i=!1){let o=new Set;if(Array.isArray(n))o=new Set(n.filter(a=>r.writes.some(([c,u])=>c===a)));else{for(let[a]of r.writes)if(a===n){o=new Set([a]);break}o=o||new Set}let s;if(i&&o.size>0){let a=Object.fromEntries(Object.entries(t).filter(([d,p])=>o.has(d))),c=new Set;for(let d in a){if(!Object.prototype.hasOwnProperty.call(a,d))continue;let p=a[d];Cn(p)&&p.isAvailable()&&c.add(d)}let u=ci(e,a,-1,{channelsToSnapshot:c}),l=pv(a,u);jr(Yi(u),l,[r],void 0,void 0),s=pi({...t,...l},n)}else s=pi(t,n);return s}function Rv(e,t,r){for(let[n,i]of r)if(["__pregel_push","__pregel_tasks"].includes(n)&&i!=null){if(!Gt(i))throw new Ce(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(i)}`);if(!(i.node in t))throw new Ce(`Invalid node name "${i.node}" in Send packet`)}e(r)}var b3=new Set([tf,Er,Tr,rt,hs,fs,Yp]),w3=new Set(YP);function jr(e,t,r,n,i){let o=new Map;for(let m of r)o.set(m,m.path?.slice(0,3)||[]);r.sort((m,h)=>{let y=o.get(m),w=o.get(h);for(let _=0;_<Math.min(y.length,w.length);_+=1){if(y[_]<w[_])return-1;if(y[_]>w[_])return 1}return y.length-w.length});let s=id(t),a=!1,c=new Set;for(let m of r){m.triggers.length>0&&(a=!0),e.versions_seen[m.name]??={};for(let h of m.triggers)h in e.channel_versions&&(e.versions_seen[m.name][h]=e.channel_versions[h]),w3.has(h)||c.add(h)}let u=v3(e.channel_versions),l=!1;for(let m of c)m in s&&s[m].consume()&&n!==void 0&&(e.channel_versions[m]=n(u),l=!0);let d={},p={};for(let m of r){let h=m.id??"";for(let[y,w]of m.writes)b3.has(y)||y in s&&(d[y]??=[],d[y].push(w),p[y]??=[],p[y].push(h))}for(let[m,h]of Object.entries(d)){if(h.length<2||s[m]?.lc_graph_name!=="DeltaChannel")continue;let y=p[m],w=h.map((_,b)=>({val:_,taskId:y[b]}));w.sort((_,b)=>_.taskId<b.taskId?-1:_.taskId>b.taskId?1:0),d[m]=w.map(_=>_.val)}u!=null&&n!=null&&(u=l?n(u):u);let f=new Set;for(let[m,h]of Object.entries(d))if(m in s){let y=s[m],w;try{w=y.update(h)}catch(_){if(_.name===Ce.unminifiable_name){let b=new Ce(`Invalid update for channel "${m}" with values ${JSON.stringify(h)}: ${_.message}`);throw b.lc_error_code=_.lc_error_code,b}else throw _}w&&n!==void 0&&(e.channel_versions[m]=n(u),y.isAvailable()&&f.add(m))}if(a)for(let m in s){if(!Object.prototype.hasOwnProperty.call(s,m))continue;let h=s[m];h.isAvailable()&&!f.has(m)&&h.update([])&&n!==void 0&&(e.channel_versions[m]=n(u),h.isAvailable()&&f.add(m))}if(a&&!_3(f,i))for(let m in s){if(!Object.prototype.hasOwnProperty.call(s,m))continue;let h=s[m];h.finish()&&n!==void 0&&(e.channel_versions[m]=n(u),h.isAvailable()&&f.add(m))}return f}function*x3(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let n=new Set;for(let i of r.updatedChannels){let o=r.triggerToNodes[i];for(let s of o??[])n.add(s)}yield*[...n].sort();return}if(!(()=>{for(let n in e.channel_versions)if(e.channel_versions[n]!==null)return!1;return!0})())for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(yield n)}function k3(e){let t,r=new Map,n=new Set;if(e)for(let[i,o,s]of e){if(i==="00000000-0000-0000-0000-000000000000"&&o==="__resume__"&&t===void 0&&(t=s),o==="__resume__"&&i!=="00000000-0000-0000-0000-000000000000"){let a=r.get(i);a||(a=[],r.set(i,a)),a.push(s)}o!=="__error__"&&n.add(i)}return{nullResume:t,resumeByTaskId:r,successfulWriteTaskIds:n}}function Ks(e,t,r,n,i,o,s){let a={},c=s.pendingWritesIndex?s:{...s,pendingWritesIndex:k3(t)},u=n[Pi];if(u?.isAvailable()){let l=u.get().length;for(let d=0;d<l;d+=1){let p=Mv([Er,d],e,t,r,n,i,o,c);p!==void 0&&(a[p.id]=p)}}for(let l of x3(e,r,c)){let d=Mv([cg,l],e,t,r,n,i,o,c);d!==void 0&&(a[d.id]=d)}return a}function Mv(e,t,r,n,i,o,s,a){let{step:c,checkpointer:u,manager:l}=a,d=o.configurable??{},p=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&KD(e[e.length-1])){let f=e[e.length-1],m=GD(f.name,f.func),h=[Er],y=p===""?f.name:`${p}|${f.name}`,w=Ri(JSON.stringify([y,c.toString(),f.name,Er,e[1],e[2]]),t.id),_=`${y}:${w}`,b=[...e.slice(0,3),!0],I={langgraph_step:c,langgraph_node:f.name,langgraph_triggers:h,langgraph_path:b,langgraph_checkpoint_ns:_,checkpoint_ns:_};if(s){let $=[],P={checkpointId:t.id,checkpointNs:_,taskId:w,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:f.name,input:f.input,proc:m,writes:$,config:{...ze(Kt(o,{metadata:I,store:a.store??o.store}),{runName:f.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Gu]:w,[gr]:C=>Rv(x=>$.push(...x),n,C),[$r]:(C,x=!1)=>pd(t,i,{name:f.name,writes:$,triggers:h,path:b},C,x),[wn]:u??d.__pregel_checkpointer,[yr]:{...d[yr],[p]:t.id},[Zr]:Nv({pendingWrites:r??[],taskId:w,currentTaskInput:f.input,resumeMap:o.configurable?.[Ga],namespaceHash:no(_),pendingWritesIndex:a.pendingWritesIndex}),[Ha]:t.channel_values[gs],checkpoint_id:void 0,checkpoint_ns:_}}),executionInfo:P},triggers:h,retry_policy:f.retry,cache_key:f.cache?{key:no((f.cache.keyFunc??JSON.stringify)([f.input])),ns:[sg,f.name??"__dynamic__"],ttl:f.cache.ttl}:void 0,id:w,path:b,writers:[],timeout:f.timeout}}else return{id:w,name:f.name,interrupts:[],path:b}}else if(e[0]==="__pregel_push"){let f=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!i.__pregel_tasks?.isAvailable())return;let m=i[Pi].get();if(f<0||f>=m.length)return;let h=ug(m[f])&&!Gt(m[f])?new qa(m[f].node,m[f].args,m[f].timeout!==void 0?{timeout:m[f].timeout}:void 0):m[f];if(!ug(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in n)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let y=[Er],w=p===""?h.node:`${p}|${h.node}`,_=Ri(JSON.stringify([w,c.toString(),h.node,Er,f.toString()]),t.id),b=`${w}:${_}`,I={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:y,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:b,checkpoint_ns:b};if(s){let $=n[h.node],P=$.getNode();if(P!==void 0){$.metadata!==void 0&&(I={...I,...$.metadata});let C=[],x={checkpointId:t.id,checkpointNs:b,taskId:_,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:h.node,input:h.args,proc:P,subgraphs:$.subgraphs,writes:C,config:{...ze(Kt(o,{metadata:I,tags:$.tags,store:a.store??o.store}),{runName:h.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Gu]:_,[gr]:D=>Rv(M=>C.push(...M),n,D),[$r]:(D,M=!1)=>pd(t,i,{name:h.node,writes:C,triggers:y,path:e},D,M),[wn]:u??d.__pregel_checkpointer,[yr]:{...d[yr],[p]:t.id},[Zr]:Nv({pendingWrites:r??[],taskId:_,currentTaskInput:h.args,resumeMap:o.configurable?.[Ga],namespaceHash:no(b),pendingWritesIndex:a.pendingWritesIndex}),[Ha]:t.channel_values[gs],checkpoint_id:void 0,checkpoint_ns:b}}),executionInfo:x},triggers:y,retry_policy:$.retryPolicy,cache_key:$.cachePolicy?{key:no(($.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[sg,$.name??"__dynamic__",h.node],ttl:$.cachePolicy.ttl}:void 0,id:_,path:e,writers:$.getWriters(),timeout:h.timeout??$.timeout}}}else return{id:_,name:h.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let f=e[1].toString(),m=n[f];if(m===void 0)return;if(r?.length){let _=p===""?f:`${p}|${f}`,b=Ri(JSON.stringify([_,c.toString(),f,cg,f]),t.id);if(a.pendingWritesIndex?a.pendingWritesIndex.successfulWriteTaskIds.has(b):r.some(I=>I[0]===b&&I[1]!=="__error__"))return}let h=Cv(t.channel_versions);if(h===void 0)return;let y=t.versions_seen[f]??{},w=m.triggers.find(_=>i[_].isAvailable()?(t.channel_versions[_]??h)>(y[_]??h):!1);if(w!==void 0){let _=I3(m,i,s);if(_===void 0)return;let b=p===""?f:`${p}|${f}`,I=Ri(JSON.stringify([b,c.toString(),f,cg,[w]]),t.id),$=`${b}:${I}`,P={langgraph_step:c,langgraph_node:f,langgraph_triggers:[w],langgraph_path:e,langgraph_checkpoint_ns:$,checkpoint_ns:$};if(s){let C=m.getNode();if(C!==void 0){m.metadata!==void 0&&(P={...P,...m.metadata});let x=[],D={checkpointId:t.id,checkpointNs:$,taskId:I,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:f,input:_,proc:C,subgraphs:m.subgraphs,writes:x,config:{...ze(Kt(o,{metadata:P,tags:m.tags,store:a.store??o.store}),{runName:f,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Gu]:I,[gr]:M=>Rv(R=>{x.push(...R)},n,M),[$r]:(M,R=!1)=>pd(t,i,{name:f,writes:x,triggers:[w],path:e},M,R),[wn]:u??d.__pregel_checkpointer,[yr]:{...d[yr],[p]:t.id},[Zr]:Nv({pendingWrites:r??[],taskId:I,currentTaskInput:_,resumeMap:o.configurable?.[Ga],namespaceHash:no($),pendingWritesIndex:a.pendingWritesIndex}),[Ha]:t.channel_values[gs],checkpoint_id:void 0,checkpoint_ns:$}}),executionInfo:D},triggers:[w],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:no((m.cachePolicy.keyFunc??JSON.stringify)([_])),ns:[sg,m.name??"__dynamic__",f],ttl:m.cachePolicy.ttl}:void 0,id:I,path:e,writers:m.getWriters(),timeout:m.timeout}}}else return{id:I,name:f,interrupts:[],path:e}}}}function XD(e,t,r,n,i,o,s,a,c){let{step:u,checkpointer:l,manager:d}=c,p=o[t];if(p===void 0)return;let f=p.getNode();if(f===void 0)return;let m=a.configurable??{},h=m.checkpoint_ns??"",y=[Er],w=h===""?t:`${h}|${t}`,_=Ri(JSON.stringify([w,u.toString(),t,Er,"node_error_handler",e.id]),n.id),b=`${w}:${_}`,I=[Er,String(e.name),t,!1],$={langgraph_step:u,langgraph_node:t,langgraph_triggers:y,langgraph_path:I,langgraph_checkpoint_ns:b,checkpoint_ns:b};p.metadata!==void 0&&($={...$,...p.metadata});let P=[],C={checkpointId:n.id,checkpointNs:b,taskId:_,threadId:m.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:t,input:e.input,proc:f,subgraphs:p.subgraphs,writes:P,config:{...ze(Kt(a,{metadata:$,tags:p.tags,store:c.store??a.store}),{runName:t,callbacks:d?.getChild(`graph:step:${u}`),configurable:{[Gu]:_,[gr]:x=>Rv(D=>P.push(...D),o,x),[$r]:(x,D=!1)=>pd(n,s,{name:t,writes:P,triggers:y,path:I},x,D),[wn]:l??m.__pregel_checkpointer,[yr]:{...m[yr],[h]:n.id},[Zr]:Nv({pendingWrites:i??[],taskId:_,currentTaskInput:e.input,resumeMap:a.configurable?.[Ga],namespaceHash:no(b)}),[Ha]:n.channel_values[gs],[ef]:new xw(String(e.name),r),checkpoint_id:void 0,checkpoint_ns:b}}),executionInfo:C},triggers:y,retry_policy:p.retryPolicy,cache_key:void 0,id:_,path:I,writers:p.getWriters()}}function I3(e,t,r){let n;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){n={};for(let[i,o]of Object.entries(e.channels))if(e.triggers.includes(o))try{n[i]=Dc(t,o,!1)}catch(s){if(s.name===Je.unminifiable_name)return;throw s}else if(o in t)try{n[i]=Dc(t,o,!1)}catch(s){if(s.name===Je.unminifiable_name)continue;throw s}}else if(Array.isArray(e.channels)){let i=!1;for(let o of e.channels)try{n=Dc(t,o,!1),i=!0;break}catch(s){if(s.name===Je.unminifiable_name)continue;throw s}if(!i)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(n=e.mapper(n)),n}function YD(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[n,i]of Object.entries(e.args)){let o=t[n];(!o||o.lc_graph_name!=="UntrackedValue")&&(r[n]=i)}return new qa(e.node,r)}function Nv({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:n,namespaceHash:i,pendingWritesIndex:o}){let s=o?o.nullResume:e.find(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__")?.[2],a={callCounter:0,interruptCounter:-1,resume:(()=>{let c=o?(o.resumeByTaskId.get(t)??[]).flat():e.filter(([u,l])=>u===t&&l==="__resume__").flatMap(([u,l,d])=>d);if(n!=null&&i in n){let u=n[i];c.push(u)}return c})(),nullResume:s,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(a.nullResume)return delete a.nullResume,e.splice(e.findIndex(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__"),1),s}};return a}var Wm={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},qm=(e,t)=>`${e.start}${t}${e.end}`;function S3(e){if(e==null)return;let t={};if(e.metadata!=null)for(let[n,i]of Object.entries(e.metadata))ZO.has(n)||(t[n]=i);let r=wD(e.tags);return r!=null&&(t.tags=r),Object.keys(t).length>0?t:void 0}function*zv(e){for(let{id:t,name:r,input:n,config:i,triggers:o,writes:s}of e){if(i?.tags?.includes("langsmith:hidden"))continue;let a={id:t,name:r,input:n,triggers:o,interrupts:s.filter(([u,l])=>u===t&&l==="__interrupt__").map(([,u])=>u)},c=S3(i);c!=null&&(a.metadata=c),yield a}}function A3(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function QD(e){let t={};for(let[r,n]of e){let i=String(r);if(i in t){let o=A3(t[i])?t[i].$writes:[t[i]];o.push(n),t[i]={$writes:o}}else t[i]=n}return t}function*eU(e,t){for(let[{id:r,name:n,config:i},o]of e)i?.tags?.includes("langsmith:hidden")||(yield{id:r,name:n,result:QD(o.filter(([s])=>Array.isArray(t)?t.includes(s):s===t)),interrupts:o.filter(s=>s[0]===rt).map(s=>s[1])})}function*tU(e,t,r,n,i,o,s,a){function c(d){let p={};return d.callbacks!=null&&(p.callbacks=d.callbacks),d.configurable!=null&&(p.configurable=d.configurable),d.maxConcurrency!=null&&(p.max_concurrency=d.maxConcurrency),d.metadata!=null&&(p.metadata=d.metadata),d.recursionLimit!=null&&(p.recursion_limit=d.recursionLimit),d.runId!=null&&(p.run_id=d.runId),d.runName!=null&&(p.run_name=d.runName),d.tags!=null&&(p.tags=d.tags),p}let u=e.configurable?.checkpoint_ns,l={};for(let d of i){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(Tv))continue;let p=`${d.name}:${d.id}`;u&&(p=`${u}|${p}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:p}}}yield{config:c(e),values:pi(t,r),metadata:n,next:i.map(d=>d.name),tasks:m$(i,o,l,a),parentConfig:s?c(s):void 0}}function m$(e,t,r,n){return e.map(i=>{let o=t.find(([u,l])=>u===i.id&&l==="__error__")?.[2],s=t.filter(([u,l])=>u===i.id&&l==="__interrupt__").map(([,,u])=>u),a=(()=>{if(o||s.length||!t.length)return;let u=t.findIndex(([l,d])=>l===i.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof n=="string")return t.find(([l,d])=>l===i.id&&d===n)?.[2];if(Array.isArray(n)){let l=t.filter(([d,p])=>d===i.id&&n.includes(p)).map(([,d,p])=>[d,p]);return l.length?QD(l):void 0}})();if(o)return{id:i.id,name:i.name,path:i.path,error:o,interrupts:s,result:a};let c=r?.[i.id];return{id:i.id,name:i.name,path:i.path,interrupts:s,...c!==void 0?{state:c}:{},result:a}})}function rU(e,t,r){console.log([`${qm(Wm.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
|
|
285
|
-
`,JSON.stringify(pi(t,r),null,2)].join(""))}function Km(e,t){let r=t.length;console.log([`${qm(Wm.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
|
|
286
|
-
`,t.map(n=>`- ${qm(Wm.green,String(n.name))} -> ${JSON.stringify(n.input,null,2)}`).join(`
|
|
287
|
-
`)].join(""))}function nU(e,t,r){let n={};for(let[i,o]of t)r.includes(i)&&(n[i]||(n[i]=[]),n[i].push(o));console.log([`${qm(Wm.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(n).length} channel${Object.keys(n).length!==1?"s":""}:\x1B[0m
|
|
288
|
-
`,Object.entries(n).map(([i,o])=>`- ${qm(Wm.yellow,i)} -> ${o.map(s=>JSON.stringify(s)).join(", ")}`).join(`
|
|
289
|
-
`)].join(""))}var jv=class extends jt{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),n=t??new AbortController;super({start(i){return o();function o(){return r.read().then(({done:s,value:a})=>{if(s){i.close();return}return i.enqueue(a),o()})}}}),this._abortController=n,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},g$=class extends jt{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(n=>{t=n});super({start:n=>{t(n)}}),r.then(n=>{this.controller=n}),this.passthroughFn=e.passthroughFn,this.modes=e.modes}push(e){this._closed||!this.controller||(this.passthroughFn?.(e),this.controller.enqueue(e))}close(){try{this.controller.close()}catch{}finally{this._closed=!0}}error(e){try{this.controller?.error(e)}finally{this._closed=!0}}},sU=class extends ps{name="StreamToolsHandler";awaitHandlers=!0;streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,n,i,o,s,a){if(!o||i&&i.includes("langsmith:hidden"))return;let c=o.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:a,toolName:s??"unknown",input:t};this.runs[r]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.toolName,input:t}])}handleToolEvent(e,t){let r=this.runs[t];r&&this.streamFn([r.ns,"tools",{event:"on_tool_event",toolCallId:r.toolCallId,name:r.toolName,data:e}])}handleToolEnd(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_end",toolCallId:r.toolCallId,name:r.toolName,output:e}])}handleToolError(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_error",toolCallId:r.toolCallId,name:r.toolName,error:e}])}};function O3(e){return JSON.stringify(e,function(t,r){let n=this[t];if(n!=null&&typeof n=="object"&&"toDict"in n&&typeof n.toDict=="function"){let{type:i,data:o}=n.toDict();return{...o,type:i}}return r})}function $3(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function y$(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function h$(e){return!y$(e)||!e.configurable.thread_id?null:{thread_id:e.configurable.thread_id,checkpoint_ns:e.configurable.checkpoint_ns||"",checkpoint_id:e.configurable.checkpoint_id||null,checkpoint_map:e.configurable.checkpoint_map||null}}function iU(e){if(y$(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([n])=>!n.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function oU(e){let t={...e,checkpoint:h$(e.config),parent_checkpoint:h$(e.parentConfig),config:iU(e.config),parent_config:iU(e.parentConfig),tasks:e.tasks.map(r=>{if(y$(r.state)){let n=h$(r.state);if(n!=null){let i={...r,checkpoint:n};return delete i.state,i}}return r})};return delete t.parentConfig,t}function aU(e){let t=new TextEncoder;return new ReadableStream({async start(r){let n=i=>{r.enqueue(t.encode(`event: ${i.event}
|
|
290
|
-
data: ${O3(i.data)}
|
|
291
|
-
|
|
292
|
-
`))};try{for await(let i of e){let[o,s,a]=i,c=a;if(s==="debug"){let u=a;u.type==="checkpoint"&&(c={...u,payload:oU(u.payload)})}s==="checkpoints"&&(c=oU(a)),n({event:o?.length?`${s}|${o.join("|")}`:s,data:c})}}catch(i){n({event:"error",data:$3(i)})}r.close()}})}function cU(...e){return new g$({passthroughFn:t=>{let r=t[1]==="checkpoints"&&sd(t[2]);for(let n of e)(n.modes.has(t[1])||r)&&n.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var uU=class{checkpointId;#e=new Set;constructor(e){this.checkpointId=e}#t(e){let t=e.includes(":")?e.slice(0,e.lastIndexOf(":")):e;return this.#e.has(t)?!1:(this.#e.add(t),!0)}async getCheckpoint(e,t,r){if(this.#t(e)){let n=[];for await(let i of t.list(r,{before:{configurable:{checkpoint_id:this.checkpointId}},limit:1}))n.push(i);return n.length>0?n[0]:void 0}return await t.getTuple(r)??void 0}};var Dv=Symbol.for("INPUT_DONE"),_$=Symbol.for("INPUT_RESUMING"),T3=25;function lU(e){if(!(e==null||typeof e!="object")){if(Rt.isInstance(e)){let t=e;t.id==null&&(t.id=Da(),t.lc_kwargs!=null&&(t.lc_kwargs.id=t.id));return}if(Array.isArray(e)){for(let t of e)lU(t);return}}}function dU(e){return e===void 0||e===""?[]:e.split("|")}function E3(e){if(!e)return[];let t="";for(let r of Object.keys(e))r!==""&&r.length>t.length&&(t=r);return dU(t)}var P3=class extends dv{cache;queue=Promise.resolve();constructor(e){super(),this.cache=e}async get(e){return this.enqueueOperation("get",e)}async set(e){return this.enqueueOperation("set",e)}async clear(e){return this.enqueueOperation("clear",e)}async stop(){await this.queue}enqueueOperation(e,...t){let r=this.queue.then(()=>this.cache[e](...t));return this.queue=r.then(()=>{},()=>{}),r}},pU=class fU{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;_exitDeltaWrites;_deltaChannelsWithOverwrite=new Set;_hasPersistedParent=!1;_initialCheckpointConfig;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";control;tasks={};stream;checkpointerPromises=new Set;isNested;resumeAtHead;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let r=t.then(n=>(this.checkpointerPromises.delete(r),n),n=>{throw n});this.checkpointerPromises.add(r)}async _awaitCheckpointerPromises(){await Promise.all([...this.checkpointerPromises])}store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let t=!1;if("__start__"in this.checkpoint.channel_versions)t=!0;else for(let a in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,a)){t=!0;break}let r=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,n=this.input===null||this.input===void 0,i=tr(this.input)&&this.input.resume!=null,o=this.input===_$,s=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return t&&(r||n||i||o||s)}get isReplaying(){return!this.skipDoneTasks}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=JD,this.checkpoint=t.checkpoint,this.checkpointMetadata=t.checkpointMetadata,this.checkpointPreviousVersions=t.checkpointPreviousVersions,this.channels=t.channels,this.checkpointPendingWrites=t.checkpointPendingWrites,this.step=t.step,this.stop=t.stop,this.config=t.config,this.checkpointConfig=t.checkpointConfig,this.isNested=t.isNested,this.resumeAtHead=t.resumeAtHead,this.manager=t.manager,this.outputKeys=t.outputKeys,this.streamKeys=t.streamKeys,this.nodes=t.nodes,this.skipDoneTasks=t.skipDoneTasks,this.store=t.store,this.cache=t.cache?new P3(t.cache):void 0,this.stream=t.stream,this.checkpointNamespace=t.checkpointNamespace,this.prevCheckpointConfig=t.prevCheckpointConfig,this.interruptAfter=t.interruptAfter,this.interruptBefore=t.interruptBefore,this.durability=t.durability,this.debug=t.debug,this.triggerToNodes=t.triggerToNodes,this.control=this.config.control,this._exitDeltaWrites=this.durability==="exit"&&this.checkpointer!=null?[]:void 0,this._hasPersistedParent=t.hasPersistedParent??!1,this._initialCheckpointConfig=t.checkpointConfig,this.checkpointIdSaved=t.checkpoint.id}static async initialize(t){let{config:r,stream:n}=t;n!==void 0&&r.configurable?.__pregel_stream!==void 0&&(n=cU(n,r.configurable[Qp]));let i=r.configurable?!("checkpoint_id"in r.configurable):!0,o=r.configurable?.[Zr];r.configurable&&o&&(o.subgraphCounter>0&&(r=Jt(r,{[on]:[r.configurable[on],o.subgraphCounter.toString()].join("|")})),o.subgraphCounter+=1);let s=r.configurable?.checkpoint_id,a=$r in(r.configurable??{});!a&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=Jt(r,{checkpoint_ns:"",checkpoint_id:void 0}));let c=r;r.configurable?.checkpoint_id===void 0&&r.configurable?.checkpoint_map!==void 0&&r.configurable?.checkpoint_map?.[r.configurable?.checkpoint_ns]&&(c=Jt(r,{checkpoint_id:r.configurable[yr][r.configurable?.checkpoint_ns]}));let u=dU(r.configurable?.checkpoint_ns),l;t.checkpointer?c.configurable?.checkpoint_id?l=await t.checkpointer.getTuple(c):r.configurable?.__pregel_replay_state?(l=await r.configurable[ag].getCheckpoint(r.configurable?.checkpoint_ns??"",t.checkpointer,c),r.configurable&&delete r.configurable[Ka]):l=await t.checkpointer.getTuple(c):l=void 0;let d=l!==void 0;l||(l={config:r,checkpoint:Mc(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]}),c={...r,...l.config,configurable:{checkpoint_ns:"",...r.configurable,...l.config.configurable}};let p=l.parentConfig,f=Yi(l.checkpoint),m={...l.metadata},h=l.pendingWrites??[],y=r.configurable?.checkpoint_ns,w=r.configurable?.[yr];typeof y=="string"&&y!==""&&typeof w=="object"&&w!==null&&y in w&&h.length>0&&(h=h.filter(([,M])=>M!==Tr));let _=!1,b=c.configurable?.thread_id,I=c.configurable?.checkpoint_ns??"";t.checkpointer&&s&&typeof b=="string"&&(_=(await t.checkpointer.getTuple({configurable:{thread_id:b,checkpoint_ns:I}}))?.config.configurable?.checkpoint_id===s&&m.source!=="update"&&m.source!=="fork");let $=await od(t.channelSpecs,f,{saver:t.checkpointer,config:c}),P=(m.step??0)+1,C=P+(r.recursionLimit??T3)+1,x={...f.channel_versions},D=t.store?new lv(t.store):void 0;return D&&await D.start(),new fU({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:f,checkpointMetadata:m,checkpointConfig:c,prevCheckpointConfig:p,checkpointNamespace:u,channels:$,isNested:a,resumeAtHead:_,manager:t.manager,skipDoneTasks:i,step:P,stop:C,checkpointPreviousVersions:x,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:n,store:D,cache:t.cache,interruptAfter:t.interruptAfter,interruptBefore:t.interruptBefore,durability:t.durability,debug:t.debug,triggerToNodes:t.triggerToNodes,hasPersistedParent:d})}_checkpointerPutAfterPrevious(t){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>this.checkpointer?.put(t.config,t.checkpoint,t.metadata,t.newVersions)),this._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,r){let n=r;if(n.length===0)return;n.every(([c])=>c in uv)&&(n=Array.from(new Map(n.map(c=>[c[0],c])).values()));let i=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){i=!0;break}let o=n;i&&(o=n.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&Gt(u)?[c,YD(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of o)this.checkpointPendingWrites.push([t,c,u]);for(let[c,u]of o){let l=this.channels[c];l!=null&&Cn(l)&&lU(u)}let s=Jt(this.checkpointConfig,{[on]:this.config.configurable?.checkpoint_ns??"",[ms]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(s,o,t)),this.tasks&&this._outputWrites(t,n),!r.length||!this.cache||!this.tasks)return;let a=this.tasks[t];a==null||a.cache_key==null||r[0][0]==="__error__"||r[0][0]==="__interrupt__"||this.cache.set([{key:[a.cache_key.ns,a.cache_key.key],value:a.writes,ttl:a.cache_key.ttl}])}_outputWrites(t,r,n=!1){let i=this.tasks[t];if(i!==void 0){if(i.config!==void 0&&(i.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(i.path?.[0]==="__pregel_push"&&i.path?.[i.path.length-1]===!0)return;let o=r.filter(s=>s[0]===rt).flatMap(s=>s[1]);this._emit([["updates",{[rt]:o}],["values",{[rt]:o}]])}else r[0][0]!=="__error__"&&this._emit(Vs(io(VD(this.outputKeys,[[i,r]],n),"updates")));n||this._emit(Vs(io(eU([[i,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([s,a])=>`ns:${s.join(",")}|key:${a}`,n=[],i={};for(let s of Object.values(this.tasks))s.cache_key!=null&&!s.writes.length&&(n.push([s.cache_key.ns,s.cache_key.key]),i[r([s.cache_key.ns,s.cache_key.key])]=s);if(n.length===0)return[];let o=await this.cache.get(n);for(let{key:s,value:a}of o){let c=i[r(s)];c!=null&&(c.writes.push(...a),t.push({task:c,result:a}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:r=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![Dv,_$].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new _o;if(Object.values(this.tasks).every(i=>i.writes.length>0)){let i=Object.values(this.tasks),o=i.flatMap(a=>a.writes);this.updatedChannels=jr(this.checkpoint,this.channels,i,this.checkpointerGetNextVersion,this.triggerToNodes);for(let[a,c]of o){let u=this.channels[a];u!=null&&Cn(u)&&Ja(c)&&this._deltaChannelsWithOverwrite.add(a)}let s=await li(io(Pv(this.outputKeys,o,this.channels),"values"));if(this._exitDeltaWrites!==void 0)for(let[a,c,u]of this.checkpointPendingWrites){let l=this.channels[c];l!=null&&Cn(l)&&this._exitDeltaWrites.push([this.step,a,c,u])}if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this.durability==="sync"&&await this._awaitCheckpointerPromises(),this._emitValuesWithCheckpointMeta(s),Vm(this.checkpoint,this.interruptAfter,i))throw this.status="interrupt_after",new _o;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[Ka]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;this.tasks=Ks(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels});let n=Object.values(this.tasks);if(this.checkpointer&&(this.stream.modes.has("checkpoints")||this.stream.modes.has("debug"))&&this._emit(await li(io(tU(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,n,this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),n.length===0)return this.status="done",!1;if(this.control!=null&&this.control.drainRequested)return this.status="draining",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[i,o,s]of this.checkpointPendingWrites){if(o==="__error__"||o==="__error_source_node__"||o==="__interrupt__"||o==="__resume__")continue;let a=n.find(c=>c.id===i);a&&a.writes.push([o,s])}this._resumeErrorHandlersIfApplicable(),n=Object.values(this.tasks);for(let i of n)i.writes.length>0&&this._outputWrites(i.id,i.writes,!0)}if(n.every(i=>i.writes.length>0))return this.tick({inputKeys:r});if(Vm(this.checkpoint,this.interruptBefore,n))throw this.status="interrupt_before",new _o;if(this.stream.modes.has("tasks")||this.stream.modes.has("debug")){let i=await li(io(zv(n),"tasks"));this._emit(i)}return!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(n=>!n.includes(":")))&&(await this._putExitDeltaWrites(),this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=pi(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(n=>n.writes.length>0)&&(this.updatedChannels=jr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(Vs(io(Pv(this.outputKeys,Object.values(this.tasks).flatMap(n=>n.writes),this.channels),"values")))),vo(t)&&!t.interrupts.length&&this._emit([["updates",{[rt]:[]}],["values",{[rt]:[]}]],this.#e())),r}async acceptPush(t,r,n){if(this.interruptAfter?.length>0&&Vm(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let i=Mv([Er,t.path??[],r,t.id,n],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!i)return;if(this.interruptBefore?.length>0&&Vm(this.checkpoint,this.interruptBefore,[i])){this.toInterrupt.push(i);return}(this.stream.modes.has("tasks")||this.stream.modes.has("debug"))&&this._emit(Vs(io(zv([i]),"tasks"))),this.debug&&Km(this.step,[i]),this.tasks[i.id]=i,this.skipDoneTasks&&this._matchWrites({[i.id]:i});let o=await this._matchCachedWrites();for(let{task:s}of o)this._outputWrites(s.id,s.writes,!0);return i}getErrorHandlerNode(t){return this.nodes[t]?.errorHandlerNode}isErrorHandlerNode(t){return this.nodes[t]?.isErrorHandler===!0}scheduleErrorHandler(t,r){let n=this.getErrorHandlerNode(String(t.name));if(!n)return;let i=XD(t,n,r,this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??this.config,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(i!==void 0)return this.tasks[i.id]=i,this._emit(Vs(io(zv([i]),"tasks"))),this.debug&&Km(this.step,[i]),i}_resumeErrorHandlersIfApplicable(){let t=new Map;for(let[r,n]of this.checkpointPendingWrites){if(n!=="__error_source_node__")continue;let i=this.checkpointPendingWrites.find(([a,c])=>a===r&&c==="__error__");if(i===void 0)continue;let o=i[2],s=new Error(o?.message??String(o));o?.name&&(s.name=o.name),t.set(r,s)}for(let[r,n]of t){let i=this.tasks[r];i!==void 0&&this.getErrorHandlerNode(String(i.name))&&(i.writes.length===0&&i.writes.push([fs,{message:n.message,name:n.name}]),this.scheduleErrorHandler(i,n))}}_suppressInterrupt(t){return vo(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,n=r?.[Zr];if(n&&n.nullResume!==void 0&&this.putWrites(Pr,[[Tr,n.nullResume]]),tr(this.input)){let u=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(Av)&&(this.config.configurable??={},this.config.configurable[Ga]=this.input.resume),u&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let l={};for(let[d,p,f]of ZD(this.input,this.checkpointPendingWrites))l[d]??=[],l[d].push([p,f]);if(Object.keys(l).length===0)throw new mg("Received empty Command input");for(let[d,p]of Object.entries(l))this.putWrites(d,p)}let i=(this.checkpointPendingWrites??[]).filter(u=>u[0]===Pr).map(u=>u.slice(1));i.length>0&&jr(this.checkpoint,this.channels,[{name:Ei,writes:i,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let o=tr(this.input),s=o&&i.length>0,a=this.isReplaying&&(this.isNested&&r?.checkpoint_ns!==void 0&&r?.checkpoint_ns!==""&&r?.checkpoint_map!==void 0&&r.checkpoint_ns in r.checkpoint_map||!(o&&this.input.resume!=null||r?.__pregel_resuming===!0||this.resumeAtHead));a&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(u=>u[1]!==Tr));let c=this.isResuming;if(c||s){let u={...this.checkpoint.versions_seen[rt]};for(let d in this.channels)Object.prototype.hasOwnProperty.call(this.channels,d)&&this.checkpoint.channel_versions[d]!==void 0&&(u[d]=this.checkpoint.channel_versions[d]);this.checkpoint.versions_seen[rt]=u,a&&this.checkpointMetadata.source!=="update"&&this.checkpointMetadata.source!=="fork"&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(d=>d[1]!==rt),await this._putCheckpoint({source:"fork"}));let l=await li(io(Pv(this.outputKeys,!0,this.channels),"values"));c?this.input=_$:s&&(await this._putCheckpoint({source:"input"}),this.input=Dv),this._emitValuesWithCheckpointMeta(l)}else{let u=await li(Ev(t,this.input));if(u.length>0){let l=Ks(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=jr(this.checkpoint,this.channels,Object.values(l).concat([{name:Ei,writes:u,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes);let d=u.filter(([p])=>{let f=this.channels[p];return f!=null&&Cn(f)});for(let[p,f]of d)Ja(f)&&this._deltaChannelsWithOverwrite.add(p);if(d.length>0)if(this._exitDeltaWrites!==void 0)for(let[p,f]of d)this._exitDeltaWrites.push([this.step,Pr,p,f]);else this.checkpointer!=null&&this.putWrites(Pr,d);await this._putCheckpoint({source:"input"}),this.input=Dv}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=Dv;else throw new mg(`Received no input writes for ${JSON.stringify(t,null,2)}`)}if(!this.isNested){let u;if(a){let l=this.checkpoint.id;(this.checkpointMetadata.source==="update"||this.checkpointMetadata.source==="fork")&&this.prevCheckpointConfig&&(l=this.prevCheckpointConfig.configurable?.checkpoint_id??l),u=new uU(l)}this.config=Jt(this.config,{[Ka]:this.isResuming,[ag]:u})}}#e(){let t=this.checkpointNamespace;if(!(t.length===0||t.length===1&&t[0]==="")||this.config.configurable?.__pregel_stream===void 0)return t;let r=E3(this.config.configurable?.[yr]);return r.length>0?r:t}_emit(t,r=this.checkpointNamespace){for(let[n,i]of t)if(this.stream.modes.has(n)&&this.stream.push([r,n,i]),(n==="checkpoints"||n==="tasks")&&this.stream.modes.has("debug")){let o=n==="checkpoints"?this.step-1:this.step,s=new Date().toISOString(),a=n==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([r,"debug",{step:o,type:a,timestamp:s,payload:i}])}}_currentCheckpointMeta(){if(!this.checkpointMetadata||!this.checkpoint?.id)return;let t=this.prevCheckpointConfig?.configurable?.checkpoint_id;return{checkpoint:{id:this.checkpoint.id,...t?{parent_id:t}:{},step:this.checkpointMetadata.step,source:this.checkpointMetadata.source}}}_emitValuesWithCheckpointMeta(t){let r=this._currentCheckpointMeta();for(let[n,i]of t)n==="values"&&r?.checkpoint!=null&&!this.stream.modes.has("checkpoints")&&this.stream.push([this.checkpointNamespace,"checkpoints",r.checkpoint]),this.stream.modes.has(n)&&this.stream.push([this.checkpointNamespace,n,i])}_putCheckpoint(t){let r=this.checkpointMetadata===t,n=this.checkpointer!=null&&(this.durability!=="exit"||r),i=c=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=Jt(this.checkpointConfig,{[on]:this.config.configurable?.checkpoint_ns??""});let u={...this.checkpoint.channel_versions},l=dd(this.checkpointPreviousVersions,u);this.checkpointPreviousVersions=u,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:Yi(c),metadata:{...this.checkpointMetadata},newVersions:l}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}},o;if(r)o={...this.checkpointMetadata.counters_since_delta_snapshot??{}};else{let c=this.checkpointMetadata.counters_since_delta_snapshot??{};o={};let u=this.updatedChannels??new Set;for(let l in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,l)||!Cn(this.channels[l]))continue;let[d,p]=c[l]??[0,0];o[l]=[u.has(l)?d+1:d,p+1]}this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}}let s=n?fv(this.channels,o):new Set;if(n)for(let c of this._deltaChannelsWithOverwrite)s.add(c);this.checkpoint=ci(this.checkpoint,n?this.channels:void 0,this.step,{id:r?this.checkpoint.id:void 0,channelsToSnapshot:s,updatedChannels:this.updatedChannels,getNextVersion:n?c=>this.checkpointerGetNextVersion(c):void 0});for(let c of s)o[c]=[0,0],this._deltaChannelsWithOverwrite.delete(c);let a={};for(let c in o){if(!Object.prototype.hasOwnProperty.call(o,c))continue;let[u,l]=o[c];(u!==0||l!==0)&&(a[c]=[u,l])}Object.keys(a).length>0?this.checkpointMetadata.counters_since_delta_snapshot=a:delete this.checkpointMetadata.counters_since_delta_snapshot,n&&i(this.checkpoint),r||(this.step+=1)}async _putExitDeltaWrites(){if(this._exitDeltaWrites===void 0||this._exitDeltaWrites.length===0||this.checkpointer==null||this._initialCheckpointConfig===void 0)return;let t=this.checkpointMetadata.counters_since_delta_snapshot??{},r=fv(this.channels,t);for(let c of this._deltaChannelsWithOverwrite)r.add(c);let n=this._exitDeltaWrites.filter(([,,c])=>!r.has(c));if(n.length===0)return;let i;if(this._hasPersistedParent)i=this._initialCheckpointConfig;else{let c=Mc();c.id=this.checkpointIdSaved??c.id,c.ts=new Date().toISOString();let u=Jt(this._initialCheckpointConfig,{[ms]:void 0});i=Jt(this._initialCheckpointConfig,{[ms]:c.id}),this._trackCheckpointerPromise(this.checkpointer.put(u,c,{source:"loop",step:-2,parents:{}},{})),this.checkpointConfig=i}let o=Jt(i,{[on]:this.config.configurable?.checkpoint_ns??"",[ms]:i.configurable?.[ms]}),s=new Map,a=[];for(let[c,u,l,d]of n){let p=`${c}\0${u}`,f=s.get(p);f===void 0&&(f=[],s.set(p,f),a.push({key:p,step:c,tid:u})),f.push([l,d])}for(let{key:c,step:u,tid:l}of a){let d=qO(u,l);this._trackCheckpointerPromise(this.checkpointer.putWrites(o,s.get(c),d))}}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=Jt(this.checkpointConfig,{[on]:this.config.configurable?.checkpoint_ns??"",[ms]:this.checkpoint.id}),r={};for(let[n,i,o]of this.checkpointPendingWrites)r[n]??=[],r[n].push([i,o]);for(let[n,i]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,i,n))}_matchWrites(t){for(let[r,n,i]of this.checkpointPendingWrites){if(n==="__error__"||n==="__interrupt__"||n==="__resume__")continue;let o=Object.values(t).find(s=>s.id===r);o&&o.writes.push([n,i])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function C3(e){return St(e?.message)}function mU(e,t,r){if(!e)return;let n=e.langgraph_checkpoint_ns,i=e.checkpoint_ns,o=n??i;if(o)return[o.split("|"),{tags:t,name:r,...e}]}var hU=class extends ps{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,n=!1){if(n&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let i=t.id;r!=null&&(Gp(t)?i??=`run-${r}-tool-${t.tool_call_id}`:((i==null||i===`run-${r}`)&&(i=this.stableMessageIdMap[r]??i??`run-${r}`),this.stableMessageIdMap[r]??=i)),i!==t.id&&(t.id=i,t.lc_kwargs.id=i),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,n,i,o,s,a){s&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=mU(s,o,a))}handleLLMNewToken(e,t,r,n,i,o){let s=o?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(C3(s)?this._emit(this.metadatas[r],s.message,r):this._emit(this.metadatas[r],new ct({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];St(r?.message)&&this._emit(this.metadatas[t],r?.message,t,!0),delete this.emittedChatModelRunIds[t]}delete this.metadatas[t],delete this.stableMessageIdMap[t]}}handleLLMError(e,t){delete this.metadatas[t]}handleChainStart(e,t,r,n,i,o,s,a){if(o!==void 0&&a===o.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=mU(o,i,a),typeof t=="object")){for(let c of Object.values(t))if((St(c)||ho(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(St(u)||ho(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(St(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let n of e)St(n)&&this._emit(r,n,t,!0);else if(e!=null&&typeof e=="object"){for(let n of Object.values(e))if(St(n))this._emit(r,n,t,!0);else if(Array.isArray(n))for(let i of n)St(i)&&this._emit(r,i,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function gU(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function yU(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function R3(e){switch(e.type){case"text":return{type:"text",text:""};case"reasoning":return{type:"reasoning",reasoning:""};case"tool_call":case"tool_call_chunk":return{type:"tool_call_chunk",...e.id!=null?{id:e.id}:{},...e.name!=null?{name:e.name}:{},args:""};default:return e}}function N3(e){switch(e.type){case"text":{let t=typeof e.text=="string"?e.text:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"text-delta",text:t}}:void 0}case"reasoning":{let t=typeof e.reasoning=="string"?e.reasoning:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"reasoning-delta",reasoning:t}}:void 0}case"tool_call_chunk":return{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"block-delta",fields:{...e,type:"tool_call_chunk"}}};default:return}}var _U=class extends ps{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;awaitHandlers=!0;constructor(e){super(),this.streamFn=e}normalizeMessageId(e,t){let r=e.id;return t!=null&&(qt.isInstance(e)?r??=`run-${t}-tool-${e.tool_call_id}`:((r==null||r===`run-${t}`)&&(r=this.stableMessageIdMap[t]??r??`run-${t}`),this.stableMessageIdMap[t]??=r)),r!==e.id&&(e.id=r,e.lc_kwargs.id=r),e.id!=null&&(this.seen[e.id]=e),e.id}emit(e,t,r){let n=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,n]])}emitFinalMessage(e,t,r,n=!1){let i=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(n&&i!=null&&this.seen[i]!==void 0)return;let o=this.normalizeMessageId(t,r),s=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",a=s==="tool"&&qt.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...o!=null?{id:o}:{},...s!=="ai"?{role:s}:{},...typeof a=="string"?{tool_call_id:a}:{}},r),(Array.isArray(t.content)?t.content:typeof t.content=="string"&&t.content.length>0?[{type:"text",text:t.content}]:[]).forEach((c,u)=>{let l=typeof c.index=="number"?c.index:u;this.emit(e,{event:"content-block-start",index:l,content:R3(c)},r);let d=N3({...c,index:l});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:l,content:c},r)}),this.emit(e,{event:"message-finish",...yU(t)!=null?{usage:yU(t)}:{},...gU(t)!=null?{responseMetadata:gU(t)}:{}},r)}handleChatModelStart(e,t,r,n,i,o,s,a){s&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=[s.langgraph_checkpoint_ns.split("|"),{tags:o,name:a,...s}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let i=e.id??`run-${t}`;this.seen[i]=!0,this.stableMessageIdMap[t]??=i,e.id==null&&(n={...e,id:i})}this.emit(r,n,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e.generations?.[0]?.[0],i=Rt.isInstance(n?.message)?n.message:void 0;if(i!=null)if(this.streamedRunIds.has(t)){let o=this.normalizeMessageId(i,t);o!=null&&(this.seen[o]=i)}else this.emitFinalMessage(r,i,t,!0);this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleLLMError(e,t){this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleChainStart(e,t,r,n,i,o,s,a){if(o!==void 0&&a===o.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:i,name:a,...o}],typeof t=="object")){for(let c of Object.values(t))if((Rt.isInstance(c)||Kp.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(Rt.isInstance(u)||Kp.isInstance(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let n=i=>{Rt.isInstance(i)&&!qt.isInstance(i)&&this.emitFinalMessage(r,i,t,!0)};if(Rt.isInstance(e))n(e);else if(Array.isArray(e))for(let i of e)n(i);else if(e!=null&&typeof e=="object")for(let i of Object.values(e))if(Array.isArray(i))for(let o of i)n(o);else n(i);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var M3=class{active=!0;lastProgress=Date.now();refreshOn;constructor(e){this.refreshOn=e}touch(){this.lastProgress=Date.now()}autoTouch(){this.refreshOn==="auto"&&(this.lastProgress=Date.now())}close(){this.active=!1}},z3=class extends ps{name="IdleProgressCallbackHandler";awaitHandlers=!1;#e;constructor(e){super(),this.#e=e}#t=()=>{this.#e.autoTouch()};handleLLMStart=this.#t;handleChatModelStart=this.#t;handleLLMNewToken=this.#t;handleLLMEnd=this.#t;handleLLMError=this.#t;handleChainStart=this.#t;handleChainEnd=this.#t;handleChainError=this.#t;handleToolStart=this.#t;handleToolEnd=this.#t;handleToolError=this.#t;handleText=this.#t;handleRetrieverStart=this.#t;handleRetrieverEnd=this.#t;handleRetrieverError=this.#t;handleCustomEvent=this.#t};function j3(e,t,r,n){let i=e.configurable??{},o={},s=i[gr];typeof s=="function"&&(o[gr]=u=>{if(t.active)return u&&u.length&&t.autoTouch(),s(u)});let a=i[yo];typeof a=="function"&&(o[yo]=(...u)=>{if(!t.active)throw new Error(`Node "${n}" attempt was cancelled after its timeout fired`);return t.autoTouch(),a(...u)});let c={...Object.keys(o).length>0?Jt(e,o):e};if(c.heartbeat=()=>{r.idleTimeout!==void 0&&t.touch()},typeof c.writer=="function"){let u=c.writer;c.writer=(l=>{if(t.active)return t.autoTouch(),u(l)})}if((r.refreshOn??"auto")==="auto"&&r.idleTimeout!==void 0){let u=new z3(t),l=c.callbacks;if(l===void 0)c.callbacks=[u];else if(Array.isArray(l))c.callbacks=[...l,u];else{let d=l.copy();d.addHandler(u,!0),c.callbacks=d}}return c}async function vU(e,t,r,n){let i=new M3(r.refreshOn??"auto"),o=new AbortController,{signal:s,dispose:a}=qs(t.signal,o.signal),c=j3({...t,signal:s},i,r,String(e.name)),u=Date.now(),l=n(c).then(w=>({type:"ok",value:w}),w=>({type:"err",error:w})),d,p,f=()=>{d!==void 0&&clearTimeout(d),p!==void 0&&clearTimeout(p)},m=new Promise(w=>{if(r.runTimeout!==void 0&&(d=setTimeout(()=>w({type:"timeout",kind:"run"}),r.runTimeout)),r.idleTimeout!==void 0){let _=r.idleTimeout,b=()=>{let I=i.lastProgress+_-Date.now();I<=0?w({type:"timeout",kind:"idle"}):p=setTimeout(b,I)};p=setTimeout(b,_)}}),h;try{h=await Promise.race([l,m])}finally{f()}if(h.type!=="timeout"){let w=Date.now();r.runTimeout!==void 0&&w-u>=r.runTimeout?h={type:"timeout",kind:"run"}:r.idleTimeout!==void 0&&w-i.lastProgress>=r.idleTimeout&&(h={type:"timeout",kind:"idle"})}if(h.type==="ok")return a?.(),h.value;if(h.type==="err")throw a?.(),h.error;let y=Date.now()-u;throw i.close(),e.writes.splice(0,e.writes.length),o.abort(),a?.(),new Iw({node:String(e.name),elapsed:y,kind:h.kind,runTimeout:r.runTimeout,idleTimeout:r.idleTimeout})}var D3=[400,401,402,403,404,405,406,407,409],U3=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||e.name==="AbortError"||e.name==="GraphValueError"||e?.code==="ECONNABORTED")return!1;let t=e?.response?.status??e?.status;return!(t&&D3.includes(+t)||e?.error?.code==="insufficient_quota")};async function Uv(e,t,r,n){let i=e.retry_policy??t,o=0,s,a,c=e.config??{};r&&(c=Jt(c,r)),c={...c,signal:n};let u=Date.now();for(c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeFirstAttemptTime:u});!n?.aborted;){e.writes.splice(0,e.writes.length),s=void 0;try{e.timeout!==void 0?a=await vU(e,c,e.timeout,l=>e.proc.invoke(e.input,l)):a=await e.proc.invoke(e.input,c);break}catch(l){if(s=l,s.pregelTaskId=e.id,kw(s)){let h=c?.configurable?.checkpoint_ns,y=s.command;if(y.graph===h){for(let w of e.writers)await w.invoke(y,c);s=void 0;break}else if(y.graph===Br.PARENT){let w=xD(h);s.command=new Br({...s.command,graph:w})}}if(_s(s)||i===void 0||(o+=1,o>=(i.maxAttempts??3))||!(i.retryOn??U3)(s))break;let d=i.initialInterval??500,p=Math.min(i.maxInterval??128e3,d*(i.backoffFactor??2)**(o-1)),f=i.jitter??!0?p+Math.random()*1e3:p;await new Promise(h=>setTimeout(h,f));let m=s.name??s.constructor.unminifiable_name??s.constructor.name;(i?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${f.toFixed(2)}ms (attempt ${o}) after ${m}: ${s}`),c=Jt(c,{[Ka]:!0}),c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:u})}}return{task:e,result:a,error:s,signalAborted:n?.aborted}}var v$=Symbol.for("promiseAdded");function L3(){let e={next:()=>{},wait:Promise.resolve(v$)};function t(r){e.next=()=>{e.wait=new Promise(t),r(v$)}}return e.wait=new Promise(t),e}var bU=class{nodeFinished;loop;handledExceptions=new WeakSet;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:n,maxConcurrency:i}=e,o=new Set,s,a=new AbortController,c=a.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks),d=l.filter(h=>h.writes.length===0),{signals:p,disposeCombinedSignal:f}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),m=this._executeTasksWithRetry(d,{signals:p,retryPolicy:r,maxConcurrency:i});for await(let{task:h,error:y,signalAborted:w}of m)this._commit(h,y),!(y!==void 0&&this.handledExceptions.has(y))&&(vo(y)||_s(y)&&!vo(s)?s=y:y&&(o.size===0||!w)&&(a.abort(),o.add(y)));if(f?.(),n?.(this.loop.step,l.map(h=>h.writes).flat()),o.size===1)throw Array.from(o)[0];if(o.size>1)throw new AggregateError(Array.from(o),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(vo(s)||pg(s)||_s(s)&&this.loop.isNested)throw s}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let n=this.loop.config.configurable?.__pregel_abort_signals??{},i=n.externalAbortSignal??r,o=t??n.timeoutAbortSignal,{signal:s,dispose:a}=qs(i,o,e),c={externalAbortSignal:i,timeoutAbortSignal:o,composedAbortSignal:s};return this.loop.config=Jt(this.loop.config,{[XP]:c}),{signals:c,disposeCombinedSignal:a}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:n,signals:i}=t??{},o=L3(),s={},a={executingTasksMap:s,barrier:o,retryPolicy:r,scheduleTask:async(p,f,m)=>this.loop.acceptPush(p,f,m)};if(i?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=qs(i?.externalAbortSignal,i?.timeoutAbortSignal),d=l.signal?new Promise((p,f)=>{u=()=>f(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(s).length>0)&&e.length;){for(;Object.values(s).length<(n??e.length)&&c<e.length;c+=1){let y=e[c];s[y.id]=Uv(y,r,{[yo]:b$?.bind(a,this,y)},i?.composedAbortSignal).catch(w=>({task:y,error:w,signalAborted:i?.composedAbortSignal?.aborted}))}let p=await Promise.race([...Object.values(s),...d?[d]:[],o.wait]);if(p===v$)continue;let f=p,{task:m,error:h}=f;if(h!==void 0&&!_s(h)&&!this.loop.isErrorHandlerNode(String(m.name))&&this.loop.getErrorHandlerNode(String(m.name))!==void 0){let y=this.loop.scheduleErrorHandler(m,h);y!==void 0&&(s[y.id]=Uv(y,r,{[yo]:b$?.bind(a,this,y)},i?.composedAbortSignal).catch(w=>({task:y,error:w,signalAborted:i?.composedAbortSignal?.aborted})),o.next())}yield f,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete s[p.task.id]}}_shouldRouteToErrorHandler(e){let t=String(e.name);return this.loop.isErrorHandlerNode(t)?!1:this.loop.getErrorHandlerNode(t)!==void 0}_commit(e,t){if(t!==void 0)if(vo(t)){if(t.interrupts.length){let r=t.interrupts.map(i=>[rt,i]),n=e.writes.filter(i=>i[0]===Tr);n.length&&r.push(...n),this.loop.putWrites(e.id,r)}}else pg(t)?e.writes.length&&this.loop.putWrites(e.id,e.writes):_s(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):(e.writes.push([fs,{message:t.message,name:t.name}]),this._shouldRouteToErrorHandler(e)&&(e.writes.push([Yp,String(e.name)]),this.handledExceptions.add(t)),this.loop.putWrites(e.id,e.writes));else this.nodeFinished&&(e.config?.tags==null||!e.config.tags.includes("langsmith:hidden"))&&this.nodeFinished(String(e.name)),e.writes.length===0&&e.writes.push([tf,null]),this.loop.putWrites(e.id,e.writes)}};async function b$(e,t,r,n,i,o={}){let s=t.config?.configurable?.[Zr];if(!s)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let a=s.callCounter;s.callCounter+=1;let c=new qD({func:r,name:n,input:i,cache:o.cache,retry:o.retry,timeout:o.timeout,callbacks:o.callbacks}),u=await this.scheduleTask(t,a,c);if(!u)return;let l=this.executingTasksMap[u.id];if(l!==void 0)return l;if(u.writes.length>0){let d=u.writes.filter(([f])=>f===hs),p=u.writes.filter(([f])=>f===fs);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${u.name}__${u.id}`)}if(p.length>0){if(p.length===1){let f=p[0][1],m=f instanceof Error?f:new Error(String(f));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${u.name}__${u.id}`)}return}else{let d=Uv(u,o.retry,{[yo]:b$.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:p,error:f})=>f?Promise.reject(f):p)}}var Uo=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function wU({nodes:e,channels:t,inputChannels:r,outputChannels:n,streamChannels:i,interruptAfterNodes:o,interruptBeforeNodes:s}){if(!t)throw new Uo("Channels not provided");let a=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Uo(`"Node name ${rt} is reserved"`);if(l.constructor===di)l.triggers.forEach(d=>a.add(d));else throw new Uo(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of a)if(!(u in t))throw new Uo(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!a.has(u)))throw new Uo(`None of the input channels ${r} are subscribed to by any node`)}else if(!a.has(r))throw new Uo(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(n)?n.forEach(u=>c.add(u)):c.add(n),i&&!Array.isArray(i)?c.add(i):Array.isArray(i)&&i.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new Uo(`Output channel '${String(u)}' not in channels`);if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new Uo(`Node ${String(u)} not in nodes`)}if(s&&s!=="*"){for(let u of s)if(!(u in e))throw new Uo(`Node ${String(u)} not in nodes`)}}function w$(e,t){if(Array.isArray(e)){for(let r of e)if(!(r in t))throw new Error(`Key ${String(r)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}function F3(e){return Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1])}var x$=class xU extends Ut{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor(t){super(),this.unique=t?.unique??this.unique,this.accumulate=t?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint(t){let r=new xU({unique:this.unique,accumulate:this.accumulate});return typeof t>"u"?r:F3(t)?(r.seen=new Set(t[0]),r.values=[...t[1]],r):(r.values=[...t],this.unique&&(r.seen=new Set(r.values)),r)}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let n=t.flat();if(n.length>0)if(this.unique)for(let i of n)this.seen.has(i)||(r=!0,this.seen.add(i),this.values.push(i));else r=!0,this.values.push(...n);return r}get(){if(this.values.length===0)throw new Je;return this.values}checkpoint(){return this.unique?[[...this.seen],[...this.values]]:[...this.values]}isAvailable(){return this.values.length!==0}};function B3(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let n of e){let i=n.params.namespace,o=i.length?`${n.method}|${i.join("|")}`:n.method;r.enqueue(t.encode(`event: ${o}
|
|
293
|
-
data: ${JSON.stringify(n.params.data??{})}
|
|
294
|
-
|
|
295
|
-
`))}}catch(n){r.enqueue(t.encode(`event: error
|
|
296
|
-
data: ${JSON.stringify({message:String(n)})}
|
|
297
|
-
|
|
298
|
-
`))}finally{r.close()}}})}var kU=class{static subscribeTo(e,t){let{key:r,tags:n}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&r!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let i;return typeof e=="string"?r?i={[r]:e}:i=[e]:i=Object.fromEntries(e.map(o=>[o,o])),new di({channels:i,triggers:Array.isArray(e)?e:[e],tags:n})}static writeTo(e,t){let r=[];for(let n of e)r.push({channel:n,value:Jr,skipNone:!1});for(let[n,i]of Object.entries(t??{}))he.isRunnable(i)||typeof i=="function"?r.push({channel:n,value:Jr,skipNone:!0,mapper:xt(i)}):r.push({channel:n,value:i,skipNone:!1});return new $t(r)}},Z3=class extends he{lc_namespace=["langgraph","pregel"];invoke(e,t){throw new Error("Not implemented")}withConfig(e){return super.withConfig(e)}stream(e,t){return super.stream(e,t)}},Lv=class extends Z3{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;streamTransformers;triggerToNodes={};constructor(e){super(e);let{streamMode:t}=e;if(t!=null&&!Array.isArray(t)&&(t=[t]),this.nodes=e.nodes,this.channels=e.channels,"__pregel_tasks"in this.channels&&"lc_graph_name"in this.channels.__pregel_tasks&&this.channels.__pregel_tasks.lc_graph_name!=="Topic")throw new Error(`Channel '${Pi}' is reserved and cannot be used in the graph.`);this.channels[Pi]=new x$({accumulate:!1}),this.autoValidate=e.autoValidate??this.autoValidate,this.streamMode=t??this.streamMode,this.inputChannels=e.inputChannels,this.outputChannels=e.outputChannels,this.streamChannels=e.streamChannels??this.streamChannels,this.interruptAfter=e.interruptAfter,this.interruptBefore=e.interruptBefore,this.stepTimeout=e.stepTimeout??this.stepTimeout,this.debug=e.debug??this.debug,this.checkpointer=e.checkpointer,this.retryPolicy=e.retryPolicy,this.config=e.config,this.store=e.store,this.cache=e.cache,this.name=e.name,this.triggerToNodes=e.triggerToNodes??this.triggerToNodes,this.userInterrupt=e.userInterrupt,this.streamTransformers=e.streamTransformers??[],this.autoValidate&&this.validate()}withConfig(e){let{streamTransformers:t,...r}=e,n=Kt(this.config,r),i=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:n,streamTransformers:i})}validate(){wU({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[e,t]of Object.entries(this.nodes))for(let r of t.triggers)this.triggerToNodes[r]??=[],this.triggerToNodes[r].push(e);return this}get streamChannelsList(){return Array.isArray(this.streamChannels)?this.streamChannels:this.streamChannels?[this.streamChannels]:Object.keys(this.channels)}get streamChannelsAsIs(){return this.streamChannels?this.streamChannels:Object.keys(this.channels)}async getGraphAsync(e){return this.getGraph(e)}*getSubgraphs(e,t){for(let[r,n]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let i=n.subgraphs?.length?n.subgraphs:[n.bound];for(let o of i){let s=Tv(o);if(s!==void 0){if(r===e){yield[r,s];return}if(e===void 0&&(yield[r,s]),t){let a=e;e!==void 0&&(a=e.slice(r.length+1));for(let[c,u]of s.getSubgraphs(a,t))yield[`${r}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:n=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let i=await od(this.channels,t.checkpoint,{saver:typeof this.checkpointer=="object"?this.checkpointer:void 0,config:t.config??e});if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([p,f])=>p===Pr).map(([p,f,m])=>[String(f),m]);d.length>0&&jr(t.checkpoint,i,[{name:Ei,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let o=Object.values(Ks(t.checkpoint,t.pendingWrites,this.nodes,i,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),s=await li(this.getSubgraphsAsync()),a=t.config.configurable?.checkpoint_ns??"",c={};for(let d of o){let p=s.find(([m])=>m===d.name);if(!p)continue;let f=`${String(d.name)}:${d.id}`;if(a&&(f=`${a}|${f}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:f}};c[d.id]=m}else{let m={configurable:{[wn]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:f}},h=p[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(n&&t.pendingWrites?.length){let d=Object.fromEntries(o.map(f=>[f.id,f]));for(let[f,m,h]of t.pendingWrites)["__error__","__interrupt__",Qa].includes(m)||f in d&&d[f].writes.push([String(m),h]);let p=o.filter(f=>f.writes.length>0);p.length>0&&jr(t.checkpoint,i,p,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=o.filter(d=>d.writes.length===0).map(d=>d.name);return{values:pi(i,this.streamChannelsAsIs),next:l,tasks:m$(o,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:Ws(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ya("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_read===void 0&&e.configurable?.__pregel_checkpointer===void 0){let s=yv(n);for await(let[a,c]of this.getSubgraphsAsync(s,!0))if(a===s)return await c.getState(jc(e,{[wn]:r}),{subgraphs:t?.subgraphs})}let i=Kt(this.config,e),o=await r.getTuple(e);return await this._prepareStateSnapshot({config:i,saved:o,subgraphCheckpointer:t?.subgraphs?r:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ya("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=yv(n);for await(let[s,a]of this.getSubgraphsAsync(o,!0))if(s===o){yield*a.getStateHistory(jc(e,{[wn]:r}),t);return}}let i=Kt(this.config,e,{configurable:{checkpoint_ns:n}});for await(let o of r.list(i,t))yield this._prepareStateSnapshot({config:o.config,saved:o})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ya("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(s=>s.updates.length===0))throw new Error("No updates provided");let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let s=yv(n);for await(let[,a]of this.getSubgraphsAsync(s,!0))return await a.bulkUpdateState(jc(e,{[wn]:r}),t);throw new Error(`Subgraph "${s}" not found`)}let i=async(s,a)=>{let c=this.config?Kt(this.config,s):s,u=await r.getTuple(c),l=u!==void 0?Yi(u.checkpoint):Mc(),d={...u?.checkpoint.channel_versions},p=u?.metadata?.step??-1,f=jc(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(f=jc(c,u.config.configurable),m={...u.metadata,...m});let{values:h,asNode:y}=a[0];if(h==null&&y===void 0){if(a.length>1)throw new Ce("Cannot create empty checkpoint with multiple updates");return Ws(await r.put(f,ci(l,void 0,p),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let w=await od(this.channels,l,{saver:r,config:u?.config??f});if(h===null&&y==="__end__"){if(a.length>1)throw new Ce("Cannot apply multiple updates when clearing state");if(u){let C=Ks(l,u.pendingWrites||[],this.nodes,w,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),x=(u.pendingWrites||[]).filter(D=>D[0]===Pr).map(D=>D.slice(1));x.length>0&&jr(l,w,[{name:Ei,writes:x,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[D,M,R]of u.pendingWrites||[])["__error__","__interrupt__",Qa].includes(M)||D in C&&C[D].writes.push([M,R]);jr(l,w,Object.values(C),r.getNextVersion.bind(r),this.triggerToNodes)}return Ws(await r.put(f,ci(l,w,p),{...m,source:"update",step:p+1,parents:u?.metadata?.parents??{}},dd(d,l.channel_versions)),u?u.metadata:void 0)}if(y==="__copy__"){if(a.length>1)throw new Ce("Cannot copy checkpoint with multiple updates");if(u==null)throw new Ce("Cannot copy a non-existent checkpoint");let C=M=>!Array.isArray(M)||M.length===0?!1:M.every(R=>Array.isArray(R)&&R.length===2),x=ci(l,void 0,p),D=await r.put(u.parentConfig??jc(u.config,{checkpoint_id:void 0}),x,{source:"fork",step:p+1,parents:u.metadata?.parents??{}},{});if(C(h)){let M=Ks(x,u.pendingWrites,this.nodes,w,D,!1,{step:p+2}),R=Object.values(M).reduce((K,{name:re,id:We})=>(K[re]??=[],K[re].push({id:We}),K),{}),B=h.reduce((K,re)=>{let[We,ne]=re;K[ne]??=[];let X=K[ne].length,Q=R[ne]?.[X]?.id;return K[ne].push({values:We,asNode:ne,taskId:Q}),K},{});return i(Ws(D,u.metadata),Object.values(B).flat())}return Ws(D,u.metadata)}if(y==="__input__"){if(a.length>1)throw new Ce("Cannot apply multiple updates when updating as input");let C=await li(Ev(this.inputChannels,h));if(C.length===0)throw new Ce(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);jr(l,w,[{name:Ei,writes:C,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let x=u?.metadata?.step!=null?u.metadata.step+1:-1,D=await r.put(f,ci(l,w,x),{source:"input",step:x,parents:u?.metadata?.parents??{}},dd(d,l.channel_versions));return await r.putWrites(D,C,Ri(Ei,l.id)),Ws(D,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let C=Ks(l,u.pendingWrites,this.nodes,w,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),x=(u.pendingWrites??[]).filter(M=>M[0]===Pr).map(M=>M.slice(1));x.length>0&&jr(u.checkpoint,w,[{name:Ei,writes:x,triggers:[]}],void 0,this.triggerToNodes);for(let[M,R,B]of u.pendingWrites)["__error__","__interrupt__",Qa].includes(R)||C[M]===void 0||C[M].writes.push([R,B]);let D=Object.values(C).filter(M=>M.writes.length>0);D.length>0&&jr(l,w,D,void 0,this.triggerToNodes)}let _=Object.values(l.versions_seen).map(C=>Object.values(C)).flat().find(C=>!!C),b=[];if(a.length===1){let{values:C,asNode:x,taskId:D}=a[0];if(x===void 0&&Object.keys(this.nodes).length===1)[x]=Object.keys(this.nodes);else if(x===void 0&&_===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(x=this.inputChannels);else if(x===void 0){let M=Object.entries(l.versions_seen).map(([R,B])=>Object.values(B).map(K=>[K,R])).flat().filter(([R,B])=>B!==rt).sort(([R],[B])=>av(R,B));M&&(M.length===1?x=M[0][1]:M[M.length-1][0]!==M[M.length-2][0]&&(x=M[M.length-1][1]))}if(x===void 0)throw new Ce('Ambiguous update, specify "asNode"');b.push({values:C,asNode:x,taskId:D})}else for(let{asNode:C,values:x,taskId:D}of a){if(C==null)throw new Ce('"asNode" is required when applying multiple updates');b.push({values:x,asNode:C,taskId:D})}let I=[];for(let{asNode:C,values:x,taskId:D}of b){if(this.nodes[C]===void 0)throw new Ce(`Node "${C.toString()}" does not exist`);let M=this.nodes[C].getWriters();if(!M.length)throw new Ce(`No writers found for node "${C.toString()}"`);I.push({name:C,input:x,proc:M.length>1?fn.from(M,{omitSequenceTags:!0}):M[0],writes:[],triggers:[rt],id:D??Ri("__interrupt__",l.id),writers:[]})}for(let C of I)await C.proc.invoke(C.input,ze({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[gr]:x=>C.writes.push(...x),[$r]:(x,D=!1)=>pd(l,w,C,x,D)}}));for(let C of I){let x=C.writes.filter(D=>D[0]!==Er);u!==void 0&&x.length>0&&await r.putWrites(f,x,C.id)}jr(l,w,I,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let $=dd(d,l.channel_versions),P=await r.put(f,ci(l,w,p+1),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},$);for(let C of I){let x=C.writes.filter(D=>D[0]===Er);x.length>0&&await r.putWrites(P,x,C.id)}return Ws(P,u?u.metadata:void 0)},o=e;for(let{updates:s}of t)o=await i(o,s);return o}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:n,outputKeys:i,interruptAfter:o,interruptBefore:s,...a}=e,c=!0,u=t!==void 0?t:this.debug,l=i;l===void 0?l=this.streamChannelsAsIs:w$(l,this.channels);let d=n;d===void 0?d=this.inputChannels:w$(d,this.channels);let p=s??this.interruptBefore??[],f=o??this.interruptAfter??[],m;r!==void 0?(m=Array.isArray(r)?r:[r],c=typeof r=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let h;if(this.checkpointer===!1)h=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)h=e.configurable[wn];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let y=e.store??this.store,w=e.cache??this.cache;if(e.durability!=null&&e.checkpointDuring!=null)throw new Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let _=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),b=e.durability??_??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,a,p,f,h,y,c,w,b]}async stream(e,t){let r=new AbortController,n=gv()?.configurable;n?.__pregel_read!==void 0&&t?.configurable?.__pregel_read===void 0&&(t={...t,configurable:{...n,...t?.configurable}});let i={recursionLimit:this.config?.recursionLimit,...t,signal:qs(t?.signal,r.signal).signal},o=await super.stream(e,i);return new jv(t?.encoding==="text/event-stream"?aU(o):o,r)}async#e(e,t){let{version:r,encoding:n,transformers:i,...o}=t,s={recursionLimit:this.config?.recursionLimit,...o,configurable:{...this.config?.configurable,...o?.configurable},version:r,streamMode:HO,subgraphs:!0,encoding:void 0},a=this.stream(e,s),c=s$({[Symbol.asyncIterator]:async function*(){let u=await a;for await(let l of u)yield l}},[...this.streamTransformers??[],...i??[]]);if(n==="text/event-stream"){let u=new AbortController;return u.signal.addEventListener("abort",()=>c.abort(u.signal.reason),{once:!0}),new jv(B3(c),u)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let n=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:qs(t?.signal,n.signal).signal};return new jv(super.streamEvents(e,i,r),n)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let r="version"in(t??{})?void 0:t?.encoding??void 0,n=t?.subgraphs,i=t?.version==="v3",o=Um(this.config,t);if(o.recursionLimit===void 0||o.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&o.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let s=await this._validateInput(e),{runId:a,...c}=o,[u,l,,d,p,f,m,h,y,w,_,b]=this._defaults(c);p.metadata={ls_integration:"langgraph",...p.metadata},typeof p.context<"u"?p.context=await this._validateContext(p.context):p.configurable=await this._validateContext(p.configurable);let I=new g$({modes:new Set(l)});if(this.checkpointer===!0){p.configurable??={};let B=p.configurable.checkpoint_ns??"";p.configurable[on]=B.split("|").map(K=>K.split(":")[0]).join("|")}if(l.includes("messages")){let B=i?new _U(re=>I.push(re)):new hU(re=>I.push(re)),{callbacks:K}=p;if(K===void 0)p.callbacks=[B];else if(Array.isArray(K))p.callbacks=K.concat(B);else{let re=K.copy();re.addHandler(B,!0),p.callbacks=re}}if(l.includes("tools")){let B=new sU(re=>I.push(re)),{callbacks:K}=p;if(K===void 0)p.callbacks=[B];else if(Array.isArray(K))p.callbacks=K.concat(B);else{let re=K.copy();re.addHandler(B,!0),p.callbacks=re}}p.writer??=B=>{if(!l.includes("custom"))return;let K=gv()?.configurable?.[on]?.split("|").slice(0,-1);I.push([K??[],"custom",B])},p.interrupt??=this.userInterrupt??l$,p.serverInfo==null&&(p.serverInfo=V3(p)),p.control??=new GO;let $={tracerInheritableMetadata:K3(p)},P=await(await mr._configureSync(p?.callbacks,void 0,p?.tags,void 0,p?.metadata,void 0,$))?.handleChainStart(this.toJSON(),WD(e,"input"),a,void 0,void 0,void 0,p?.runName??this.getName()),C=id(this.channels),x,D,R=(async()=>{try{x=await pU.initialize({input:s,config:p,checkpointer:h,nodes:this.nodes,channelSpecs:C,outputKeys:d,streamKeys:this.streamChannelsAsIs,store:y,cache:_,stream:I,interruptAfter:m,interruptBefore:f,manager:P,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:b});let B=new bU({loop:x,nodeFinished:p.configurable?.[JP]});t?.subgraphs&&(x.config.configurable={...x.config.configurable,[Qp]:x.stream}),await this._runLoop({loop:x,runner:B,debug:u,config:p}),b==="sync"&&await Promise.all(x?.checkpointerPromises??[])}catch(B){D=B}finally{try{x&&(await x.store?.stop(),await x.cache?.stop()),await Promise.all(x?.checkpointerPromises??[])}catch(B){D=D??B}D?(await new Promise(B=>{queueMicrotask(B)}),I.error(D)):I.close()}})();try{for await(let B of I){if(B===void 0)throw new Error("Data structure error.");let[K,re,We]=B,ne="version"in(t??{});if(l.includes(re)||re==="checkpoints"&&sd(We)&&(i||ne&&n&&l.includes("values"))){if(r==="text/event-stream"){n?yield[K,re,We]:yield[null,re,We];continue}n&&!w?yield[K,re,We]:w?n?yield[K,We]:yield We:yield[re,We]}}}catch(B){throw await P?.handleChainError(D),B}finally{await R}await P?.handleChainEnd(x?.output??{},a,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",n={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},i=[],o=await this.stream(e,n),s=[],a;for await(let c of o)r==="values"?Xa(c)?s.push(c[rt]):a=c:i.push(c);if(r==="values"){if(s.length>0){let c=s.flat(1);if(a==null)return{[rt]:c};if(typeof a=="object")return{...a,[rt]:c}}return a}return i}async _runLoop(e){let{loop:t,runner:r,debug:n,config:i}=e,o;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:s}of await t._matchCachedWrites())t._outputWrites(s.id,s.writes,!0);n&&rU(t.checkpointMetadata.step,t.channels,this.streamChannelsList),n&&Km(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(s,a)=>{n&&nU(s,a,this.streamChannelsList)},maxConcurrency:i.maxConcurrency,signal:i.signal})}if(t.status==="draining")throw t.control==null?new Error("Draining status requires run control"):new dg(t.control.drainReason??"shutdown");if(t.status==="out_of_steps")throw new ww([`Recursion limit of ${i.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(s){if(o=s,!await t.finishAndHandleError(o))throw s}finally{o===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function V3(e){let t=e.metadata??{},r=e.configurable??{},n=r.assistant_id??t.assistant_id,i=r.graph_id??t.graph_id,o=r.langgraph_auth_user,s;if(o!=null&&typeof o=="object"&&"identity"in o&&(s=o),n!=null||i!=null||s!=null)return{assistantId:n!=null?String(n):"",graphId:i!=null?String(i):"",user:s}}var W3=new Set(["key","token","secret","password","auth"]);function q3(e,t){let r=e.toLowerCase(),n=!1;for(let i of W3)if(r.includes(i)){n=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||n}function K3(e){let t=e.configurable;if(!t)return;let r=e.context,n={};for(let[i,o]of Object.entries(t)){if(r!=null&&Object.prototype.hasOwnProperty.call(r,i)&&Object.is(r[i],o)){i.startsWith("__")||(n[i]=void 0);continue}q3(i,o)||(n[i]=o)}return Object.keys(n).length>0?n:void 0}var fi=class IU extends Ut{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new IU(this.guard);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0){let r=this.value.length>0;return this.value=[],r}if(t.length!==1&&this.guard)throw new Ce("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Je;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Je;return this.value[0]}isAvailable(){return this.value.length!==0}};var k$=class{path;ends;constructor(e){he.isRunnable(e.path)?this.path=e.path:this.path=xt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return $t.registerWriter(new or({name:"<branch_run>",trace:!1,func:async(r,n)=>{try{return await this._route(r,n,e,t)}catch(i){throw i.name===ys.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
299
|
-
NodeInterrupt should only be thrown inside a node, not in edge conditions.`),i}}}))}async _route(e,t,r,n){let i=await this.path.invoke(n?n(t):e,t);Array.isArray(i)||(i=[i]);let o;if(this.ends?o=i.map(s=>Gt(s)?s:this.ends[s]):o=i,o.some(s=>!s))throw new Error("Branch condition returned unknown or null destination");if(o.filter(Gt).some(s=>s.node==="__end__"))throw new Ce("Cannot send a packet to the END node");return await r(o,t)??e}},I$=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(e){this.compiled&&console.warn(e)}get allEdges(){return this.edges}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,o]of r){for(let a of["|",":"])if(n.includes(a))throw new Error(`"${a}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__")throw new Error(`Node \`${n}\` is reserved.`);let s=xt(i);this.nodes[n]={runnable:s,metadata:o?.metadata,subgraphs:Zm(s)?[s]:o?.subgraphs,ends:o?.ends}}return this}addEdge(e,t){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),e==="__end__")throw new Error("END cannot be a start node");if(t==="__start__")throw new Error("START cannot be an end node");if(Array.from(this.edges).some(([r])=>r===e)&&!("channels"in this))throw new Error(`Already found path for ${e}. For multiple edges, use StateGraph.`);return this.edges.add([e,t]),this}addConditionalEdges(e,t,r){let n=typeof e=="object"?e:{source:e,path:t,pathMap:r};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),he.isRunnable(n.path)||(n.path=xt(n.path));let i=n.path.getName()==="RunnableLambda"?"condition":n.path.getName();if(this.branches[n.source]&&this.branches[n.source][i])throw new Error(`Condition \`${i}\` already present for node \`${e}\``);return this.branches[n.source]??={},this.branches[n.source][i]=new k$(n),this}setEntryPoint(e){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Ye,e)}setFinishPoint(e){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(e,Ze)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:n,transformers:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let o=new S$({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Ye]:new fi,[Ze]:new fi},inputChannels:Ye,outputChannels:Ze,streamChannels:[],streamMode:"values",name:n,streamTransformers:i});for(let[s,a]of Object.entries(this.nodes))o.attachNode(s,a);for(let[s,a]of this.edges)o.attachEdge(s,a);for(let[s,a]of Object.entries(this.branches))for(let[c,u]of Object.entries(a))o.attachBranch(s,c,u);return o.validate()}validate(e){let t=new Set([...this.allEdges].map(([n,i])=>n));for(let[n]of Object.entries(this.branches))t.add(n);for(let n of t)if(n!=="__start__"&&!(n in this.nodes))throw new Error(`Found edge starting at unknown node \`${n}\``);let r=new Set([...this.allEdges].map(([n,i])=>i));for(let[n,i]of Object.entries(this.branches))for(let o of Object.values(i))if(o.ends!=null)for(let s of Object.values(o.ends))r.add(s);else{r.add(Ze);for(let s of Object.keys(this.nodes))s!==n&&r.add(s)}for(let n of Object.values(this.nodes))for(let i of n.ends??[])r.add(i);if(Object.values(this.nodes).some(n=>n.isErrorHandler))for(let n of Object.keys(this.nodes))r.add(n);for(let n of Object.keys(this.nodes))if(!this.nodes[n].isErrorHandler&&!r.has(n))throw new Sw([`Node \`${n}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
|
|
300
|
-
`),{lc_error_code:"UNREACHABLE_NODE"});for(let n of r)if(n!=="__end__"&&!(n in this.nodes))throw new Error(`Found edge ending at unknown node \`${n}\``);if(e){for(let n of e)if(!(n in this.nodes))throw new Error(`Interrupt node \`${n}\` is not present`)}this.compiled=!0}},S$=class extends Lv{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new fi,this.nodes[e]=new di({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new $t([{channel:e,value:Jr}],[zt])),this.streamChannels.push(e)}attachEdge(e,t){if(t==="__end__"){if(e==="__start__")throw new Error("Cannot have an edge from START to END");this.nodes[e].writers.push(new $t([{channel:Ze,value:Jr}],[zt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Ye]=kU.subscribeTo(Ye,{tags:[zt]})),this.nodes[e].pipe(r.run(i=>new $t(i.map(o=>Gt(o)?o:{channel:o==="__end__"?Ze:`branch:${e}:${t}:${o}`,value:Jr}),[zt])));let n=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let i of n)if(i!=="__end__"){let o=`branch:${e}:${t}:${i}`;this.channels[o]=new fi,this.nodes[i].triggers.push(o),this.nodes[i].channels.push(o)}}async getGraphAsync(e){let t=e?.xray,r=new $c,n={[Ye]:r.addNode({schema:Y.any()},Ye)},i={},o={};t&&(o=Object.fromEntries((await li(this.getSubgraphsAsync())).filter(u=>SU(u[1]))));let s=[];function a(u,l,d,p=!1){if(l==="__end__"&&i.__end__===void 0&&(i[Ze]=r.addNode({schema:Y.any()},Ze)),n[u]!==void 0){if(i[l]===void 0)throw new Error(`End node ${l} not found!`);return s.push({src:u,dest:l,conditional:p}),r.addEdge(n[u],i[l],d!==l?d:void 0,p)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Xt(u),p=l.runnable,f=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?f.__interrupt="before,after":this.interruptBefore?.includes(u)?f.__interrupt="before":this.interruptAfter?.includes(u)&&(f.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?await o[u].getGraphAsync({...e,xray:m}):p.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let _=function(I){return I?I.lc_runnable:!1},b=function(I,$){if(I!==void 0&&!ls(I))return I;if(_($))try{let P=$.getName();return P=P.startsWith("Runnable")?P.slice(8):P,P}catch{return $.getName()}else return $.name??"UnknownSchema"},[y,w]=r.extend(h,d);if(y===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);w!==void 0&&(n[d]={name:b(w.id,w.data),...w}),i[d]={name:b(y.id,y.data),...y}}else{let y=r.addNode(p,d,f);n[d]=y,i[d]=y}}else{let m=r.addNode(p,d,f);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)a(Xt(u),Xt(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(p=>p!==u).map(p=>[Xt(p),Xt(p)])),[Ze]:Ze};for(let p of Object.values(l)){let f;p.ends!==void 0?f=p.ends:f=d;for(let[m,h]of Object.entries(f))a(Xt(u),Xt(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)a(Xt(u),Xt(d),void 0,!0);return AU(this.builder.nodes,s,a),r}getGraph(e){let t=e?.xray,r=new $c,n={[Ye]:r.addNode({schema:Y.any()},Ye)},i={},o={};t&&(o=Object.fromEntries(Vs(this.getSubgraphs()).filter(u=>SU(u[1]))));let s=[];function a(u,l,d,p=!1){if(l==="__end__"&&i.__end__===void 0&&(i[Ze]=r.addNode({schema:Y.any()},Ze)),n[u]!==void 0){if(i[l]===void 0)throw new Error(`End node ${l} not found!`);return s.push({src:u,dest:l,conditional:p}),r.addEdge(n[u],i[l],d!==l?d:void 0,p)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Xt(u),p=l.runnable,f=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?f.__interrupt="before,after":this.interruptBefore?.includes(u)?f.__interrupt="before":this.interruptAfter?.includes(u)&&(f.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?o[u].getGraph({...e,xray:m}):p.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let _=function(I){return I?I.lc_runnable:!1},b=function(I,$){if(I!==void 0&&!ls(I))return I;if(_($))try{let P=$.getName();return P=P.startsWith("Runnable")?P.slice(8):P,P}catch{return $.getName()}else return $.name??"UnknownSchema"},[y,w]=r.extend(h,d);if(y===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);w!==void 0&&(n[d]={name:b(w.id,w.data),...w}),i[d]={name:b(y.id,y.data),...y}}else{let y=r.addNode(p,d,f);n[d]=y,i[d]=y}}else{let m=r.addNode(p,d,f);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)a(Xt(u),Xt(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(p=>p!==u).map(p=>[Xt(p),Xt(p)])),[Ze]:Ze};for(let p of Object.values(l)){let f;p.ends!==void 0?f=p.ends:f=d;for(let[m,h]of Object.entries(f))a(Xt(u),Xt(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)a(Xt(u),Xt(d),void 0,!0);return AU(this.builder.nodes,s,a),r}};function SU(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Xt(e){return e==="subgraph"?`"${e}"`:e}function AU(e,t,r){let n=new Set(t.map(o=>o.src)),i=[...new Set(t.filter(o=>!o.conditional&&o.dest!=="__end__").map(o=>o.dest))].sort();for(let o of i){if(n.has(o))continue;let s=Object.keys(e).find(a=>Xt(a)===o);s!==void 0&&e[s]?.isErrorHandler||r(o,Ze)}}function Gs(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function OU(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Hs(e){if(OU(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function Lo(e){if(e!=null&&Gs(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let r=t;if(!r.issues){let n=r.value;return()=>n}}}catch{}}var G3=e=>e!=null&&e.lc_graph_name==="DeltaChannel",Fv=class $U extends Ut{lc_graph_name="DeltaChannel";value;reducer;snapshotFrequency;initialValueFactory;constructor(t,r){super();let n=r?.snapshotFrequency??1e3;if(!Number.isInteger(n)||n<=0)throw new Error(`snapshotFrequency must be a positive integer, got ${n}`);this.reducer=t,this.snapshotFrequency=n,this.initialValueFactory=r?.initialValueFactory??(()=>[]),this.value=void 0}fromCheckpoint(t){let r=new $U(this.reducer,{snapshotFrequency:this.snapshotFrequency,initialValueFactory:this.initialValueFactory});return t===void 0?r.value=this.initialValueFactory():Ew(t)?r.value=t.value:r.value=t,r}replayWrites(t){let r=t.map(s=>s[2]);if(r.length===0)return;let n=this.value,i=0;for(let s=0;s<r.length;s+=1){let[a,c]=Jn(r[s]);a&&(n=c??this.initialValueFactory(),i=s+1)}let o=r.slice(i);this.value=o.length>0?this.reducer(n,o):n}update(t){if(t.length===0)return!1;let r,n=!1;for(let o of t)if(Ja(o)){if(n)throw new Ce("Can receive only one Overwrite value per step.");n=!0,[,r]=Jn(o)}if(n)return this.value=r??this.initialValueFactory(),!0;let i=this.value===void 0?this.initialValueFactory():this.value;return this.value=this.reducer(i,t),!0}get(){if(this.value===void 0)throw new Je;return this.value}checkpoint(){}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:!G3(t)||this.snapshotFrequency!==t.snapshotFrequency?!1:this.reducer===t.reducer}};var A$=Symbol.for("langgraph.channel.missing"),Bv=class TU extends Ut{lc_graph_name="UntrackedValue";guard;_value=A$;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new TU({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new Ce("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=t[t.length-1],!0}get(){if(this._value===A$)throw new Je;return this._value}checkpoint(){}isAvailable(){return this._value!==A$}};var Js=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),O$=class EU extends Ut{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new EU(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let n of t)if(this.names.has(n))this.seen.has(n)||(this.seen.add(n),r=!0);else throw new Ce(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!Js(this.names,this.seen))throw new Je}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&Js(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&Js(this.names,this.seen)}},$$=class PU extends Ut{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let r=new PU(this.names);if(typeof t<"u"){let[n,i]=t;r.seen=new Set(n),r.finished=i}return r}update(t){let r=!1;for(let n of t)if(this.names.has(n)&&!this.seen.has(n))this.seen.add(n),r=!0;else if(!this.names.has(n))throw new Ce(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!Js(this.names,this.seen))throw new Je}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&Js(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&Js(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&Js(this.names,this.seen)}};var T$=Symbol.for("langgraph.state.reduced_value"),Fo=class{[T$]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.jsonSchemaExtra=t.jsonSchemaExtra,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&T$ in e&&e[T$]===!0}};var CU=Symbol.for("langgraph.state.untracked_value"),Uc=class{[CU]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&CU in e}};var E$=Symbol.for("langgraph.state.delta_value"),Bo=class{[E$]=!0;valueSchema;inputSchema;reducer;snapshotFrequency;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.snapshotFrequency=t.snapshotFrequency,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&E$ in e&&e[E$]===!0}};var P$=Symbol.for("langgraph.state.state_schema"),mi=class{[P$]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(Bo.isInstance(r)){let n=Lo(r.valueSchema);e[t]=new Fv(r.reducer,{snapshotFrequency:r.snapshotFrequency,initialValueFactory:n})}else if(Fo.isInstance(r)){let n=Lo(r.valueSchema);e[t]=new jo(r.reducer,n)}else if(Uc.isInstance(r)){let n=r.schema?Lo(r.schema):void 0;e[t]=new Bv({guard:r.guard,initialValueFactory:n})}else if(Gs(r))e[t]=new ui(Lo(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, DeltaValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,n]of Object.entries(this.fields)){let i;if(Bo.isInstance(n)||Fo.isInstance(n)?(i=Hs(n.valueSchema),n.jsonSchemaExtra&&(i={...i??{},...n.jsonSchemaExtra})):Uc.isInstance(n)?i=n.schema?Hs(n.schema):void 0:Gs(n)&&(i=Hs(n)),i){e[r]=i;let o=!1;Bo.isInstance(n)||Fo.isInstance(n)?o=Lo(n.valueSchema)!==void 0:Uc.isInstance(n)?o=n.schema?Lo(n.schema)!==void 0:!1:o=Lo(n)!==void 0,o||t.push(r)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,r]of Object.entries(this.fields)){let n;Bo.isInstance(r)||Fo.isInstance(r)?(n=Hs(r.inputSchema),r.jsonSchemaExtra&&(n={...n??{},...r.jsonSchemaExtra})):Uc.isInstance(r)?n=r.schema?Hs(r.schema):void 0:Gs(r)&&(n=Hs(r)),n&&(e[t]=n)}return{type:"object",properties:e}}getChannelKeys(){return Object.entries(this.fields).map(([e])=>e)}getAllKeys(){return Object.keys(this.fields)}async validateInput(e){if(e==null||typeof e!="object")return e;let t={};for(let[r,n]of Object.entries(e)){let i=this.fields[r];if(i===void 0){t[r]=n;continue}let o;if(Bo.isInstance(i)||Fo.isInstance(i)){let[s,a]=Jn(n);if(s){o=i.valueSchema;let c=await o["~standard"].validate(a);if(c.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(c.issues)}`);t[r]={[Ti]:c.value};continue}o=i.inputSchema}else Uc.isInstance(i)?o=i.schema:Gs(i)&&(o=i);if(o){let s=await o["~standard"].validate(n);if(s.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(s.issues)}`);t[r]=s.value}else t[r]=n}return t}static isInstance(e){return typeof e=="object"&&e!==null&&P$ in e&&e[P$]===!0}};function Lc(e,t){let r=Array.isArray(e)?e:[e],n=Array.isArray(t)?t:[t],i=r.map(er),o=n.map(er);for(let l of i)(l.id===null||l.id===void 0)&&(l.id=Da(),l.lc_kwargs.id=l.id);let s;for(let l=0;l<o.length;l+=1){let d=o[l];(d.id===null||d.id===void 0)&&(d.id=Da(),d.lc_kwargs.id=d.id),Gn.isInstance(d)&&d.id==="__remove_all__"&&(s=l)}if(s!=null)return o.slice(s+1);let a=[...i],c=new Map(a.map((l,d)=>[l.id,d])),u=new Set;for(let l of o){let d=c.get(l.id);if(d!==void 0)Gn.isInstance(l)?u.add(l.id):(u.delete(l.id),a[d]=l);else{if(Gn.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,a.length),a.push(l)}}return a.filter(l=>!u.has(l.id))}function C$(e,t){let r=[];for(let a of t)Array.isArray(a)?r.push(...a):r.push(a);let n=e.length>0&&Rt.isInstance(e[0])?e:e.map(er),i=r.map(er),o=new Map;for(let a=0;a<n.length;a+=1){let c=n[a].id;c!=null&&o.set(c,a)}let s=[...n];for(let a of i){let c=a.id;Gn.isInstance(a)&&c==="__remove_all__"?(s.length=0,o.clear()):c==null?s.push(a):Gn.isInstance(a)?o.has(c)&&(s[o.get(c)]=null,o.delete(c)):o.has(c)?s[o.get(c)]=a:(o.set(c,s.length),s.push(a))}return s.filter(a=>a!==null)}var RU=Y.custom().default(()=>[]),NU=Y.custom(),H3=new Fo(RU,{inputSchema:NU,reducer:Lc,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}}),J3=new Bo(RU,{inputSchema:NU,reducer:C$,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var X3=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let r=this.get(e);this._map.set(e,t(r))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},r=Oo(e);for(let[n,i]of Object.entries(r)){let o=this.get(i);o?.reducer?t[n]=new jo(o.reducer.fn,o.default):t[n]=new ui(o?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,o])=>o===!0).sort(([o],[s])=>o.localeCompare(s)).map(([o,s])=>`${o}:${s}`).join("|"),n=this._extensionCache.get(r)??new Map;if(n.has(e))return n.get(e);let i=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let o=Object.entries(Oo(e)).map(([s,a])=>{let c=this.get(a),u=t.withReducerSchema?c?.reducer?.schema??a:a;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=ti(u)??ti(a),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[s,u]});i=Ey(e,Object.fromEntries(o)),_t(i)&&(i._def.unknownKeys="strip")}return t.asPartial&&(i=Ns(i)),n.set(e,i),this._extensionCache.set(r,n),i}},Gm=new X3;function MU(e,t){if(t.reducer&&!t.default){let r=Py(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Gm.extend(r,()=>t),r}else return Gm.extend(e,()=>t),e}function Fc(e){return e==null?!1:!!(mi.isInstance(e)||_r(e)||typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.values(e).every(t=>typeof t=="function"||WO(t)))}function zU(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&Fc(t.state),n="stateSchema"in t&&Fc(t.stateSchema),i="input"in t&&Fc(t.input);return!(!r&&!n&&!i||"input"in t&&t.input!=null&&!Fc(t.input)||"output"in t&&t.output!=null&&!Fc(t.output))}var Zo="__root__",fd="__default_error_handler__",Zv=Symbol.for("langgraph.state.partial"),Xs=class extends I${channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Gm;_configSchema;_configRuntimeSchema;_interrupt;_writer;_nodeDefaults={};constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),n=r.state??r.stateSchema??r.input;if(!n)throw new rf;let i=this._getChannelsFromSchema(n);this._schemaDefinition=i,mi.isInstance(n)?this._schemaRuntimeDefinition=n:_r(n)&&(this._schemaRuntimeDefinition=n),r.input?mi.isInstance(r.input)?this._inputRuntimeDefinition=r.input:_r(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Zv:this._inputRuntimeDefinition=Zv,r.output?mi.isInstance(r.output)?this._outputRuntimeDefinition=r.output:_r(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let o=r.input?this._getChannelsFromSchema(r.input):i,s=r.output?this._getChannelsFromSchema(r.output):i;this._inputDefinition=o,this._outputDefinition=s,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&_r(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}setNodeDefaults(e){return e.retryPolicy!==void 0&&(this._nodeDefaults.retryPolicy=e.retryPolicy),e.cachePolicy!==void 0&&(this._nodeDefaults.cachePolicy=typeof e.cachePolicy=="boolean"?e.cachePolicy?{}:void 0:e.cachePolicy),e.timeout!==void 0&&(this._nodeDefaults.timeout=Wa(e.timeout)),e.errorHandler!==void 0&&(this._nodeDefaults.errorHandler=e.errorHandler),this}_createDefaultErrorHandlerSpec(){let e=this._nodeDefaults.errorHandler;if(e!==void 0)return{runnable:new or({func:(t,r)=>{let n=r?.configurable?.[ef];return e(t,n,r)},name:fd,trace:!1}),metadata:void 0,input:this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0}}_normalizeToStateGraphInit(e,t){if(zU(e)){if(_r(t)||mv.isInstance(t))return{...e,context:t};let r=t;return{...e,input:e.input??r?.input,output:e.output??r?.output,context:e.context??r?.context,interrupt:e.interrupt??r?.interrupt,writer:e.writer??r?.writer,nodes:e.nodes??r?.nodes}}if(Fc(e)){if(_r(t)||mv.isInstance(t))return{state:e,context:t};let r=t;return{state:e,input:r?.input,output:r?.output,context:r?.context,interrupt:r?.interrupt,writer:r?.writer,nodes:r?.nodes}}if(Q3(e))return{state:Y3(e.channels)};throw new rf}_getChannelsFromSchema(e){if(mi.isInstance(e))return e.getChannels();if(_r(e))return this._metaRegistry.getChannelsForSchema(e);if(typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot")return e.spec;if(typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e;throw new rf("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([e,t])=>e.map(r=>[r,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,r]of Object.entries(e)){let n;if(typeof r=="function"?n=r():n=r,this.channels[t]!==void 0){if(!this.channels[t].equals(n)&&n.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=n}}}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([n,i])=>[n,i]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,o]of r){if(n in this.channels)throw new Error(`${n} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let p of["|",":"])if(n.includes(p))throw new Error(`"${p}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__"||n==="__start__")throw new Error(`Node \`${n}\` is reserved.`);let s=this._schemaDefinition;o?.input!==void 0&&(s=this._getChannelsFromSchema(o.input)),this._addSchema(s);let a;he.isRunnable(i)?a=i:typeof i=="function"?a=new or({func:i,name:n,trace:!1}):a=xt(i);let c=o?.cachePolicy,u;c!==void 0&&(u=typeof c=="boolean"?c?{}:!1:c);let l;if(o?.errorHandler!==void 0){if(l=`__error_handler__${n}`,l in this.nodes)throw new Error(`Cannot add error handler to node \`${n}\`: the reserved name \`${l}\` is already in use. StateGraph registers \`__error_handler__<nodeName>\` when you pass \`errorHandler\` in addNode options. Remove or rename the existing node with that name (for example, you may have added it manually).`);let p=o.errorHandler,f={runnable:new or({func:(m,h)=>{let y=h?.configurable?.[ef];return p(m,y,h)},name:l,trace:!1}),metadata:void 0,input:s??this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0};this.nodes[l]=f}let d={runnable:a,retryPolicy:o?.retryPolicy,cachePolicy:u,timeout:Wa(o?.timeout),metadata:o?.metadata,input:s??this._schemaDefinition,subgraphs:Zm(a)?[a]:o?.subgraphs,ends:o?.ends,defer:o?.defer,errorHandlerNode:l};this.nodes[n]=d}return this}addEdge(e,t){if(typeof e=="string")return super.addEdge(e,t);this.compiled&&console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let r of e){if(r==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(n=>n===r))throw new Error(`Need to add a node named "${r}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(r=>r===t))throw new Error(`Need to add a node named "${t}" first`);return this.waitingEdges.add([e,t]),this}addSequence(e){let t=Array.isArray(e)?e:Object.entries(e);if(t.length===0)throw new Error("Sequence requires at least one node.");let r;for(let[n,i,o]of t){if(n in this.nodes)throw new Error(`Node names must be unique: node with the name "${n}" already exists.`);let s=n;this.addNode(n,i,o),r!=null&&this.addEdge(r,s),r=s}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:s,transformers:a}={}){let c=this._createDefaultErrorHandlerSpec();if(c!==void 0){if(fd in this.nodes)throw new Error(`Cannot apply a default error handler: the reserved node name \`${fd}\` is already in use. setNodeDefaults({ errorHandler }) registers a node with that name; rename the conflicting node.`);this.nodes[fd]=c}try{return this._compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:s,transformers:a,defaultErrorHandlerNode:c!==void 0?fd:void 0})}finally{c!==void 0&&delete this.nodes[fd]}}_compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:s,transformers:a,defaultErrorHandlerNode:c}){this.validate([...Array.isArray(n)?n:[],...Array.isArray(i)?i:[]]);let u=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),l=u.length===1&&u[0]===Zo?Zo:u,d=Object.keys(this.channels),p=d.length===1&&d[0]===Zo?Zo:d,f=this._interrupt,m=new DU({builder:this,checkpointer:e,interruptAfter:i,interruptBefore:n,autoValidate:!1,nodes:{},channels:{...this.channels,[Ye]:new fi},inputChannels:Ye,outputChannels:l,streamChannels:p,streamMode:"updates",store:t,cache:r,name:o,description:s,userInterrupt:f,streamTransformers:a});m.attachNode(Ye);let h=this._nodeDefaults,y=h.retryPolicy!==void 0||h.cachePolicy!==void 0||h.timeout!==void 0||c!==void 0;for(let[w,_]of Object.entries(this.nodes)){let b=_.isErrorHandler===!0,I=y?{..._,retryPolicy:_.retryPolicy??h.retryPolicy,cachePolicy:b||_.cachePolicy===!1?void 0:_.cachePolicy??h.cachePolicy,timeout:_.timeout??h.timeout,errorHandlerNode:!b&&c!==void 0&&_.errorHandlerNode===void 0?c:_.errorHandlerNode}:_;m.attachNode(w,I)}m.attachBranch(Ye,bw,jU(),{withReader:!1});for(let[w]of Object.entries(this.nodes))m.attachBranch(w,bw,jU(),{withReader:!1});for(let[w,_]of this.edges)m.attachEdge(w,_);for(let[w,_]of this.waitingEdges)m.attachEdge(w,_);for(let[w,_]of Object.entries(this.branches))for(let[b,I]of Object.entries(_))m.attachBranch(w,b,I);return m.validate()}};function Y3(e){let t={};for(let[r,n]of Object.entries(e))r===Zo?t[r]=hv(n):t[r]=hv(n);return t}var DU=class extends S${description;_metaRegistry=Gm;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let r;e==="__start__"?r=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([c])=>c):r=Object.keys(this.builder.channels);function n(c){if(tr(c))return c.graph===Br.PARENT?null:c._updateAsTuples();if(Array.isArray(c)&&c.length>0&&c.some(u=>tr(u))){let u=[];for(let l of c)if(tr(l)){if(l.graph===Br.PARENT)continue;u.push(...l._updateAsTuples())}else u.push([Zo,l]);return u}else if(c!=null)return[[Zo,c]];return null}let i=e,o=async c=>{if(c==null||c.length===0)return c;let u=this.builder._schemaRuntimeDefinition;if(mi.isInstance(u)){let l=new Set(u.getChannelKeys());return Promise.all(c.map(async([d,p])=>{if(!l.has(d))return[d,p];let f=await u.validateInput({[d]:p});return[d,Object.prototype.hasOwnProperty.call(f,d)?f[d]:p]}))}if(_r(u)){let l=new Set(Object.keys(Oo(u)));if(c.filter(([f])=>l.has(f)).length===0)return c;let d=Ns(this._metaRegistry.getExtendedChannelSchemas(u,{withReducerSchema:!0})),p=Ns(u);return c.map(([f,m])=>{if(!l.has(f))return[f,m];let[h,y]=Jn(m);if(h){let _=Rs(p,{[f]:y});return[f,Object.prototype.hasOwnProperty.call(_,f)?{[Ti]:_[f]}:m]}let w=Rs(d,{[f]:m});return[f,Object.prototype.hasOwnProperty.call(w,f)?w[f]:m]})}return c};async function s(c){if(c){if(tr(c))return c.graph===Br.PARENT?null:o(c._updateAsTuples().filter(([u])=>r.includes(u)));if(Array.isArray(c)&&c.length>0&&c.some(tr)){let u=[];for(let l of c)if(tr(l)){if(l.graph===Br.PARENT)continue;u.push(...l._updateAsTuples().filter(([d])=>r.includes(d)))}else{let d=await s(l);d&&u.push(...d??[])}return o(u)}else{if(typeof c=="object"&&!Array.isArray(c))return o(Object.entries(c).filter(([u])=>r.includes(u)));{let u=Array.isArray(c)?"array":typeof c;throw new Ce(`Expected node "${i.toString()}" to return an object or an array containing at least one Command object, received ${u}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let a=[{value:Jr,mapper:new or({func:r.length&&r[0]===Zo?n:s,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new di({tags:[zt],triggers:[Ye],channels:[Ye],writers:[new $t(a,[zt])]});else{let c=t?.input??this.builder._schemaDefinition,u=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(c)).map(m=>[m,m])),l=Object.keys(u).length===1&&Zo in u,d=`branch:to:${e}`;this.channels[d]=t?.defer?new KO:new fi(!1);let p=t?.cachePolicy,f=p===!1?void 0:p;this.nodes[e]=new di({triggers:[d],channels:l?Object.keys(u):u,writers:[new $t(a,[zt])],mapper:l?void 0:m=>Object.fromEntries(Object.entries(m).filter(([h])=>h in u)),bound:t?.runnable,metadata:t?.metadata,retryPolicy:t?.retryPolicy,cachePolicy:f,timeout:t?.timeout,subgraphs:t?.subgraphs,ends:t?.ends,isErrorHandler:t?.isErrorHandler,errorHandlerNode:t?.errorHandlerNode})}}attachEdge(e,t){if(t!=="__end__"){if(typeof e=="string")this.nodes[e].writers.push(new $t([{channel:`branch:to:${t}`,value:null}],[zt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new $$(new Set(e)):new O$(new Set(e)),this.nodes[t].triggers.push(r);for(let n of e)this.nodes[n].writers.push(new $t([{channel:r,value:n}],[zt]))}}}attachBranch(e,t,r,n={withReader:!0}){let i=async(o,s)=>{let a=o.filter(u=>u!==Ze);if(!a.length)return;let c=a.map(u=>Gt(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await $t.doWrite({...s,tags:(s.tags??[]).concat([zt])},c)};this.nodes[e].writers.push(r.run(i,n.withReader?o=>FD.doRead(o,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,r=this.builder._schemaRuntimeDefinition;if(mi.isInstance(t)){if(tr(e)){let i=e;return e.update&&(i.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await t.validateInput(e)}if(t===Zv&&mi.isInstance(r)){if(tr(e)){let i=e;return e.update&&(i.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await r.validateInput(e)}let n=(()=>{let i=o=>{if(o!=null)return this._metaRegistry.getExtendedChannelSchemas(o,{withReducerSchema:!0})};if(_r(t))return i(t);if(t===Zv)return _r(r)?Ns(i(r)):void 0})();if(tr(e)){let i=e;if(e.update&&n!=null){let o=Array.isArray(e.update)?Object.fromEntries(e.update):e.update,s=Rs(n,o);i.update=Object.fromEntries(Object.keys(o).map(a=>[a,s[a]]))}return i}return n!=null?Rs(n,e):e}isInterrupted(e){return Xa(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return _r(t)&&Rs(t,e),e}};function Q3(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function eG(e){if(Gt(e))return[e];let t=[];tr(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(tr));let r=[];for(let n of t){if(n.graph===Br.PARENT)throw new fg(n);Gt(n.goto)||typeof n.goto=="string"?r.push(n.goto):Array.isArray(n.goto)&&r.push(...n.goto)}return r}function jU(){return new k$({path:new or({func:eG,tags:[zt],trace:!1,recurse:!1,name:"<control_branch>"})})}var UU=function(t,r){let{name:n,checkpointer:i,store:o,cache:s}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t,a=Wa(typeof t=="string"?void 0:t.timeout);if(UD(r)||LD(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let c="updates",u=HD(n,r);function l(m){return typeof m=="object"&&m!==null&&"__lg_type"in m&&m.__lg_type==="__pregel_final"}let d=new or({name:"pluckReturnValue",func:m=>l(m)?m.value:m}),p=new or({name:"pluckSaveValue",func:m=>l(m)?m.save:m}),f=new di({bound:u,triggers:[Ye],channels:[Ye],timeout:a,writers:[new $t([{channel:Ze,value:Jr,mapper:d},{channel:gs,value:Jr,mapper:p}],[zt])]});return new Lv({name:n,checkpointer:i,nodes:{[n]:f},channels:{[Ye]:new fi,[Ze]:new ui,[gs]:new ui},inputChannels:Ye,outputChannels:Ze,streamChannels:Ze,streamMode:c,store:o,cache:s})};UU.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};var tG=tt.Root({messages:tt({reducer:Lc,default:()=>[]})}),LU={reducer:{fn:Lc},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},rG=nr.object({messages:MU(nr.custom(),LU)});function Hm(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
301
|
-
|
|
302
|
-
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
303
|
-
`,e}function j(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}function g(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}var Ys=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Ys=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function Vo(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}var Jm=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};var A=class extends Error{},pt=class e extends A{constructor(t,r,n,i){super(`${e.makeMessage(t,r,n)}`),this.status=t,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=r;let o=r;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(t,r,n){let i=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,r,n,i){if(!t||!i)return new Nn({message:n,cause:Jm(r)});let o=r?.error;return t===400?new Qs(t,o,n,i):t===401?new ea(t,o,n,i):t===403?new ta(t,o,n,i):t===404?new ra(t,o,n,i):t===409?new na(t,o,n,i):t===422?new ia(t,o,n,i):t===429?new oa(t,o,n,i):t>=500?new sa(t,o,n,i):new e(t,o,n,i)}},De=class extends pt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}},Nn=class extends pt{constructor({message:t,cause:r}){super(void 0,void 0,t||"Connection error.",void 0),r&&(this.cause=r)}},Tt=class extends Nn{constructor({message:t}={}){super({message:t??"Request timed out."})}},Qs=class extends pt{},ea=class extends pt{},ta=class extends pt{},ra=class extends pt{},na=class extends pt{},ia=class extends pt{},oa=class extends pt{},sa=class extends pt{},aa=class extends A{constructor(){super("Could not parse response content as the length limit was reached")}},ca=class extends A{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},Xr=class extends Error{constructor(t){super(t)}},Mn=class extends pt{constructor(t,r,n){let i="OAuth2 authentication error",o;if(r&&typeof r=="object"){let s=r;o=s.error;let a=s.error_description;a&&typeof a=="string"?i=a:o&&(i=o)}super(t,r,i,n),this.error_code=o}},Bc=class extends A{constructor(t,r,n){super(t),this.provider=r,this.cause=n}};var iG=/^[a-z][a-z0-9+.-]*:/i,FU=e=>iG.test(e),kr=e=>(kr=Array.isArray,kr(e)),R$=kr;function Vv(e){return typeof e!="object"?{}:e??{}}function N$(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function zn(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}var M$=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new A(`${e} must be an integer`);if(t<0)throw new A(`${e} must be a positive integer`);return t};var BU=e=>{try{return JSON.parse(e)}catch{return}};var md=e=>new Promise(t=>setTimeout(t,e));function Xm(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function z$(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Ym(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return z$({start(){},async pull(r){let{done:n,value:i}=await t.next();n?r.close():r.enqueue(i)},async cancel(){await t.return?.()}})}function Wv(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let r=await t.read();return r?.done&&t.releaseLock(),r}catch(r){throw t.releaseLock(),r}},async return(){let r=t.cancel();return t.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Wo(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var VU;function pr(e){let t;return(VU??(t=new globalThis.TextEncoder,VU=t.encode.bind(t)))(e)}var WU;function qU(e){let t;return(WU??(t=new globalThis.TextDecoder,WU=t.decode.bind(t)))(e)}var j$,Ft,kt,Nt,oo,Zc,GU,Qm=64*1024,Vc=class{constructor(){j$.add(this),Ft.set(this,void 0),kt.set(this,void 0),Nt.set(this,void 0),oo.set(this,void 0),Zc.set(this,void 0),j(this,Ft,new Uint8Array,"f"),j(this,kt,0,"f"),j(this,Nt,0,"f"),j(this,oo,0,"f"),j(this,Zc,!1,"f")}decode(t){if(t==null)return[];let r;if(t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="string"?r=pr(t):r=t,r.length===0)return[];if(g(this,Zc,"f")&&(j(this,Zc,!1,"f"),r[0]===10&&(r=r.subarray(1)),r.length===0))return[];g(this,j$,"m",GU).call(this,r);let n=[],i;for(;(i=oG(g(this,Ft,"f"),g(this,oo,"f"),g(this,Nt,"f")))!=null;){let o=qU(g(this,Ft,"f").subarray(g(this,kt,"f"),i.preceding));n.push(o),j(this,kt,i.index,"f"),i.carriage&&(g(this,kt,"f")<g(this,Nt,"f")&&g(this,Ft,"f")[g(this,kt,"f")]===10?j(this,kt,g(this,kt,"f")+1,"f"):g(this,kt,"f")===g(this,Nt,"f")&&j(this,Zc,!0,"f")),j(this,oo,g(this,kt,"f"),"f")}if(j(this,oo,g(this,Nt,"f"),"f"),g(this,kt,"f")===g(this,Nt,"f"))j(this,kt,0,"f"),j(this,Nt,0,"f"),j(this,oo,0,"f"),g(this,Ft,"f").length>Qm&&j(this,Ft,new Uint8Array,"f");else if(n.length>0&&g(this,Ft,"f").length>Qm){let o=g(this,Nt,"f")-g(this,kt,"f");if(o<=Qm||g(this,Ft,"f").length>o*4){let s=o<=Qm?Math.min(Math.max(o*2,256),Qm):o*2,a=new Uint8Array(s);a.set(g(this,Ft,"f").subarray(g(this,kt,"f"),g(this,Nt,"f"))),j(this,Ft,a,"f"),j(this,kt,0,"f"),j(this,Nt,o,"f"),j(this,oo,o,"f")}}return n}flush(){return j(this,Zc,!1,"f"),g(this,kt,"f")===g(this,Nt,"f")?[]:this.decode(`
|
|
304
|
-
`)}};Ft=new WeakMap,kt=new WeakMap,Nt=new WeakMap,oo=new WeakMap,Zc=new WeakMap,j$=new WeakSet,GU=function(t){if(g(this,Nt,"f")+t.length>g(this,Ft,"f").length){let r=g(this,Nt,"f")-g(this,kt,"f");if(g(this,kt,"f")>=g(this,Ft,"f").length/2&&r+t.length<=g(this,Ft,"f").length)g(this,Ft,"f").copyWithin(0,g(this,kt,"f"),g(this,Nt,"f"));else{let n=Math.max(g(this,Ft,"f").length*2,r+t.length,256),i=new Uint8Array(n);i.set(g(this,Ft,"f").subarray(g(this,kt,"f"),g(this,Nt,"f"))),j(this,Ft,i,"f")}j(this,oo,g(this,oo,"f")-g(this,kt,"f"),"f"),j(this,Nt,r,"f"),j(this,kt,0,"f")}g(this,Ft,"f").set(t,g(this,Nt,"f")),j(this,Nt,g(this,Nt,"f")+t.length,"f")};Vc.NEWLINE_CHARS=new Set([`
|
|
305
|
-
`,"\r"]);Vc.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function oG(e,t,r){for(let o=t;o<r;o++){if(e[o]===10)return{preceding:o,index:o+1,carriage:!1};if(e[o]===13)return{preceding:o,index:o+1,carriage:!0}}return null}function HU(e){for(let t=0;t<e.length-1;t++){let r=KU(e,t);if(r>0){let n=t+r,i=KU(e,n);if(i>0)return n+i}}return-1}function KU(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}var Kv={off:0,error:200,warn:300,info:400,debug:500},D$=(e,t,r)=>{if(e){if(pe(Kv,e))return e;Mt(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Kv))}`)}};function eh(){}function qv(e,t,r){return!t||Kv[e]>Kv[r]?eh:t[e].bind(t)}var sG={error:eh,warn:eh,info:eh,debug:eh},JU=new WeakMap;function Mt(e){let t=e.logger,r=e.logLevel??"off";if(!t)return sG;let n=JU.get(t);if(n&&n[0]===r)return n[1];let i={error:qv("error",t,r),warn:qv("warn",t,r),info:qv("info",t,r),debug:qv("debug",t,r)};return JU.set(t,[r,i]),i}var XU=new Set(["apikey","accesstoken","refreshtoken","sessiontoken","sessionid","idtoken","authtoken","authorization","token","password","clientsecret","xamzsecuritytoken","xamzsignature","xamzcredential"]);function th(e){let t=e.toLowerCase().replace(/[-_]/gu,"");return XU.has(t)||XU.has(t.replace(/^x/u,""))}var aG=new Set(["authorization","proxy-authorization","api-key","x-api-key","x-amz-security-token","cookie","set-cookie","x-session-token","x-session-id","x-auth-token","x-id-token"]);function Hv(e){return aG.has(e.toLowerCase().replace(/_/gu,"-"))||th(e)}function Gv(e){let t=new URL(e);t.username="",t.password="",t.hash="";for(let r of t.searchParams.keys())th(r)&&t.searchParams.set(r,"***");return t.href}var qo=e=>{if(e.options){if(e.options={...e.options},delete e.options.headers,e.options.path){let t=e.options.path,r=new URL(Gv(new URL(t,"https://redacted.invalid").href));e.options.path=r.origin==="https://redacted.invalid"?`${t.startsWith("/")?"/":""}${r.pathname.slice(1)}${r.search}`:r.href}e.options.query&&(e.options.query=Object.fromEntries(Object.entries(e.options.query).map(([t,r])=>[t,th(t)?"***":r])))}return e.url&&(e.url=Gv(e.url)),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,r])=>[t,Hv(t)?"***":r]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e};var rh;function YU(){let e=[],t=0;return{get length(){return e.length-t},enqueue(r){e.push(r)},dequeue(){if(t===e.length)return;let r=e[t];return e[t]=void 0,t+=1,t===e.length?(e=[],t=0):t>=1024&&t*2>=e.length&&(e=e.slice(t),t=0),r}}}var Yr=class e{constructor(t,r,n){rh.set(this,void 0),this.iterator=t,this.controller=r,j(this,rh,n,"f")}static fromSSEResponse(t,r,n,i){let o=!1,s=n?Mt(n):console;async function*a(){if(o)throw new A("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let c=!1,u=!1;try{for await(let l of uG(t,r)){if(l.data==="[DONE]"){u=!0;break}if(l.event===null||!l.event.startsWith("thread.")){let d;try{d=JSON.parse(l.data)}catch{throw s.error("Could not parse message into JSON:"),s.error("From chunk:"),new SyntaxError("Error reading response: malformed server-sent event JSON.")}if(l.event==="error")throw new pt(void 0,d?.error??d,void 0,t.headers);if(d&&d.error)throw new pt(void 0,d.error,void 0,t.headers);yield i?{event:l.event,data:d}:d}else{let d;try{d=JSON.parse(l.data)}catch{throw s.error("Could not parse message into JSON:"),s.error("From chunk:"),new SyntaxError("Error reading response: malformed server-sent event JSON.")}yield{event:l.event,data:d}}}c=!0}catch(l){if(u||Vo(l)||r.signal.aborted&&l===r.signal.reason)return;throw l}finally{c||r.abort()}}return new e(a,r,n)}static fromReadableStream(t,r,n){let i=!1;async function*o(){let a=new Vc,c=t.getReader(),u=!1,l,d=()=>{l??(l=c.cancel()),l.catch(()=>{})};r.signal.addEventListener("abort",d,{once:!0});try{if(r.signal.aborted){d();return}for(;;){let{value:p,done:f}=await c.read();if(f){u=!0;break}if(r.signal.aborted)return;for(let m of a.decode(p)){if(r.signal.aborted)return;yield m}}if(r.signal.aborted)return;for(let p of a.flush()){if(r.signal.aborted)return;yield p}}finally{r.signal.removeEventListener("abort",d),u||d(),c.releaseLock()}}async function*s(){if(i)throw new A("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(let c of o())if(!a&&c){let u;try{u=JSON.parse(c)}catch(l){throw l instanceof SyntaxError?new SyntaxError("Error reading response: malformed newline-delimited JSON."):l}yield u}a=!0}catch(c){if(r.signal.aborted||Vo(c))return;throw c}finally{a||r.abort()}}return new e(s,r,n)}[(rh=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=YU(),r=YU(),n=this.iterator(),i=o=>({next:()=>{if(o.length===0){let s=n.next();t.enqueue(s),r.enqueue(s)}return o.dequeue()}});return[new e(()=>i(t),this.controller,g(this,rh,"f")),new e(()=>i(r),this.controller,g(this,rh,"f"))]}toReadableStream(){let t;return z$({start:async()=>{t=this[Symbol.asyncIterator]()},async pull(r){try{let{value:n,done:i}=await t.next();if(i)return r.close();let o=pr(JSON.stringify(n)+`
|
|
306
|
-
`);r.enqueue(o)}catch(n){r.error(n)}},async cancel(){await t.return?.()}})}};function cG(e,t){let r=typeof e.getReader=="function"?e.getReader():void 0,n=r?{next:()=>r.read(),return:()=>r.cancel()}:Wv(e)[Symbol.asyncIterator](),i={value:void 0,done:!0},o=!1,s=!1,a,c,u=()=>new Promise(f=>{c=f}),l=()=>{if(s||o)return a;s=!0;try{a=Promise.resolve(n.return?.())}catch(f){a=Promise.reject(f)}return a.catch(()=>{}),a},d=()=>{queueMicrotask(()=>{c?.(),l()})};return{iterator:{async next(){if(t.aborted)return i;let f=u().then(()=>i);try{let m=await Promise.race([n.next(),f]);return t.aborted?i:m.done?(o=!0,i):{value:m.value,done:!1}}catch(m){if(t.aborted&&(Vo(m)||m===t.reason))return i;throw m}finally{c=void 0}},async return(){let f=l();if(f&&!t.aborted){let m=u();try{t.aborted||await Promise.race([f,m])}finally{c=void 0}}return i},[Symbol.asyncIterator](){return this}},start(){t.addEventListener("abort",d,{once:!0}),t.aborted&&d()},async cleanup(f){let m;try{t.removeEventListener("abort",d)}catch(h){m=h}if(!o){let h=l();if(h&&!f&&!t.aborted)try{await h}catch(y){m??(m=y)}}if(r)try{r.releaseLock()}catch(h){m??(m=h)}if(m!==void 0&&!f&&!t.aborted)throw m}}}async function*uG(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product==="ReactNative"?new A("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new A("Attempted to iterate over a response with no body");let r=new U$,n=new Vc,{signal:i}=t,o=cG(e.body,i),s=!1;try{o.start();for await(let a of dG(o.iterator)){if(i.aborted)return;for(let c of n.decode(a)){if(i.aborted)return;let u=r.decode(c);u&&(yield u)}}if(i.aborted)return;for(let a of n.flush()){if(i.aborted)return;let c=r.decode(a);c&&(yield c)}}catch(a){if(s=!0,!i.aborted||!Vo(a)&&a!==i.reason)throw a}finally{await o.cleanup(s)}}var lG=3;async function*dG(e){let t=new Uint8Array,r=0,n=0,i=0;for await(let o of e){if(o==null)continue;let s;if(o instanceof ArrayBuffer?s=new Uint8Array(o):typeof o=="string"?s=pr(o):s=o,n+s.length>t.length){let c=n-r;if(r>=t.length/2&&c+s.length<=t.length)t.copyWithin(0,r,n);else{let u=new Uint8Array(Math.max(t.length*2,c+s.length));u.set(t.subarray(r,n)),t=u}i-=r,r=0,n=c}t.set(s,n),n+=s.length;let a;for(;(a=HU(t.subarray(i,n)))!==-1;)a+=i,yield t.slice(r,a),r=a,i=r;i=Math.max(r,n-lG)}n>r&&(yield t.slice(r,n))}var U$=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.slice(0,-1)),!t){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
307
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,,n]=pG(t,":"),i=n;return i.startsWith(" ")&&(i=i.slice(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};function pG(e,t){let r=e.indexOf(t);return r!==-1?[e.slice(0,r),t,e.slice(r+t.length)]:[e,"",""]}async function Wc(e,t){let{response:r,requestLogID:n,retryOfRequestLogID:i,startTime:o}=t,s=await(async()=>{if(t.options.stream)return Mt(e).debug("response",r.status,r.url,r.headers,r.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(r,t.controller,e,t.options.__synthesizeEventData):Yr.fromSSEResponse(r,t.controller,e,t.options.__synthesizeEventData);if(r.status===204)return null;if(t.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(r.headers.get("content-length")==="0")return;let p=await r.text();if(!p)return;let f=JSON.parse(p);return nh(f,r)}return await r.text()})().catch(a=>{throw fG(a,t.controller.signal)});return Mt(e).debug(`[${n}] response parsed`,qo({retryOfRequestLogID:i,url:r.url,status:r.status,body:s,durationMs:Date.now()-o})),s}function fG(e,t){if(!t.aborted||e!==t.reason||Vo(e))return e;let r="This operation was aborted",n=globalThis.DOMException;return typeof n=="function"?new n(r,"AbortError"):Object.assign(new Error(r),{name:"AbortError"})}function nh(e,t){return!e||typeof e!="object"||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}var ua="7.10.0";var r4=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function mG(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var hG=()=>{let e=mG();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ua,"X-Stainless-OS":e4(Deno.build.os),"X-Stainless-Arch":QU(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ua,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ua,"X-Stainless-OS":e4(globalThis.process.platform??"unknown"),"X-Stainless-Arch":QU(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=gG();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ua,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ua,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function gG(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let n=r.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,s=n[3]||0;return{browser:t,version:`${i}.${o}.${s}`}}}return null}var QU=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",e4=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),t4,n4=()=>t4??(t4=hG());var ih=new WeakMap;function i4(e,t){let r=ih.get(e);return r||(r=new Set,ih.set(e,r)),r.add(t),()=>{let n=ih.get(e);n&&(n.delete(t),n.size===0&&ih.delete(e))}}var o4=({headers:e,body:t})=>{let r=typeof t=="object"&&t!==null?ih.get(t):void 0,n;if(!r||r.size===0)n=JSON.stringify(t);else{let i=[...r];n=JSON.stringify(t,function(o,s){let a=s;for(let c of i){let u=c.value(this,o,a);u!==void 0&&(a=u)}return a});for(let o of i)o.complete()}return{bodyHeaders:{"content-type":"application/json"},body:n}};var L$="RFC3986",F$=String,B$={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:F$},s4="RFC1738";var a4,c4=(e,t)=>{let r=a4??Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty);return a4=r,r(e,t)};var so=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var Z$=1024,u4=(e,t,r,n,i)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,a=>"%26%23"+Number.parseInt(a.slice(2),16)+"%3B");let s="";for(let a=0;a<o.length;){let c=Math.min((Math.floor(a/Z$)+1)*Z$,o.length);c<o.length&&o.codePointAt(c-1)>65535&&(c+=1);let u=o.length>=Z$?o.slice(a,c):o,l=[];for(let d=0;d<u.length;++d){let p=u.charCodeAt(d);if(p===45||p===46||p===95||p===126||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||i===s4&&(p===40||p===41)){l[l.length]=u.charAt(d);continue}if(p<128){l[l.length]=so[p];continue}if(p<2048){l[l.length]=so[192|p>>6]+so[128|p&63];continue}if(p<55296||p>=57344){l[l.length]=so[224|p>>12]+so[128|p>>6&63]+so[128|p&63];continue}d+=1,p=65536+((p&1023)<<10|u.charCodeAt(d)&1023),l[l.length]=so[240|p>>18]+so[128|p>>12&63]+so[128|p>>6&63]+so[128|p&63]}s+=l.join(""),a=c}return s};function l4(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function V$(e,t){if(kr(e)){let r=[];for(let n of e)r.push(t(n));return r}return t(e)}var p4={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},f4=function(t,r){Array.prototype.push.apply(t,kr(r)?r:[r])},d4,Yt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:u4,encodeValuesOnly:!1,format:L$,formatter:F$,indices:!1,serializeDate(e){return(d4??(d4=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function _G(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var W$={};function m4(e,t,r,n,i,o,s,a,c,u,l,d,p,f,m,h,y,w){let _=e,b=w,I=0,$=!1;for(;(b=b.get(W$))!==void 0&&!$;){let M=b.get(e);if(I+=1,M!==void 0){if(M===I)throw new RangeError("Cyclic object value");$=!0}b.get(W$)===void 0&&(I=0)}if(typeof u=="function"?_=u(t,_):_ instanceof Date?_=p?.(_):r==="comma"&&kr(_)&&(_=V$(_,M=>M instanceof Date?p?.(M):M)),_===null){if(o)return c&&!h?c(t,Yt.encoder,y,"key",f):t;_=""}if(_G(_)||l4(_)){if(c){let M=h?t:c(t,Yt.encoder,y,"key",f);return[m?.(M)+"="+m?.(c(_,Yt.encoder,y,"value",f))]}return[m?.(t)+"="+m?.(String(_))]}let P=[];if(_===void 0)return P;let C;if(r==="comma"&&kr(_))h&&c&&(_=V$(_,c)),C=[{value:_.length>0?_.join(",")||null:void 0}];else if(kr(u))C=u;else{let M=Object.keys(_);l&&M.sort(l),C=M}let x=a?String(t).replace(/\./g,"%2E"):String(t),D=n&&kr(_)&&_.length===1?x+"[]":x;if(i&&kr(_)&&_.length===0)return D+"[]";for(let M of C){let R=typeof M=="object"&&M.value!==void 0?M.value:_[M];if(s&&R===null)continue;let B=d&&a?M.replace(/\./g,"%2E"):M,K;kr(_)?K=typeof r=="function"?r(D,B):D:K=D+(d?"."+B:"["+B+"]"),w.set(e,I);let re=new WeakMap([[W$,w]]);f4(P,m4(R,K,r,n,i,o,s,a,r==="comma"&&h&&kr(_)?null:c,u,l,d,p,f,m,h,y,re))}return P}function vG(e=Yt){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||Yt.charset;if(e.charset!==void 0&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=L$;if(e.format!==void 0){if(!c4(B$,e.format))throw new TypeError("Unknown format option provided.");r=e.format}let n=B$[r],i=Yt.filter;(typeof e.filter=="function"||kr(e.filter))&&(i=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in p4?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=Yt.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let s;return e.allowDots===void 0?s=e.encodeDotInKeys?!0:Yt.allowDots:s=!!e.allowDots,{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:Yt.addQueryPrefix,allowDots:s,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:Yt.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Yt.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?Yt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Yt.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:Yt.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:Yt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Yt.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Yt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Yt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Yt.strictNullHandling}}function h4(e,t={}){let r=e,n=vG(t),i,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):kr(n.filter)&&(o=n.filter,i=o);let s=[];if(typeof r!="object"||r===null)return"";let a=p4[n.arrayFormat],c=a==="comma"&&n.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);let u=new WeakMap;for(let p of i)n.skipNulls&&r[p]===null||f4(s,m4(r[p],p,a,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u));let l=s.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(d+=n.charset==="iso-8859-1"?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),l.length>0?d+l:""}function g4(e){return h4(e,{arrayFormat:"brackets"})}var wG=new Map([["global","https://api.openai.com/v1"],["us","https://us.api.openai.com/v1"],["eu","https://eu.api.openai.com/v1"],["ae","https://ae.api.openai.com/v1"]]);function q$(e){if(e.dataResidency===null||e.dataResidency===void 0)return;if(pe(e,"baseURL"))throw new A("The `dataResidency` and `baseURL` options are mutually exclusive.");let t=wG.get(e.dataResidency);if(t===void 0)throw new A("Invalid `dataResidency`; expected one of: global, us, eu, ae.");return t}var oh,qc=class e extends Promise{constructor(t,r,n=Wc){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=n,oh.set(this,void 0),j(this,oh,t,"f")}_thenUnwrap(t){return new e(g(this,oh,"f"),this.responsePromise,async(r,n)=>nh(t(await this.parseResponse(r,n),n),n.response))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r,request_id:r.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(g(this,oh,"f"),t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};oh=new WeakMap;var Jv,hd=class{constructor(t,r,n,i){Jv.set(this,void 0),j(this,Jv,t,"f"),this.options=i,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let t=this.nextPageRequestOptions();if(!t)throw new A("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await g(this,Jv,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(Jv=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let r of t.getPaginatedItems())yield r}},sh=class extends qc{constructor(t,r,n){super(t,r,async(i,o)=>new n(i,o.response,await Wc(i,o),o.options))}async*[Symbol.asyncIterator](){let t=await this;for await(let r of t)yield r}},Ir=class extends hd{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},ve=class extends hd{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.getPaginatedItems(),r=t[t.length-1]?.id;return r?{...this.options,query:{...Vv(this.options.query),after:r}}:null}},qe=class extends hd{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.last_id;return t?{...this.options,query:{...Vv(this.options.query),after:t}}:null}},Bt=class extends hd{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.next=n.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.next;return t?{...this.options,query:{...Vv(this.options.query),after:t}}:null}};var kG={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},IG="urn:ietf:params:oauth:grant-type:token-exchange",SG=.5;function AG(e,t,r){let n=(r??1200)*1e3,i=Math.min(n,(e-t)*SG);return e-i}var y4=Response.prototype,OG=y4.arrayBuffer;function $G(e,t){let r=Object.getOwnPropertyDescriptor(t,"constructor")?.value;if(t===e||typeof r!="function"||Object.getOwnPropertyDescriptor(r,"name")?.value!=="Response"||Object.getOwnPropertyDescriptor(r,"prototype")?.value!==t)return!1;let n=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return(n?.value==="Response"||typeof n?.get=="function")&&typeof Object.getOwnPropertyDescriptor(t,"headers")?.get=="function"&&typeof Object.getOwnPropertyDescriptor(t,"ok")?.get=="function"&&typeof Object.getOwnPropertyDescriptor(t,"status")?.get=="function"}function TG(e,t){if(e===t)return!0;let r=Object.getOwnPropertyDescriptor(e,"constructor")?.value;return t!==null&&Object.getPrototypeOf(t)===e&&typeof r=="function"&&Object.getOwnPropertyDescriptor(r,"name")?.value==="Body"&&Object.getOwnPropertyDescriptor(r,"prototype")?.value===e}function EG(e){let t=globalThis;return new TextDecoder("utf-8",{ignoreBOM:typeof t.Bun?.version=="string"}).decode(e)}async function PG(e){let t,r=null;for(let i=0,o=e;o!==null&&i<16&&o!==y4;o=Object.getPrototypeOf(o),i+=1){$G(e,o)&&(r=o);let s=Object.getOwnPropertyDescriptor(o,"json");if(!s)continue;if(typeof s.value!="function")break;let a=Object.getOwnPropertyDescriptor(o,"text")?.value;if(typeof a=="function"&&TG(o,r)){t=a;break}return s.value.call(e)}let n=t===void 0?EG(await OG.call(e)):await t.call(e);try{return JSON.parse(n)}catch{throw new SyntaxError("Token exchange response contains invalid JSON")}}function CG(e){return typeof globalThis.Bun?.version=="string"?/[^\t\u0020-\u007E]|^[\t ]|[\t ]$/u.test(e):/[^\t\u0020-\u007E\u0080-\u00FF]|^[\t ]|[\t ]$/u.test(e)}var Xv=class e{constructor(t,r){this.cachedToken=null,this.refreshPromise=null,this.tokenGeneration=0,this.tokenExchangeUrl="https://auth.openai.com/oauth/token";let{identityProviderId:n,serviceAccountId:i,clientId:o,refreshBufferSeconds:s,provider:a}=t;this.config={identityProviderId:n,serviceAccountId:i,...o===void 0?{}:{clientId:o},...s===void 0?{}:{refreshBufferSeconds:s},provider:{tokenType:a.tokenType,getToken:a.getToken.bind(a)}},this.fetch=r??Xm()}async getToken(){if(!this.cachedToken||e.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;let t=this.refreshToken(this.tokenGeneration);this.refreshPromise=t;try{return await t}finally{this.refreshPromise===t&&(this.refreshPromise=null)}}if(e.needsRefresh(this.cachedToken)&&!this.refreshPromise){let t=this.refreshToken(this.tokenGeneration).finally(()=>{this.refreshPromise===t&&(this.refreshPromise=null)});this.refreshPromise=t,t.catch(()=>null)}return this.cachedToken.token}async refreshToken(t){let r=await this.config.provider.getToken(),n={grant_type:IG,subject_token:r,subject_token_type:kG[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId};this.config.clientId&&(n.client_id=this.config.clientId);let i=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),redirect:"manual"});if(!i.ok){let l=await i.text(),d;try{d=JSON.parse(l)}catch{}throw i.status===400||i.status===401||i.status===403?new Mn(i.status,d,i.headers):pt.generate(i.status,d,`Token exchange failed with status ${i.status}`,i.headers)}let o=await PG(i),s=typeof o=="object"&&o!==null&&"access_token"in o?o.access_token:void 0;if(typeof s!="string"||s.trim().length===0||CG(s))throw new A("Token exchange response missing 'access_token' field");let a=o.expires_in??3600;if(typeof a!="number"||!Number.isFinite(a)||a<=0)throw new A("Token exchange response has invalid 'expires_in' field");let c=Date.now(),u=c+a*1e3;if(!Number.isSafeInteger(u)||u<=c)throw new A("Token exchange response has invalid 'expires_in' field");return this.tokenGeneration===t&&(this.cachedToken={token:s,expiresAt:u,refreshAt:AG(u,c,this.config.refreshBufferSeconds)}),s}static isTokenExpired(t){return Date.now()>=t.expiresAt}static needsRefresh(t){return Date.now()>=t.refreshAt}invalidateToken(){this.tokenGeneration+=1,this.cachedToken=null,this.refreshPromise=null}};var _4="https://mtls.api.openai.com/v1";function gd(e){let t;try{t=new URL(e)}catch{throw new A("X.509 workload identity requires the approved global mTLS API origin.")}if(t.origin!=="https://mtls.api.openai.com"||t.username||t.password)throw new A("X.509 workload identity requires the approved global mTLS API origin.");for(let r of t.searchParams.keys())if(th(r))throw new A("X.509 workload identity cannot send conflicting query authentication credentials.");return t}var v4=Symbol("brand.privateNullableHeaders"),RG=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function*NG(e){if(!e)return;if(v4 in e){let{values:n,nulls:i}=e;yield*n.entries();for(let o of i)yield[o,null];return}let t=!1,r;e instanceof Headers?r=e.entries():R$(e)?r=e:(t=!0,r=Object.entries(e??{}));for(let n of r){let i=n[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let o=R$(n[1])?n[1]:[n[1]],s=!1;for(let a of o)a!==void 0&&(t&&!s&&(s=!0,yield[i,null]),yield[i,a])}}var L=e=>{let t=new Headers,r=new Set;for(let n of e){let i=new Set;for(let[o,s]of NG(n)){if(!RG.test(o))throw new TypeError(`Header name must be a valid HTTP token ["${o}"]`);let a=o.toLowerCase();i.has(a)||(t.delete(a),i.add(a)),s===null?(t.delete(a),r.add(a)):(t.append(a,s),r.delete(a))}}return{[v4]:!0,values:t,nulls:r}};var K$={};Kn(K$,{findRegisteredX509Transport:()=>MG,findX509Credential:()=>qG,findX509OAuthError:()=>VG,isApprovedX509Client:()=>BG,isRetryableX509IssuerError:()=>LG,isTransientX509ConnectionError:()=>DG,markApprovedX509Client:()=>FG,markRetryableX509IssuerError:()=>UG,markTransientX509ConnectionError:()=>jG,rememberRegisteredX509Transport:()=>zG,rememberX509Credential:()=>WG,rememberX509OAuthError:()=>ZG});var b4=new WeakMap,w4=new WeakSet,x4=new WeakSet,k4=new WeakSet,I4=new WeakMap,S4=new WeakMap,MG=WeakMap.prototype.get.bind(b4),zG=WeakMap.prototype.set.bind(b4),jG=WeakSet.prototype.add.bind(w4),DG=WeakSet.prototype.has.bind(w4),UG=WeakSet.prototype.add.bind(x4),LG=WeakSet.prototype.has.bind(x4),FG=WeakSet.prototype.add.bind(k4),BG=WeakSet.prototype.has.bind(k4),ZG=WeakMap.prototype.set.bind(I4),VG=WeakMap.prototype.get.bind(I4),WG=WeakMap.prototype.set.bind(S4),qG=WeakMap.prototype.get.bind(S4);var G$=gw(A4(),1),KG=typeof G$.findRegisteredX509Transport=="function"?G$:K$,{findRegisteredX509Transport:O4,rememberRegisteredX509Transport:YEe,markTransientX509ConnectionError:QEe,isTransientX509ConnectionError:Qv,markRetryableX509IssuerError:ePe,isRetryableX509IssuerError:H$,markApprovedX509Client:$4,isApprovedX509Client:GG,rememberX509OAuthError:tPe,findX509OAuthError:T4,rememberX509Credential:rPe,findX509Credential:E4}=KG;function P4(e){if(!e||typeof e!="object")throw new A("X.509 workload identity requires an approved X.509 transport capability.");let t=O4(e);if(!t)throw new A("X.509 workload identity requires an approved X.509 transport capability.");return t}var Ge,Dr,Kc,Gc,ao,jn,Go,Ho,sr,Hc,Ko,Un,Dn,M4,tb,z4,C4,j4,D4,R4,U4,gt,X$,HG=["dispatcher","agent","client","tls","proxy"],yd=(e,t)=>Headers.prototype.get.call(e,t),JG=1200*1e3,N4=1e3,eb=e=>{let t=new De;return Object.defineProperty(t,"cause",{value:e.reason,writable:!0,configurable:!0}),t};function J$(e){for(let t of Headers.prototype.keys.call(e)){let r=t.toLowerCase().split("_").join("-");if(r!=="authorization"&&Hv(r)||r==="host")throw new A("X.509 workload identity cannot send conflicting authentication credentials.")}}function XG(e,t){let r=new AbortController,n=e===void 0?void 0:setTimeout(()=>r.abort(new Tt),e),i=n;typeof i=="object"&&i!==null&&"unref"in i&&typeof i.unref=="function"&&i.unref();let o=()=>r.abort(t?.reason);return t?.addEventListener("abort",o,{once:!0}),t?.aborted&&o(),{signal:r.signal,dispose:()=>{t?.removeEventListener("abort",o),n&&clearTimeout(n)}}}function YG(e,t){let r,n=new Promise((i,o)=>{r=()=>o(t.reason),t.addEventListener("abort",r,{once:!0}),t.aborted&&r()});return{result:Promise.race([e.promise,n]),dispose:()=>{r&&t.removeEventListener("abort",r)}}}function rb(e){if(!e||typeof e!="object")return!1;let t=e;for(;t!==null&&t!==Object.prototype;){let n=Object.getOwnPropertyDescriptor(t,"provider");if(n){if(!("value"in n)||n.value!==void 0)return!1;break}t=Object.getPrototypeOf(t)}let r=e;for(;r!==null&&r!==Object.prototype;){let n=Object.getOwnPropertyDescriptor(r,"type");if(n){if(!("value"in n))throw new A("X.509 workload identity type must be a plain data property.");return n.value==="x509"}r=Object.getPrototypeOf(r)}return!1}function Y$(e){if(!e)return;for(let r of HG)if(pe(e,r))throw new A("X.509 workload identity cannot override its approved transport capability.");let t=Object.getOwnPropertyDescriptor(e,"redirect")?.value;if(t!==void 0&&t!=="manual")throw new A("X.509 workload identity requests require manual redirects.")}function ah(e){if(Y$(e),e&&["body","headers","method","signal"].some(t=>pe(e,t)))throw new A("X.509 workload identity cannot override its request body, headers, method, or signal through fetch options.")}function Q$(e){ah(e);let t={...e};return ah(t),t}var Sr=class{constructor(t,r,n,i){if(Ge.add(this),Kc.set(this,void 0),Gc.set(this,void 0),ao.set(this,void 0),jn.set(this,void 0),Go.set(this,void 0),Ho.set(this,void 0),sr.set(this,void 0),Hc.set(this,void 0),Ko.set(this,void 0),Un.set(this,void 0),Dn.set(this,0),j(this,sr,P4(r),"f"),j(this,Kc,t.identityProviderId,"f"),j(this,Gc,t.serviceAccountId,"f"),j(this,ao,t.refreshBufferMs,"f"),j(this,jn,t.refreshBufferSeconds,"f"),j(this,Go,n,"f"),j(this,Ho,i,"f"),g(this,ao,"f")!==void 0&&g(this,jn,"f")!==void 0)throw new A("X.509 workload identity cannot combine refreshBufferSeconds and refreshBufferMs.");if(g(this,ao,"f")!==void 0&&(!Number.isSafeInteger(g(this,ao,"f"))||g(this,ao,"f")<0))throw new A("X.509 workload identity requires a nonnegative integer refreshBufferMs.");if(g(this,jn,"f")!==void 0&&(!Number.isSafeInteger(g(this,jn,"f"))||g(this,jn,"f")<0||!Number.isSafeInteger(g(this,jn,"f")*1e3)))throw new A("X.509 workload identity requires a nonnegative integer refreshBufferSeconds.");j(this,Hc,g(this,jn,"f")===void 0?g(this,ao,"f")??JG:g(this,jn,"f")*1e3,"f")}identitySnapshot(){return{type:"x509",identityProviderId:g(this,Kc,"f"),serviceAccountId:g(this,Gc,"f"),...g(this,ao,"f")===void 0?{}:{refreshBufferMs:g(this,ao,"f")},...g(this,jn,"f")===void 0?{}:{refreshBufferSeconds:g(this,jn,"f")}}}static shouldAuthenticate(t,r,n=t.headers){return!L([r,n]).nulls.has("authorization")}snapshotHeaders(t,r){let n=g(this,Ge,"m",gt).call(this);return n.defaultHeaders??(n.defaultHeaders=L([t])),n.requestHeaders??(n.requestHeaders=L([r])),this.headerSnapshots()}headerSnapshots(){let{defaultHeaders:t,requestHeaders:r}=g(this,Ge,"m",gt).call(this);if(!t||!r)throw new A("X.509 workload identity requires snapshotted request headers.");return{defaultHeaders:t,requestHeaders:r}}snapshotTenant(t,r){if(t!==g(this,Go,"f")||r!==g(this,Ho,"f"))throw new A("X.509 workload identity cannot override its enrolled organization or project.");let n=g(this,Ge,"m",gt).call(this);return n.tenant={organization:t,project:r},n.tenant}tenantSnapshot(){let{tenant:t}=g(this,Ge,"m",gt).call(this);if(!t)throw new A("X.509 workload identity requires snapshotted tenant selectors.");return t}snapshotAPIURL(t){gd(t),g(this,Ge,"m",gt).call(this).apiURL=t}requestAPIURL(){let{apiURL:t}=g(this,Ge,"m",gt).call(this);if(t===void 0)throw new A("X.509 workload identity requires a snapshotted API destination.");return t}snapshotRequest(t,r,n){var i;(i=g(this,Ge,"m",gt).call(this)).request??(i.request={signal:t,timeout:r,fetchOptions:n})}requestSnapshot(){let{request:t}=g(this,Ge,"m",gt).call(this);if(!t)throw new A("X.509 workload identity requires snapshotted request settings.");return t}beginRequestPreparation(){let t=g(this,Ge,"m",gt).call(this);t.deadlineArmed&&t.preparationStartedAt===void 0&&(t.preparationStartedAt=performance.now(),t.preparationWallStartedAt=Date.now())}beginRequestPlanning(){g(this,Ge,"m",gt).call(this).phase="planning"}beginRequestNetwork(){let t=g(this,Ge,"m",gt).call(this);t.deadlineArmed?t.preparationStartedAt!==void 0&&(t.monotonicStartedAt+=performance.now()-t.preparationStartedAt,t.wallStartedAt+=Date.now()-(t.preparationWallStartedAt??Date.now()),delete t.preparationStartedAt,delete t.preparationWallStartedAt):(t.wallStartedAt=Date.now(),t.monotonicStartedAt=performance.now(),t.deadlineArmed=!0)}isPlanningRequest(){return g(this,Ge,"m",gt).call(this).phase==="planning"}authorizePlannedRequest(t,r,n,i=!1){let o=g(this,Ge,"m",gt).call(this),s=Object.getOwnPropertyDescriptor(r,"headers"),a=Object.getOwnPropertyDescriptor(r,"body"),c=Object.getOwnPropertyDescriptor(r,"signal"),u=Object.getOwnPropertyDescriptor(r,"redirect");if(o.phase!=="planning"||!s||!(s.value instanceof Headers)||!a&&"body"in r||[a,c,u].some(d=>d&&!("value"in d)))throw new A("X.509 workload identity requires an approved final request.");this.snapshotAPIURL(t),Y$(r);try{J$(s.value)}catch{throw new A("X.509 workload identity cannot use caller-supplied authentication credentials.")}if(yd(s.value,"Authorization")!==null)throw new A("X.509 workload identity cannot use caller-supplied authorization credentials.");if(g(this,Ge,"m",X$).call(this,s.value),!i&&(c?.value??void 0)!==(this.requestSnapshot().signal??void 0))throw new A("X.509 workload identity must preserve its approved request signal.");let l=this.requestSnapshot();o.request={...l,timeout:Math.min(l.timeout,n)},o.phase="authorizing"}ownRequestBody(t,r){t instanceof ReadableStream&&t!==r&&(g(this,Ge,"m",gt).call(this).materializedBody=t)}static isStreamingRequestBody(t){return globalThis.ReadableStream!==void 0&&t instanceof globalThis.ReadableStream||typeof t=="object"&&t!==null&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")}retireRequestBody(){let t=g(this,Ge,"m",gt).call(this),r=t.materializedBody;delete t.materializedBody,r&&g(Dr,Dr,"m",M4).call(Dr,r)}releaseRequestBody(t){let r=g(this,Ge,"m",gt).call(this);r.materializedBody===t?delete r.materializedBody:this.retireRequestBody()}setEffectiveSignal(t){t?g(this,Ge,"m",gt).call(this).effectiveSignal=t:delete g(this,Ge,"m",gt).call(this).effectiveSignal}effectiveSignal(){let t=g(this,Ge,"m",gt).call(this);return t.effectiveSignal??t.request?.signal}runRequest(t,r){return g(this,sr,"f").run(async()=>{let n=g(this,sr,"f").current();if(!n)throw new A("X.509 workload identity requires an active certificate request scope.");n.owner=this,n.requestOwner=r;try{return await t()}finally{this.retireRequestBody(),this.releaseRequestCredentials(),delete n.requestOwner,delete n.owner}})}inRequest(t){let r=g(this,sr,"f").current();return r?.owner===this&&r.requestOwner===t&&r.phase!=="authorizing"}matches(t){return g(this,sr,"f")===g(t,sr,"f")&&g(this,Kc,"f")===g(t,Kc,"f")&&g(this,Gc,"f")===g(t,Gc,"f")&&g(this,Go,"f")===g(t,Go,"f")&&g(this,Ho,"f")===g(t,Ho,"f")&&g(this,Hc,"f")===g(t,Hc,"f")}continuation(){let{wallStartedAt:t,monotonicStartedAt:r,deadlineArmed:n,request:i,requestOwner:o,effectiveSignal:s}=g(this,Ge,"m",gt).call(this),a={wallStartedAt:t,monotonicStartedAt:r,owner:this,...n?{deadlineArmed:n}:{},...i?{request:i}:{},...s?{effectiveSignal:s}:{},...o?{requestOwner:o}:{}};return c=>g(this,sr,"f").resume(a,async()=>{try{return await c()}finally{this.releaseRequestCredentials(),delete a.requestOwner,delete a.owner}})}releaseRequestCredentials(){let t=g(this,Ge,"m",gt).call(this);delete t.request,delete t.phase,delete t.deadlineArmed,delete t.preparationStartedAt,delete t.preparationWallStartedAt,delete t.effectiveSignal,delete t.materializedBody,delete t.apiURL,delete t.tenant,delete t.token,delete t.defaultHeaders,delete t.requestHeaders,delete t.tokenGeneration,delete t.headers,delete t.authorization}requestStartedAt(t){return g(this,sr,"f").current()?.wallStartedAt}usedWorkloadToken(t){return g(this,sr,"f").current()?.token!==void 0}remainingTimeout(t,r){let n=g(this,sr,"f").current();if(n===void 0)return r;let i=r-(performance.now()-n.monotonicStartedAt);if(i<=0)throw new Tt;return i}async waitForRetry(t,r){try{await g(this,sr,"f").sleep(t,r)}catch(n){throw r?.aborted?eb(r):n}}static isRetryableFailure(t){return typeof t=="object"&&t!==null&&(Qv(t)||H$(t))}static retryHeaders(t){if(!t||typeof t!="object"||!H$(t))return;let r=Object.getOwnPropertyDescriptor(t,"headers")?.value;return r instanceof Headers?r:void 0}async getToken(t,r){let n=r?r.signal:t?.signal;if(n?.aborted)throw eb(n);t&&ah(r?r.fetchOptions:t.fetchOptions),g(this,Ge,"m",U4).call(this,r);let i=t?g(this,Ge,"m",gt).call(this):void 0,o=g(this,Ko,"f");if(o&&performance.now()<o.refreshAt&&Date.now()<o.wallRefreshAt)return g(Dr,Dr,"m",tb).call(Dr,i,o);let s=r&&t?this.remainingTimeout(t,r.timeout):r?.timeout,{signal:a,dispose:c}=XG(s,n);if(n?.aborted)throw c(),eb(n);let u=g(this,Un,"f")??g(this,Ge,"m",D4).call(this);u.waiters+=1;let l=YG(u,a);try{let d=await l.result,p=g(this,Ko,"f");if(!p||p.accessToken!==d.accessToken)throw new De;return g(Dr,Dr,"m",tb).call(Dr,i,p)}catch(d){return await g(this,Ge,"m",z4).call(this,d,u,o,i,t,r)}finally{l.dispose(),c(),u.waiters-=1,g(this,Ge,"m",j4).call(this,u)}}invalidateToken(){let t=g(this,sr,"f").current();if(!t?.token||g(this,Ko,"f")?.accessToken!==t.token||g(this,Ko,"f").generation!==t.tokenGeneration)return;j(this,Dn,g(this,Dn,"f")+1,"f"),j(this,Ko,void 0,"f");let r=g(this,Un,"f");j(this,Un,void 0,"f"),r?.controller.abort(new De)}bindRequest(t,r,n){if(!(r.headers instanceof Headers))throw new A("X.509 workload identity requires the original workload authorization headers.");let i=g(this,Ge,"m",gt).call(this),{token:o}=i,s=t.__security??{bearerAuth:!0},a=o?`Bearer ${o}`:null;!o&&s.adminAPIKeyAuth&&n!==null&&yd(r.headers,"Authorization")!==null&&(a=new Headers({Authorization:`Bearer ${n}`}).get("Authorization")),i.headers=r.headers,i.authorization=a,this.assertRequest(r)}adoptRequestHeaders(t){let r=g(this,Ge,"m",gt).call(this),n=r.headers;if(!(n instanceof Headers)||!(t.headers instanceof Headers))throw new A("X.509 workload identity must preserve its issued workload authorization.");r.headers=t.headers;try{this.assertRequest(t)}catch(i){throw r.headers=n,i}}assertRequest(t){let{headers:r}=t;if(!(r instanceof Headers))throw new A("X.509 workload identity must preserve its issued workload authorization.");let n=g(this,sr,"f").current();if(!n||n.headers!==r||n.authorization===void 0||yd(r,"Authorization")!==n.authorization)throw new A("X.509 workload identity must preserve its issued workload authorization.");g(this,Ge,"m",X$).call(this,r),J$(r)}fetch(){return async(t,r={})=>{let n=gd(typeof t=="string"||t instanceof URL?t:t.url);Y$(r),this.assertRequest(r);let i=r.headers;if(!(i instanceof Headers))throw new A("X.509 workload identity must preserve its issued workload authorization.");let o=new Headers([...Headers.prototype.entries.call(i)]);return J$(o),r.headers=o,r.redirect="manual",await g(this,sr,"f").dispatch(n,r)}}};Dr=Sr,Kc=new WeakMap,Gc=new WeakMap,ao=new WeakMap,jn=new WeakMap,Go=new WeakMap,Ho=new WeakMap,sr=new WeakMap,Hc=new WeakMap,Ko=new WeakMap,Un=new WeakMap,Dn=new WeakMap,Ge=new WeakSet,M4=async function(t){try{await Wo(t)}catch{}},tb=function(t,r){return t&&(t.token=r.accessToken,t.tokenGeneration=r.generation),r.accessToken},z4=async function(t,r,n,i,o,s){let a=s?s.signal:o?.signal;if(a?.aborted)throw eb(a);if(r.controller.signal.aborted&&r.generation!==g(this,Dn,"f"))return await this.getToken(o,s);let c=g(this,Ge,"m",C4).call(this,t,n,i);if(c!==void 0)return c;if(t&&typeof t=="object"&&!(t instanceof Mn)){let u=T4(t);if(u)throw new Mn(u.status,u.error,u.headers)}throw t},C4=function(t,r,n){if(!r||r!==g(this,Ko,"f")||performance.now()>=r.expiresAt||Date.now()>=r.wallExpiresAt||!Dr.isRetryableFailure(t))return;let i=Dr.retryHeaders(t),o=i?.get("retry-after-ms"),s=o?Number(o):void 0,a=i?.get("retry-after");if(a&&(s===void 0||Number.isNaN(s))){let u=Number(a);s=Number.isNaN(u)?Date.parse(a)-Date.now():u*1e3}let c=s!==void 0&&Number.isFinite(s)&&s>=0&&s<=6e4?Math.max(N4,s):N4;return r.refreshAt=Math.min(r.expiresAt,performance.now()+c),r.wallRefreshAt=Math.min(r.wallExpiresAt,Date.now()+c),g(Dr,Dr,"m",tb).call(Dr,n,r)},j4=function(t){t.waiters!==0||g(this,Un,"f")!==t||queueMicrotask(()=>{t.waiters===0&&g(this,Un,"f")===t&&(j(this,Un,void 0,"f"),j(this,Dn,g(this,Dn,"f")+1,"f"),t.controller.abort(new De))})},D4=function(){let t=new AbortController,r=g(this,Dn,"f"),n={controller:t,generation:r,waiters:0,promise:g(this,Ge,"m",R4).call(this,t,r)};return j(this,Un,n,"f"),n},R4=async function(t,r){let n=performance.now(),i=Date.now();try{let o=await g(this,sr,"f").exchange(g(this,Kc,"f"),g(this,Gc,"f"),t.signal),s=o.expiresIn*1e3,a=n+s,c=i+s;if(performance.now()>=a||Date.now()>=c)throw new A("X.509 workload identity token expired before its exchange completed.");if(g(this,Dn,"f")!==r||t.signal.aborted||g(this,Un,"f")?.controller!==t)throw new De;return j(this,Dn,g(this,Dn,"f")+1,"f"),j(this,Ko,{accessToken:o.accessToken,generation:g(this,Dn,"f"),expiresAt:a,refreshAt:a-Math.min(g(this,Hc,"f"),s/2),wallExpiresAt:c,wallRefreshAt:c-Math.min(g(this,Hc,"f"),s/2)},"f"),o}finally{g(this,Un,"f")?.controller===t&&j(this,Un,void 0,"f")}},U4=function(t){if(!t)return;if(t.organization!==g(this,Go,"f")||t.project!==g(this,Ho,"f"))throw new A("X.509 workload identity cannot override its enrolled organization or project.");gd(t.apiURL);let r=L([t.defaultHeaders,t.requestHeaders]);if(g(this,Go,"f")!==null&&r.nulls.has("openai-organization")||g(this,Ho,"f")!==null&&r.nulls.has("openai-project"))throw new A("X.509 workload identity cannot omit its enrolled organization or project.");for(let n of r.values.keys()){let i=n.toLowerCase().split("_").join("-");if((i==="openai-organization"||i==="openai-project")&&(n!==i||yd(r.values,n)!==(i==="openai-organization"?t.organization:t.project)))throw new A("X.509 workload identity cannot override its enrolled organization or project.");if(Hv(i)||i==="host")throw new A("X.509 workload identity cannot use caller-supplied authentication credentials.")}},gt=function(){let t=g(this,sr,"f").current();if(!t||t.owner!==this)throw new A("X.509 workload identity requires an active certificate request scope.");return t},X$=function(t){if(yd(t,"OpenAI-Organization")!==g(this,Go,"f")||yd(t,"OpenAI-Project")!==g(this,Ho,"f"))throw new A("X.509 workload identity cannot override its enrolled organization or project.");for(let r of Headers.prototype.keys.call(t)){let n=r.toLowerCase().split("_").join("-");if((n==="openai-organization"||n==="openai-project")&&r!==n)throw new A("X.509 workload identity cannot override its enrolled organization or project.")}};function L4(e){let{credential:t}=e;if(t===void 0)return{credential:t,options:e};let r=E4(t);if(!r)throw new A("An X.509 credential must be created by the SDK authentication helper.");let n=["apiKey","adminAPIKey","workloadIdentity","x509Transport"].filter(i=>{let o=e[i];return o!=null});if(n.length>0)throw new A(`The \`credential\` option cannot be combined with ${n.map(i=>`\`${i}\``).join(", ")}.`);return{credential:t,options:{...e,apiKey:null,adminAPIKey:null,baseURL:e.baseURL??null,organization:e.organization??null,project:e.project??null,workloadIdentity:r.identity,x509Transport:r.transport}}}function QG({apiKey:e,adminAPIKey:t}){return e!=null||t!=null}function eH(e,t){let r=e.provider,n=t.credential??t.workloadIdentity,i=t.provider??(n?void 0:r);return i!==r&&(delete e.baseURL,delete e.organization,delete e.project,delete e.defaultHeaders,delete e.defaultQuery,delete e.fetchOptions,delete e.fetch),i&&(delete e.apiKey,delete e.adminAPIKey,delete e.credential,delete e.workloadIdentity,delete e.x509Transport,delete e.baseURL),i}function F4(e,t,r,n){let i=pe(t,"workloadIdentity")?t.workloadIdentity:e.workloadIdentity,o=r!==void 0&&(QG(t)&&t.workloadIdentity===void 0||t.provider!==void 0);r!==void 0&&pe(t,"workloadIdentity")&&delete e.x509Transport;let s=r!==void 0&&!o&&t.credential===void 0&&!pe(t,"workloadIdentity")&&!pe(t,"x509Transport")?r:void 0,a=t.credential===void 0?s:t.credential,c=a!==void 0||!o&&rb(i);return n!==c&&(delete e.fetch,delete e.baseURL,delete e.organization,delete e.project,delete e.defaultHeaders,delete e.defaultQuery,delete e.fetchOptions,c?e.apiKey=null:(delete e.x509Transport,o&&delete e.workloadIdentity)),a!==void 0&&(delete e.apiKey,delete e.adminAPIKey,delete e.workloadIdentity,delete e.x509Transport,e.credential=a,t.credential!==void 0&&(delete e.organization,delete e.project,delete e.defaultHeaders,delete e.defaultQuery,delete e.fetchOptions)),{credential:a,provider:eH(e,t)}}var Z4=Symbol("brand.privateStreamingFile");function ib(e,t,r){if(typeof t!="string"||!t)throw new TypeError("toStreamingFile requires a non-empty file name");let n=r?.type;return n&&G4(n),{[Z4]:!0,data:e,name:t,...n?{type:n}:{}}}var iT=()=>{if(typeof File>"u"){let{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&Number.parseInt(e.versions.node.split("."),10)<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to a supported Node.js LTS release, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Jo(e,t,r){return iT(),new File(e,t??"unknown_file",r)}function Jc(e,t){if(typeof e!="object"||e===null)return;let r="name"in e?e.name:void 0,n=r&&String(r)||"filename"in e&&e.filename&&String(e.filename);if(n)return t?.stripFilename===!1?V4(n):ch(n);let i="url"in e&&e.url&&String(e.url);if(i)try{return ch(new URL(i).pathname)}catch{return ch(i)}let o="path"in e&&e.path&&String(e.path);return o?ch(o):void 0}function ch(e){return e.split(/[\\/]/).pop()||void 0}function V4(e){let t=e.replace(/\\/g,"/");if(t.startsWith("/")||/^[A-Za-z]:/.test(t)||t.split("/").includes(".."))throw new TypeError("Upload file name must be a safe relative path without parent directory segments");return t}var _d=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function",la=async(e,t,r)=>tT(e.body)?nb(e.body)?q4(e,r):{...e,body:await W4(e.body,t,r)}:e,Zt=async(e,t,r)=>nb(e.body)?q4(e,r):{...e,body:await W4(e.body,t,r)},B4=new WeakMap;function tH(e){let t=typeof e=="function"?e:e.fetch,r=B4.get(t);if(r)return r;let n=(async()=>{try{let i;if("Response"in t)i=t.Response;else{let s=await t("data:,");await s.arrayBuffer(),i=s.constructor}let o=new FormData;return o.toString()!==await new i(o).text()}catch{return!0}})();return B4.set(t,n),n}var W4=async(e,t,r={})=>{if(!await tH(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([i,o])=>nT(n,i,o,r))),n},ob=e=>e instanceof Blob,oT=e=>typeof e=="object"&&e!==null&&"getReader"in e&&typeof e.getReader=="function",lh=e=>typeof e=="object"&&e!==null&&Z4 in e,sb=e=>typeof e=="object"&&e!==null&&(e instanceof Response||_d(e)||oT(e)||lh(e)||ob(e)),nb=e=>{if(lh(e)||_d(e)||oT(e))return!0;if(Array.isArray(e))return e.some(nb);if(e&&typeof e=="object"&&!ob(e)&&!(e instanceof Response)){for(let t of Object.keys(e))if(nb(e[t]))return!0}return!1},tT=e=>{if(sb(e))return!0;if(Array.isArray(e))return e.some(tT);if(e&&typeof e=="object"){for(let t of Object.keys(e))if(tT(e[t]))return!0}return!1},rH=(e,t)=>{let r=[];for(let n of e)sb(n.value)&&!t.has(n.value)&&t.set(n.value,K4(n.value,{stripFilenames:!1})),r.push(n);return r},q4=(e,t={})=>{let r=iH(e.body),n=t.stripFilenames===!1?new WeakMap:void 0,i=n?rH(r,n):r,o=`openai-${Math.random().toString(36).slice(2)}`,s=Ym(nH(i,o,t,n));return{...e,body:s,headers:L([{"content-type":`multipart/form-data; boundary=${o}`},e.headers])}};async function*nH(e,t,r,n){for await(let{key:i,value:o}of e){if(sb(o)){let s=n?.get(o)??K4(o,r),a=oH(o);yield pr(`--${t}\r
|
|
308
|
-
`),yield pr(`Content-Disposition: form-data; name="${eT(i)}"; filename="${eT(s)}"\r
|
|
309
|
-
Content-Type: ${a}\r
|
|
310
|
-
\r
|
|
311
|
-
`),yield*uh(sH(o))}else yield pr(`--${t}\r
|
|
312
|
-
`),yield pr(`Content-Disposition: form-data; name="${eT(i)}"\r
|
|
313
|
-
\r
|
|
314
|
-
${String(o)}`);yield pr(`\r
|
|
315
|
-
`)}yield pr(`--${t}--\r
|
|
316
|
-
`)}function*iH(e){if(!(!e||typeof e!="object"))for(let[t,r]of Object.entries(e))yield*rT(t,r)}function*rT(e,t){if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||sb(t))yield{key:e,value:t};else if(Array.isArray(t))for(let r of t)yield*rT(e+"[]",r);else if(typeof t=="object")for(let[r,n]of Object.entries(t))yield*rT(`${e}[${r}]`,n);else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}}function K4(e,t){if(lh(e)){let{name:r}=e;if(typeof r!="string"||!r)throw new TypeError("Streaming upload file name must be a non-empty string");return t.stripFilenames===!1?V4(r):ch(r)??"unknown_file"}return Jc(e,{stripFilename:t.stripFilenames})??"unknown_file"}function oH(e){let t;return lh(e)||ob(e)?{type:t}=e:e instanceof Response&&(t=e.headers.get("content-type")??void 0),G4(t||"application/octet-stream")}function G4(e){if(typeof e!="string")throw new TypeError("Streaming upload content type must be a string");for(let t=0;t<e.length;t+=1){let r=e.codePointAt(t)??0;if(r<=31||r===127)throw new TypeError("Streaming upload content type must not contain control characters")}return e}function sH(e){return lh(e)?e.data:e}async function*uh(e){if(typeof e=="string")yield pr(e);else if(ArrayBuffer.isView(e))yield new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof ArrayBuffer)yield new Uint8Array(e);else if(e instanceof Response)yield*uh(e.body||await e.blob());else if(e instanceof Blob)typeof e.stream=="function"?yield*uh(e.stream()):yield new Uint8Array(await e.arrayBuffer());else if(oT(e))for await(let t of Wv(e))yield*uh(t);else if(_d(e))for await(let t of e)yield*uh(t);else throw new TypeError(`Invalid streaming file chunk: ${String(e)}`)}function eT(e){return Array.from(e,t=>{let r=t.codePointAt(0)??0;return r<=31||r===127||t==='"'||t==="\\"?encodeURIComponent(t):t}).join("")}var nT=async(e,t,r,n)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")e.append(t,String(r));else if(r instanceof Response){let i=await r.blob();e.append(t,Jo([i],Jc(r,{stripFilename:n.stripFilenames}),{type:i.type}))}else if(_d(r))e.append(t,Jo([await new Response(Ym(r)).blob()],Jc(r,{stripFilename:n.stripFilenames})));else if(ob(r)){let i=Jc(r,{stripFilename:n.stripFilenames});i===void 0?e.append(t,r):e.append(t,r,i)}else if(Array.isArray(r)){let i=await Promise.all(r.map(async o=>{let s=new FormData;return await nT(s,t+"[]",o,n),s}));for(let o of i)if(o)for(let[s,a]of o.entries())e.append(s,a)}else if(typeof r=="object")await Promise.all(Object.entries(r).map(([i,o])=>nT(e,`${t}[${i}]`,o,n)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var H4=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",aH=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&H4(e),cH=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function",uH=(e,t)=>t?.type!=null&&t.type!==e.type||t?.lastModified!=null&&t.lastModified!==e.lastModified||t?.endings!=null,lH=(e,t,r)=>(t==null||t===e.name)&&!uH(e,r);async function dh(e,t,r){if(iT(),e=await e,aH(e)){let i={...r,type:r?.type??e.type,lastModified:r?.lastModified??e.lastModified};return e instanceof File?lH(e,t,r)?e:Jo([e],t??e.name,i):Jo([await e.arrayBuffer()],t??e.name,i)}if(cH(e)){let i=await e.blob();t||(t=Jc(e));let o=r?.type===void 0&&i.type?{...r,type:i.type}:r;return Jo(await sT(i),t,o)}let n=await sT(e);if(t||(t=Jc(e)),r?.type===void 0){let i=n.find(o=>typeof o=="object"&&"type"in o&&!!o.type);i&&(r={...r,type:i.type})}return Jo(n,t,r)}async function sT(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(H4(e))t.push(e instanceof Blob?e:new Blob([await e.arrayBuffer()],{type:e.type}));else if(_d(e))for await(let r of e)t.push(...await sT(r));else{let r=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${dH(e)}`)}return t}function dH(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(r=>`"${r}"`).join(", ")}]`}var O=class{constructor(t){this._client=t}};function X4(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var J4=Object.freeze(Object.create(null)),fH=(e=X4)=>function(r,...n){if(r.length===1)return r[0];let i=!1,o=[],s="";for(let l=0;l<r.length;l+=1)if(l in r){let d=r[l];/[?#]/.test(d)&&(i=!0);let p=n[l],f=(i?encodeURIComponent:e)(""+p);l!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??J4)??J4)?.toString)&&(f=p+"",o.push({start:s.length+d.length,length:f.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),s+=d+(l===n.length?"":f)}let a=s.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(a))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((l,d)=>l.start-d.start),o.length>0){let l=0,d="";for(let p of o){let f=" ".repeat(p.start-l),m="^".repeat(p.length);l=p.start+p.length,d+=f+m}throw new A(`Path parameters result in path with invalid segments:
|
|
317
|
-
${o.map(p=>p.error).join(`
|
|
318
|
-
`)}
|
|
319
|
-
${s}
|
|
320
|
-
${d}`)}return s},S=fH(X4);var Xc=class extends O{list(t,r={},n){return this._client.getAPIList(S`/chat/completions/${t}/messages`,ve,{query:r,...n,__security:{bearerAuth:!0}})}};function co(e){return e!==void 0&&"function"in e&&e.function!==void 0}function Y4(e,t){let r={...e,type:"json_schema"};return r.json_schema={...r.json_schema},delete r.toJSON,delete r.json_schema.toJSON,Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}function hH(e){return e?.$brand==="auto-parseable-response-format"}function uo(e){return hH(e)||e?.type==="json_schema"}function hi(e,t){if(!uo(e))return null;if(typeof e=="object"&&e!==null&&"$parseRaw"in e&&typeof e.$parseRaw=="function")return e.$parseRaw(t);try{return JSON.parse(t)}catch(r){throw r instanceof SyntaxError?new SyntaxError("Error reading response: invalid structured output JSON."):r}}function gi(e){return e?.$brand==="auto-parseable-tool"}function Q4(e,t){return!t||!cT(t)?{...e,choices:e.choices.map(r=>({...r,message:{...r.message,parsed:null,...r.message.tool_calls?{tool_calls:r.message.tool_calls}:void 0}}))}:ph(e,t)}function ph(e,t){let r=e.choices.map(n=>{if(n.finish_reason==="length")throw new aa;if(n.finish_reason==="content_filter")throw new ca;return{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:n.message.tool_calls?.map(i=>yH(t,i))??void 0}:void 0,parsed:n.message.content!==null&&n.message.content!==void 0&&!n.message.refusal&&(n.message.content!==""||!n.message.tool_calls?.length&&!n.message.function_call)?gH(t,n.message.content):null}}});return{...e,choices:r}}function gH(e,t){return hi(e.response_format,t)}function yH(e,t){if(t.type==="custom")return t;if(t.type!=="function"){let i=t.type;throw new A(`Currently only \`function\` and \`custom\` tool calls are supported; Received \`${i}\``)}let r=e.tools?.find(i=>co(i)&&i.function?.name===t.function.name),n=null;return gi(r)?n=r.$parseRaw(t.function.arguments):r?.function.strict&&(n=hi({type:"json_schema",$parseRaw:void 0},t.function.arguments)),{...t,function:{...t.function,parsed_arguments:n}}}function ab(e,t){if(!e||!("tools"in e)||!e.tools||t.type!=="function")return!1;let r=e.tools?.find(n=>co(n)&&n.function?.name===t.function?.name);return co(r)&&(gi(r)||r?.function.strict||!1)}function cT(e){return uo(e.response_format)?!0:e.tools?.some(t=>gi(t)||t.type==="function"&&t.function.strict===!0)??!1}function eL(e){for(let t of e??[])if(t.type!=="custom"){if(t.type!=="function"){let r=t.type;throw new A(`Currently only \`function\` and \`custom\` tool types are supported; Received \`${r}\``)}if(t.function.strict!==!0)throw new A(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var Xo=e=>e?.role==="assistant",fh=e=>e?.role==="tool";var yi,lb,db,hh,gh,pb,yh,Ln,mb,bh,_h,vd,da,Yc,hb,gb,bd,aL,mT,cL,hT,fb,tL=4096,vh=8*1024*1024,_H=4096,wh=256,vH=JSON.stringify,bH=JSON.parse,uT=new WeakSet,wH=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),"buffer")?.get,xH=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),"length")?.get,kH=Object.getOwnPropertyDescriptor(DataView.prototype,"buffer")?.get,rL=Object.getOwnPropertyDescriptor(Symbol.prototype,"description")?.get,IH=Date.prototype.getTime,SH=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength")?.get,AH=typeof SharedArrayBuffer=="function"?Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,"byteLength")?.get:void 0,mh=Object.getOwnPropertyDescriptor(new Error("native stack descriptor"),"stack"),lo=Function.prototype.toString,OH=Object.prototype.toString,cb=Object.getOwnPropertyDescriptor(Error,"isError"),nL=cb&&"value"in cb&&typeof cb.value=="function"?cb.value:void 0,$H=lo.call(Error),TH=lo.call(Date),EH=lo.call(Function),yb=new Set([Nn.prototype,Tt.prototype,pt.prototype,A.prototype,De.prototype,ea.prototype,Qs.prototype,na.prototype,ca.prototype,sa.prototype,Xr.prototype,aa.prototype,ra.prototype,Mn.prototype,ta.prototype,oa.prototype,Bc.prototype,ia.prototype]),uL=new Set,lL=new Map,iL=new WeakMap;function PH(){if(!(typeof process>"u"))try{let e=Object.getOwnPropertyDescriptor(process,"getBuiltinModule");if(!e||!("value"in e)||typeof e.value!="function")return;let t=Reflect.apply(e.value,process,["node:util"]);if(typeof t!="object"||t===null)return;let r=Object.getOwnPropertyDescriptor(t,"types");if(!r||!("value"in r)||typeof r.value!="object"||r.value===null)return;let n=Object.getOwnPropertyDescriptor(r.value,"isProxy");return!n||!("value"in n)||typeof n.value!="function"?void 0:n.value}catch{return}}var CH=PH();function _b(e){if(typeof e!="function")return;let t=Object.getOwnPropertyDescriptor(e,"prototype");if(!t||!("value"in t)||typeof t.value!="object"&&typeof t.value!="function")return;yb.add(t.value);let r=lo.call(e);if(/^function [A-Za-z_$][\w$]*\(\) \{ \[native code\] \}$/u.test(r)&&t.configurable===!1&&t.writable===!1){uL.add(r);let n=new Map;for(let i of Reflect.ownKeys(t.value)){let o=Object.getOwnPropertyDescriptor(t.value,i);o&&n.set(i,o)}lL.set(r,n)}}for(let e of[Object,Function,Array,Date,Map,Set,ArrayBuffer,DataView,Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array])_b(e);for(let e of["SharedArrayBuffer","AggregateError","Float16Array","BigInt64Array","BigUint64Array","Blob","File","Headers"]){let t=Object.getOwnPropertyDescriptor(globalThis,e);t&&"value"in t&&_b(t.value)}var lT=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),"constructor");lT&&"value"in lT&&_b(lT.value);typeof Buffer=="function"&&_b(Buffer);var RH=(()=>{if(typeof Blob=="function")try{let e=new Blob([]);for(let t of Object.getOwnPropertySymbols(e)){let r=Object.getOwnPropertyDescriptor(e,t);if(r&&"value"in r&&typeof r.value=="object"&&r.value)return Object.getPrototypeOf(r.value)}}catch{return}})(),NH=Map.prototype.entries,MH=Set.prototype.values,ub=typeof Headers=="function"?Object.getOwnPropertyDescriptor(Headers.prototype,"entries"):void 0,oL=ub&&"value"in ub&&typeof ub.value=="function"?ub.value:void 0,zH=new Set(["ArrayBuffer","SharedArrayBuffer","Blob","File","Map","Date","Set","Headers"]);function vb(e){let t=Object.getOwnPropertyDescriptor(e,"constructor");if(!t||!("value"in t)||typeof t.value!="function")return;let r=t.value,n=lo.call(r),i=lL.get(n);if(!uL.has(n)||!i)return;let o=Object.getOwnPropertyDescriptor(r,"prototype");if(!(!o||!("value"in o)||o.value!==e||o.configurable!==!1||o.writable!==!1))return{constructor:r,descriptors:i,functionPrototype:Object.getPrototypeOf(r)}}function jH(e){return yb.has(e)||vb(e)!==void 0}function dT(e,t,r){if(t===void 0)return e===void 0;if(typeof e!="function"||typeof t!="function")return!1;let n=lo.call(t);if(lo.call(e)!==n)return!1;let i=Object.getPrototypeOf(e);if(i===r)return!0;if(!/^function [A-Za-z_$][\w$]*\(\) \{ \[native code\] \}$/u.test(n))return!1;let o=vb(i);return o!==void 0&&lo.call(o.constructor)===EH}function DH(e,t,r){return!t||e.configurable!==t.configurable||e.enumerable!==t.enumerable||"value"in e!="value"in t?!1:"value"in e&&"value"in t?e.writable!==t.writable?!1:typeof t.value=="function"?dT(e.value,t.value,r):t.value!==null&&typeof t.value=="object"?!1:Object.is(e.value,t.value):dT(e.get,t.get,r)&&dT(e.set,t.set,r)}function sL(e){if(nL)return nL.call(Error,e);let t=e;for(let r=0;t!==null&&r<wh;r+=1){if(Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))return!1;t=Object.getPrototypeOf(t)}return t===null&&OH.call(e)==="[object Error]"}function UH(e,t){if(typeof t.get!="function"||typeof t.set!="function")return;let r=Object.getPrototypeOf(e);for(let n=0;r!==null&&n<wh;n+=1){let i=Object.getOwnPropertyDescriptor(r,"constructor");if(i&&"value"in i&&typeof i.value=="function"){let o=i.value;if(lo.call(o)===$H&&jH(r)){let s=Object.getPrototypeOf(o);return Object.getPrototypeOf(t.get)===s&&Object.getPrototypeOf(t.set)===s?{constructor:o,prototype:r}:void 0}}r=Object.getPrototypeOf(r)}}function LH(e,t){if(!sL(e))return!1;if(mh&&!("value"in mh)&&typeof mh.get=="function"&&Object.prototype.isPrototypeOf.call(Error.prototype,e)&&t.get===mh.get&&t.set===mh.set)return!0;let r=UH(e,t);if(!r)return!1;let n=iL.get(r.prototype);if(!n){let i=Reflect.construct(r.constructor,[]);if(typeof i!="object"||i===null||!sL(i)||Object.getPrototypeOf(i)!==r.prototype||(n=Object.getOwnPropertyDescriptor(i,"stack"),!n||"value"in n||typeof n.get!="function"||typeof n.set!="function"))return!1;iL.set(r.prototype,n)}return t.get===n.get&&t.set===n.set}function pT(){let e=[],t=0;return{get length(){return e.length-t},enqueue(r){e.push(r)},dequeue(){if(t===e.length)return;let r=e[t];return e[t]=void 0,t+=1,t===e.length?(e=[],t=0):t>=1024&&t*2>=e.length&&(e=e.slice(t),t=0),r},clear(){e=[],t=0}}}function FH(e){let t=Object.getPrototypeOf(e);for(let r=0;t!==null&&r<wh;r+=1){if(t===Date.prototype)return"Date";if(!yb.has(t)){let i=Object.getOwnPropertyDescriptor(t,"constructor");if(i&&"value"in i&&typeof i.value=="function"&&lo.call(i.value)===TH&&vb(t))return"Date"}let n=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);if(n&&"value"in n&&typeof n.value=="string"&&zH.has(n.value))return n.value;t=Object.getPrototypeOf(t)}}function BH(e,t,r){if(ArrayBuffer.isView(e)){let a,c="typed-array";try{a=wH?.call(e)}catch{c="data-view",a=kH?.call(e)}return typeof a!="object"||a===null?{bytes:Number.POSITIVE_INFINITY,kind:c}:(t(a,r+1),{bytes:0,kind:c})}let n=FH(e);if(!n)return;let i,o="buffer";switch(n){case"ArrayBuffer":{i=SH;break}case"SharedArrayBuffer":{i=AH;break}case"Blob":case"File":return{bytes:Number.POSITIVE_INFINITY,kind:"blob"};case"Map":return{bytes:0,kind:"map"};case"Date":return Reflect.apply(IH,e,[]),{bytes:8,kind:"date"};case"Set":return{bytes:0,kind:"set"};case"Headers":return{bytes:0,kind:"headers"};default:return}let s=i?.call(e);return{bytes:typeof s=="number"&&Number.isSafeInteger(s)&&s>=0?s:Number.POSITIVE_INFINITY,kind:o}}function ZH(e,t,r){if(t==="map"){for(let[n,i]of NH.call(e))if(!r(n,8)||!r(i,8))return!1}if(t==="set"){for(let n of MH.call(e))if(!r(n,8))return!1}if(t==="headers"){if(!oL)return!1;for(let[n,i]of oL.call(e))if(!r(n,8)||!r(i,8))return!1}return!0}function VH(e,t,r){if(Array.isArray(e)){let i=Object.getOwnPropertyDescriptor(e,"length"),o=i&&"value"in i?i.value:void 0;if(typeof o!="number"||!Number.isSafeInteger(o)||o<0||o>Math.floor(r/16))return}if(t!=="typed-array")return Reflect.ownKeys(e);let n=xH?.call(e);if(!(typeof n!="number"||!Number.isSafeInteger(n)||n<0||n>_H))return Reflect.ownKeys(e).filter(i=>{if(typeof i!="string")return!0;let o=Number(i);return!Number.isInteger(o)||o<0||o>=n||String(o)!==i})}function dL(e,t,r,n,i,o){let s=VH(e,t,n());if(s===void 0)return!1;for(let a of s){if(!i(typeof a=="string"?a.length*2+8:8))return!1;typeof a=="symbol"&&o(a,r+1);let c=Object.getOwnPropertyDescriptor(e,a);if(!c)return!1;if(!("value"in c)){if(a==="stack"&&LH(e,c))continue;return!1}o(c.value,r+1,t==="blob")}return!0}function WH(e,t,r,n,i,o,s,a){let c=Object.getPrototypeOf(e);for(let u=t+1;c!==null;u+=1){if(u>=wh)return!1;if(yb.has(c)||r&&c===RH)return!0;if(n.has(c))return s(c,u),i()>=0;n.add(c);let l=c;if(!a(l,()=>{if(!o(16))return!1;let p=vb(l);if(!p)return dL(l,void 0,u,i,o,s);for(let f of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,f);if(!m)return!1;if(!DH(m,p.descriptors.get(f),p.functionPrototype)){if(!o(typeof f=="string"?f.length*2+8:8)||!("value"in m))return!1;typeof f=="symbol"&&s(f,u+1),s(m.value,u+1)}}return i()>=0}))return!1;c=Object.getPrototypeOf(l)}return!0}var qH=32,KH=32,pL=8,fL=16,GH=128*1024;function fT(e,t){let r=0,n=0,i=new WeakSet,o=new Set,s=new Set,a=new Map,c,u=()=>t-r,l=h=>!Number.isSafeInteger(h)||h<0?(r=t+1,!1):(r+=h,c?c.bytes+=h:n+=h,r<=t),d=h=>{c?c.edges.add(h):s.add(h)},p=(h,y)=>{d(h);let w={bytes:0,edges:new Set};a.set(h,w);let _=c;c=w;try{return y()}finally{c=_}},f=h=>{if(o.has(h)){d(h),l(8);return}o.add(h),p(h,()=>{if(!rL)return!1;let y=Reflect.apply(rL,h,[]);return l(8+(y?.length??0)*2)})||(r=t+1)},m=(h,y,w=!1)=>{if(!(r>t)){if(typeof h=="string"){l(h.length*2);return}if(typeof h=="symbol"){f(h);return}if(typeof h=="function"){r=t+1;return}if(h===null||typeof h!="object"){l(8);return}if(CH?.(h)){r=t+1;return}if(y>=wh){r=t+1;return}if(i.has(h)){d(h),l(8);return}i.add(h),p(h,()=>{if(!l(16))return!1;let _=BH(h,m,y);return!WH(h,y,w,i,u,l,m,p)||_!==void 0&&!l(_.bytes)||!ZH(h,_?.kind,(b,I)=>l(I)?(m(b,y+1),r<=t):!1)?!1:dL(h,_?.kind,y,u,l,m)})||(r=t+1)}};try{m(e,0)}catch{return}return r<=t?{scalarBytes:n,roots:s,nodes:a}:void 0}function HH(e,t){if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}function gT(e,t){return e.bytes+KH+e.edges.size*pL+t*fL}function yT(e){return qH+e.scalarBytes+e.roots.size*pL}function JH(e,t,r,n){let i=new Set,o=[...e];for(;o.length;){if(n.remaining-=1,n.remaining<0)return;let s=o.pop();if(i.has(s))continue;let a=t.get(s)??r.get(s);if(!a)return;i.add(s);for(let c of a.edges)o.push(c)}return i}function _T(e,t,r,n,i){let o=n.get(e);if(o)return i&&(o.node=i),o;let s=i??t.nodes.get(e)??r.get(e);if(!s)return;let a={node:s,ownerDelta:0};return n.set(e,a),a}function XH(e,t,r,n,i){let o=new Set([e]);for(let[s,a]of t.nodes){if(i.remaining-=1,i.remaining<0)return;let c=r.get(s);if(!c)continue;let u=!HH(c.edges,a.edges);if((c.bytes!==a.bytes||u)&&_T(s,t,r,n,a),!!u)for(let l of c.owners){if(i.remaining-=1,i.remaining<0)return;o.add(l)}}return o}function YH(e,t,r,n,i,o){for(let s of e.identities){if(o.remaining-=1,o.remaining<0)return!1;if(!t.has(s)){let a=_T(s,r,n,i);if(!a)return!1;a.ownerDelta-=1}}for(let s of t){if(o.remaining-=1,o.remaining<0)return!1;if(!e.identities.has(s)){let a=_T(s,r,n,i);if(!a)return!1;a.ownerDelta+=1}}return!0}function QH(e,t,r,n,i,o){let s=new Map;for(let a of r){let c=a===e?t.roots:a.roots,u=JH(c,t.nodes,n,o);if(!u||!YH(a,u,t,n,i,o))return;s.set(a,u)}return s}function eJ(e,t,r,n,i,o){let s=e-(n?0:yT(t))+yT(r);for(let[a,c]of i){let u=o.get(a),l=(u?.owners.size??0)+c.ownerDelta;if(l<0)return;u&&(s-=gT(u,u.owners.size)),l&&(s+=gT(c.node,l))}return Number.isSafeInteger(s)&&s>=0&&s<=vh?s:void 0}function tJ(e,t,r){for(let[n,i]of t){let o=e.get(n);(o?.owners.size??0)+i.ownerDelta&&(o?(o.bytes=i.node.bytes,o.edges=i.node.edges):e.set(n,{bytes:i.node.bytes,edges:i.node.edges,owners:new Set}))}for(let[n,i]of r){for(let o of n.identities)i.has(o)||e.get(o)?.owners.delete(n);for(let o of i)n.identities.has(o)||e.get(o).owners.add(n);n.identities=i}for(let n of t.keys())e.get(n)?.owners.size===0&&e.delete(n)}function rJ(){let e=new Map,t=0,r=(i,o,s)=>{let a={remaining:GH},c=new Map,u=XH(i,o,e,c,a);if(!u)return!1;let l=QH(i,o,u,e,c,a);if(!l)return!1;let d=eJ(t,i,o,s,c,e);return d===void 0?!1:(tJ(e,c,l),i.scalarBytes=o.scalarBytes,i.roots=o.roots,t=d,!0)};return{retain(i){let o={scalarBytes:0,roots:new Set,identities:new Set};return r(o,i,!0)?o:void 0},refresh(i,o){return r(i,o,!1)},release:i=>{t-=yT(i);for(let o of i.identities){let s=e.get(o);s?.owners.delete(i)&&(t-=fL,s.owners.size===0&&(t-=gT(s,0),e.delete(o)))}i.identities.clear()},clear(){e.clear(),t=0}}}var pa=class{constructor(){yi.add(this),this.controller=new AbortController,lb.set(this,void 0),db.set(this,()=>{}),hh.set(this,()=>{}),gh.set(this,void 0),pb.set(this,()=>{}),yh.set(this,()=>{}),Ln.set(this,Object.create(null)),mb.set(this,[]),bh.set(this,new WeakMap),_h.set(this,new Set),vd.set(this,new Set),da.set(this,0),Yc.set(this,!1),hb.set(this,!1),gb.set(this,!1),bd.set(this,!1),j(this,lb,new Promise((t,r)=>{j(this,db,t,"f"),j(this,hh,r,"f")}),"f"),j(this,gh,new Promise((t,r)=>{j(this,pb,t,"f"),j(this,yh,r,"f")}),"f"),g(this,lb,"f").catch(()=>{}),g(this,gh,"f").catch(()=>{})}_run(t){setTimeout(()=>{let r=!1;Promise.resolve().then(t).catch(n=>{r=!0,g(this,yi,"m",fb).call(this,n)}).then(()=>{if(!r){try{this._emitFinal()}catch(n){g(this,yi,"m",fb).call(this,n);return}this._emit("end")}})},0)}_connected(){this.ended||(g(this,db,"f").call(this),this._emit("connect"))}get ended(){return g(this,Yc,"f")}get errored(){return g(this,hb,"f")}get aborted(){return g(this,gb,"f")}abort(){this.controller.abort()}_listenForAbort(t){if(!t||this.ended)return;if(t.aborted){this.controller.abort();return}let r=()=>this.controller.abort();t.addEventListener("abort",r,{once:!0}),g(this,mb,"f").push({signal:t,listener:r})}on(t,r){var n;return((n=g(this,Ln,"f"))[t]||(n[t]=[])).push({listener:r}),this}off(t,r){let n=g(this,Ln,"f")[t];if(!n)return this;let i=g(this,bh,"f").get(r);if(i?.event===t&&!i.registration.removed&&!i.registration.detached)return g(this,yi,"m",cL).call(this,t,i.registration),this;let o=n.findIndex(s=>!s.removed&&s.listener===r);return o!==-1&&n.splice(o,1),this}once(t,r){var n;return((n=g(this,Ln,"f"))[t]||(n[t]=[])).push({listener:r,once:!0}),this}emitted(t){return new Promise((r,n)=>{j(this,bd,!0,"f");let i=s=>{this.off(t,o),n(s)},o=(...s)=>{t!=="error"&&this.off("error",i),r(s.length>1?s:s[0])};t!=="error"&&g(this,yi,"m",mT).call(this,"error",i),g(this,yi,"m",mT).call(this,t,o)})}events(t){return this._createIterator(r=>{let n=(...i)=>{uT.add(i);try{r(i)}finally{uT.delete(i)}};return this.on(t,n),()=>this.off(t,n)},{rejectOnError:t!=="error",rejectOnAbort:t!=="abort"})}_createIterator(t,{rejectOnError:r=!0,rejectOnAbort:n=!0,onReturn:i}={}){let o=pT(),s=pT(),a=pT(),c=rJ(),u=this.ended,l,d=!1,p=()=>{},f=()=>({value:void 0,done:!0}),m=()=>{for(;a.length;)a.dequeue().resolve(f())},h=()=>{!l||d||!a.length||(d=!0,a.dequeue().reject(l))},y=()=>{p(),this.off("end",P),r&&this.off("error",$),n&&this.off("abort",$)},w=C=>{C.active=!1,C.check&&(g(this,vd,"f").delete(C.check),C.check=void 0)},_=(C=!1)=>{if(C){for(;s.length;)w(s.dequeue());o.clear(),c.clear()}let x=new A(`Event stream iterator buffer limit exceeded (${tL} events or ${vh} bytes); consume events as they arrive.`);try{g(this,yi,"m",fb).call(this,x)}finally{this.controller.abort()}return x},b=(C,x)=>{if(!x.active||g(this,Yc,"f"))return;let D=fT(C,vh);(!D||!c.refresh(x.retention,D))&&_(!0)},I=C=>{if(u)return;let x=a.dequeue();if(x)x.resolve({value:C,done:!1});else{if(o.length>=tL){_();return}let D=fT(C,vh),M=D&&c.retain(D);if(!M){_();return}if(typeof C=="object"&&C!==null&&uT.has(C)){let K=C;for(let re=0;re<K.length;re+=1){let We=K[re];typeof We=="string"&&(K[re]=bH(vH(We)))}}let R={retention:M,active:!0,check:void 0};o.enqueue(C),s.enqueue(R);let B=()=>{R.check=void 0,b(C,R)};R.check=B,g(this,vd,"f").add(B)}},$=C=>{l=C,o.length||h()},P=()=>{u=!0,y(),o.length||(h(),m())};return u||(p=t(I),this.on("end",P),r&&this.on("error",$),n&&this.on("abort",$)),{next:()=>{if(o.length){let C=o.dequeue(),x=s.dequeue();w(x);let D=fT(C,vh);if(!D||!c.refresh(x.retention,D)){let M=_(!0);return d=!0,Promise.reject(M)}return c.release(x.retention),Promise.resolve({value:C,done:!1})}return l&&!d?(d=!0,Promise.reject(l)):u?Promise.resolve(f()):new Promise((C,x)=>{a.enqueue({resolve:C,reject:x})})},return:()=>{for(u=!0;s.length;)w(s.dequeue());return o.clear(),c.clear(),y(),m(),i&&(this.done().catch(()=>{}),i()),Promise.resolve(f())},[Symbol.asyncIterator](){return this}}}async done(){j(this,bd,!0,"f"),await g(this,gh,"f")}_hasListeners(t){return!!g(this,Ln,"f")[t]?.some(r=>!r.removed)}_emit(t,...r){if(g(this,Yc,"f"))return;t==="end"&&(g(this,yi,"m",aL).call(this),j(this,Yc,!0,"f"),g(this,pb,"f").call(this));let n=g(this,Ln,"f")[t];if(n){g(this,Ln,"f")[t]=n.filter(i=>(i.once&&(i.detached=!0),!i.once&&!i.removed)),j(this,da,g(this,da,"f")+1,"f");try{for(let i of n)i.removed||i.listener(...r)}finally{if(j(this,da,g(this,da,"f")-1,"f"),g(this,da,"f")===0){g(this,yi,"m",hT).call(this);for(let i of g(this,vd,"f"))g(this,vd,"f").delete(i),g(this,Yc,"f")||i()}}}if(t==="abort"){let i=r[0];!g(this,bd,"f")&&!n?.length&&Promise.reject(i),g(this,hh,"f").call(this,i),g(this,yh,"f").call(this,i),this._emit("end");return}if(t==="error"){let i=r[0];!g(this,bd,"f")&&!n?.length&&Promise.reject(i),g(this,hh,"f").call(this,i),g(this,yh,"f").call(this,i),this._emit("end")}}_emitFinal(){}};lb=new WeakMap,db=new WeakMap,hh=new WeakMap,gh=new WeakMap,pb=new WeakMap,yh=new WeakMap,Ln=new WeakMap,mb=new WeakMap,bh=new WeakMap,_h=new WeakMap,vd=new WeakMap,da=new WeakMap,Yc=new WeakMap,hb=new WeakMap,gb=new WeakMap,bd=new WeakMap,yi=new WeakSet,aL=function(){for(let{signal:t,listener:r}of g(this,mb,"f").splice(0))t.removeEventListener("abort",r)},mT=function(t,r){let n=g(this,Ln,"f")[t],i=n?.length??0;this.once(t,r);let o=g(this,Ln,"f")[t],[s]=o?.slice(-1)??[];(n===void 0||o===n)&&o?.length===i+1&&s?.listener===r&&s.once&&g(this,bh,"f").set(r,{event:t,registration:s})},cL=function(t,r){r.removed||(r.removed=!0,g(this,bh,"f").delete(r.listener),g(this,_h,"f").add(t),g(this,da,"f")===0&&g(this,yi,"m",hT).call(this))},hT=function(){for(let t of g(this,_h,"f")){let r=t,n=g(this,Ln,"f")[r];n&&(g(this,Ln,"f")[r]=n.filter(i=>!i.removed))}g(this,_h,"f").clear()},fb=function(t){if(j(this,hb,!0,"f"),t instanceof Error&&t.name==="AbortError"&&(t=new De),t instanceof De)return j(this,gb,!0,"f"),this._emit("abort",t);if(t instanceof A)return this._emit("error",t);if(t instanceof Error){let r=new A(t.message);return r.cause=t,this._emit("error",r)}return this._emit("error",new A(String(t)))};function mL(e){return typeof e.parse=="function"}var hn,Qc,bb,vT,wb,bT,wT,xT,hL,gL,nJ=10;function iJ(e){for(let t of e.choices)for(let r of t.message.tool_calls??[])r.id||(r.id=`call_${Ys()}`)}function oJ(e){if(!Xo(e))return e;let t={role:"assistant"};return e.audio!=null&&(t.audio={id:e.audio.id}),e.content!==void 0&&(t.content=e.content),e.function_call!=null&&(t.function_call=e.function_call),e.name!==void 0&&(t.name=e.name),e.refusal!=null&&(t.refusal=e.refusal),e.tool_calls!==void 0&&(t.tool_calls=e.tool_calls.map(r=>r.type==="custom"?{id:r.id,type:r.type,custom:{input:r.custom.input,name:r.custom.name}}:{id:r.id,type:r.type,function:{arguments:r.function.arguments,name:r.function.name}})),t}var eu=class extends pa{constructor(){super(...arguments),hn.add(this),this._chatCompletions=[],bb.set(this,!1),this.messages=[]}_addChatCompletion(t){j(this,bb,!this.controller.signal.aborted,"f"),iJ(t),this._chatCompletions.push(t),this._emit("chatCompletion",t);let r=t.choices[0]?.message;return r&&this._addMessage(r),t}_addMessage(t,r=!0){if("content"in t||(t.content=null),this.messages.push(t),r){if(this._emit("message",t),fh(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(Xo(t)&&t.tool_calls)for(let n of t.tool_calls)n.type==="function"&&this._emit("functionToolCall",n.function)}}async finalChatCompletion(){await this.done();let t=this._chatCompletions[this._chatCompletions.length-1];if(!t)throw new A("stream ended without producing a ChatCompletion");return t}async finalContent(){return await this.done(),g(this,hn,"m",vT).call(this)}async finalMessage(){return await this.done(),g(this,hn,"m",wb).call(this)}async finalFunctionToolCall(){return await this.done(),g(this,hn,"m",bT).call(this)}async finalFunctionToolCallResult(){return await this.done(),g(this,hn,"m",wT).call(this)}async totalUsage(){return await this.done(),g(this,hn,"m",xT).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let t=this._chatCompletions[this._chatCompletions.length-1];t&&this._emit("finalChatCompletion",t);let r=g(this,hn,"m",wb).call(this);r&&this._emit("finalMessage",r);let n=g(this,hn,"m",vT).call(this);n&&this._emit("finalContent",n);let i=g(this,hn,"m",bT).call(this);i&&this._emit("finalFunctionToolCall",i);let o=g(this,hn,"m",wT).call(this);o!=null&&this._emit("finalFunctionToolCallResult",o),this._chatCompletions.some(s=>s.usage)&&this._emit("totalUsage",g(this,hn,"m",xT).call(this))}async _createChatCompletion(t,r,n){this._listenForAbort(n?.signal),g(Qc,Qc,"m",hL).call(Qc,r);let i=await t.chat.completions.create({...r,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(ph(i,r))}async _runChatCompletion(t,r,n){for(let i of r.messages)this._addMessage(i,!1);return await this._createChatCompletion(t,r,n)}async _runTools(t,r,n,i){let o="tool",{tool_choice:s="auto",stream:a,toolContext:c,...u}=r,l=c,d=typeof s!="string"&&s.type==="function"&&s?.function?.name,{maxChatCompletions:p=nJ,afterCompletion:f}=i||{},m=r.tools.map(b=>{if(gi(b)){if(!b.$callback)throw new A("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:b.$callback,name:b.function.name,description:b.function.description||"",parameters:b.function.parameters,parse:b.$parseRaw,strict:!0}}}return b}),h=Object.create(null);for(let b of m)b.type==="function"&&(h[b.function.name||b.function.function.name]=b.function);let y="tools"in r?m.map(b=>b.type==="function"?{type:"function",function:{name:b.function.name||b.function.function.name,parameters:b.function.parameters,description:b.function.description,strict:b.function.strict}}:b):void 0;for(let b of r.messages)this._addMessage(b,!1);let w=!1,_=async b=>{let I=w;if(w=!1,b.type!=="function")return{message:void 0,functionCalled:!1};let $=b.id,{name:P,arguments:C}=b.function,x=h[P];if(!x){let R=`Invalid tool_call: ${JSON.stringify(P)}. Available options are: ${Object.keys(h).map(B=>JSON.stringify(B)).join(", ")}. Please try again`;return{message:{role:o,tool_call_id:$,content:R},functionCalled:!1}}if(d&&d!==P){let R=`Invalid tool_call: ${JSON.stringify(P)}. ${JSON.stringify(d)} requested. Please try again`;return{message:{role:o,tool_call_id:$,content:R},functionCalled:!1}}let D;if(mL(x)){let R;try{R=await x.parse(C)}catch(B){if(this.controller.signal.aborted)throw new De;let K=B instanceof Error?B.message:String(B);return{message:{role:o,tool_call_id:$,content:K},functionCalled:!1}}if(this.controller.signal.aborted)throw new De;D=await x.function(R,n,l)}else{if(this.controller.signal.aborted&&!I)throw new De;D=await x.function(C,n,l)}let M=g(Qc,Qc,"m",gL).call(Qc,D);return{message:{role:o,tool_call_id:$,content:M},functionCalled:!0}};for(let b=0;b<p;++b){let I=await this._createChatCompletion(t,{...u,tool_choice:s,tools:y,messages:this.messages.map(oJ)},i);w=this.controller.signal.aborted&&g(this,bb,"f");let $=I.choices[0]?.message;if(!$)throw new A("missing message in ChatCompletion response");if(!$.tool_calls?.length){await f?.(I,n);return}if(d||r.parallel_tool_calls===!1)for(let P of $.tool_calls){let C=await _(P);if(C.message&&this._addMessage(C.message),this.controller.signal.aborted)throw new De;if(d&&C.functionCalled){await f?.(I,n);return}}else{let P=await Promise.allSettled($.tool_calls.map(_));if(!this.controller.signal.aborted){for(let C of P)if(C.status==="rejected")throw C.reason}for(let C of P)C.status==="fulfilled"&&C.value.message&&this._addMessage(C.value.message);if(this.controller.signal.aborted)throw new De}await f?.(I,n)}}};Qc=eu,bb=new WeakMap,hn=new WeakSet,vT=function(){return g(this,hn,"m",wb).call(this).content??null},wb=function(){let t=this.messages.length;for(;t-- >0;){let r=this.messages[t];if(Xo(r))return{...r,content:r.content??null,refusal:r.refusal??null}}throw new A("stream ended without producing a ChatCompletionMessage with role=assistant")},bT=function(){for(let t=this.messages.length-1;t>=0;t--){let r=this.messages[t];if(Xo(r)&&r?.tool_calls?.length)for(let n=r.tool_calls.length-1;n>=0;n--){let i=r.tool_calls[n];if(i?.type==="function")return i.function}}},wT=function(){for(let t=this.messages.length-1;t>=0;t--){let r=this.messages[t];if(fh(r)&&r.content!=null&&typeof r.content=="string"&&this.messages.some(n=>n.role==="assistant"&&n.tool_calls?.some(i=>i.type==="function"&&i.id===r.tool_call_id)))return r.content}},xT=function(){let t={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:r}of this._chatCompletions)r&&(t.completion_tokens+=r.completion_tokens,t.prompt_tokens+=r.prompt_tokens,t.total_tokens+=r.total_tokens);return t},hL=function(t){if(t.n!=null&&t.n>1)throw new A("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},gL=function(t){return typeof t=="string"?t:t===void 0?"undefined":JSON.stringify(t)};var xh=class e extends eu{static runTools(t,r,n){let i=new e,o={...n,__metadata:{...n?.__metadata,helperMethod:"runTools"}};return i._run(()=>i._runTools(t,r,i,o)),i}_addMessage(t,r=!0){super._addMessage(t,r),Xo(t)&&t.content&&this._emit("content",t.content)}};var ar={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},kT=class extends Error{},kh=class extends Error{};function sJ(e,t=ar.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return aJ(e.trim(),t)}var aJ=(e,t)=>{let r=e.length,n=0,i=p=>{throw new kT(`${p} at position ${n}`)},o=p=>{throw new kh(`${p} at position ${n}`)},s=()=>(d(),n>=r&&i("Unexpected end of input"),e[n]==='"'?a():e[n]==="{"?c():e[n]==="["?u():e.substring(n,n+4)==="null"||ar.NULL&t&&r-n<4&&"null".startsWith(e.substring(n))?(n+=4,null):e.substring(n,n+4)==="true"||ar.BOOL&t&&r-n<4&&"true".startsWith(e.substring(n))?(n+=4,!0):e.substring(n,n+5)==="false"||ar.BOOL&t&&r-n<5&&"false".startsWith(e.substring(n))?(n+=5,!1):e.substring(n,n+8)==="Infinity"||ar.INFINITY&t&&r-n<8&&"Infinity".startsWith(e.substring(n))?(n+=8,1/0):e.substring(n,n+9)==="-Infinity"||ar.MINUS_INFINITY&t&&r-n>1&&r-n<9&&"-Infinity".startsWith(e.substring(n))?(n+=9,-1/0):e.substring(n,n+3)==="NaN"||ar.NAN&t&&r-n<3&&"NaN".startsWith(e.substring(n))?(n+=3,Number.NaN):l()),a=()=>{let p=n,f=!1;for(n++;n<r&&(e[n]!=='"'||f&&e[n-1]==="\\");)f=e[n]==="\\"?!f:!1,n++;if(e.charAt(n)==='"')try{return JSON.parse(e.substring(p,++n-Number(f)))}catch(m){o(String(m))}else if(ar.STR&t)try{return JSON.parse(e.substring(p,n-Number(f))+'"')}catch{return JSON.parse(e.substring(p,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{n++,d();let p={};try{for(;e[n]!=="}";){if(d(),n>=r&&ar.OBJ&t)return p;let f=a();d(),n++;try{let m=s();Object.defineProperty(p,f,{value:m,writable:!0,enumerable:!0,configurable:!0})}catch(m){if(ar.OBJ&t)return p;throw m}d(),e[n]===","&&n++}}catch{if(ar.OBJ&t)return p;i("Expected '}' at end of object")}return n++,p},u=()=>{n++;let p=[];try{for(;e[n]!=="]";)p.push(s()),d(),e[n]===","&&n++}catch{if(ar.ARR&t)return p;i("Expected ']' at end of array")}return n++,p},l=()=>{if(n===0){e==="-"&&ar.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e)}catch(f){if(ar.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}o(String(f))}}let p=n;for(e[n]==="-"&&n++;e[n]&&!",]}".includes(e[n]);)n++;n===r&&!(ar.NUM&t)&&i("Unterminated number literal");try{return JSON.parse(e.substring(p,n))}catch{e.substring(p,n)==="-"&&ar.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e.substring(p,e.lastIndexOf("e")))}catch(f){o(String(f))}}},d=()=>{for(;n<r&&`
|
|
321
|
-
\r `.includes(e[n]);)n++};return s()},yL=e=>sJ(e,ar.ALL^ar.NUM);var yt,Vt,fa,tu,Ur,Fn,gn,IT,wd,ST,AT,OT,xd,Ih,_L;function vL(e){try{return yL(e)}catch(t){if(t instanceof kh||t instanceof SyntaxError)return hi({type:"json_schema",$parseRaw:void 0},e);throw t}}var DT="chat.completion.chunk.message:";function SL(e,t,r){let n={type:"message",message:t,...r?{tool_call_ids:r}:{}};return{id:e.id,choices:[],created:e.created,model:e.model,object:`${DT}${JSON.stringify(n)}`}}function cJ(e){return"type"in e&&e.type==="message"&&"message"in e||"object"in e&&typeof e.object=="string"&&e.object.startsWith(DT)}function uJ(e){return"type"in e?e:JSON.parse(e.object.slice(DT.length))}var xb=128,ma=128,lJ=16*1024*1024,dJ=65536,UT=128,AL=64*1024*1024,bL=1024;function NT(){return{bytes:0,depth:0,fragments:0,work:0,escaped:!1,has_non_whitespace:!1,in_string:!1,last_parsed_bytes:0,pending_high_surrogate:!1}}function MT(e,t,r,n){if(t.fragments>=dJ)throw new A("Chat completion stream exceeded its structured JSON fragment limit");let i=0,{depth:o,escaped:s,has_non_whitespace:a,in_string:c}=e,u=!1,l=!0;for(let p of r){let f=i,m=p.codePointAt(0);if(l&&e.pending_high_surrogate&&m>=56320&&m<=57343||m<=127?i+=1:m<=2047?i+=2:m<=65535?i+=3:i+=4,l=!1,t.bytes+i>lJ)throw new A("Chat completion stream exceeded its structured JSON byte limit");if(n&&n.work+i>AL)throw n.work+=f,new A("Chat completion stream exceeded its structured JSON parse-work limit");if(p!==" "&&p!==`
|
|
322
|
-
`&&p!=="\r"&&p!==" "&&(a=!0),c){s?s=!1:p==="\\"?s=!0:p==='"'&&(c=!1,u||(u=o===0));continue}if(p==='"')c=!0;else if(p==="{"||p==="["){if(o+=1,o>UT)throw new A("Chat completion stream exceeded its structured JSON nesting depth limit")}else(p==="}"||p==="]")&&o>0&&(o-=1,u||(u=o===0))}if(e.bytes+=i,e.fragments+=1,e.depth=o,e.escaped=s,e.has_non_whitespace=a,e.in_string=c,r.length>0){let p=r.codePointAt(r.length-1)??0;e.pending_high_surrogate=p>=55296&&p<=56319}if(t.bytes+=i,t.fragments+=1,n&&(n.work+=i),!a||i===0)return!1;let d=Math.max(bL,Math.floor(e.last_parsed_bytes/2));return!(e.bytes>bL&&!u&&e.bytes-e.last_parsed_bytes<d)}function zT(e,t){return t.work+e.bytes>AL?!1:(t.work+=e.bytes,e.work+=e.bytes,e.last_parsed_bytes=e.bytes,!0)}function Bn(e,t){let r=Object.getOwnPropertyDescriptor(e,t);if(!r){let n=Object.getPrototypeOf(e);for(let i=0;n!==null;i+=1){if(i>=UT||Object.getOwnPropertyDescriptor(n,t))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");n=Object.getPrototypeOf(n)}return}if(!("value"in r)||typeof r.value!="string"&&r.value!==null&&r.value!==void 0)throw new A("Chat completion stream contains an unsafe structured JSON snapshot");return r.value}function Sh(e){let t=Object.getOwnPropertyDescriptor(e,"message");if(!t||!("value"in t)||typeof t.value!="object"||t.value===null)throw new A("Chat completion stream contains an unsafe structured JSON snapshot");return t.value}function wL(e,t,r,n){let i=Object.getOwnPropertyDescriptor(e,t);if(!i){let s=Object.getPrototypeOf(e);for(let a=0;s!==null;a+=1){if(a>=UT||Object.getOwnPropertyDescriptor(s,t))throw new A(`Chat completion stream contains an unsafe snapshot ${n} collection`);s=Object.getPrototypeOf(s)}return}if(!("value"in i)||!Array.isArray(i.value))throw new A(`Chat completion stream contains an unsafe snapshot ${n} collection`);let o=Object.getOwnPropertyDescriptor(i.value,"length");if(!o||!("value"in o)||!Number.isSafeInteger(o.value)||o.value>r)throw new A(`Chat completion stream exceeded its snapshot ${n} limit`);return i.value}function $T(e,t){let r=Object.getOwnPropertyDescriptor(e,t);if(r){if(!("value"in r))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");return r.value}}function xL(e,t,r,n){let i=Object.getOwnPropertyDescriptor(e,"length"),o=i&&"value"in i?i.value:void 0;if(typeof o!="number"||!Number.isSafeInteger(o)||o<0||o>t)throw new A(`Chat completion stream exceeded its snapshot ${r} limit`);let s=[];s.length=o;for(let a=0;a<o;a+=1){let c=Object.getOwnPropertyDescriptor(e,a);if(c){if(!("value"in c))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");s[a]=n(c.value,a)}}return s}function ru(e,t,r){let n=NT(),i=t??{bytes:0,fragments:0,work:0};if(MT(n,i,e,r),!zT(n,i))throw new A("Chat completion stream exceeded its structured JSON parse-work limit");return e}function kb(e){let t=Object.getOwnPropertyDescriptor(e,"type"),r=Object.getOwnPropertyDescriptor(e,"function");if(!t||!("value"in t)||t.value!=="function"||!r||!("value"in r)||typeof r.value!="object"||r.value===null)return;let n=Object.getOwnPropertyDescriptor(r.value,"name");if(!(!n||!("value"in n)||typeof n.value!="string"||n.value.length===0))return{type:"function",name:n.value}}function TT(e,t){let r=kb(e);if(!r||r.name!==t.name||r.type!==t.type)throw new A("Chat completion stream contains a changed tool call identity")}function Ah(e,t){return Object.prototype.propertyIsEnumerable.call(t,"__proto__")&&!pe(e,"__proto__")&&Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0}),Object.assign(e,t)}function Oh(e,t=[]){let r=Object.getOwnPropertyDescriptors(e);for(let n of t){let i=r[n];!i&&!(n in e)||(r[n]={value:i&&"value"in i?i.value:Reflect.get(e,n,e),enumerable:i?.enumerable??!1,configurable:i?.configurable??!0,writable:i&&"writable"in i?i.writable:!1})}return Object.create(Object.getPrototypeOf(e),r)}function pJ(e){let t=Oh(e);if(e.tools){let r=[],n=Object.getOwnPropertyDescriptor(e.tools,"length"),i=n&&"value"in n?n.value:void 0,o=typeof i=="number"&&Number.isSafeInteger(i)&&i>=0?Math.min(i,ma):0;for(let s=0;s<o;s+=1){let a=Object.getOwnPropertyDescriptor(e.tools,String(s));if(!a||!("value"in a)){r.length=s+1;continue}let c=a.value,u=Oh(c,["type","$brand","$parseRaw","$callback","function"]),l=Object.getOwnPropertyDescriptors(u);if(co(u)){let d=l.function;l.function={...d&&"value"in d?d:{configurable:!0,enumerable:!0,writable:!0},value:Oh(u.function,["name","strict"])}}r[s]=Object.create(Object.getPrototypeOf(c),l)}t.tools=r}return e.response_format&&(t.response_format=Oh(e.response_format,["type","$brand","$parseRaw"])),t}var ET=4096,PT=JSON.stringify,fJ=1024*1024,mJ=64,CT=Symbol("omitted serialized parser value"),cr=Symbol("unsafe serialized parser value");function OL(e,t){let r=new WeakSet,n=o=>!Number.isSafeInteger(o)||o<0||t.bytes+o>fJ?!1:(t.bytes+=o,!0),i=(o,s)=>{if(s>mJ||t.nodes>=ET)return cr;if(t.nodes+=1,o===void 0||typeof o=="function"||typeof o=="symbol")return CT;if(typeof o=="bigint")return cr;if(o===null||typeof o=="boolean"||typeof o=="number"){let u=PT(o);return typeof u=="string"&&n(u.length)?u:cr}if(typeof o=="string")return n(o.length*6+2)?PT(o):cr;if(typeof o!="object"||r.has(o))return cr;let a=Array.isArray(o),c=Object.getPrototypeOf(o);if(a&&c!==Array.prototype||!a&&c!==null&&c!==Object.prototype)return cr;for(let u=o;u!==null;u=Object.getPrototypeOf(u)){let l=Object.getOwnPropertyDescriptor(u,"toJSON");if(l){if(!("value"in l)||typeof l.value=="function")return cr;break}}r.add(o);try{if(!n(2))return cr;if(a){let p=Object.getOwnPropertyDescriptor(o,"length"),f=p&&"value"in p?p.value:void 0;if(typeof f!="number"||!Number.isSafeInteger(f)||f<0||f>ET-t.nodes)return cr;let m=[];for(let h=0;h<f;h+=1){let y=String(h),w=Object.getOwnPropertyDescriptor(o,y);if(!w){if(Object.getOwnPropertyDescriptor(Array.prototype,y)||Object.getOwnPropertyDescriptor(Object.prototype,y)||(t.nodes+=1,!n(4)))return cr;m.push("null");continue}if(!("value"in w))return cr;let _=i(w.value,s+1);if(_===cr)return _;m.push(_===CT?"null":_)}return`[${m.join(",")}]`}let u=Reflect.ownKeys(o);if(u.length>ET-t.nodes)return cr;let l=[];for(let p of u){if(typeof p!="string")continue;let f=Object.getOwnPropertyDescriptor(o,p);if(!f)return cr;if(f.enumerable){if(!("value"in f))return cr;l.push([p,f.value])}}l.sort(([p],[f])=>p===f?0:p<f?-1:1);let d=[];for(let[p,f]of l){let m=i(f,s+1);if(m===cr)return m;if(m!==CT){if(!n(p.length*6+3))return cr;d.push(`${PT(p)}:${m}`)}}return`{${d.join(",")}}`}finally{r.delete(o)}};try{let o=i(e,0);return typeof o=="string"?o:void 0}catch{return}}function kL(e,t,r,n){let i=Object.getOwnPropertyDescriptor(t,"$parseRaw"),o=Object.getOwnPropertyDescriptor(r,n);if(!i||!("value"in i)||typeof i.value!="function"||!o||!("value"in o))return;let s=OL(o.value,{nodes:0,bytes:0});s!==void 0&&e.set(t,s)}function IL(e,t,r,n,i){let o=t&&e.get(t),s=Object.getOwnPropertyDescriptor(r,n);return o!==void 0&&s!==void 0&&"value"in s&&OL(i,{nodes:0,bytes:0})===o}function kd(e,t){return e&&"value"in e?{...e,value:t}:{configurable:!0,enumerable:!0,writable:!0,value:t}}function jT(e,t,r){for(let n of r){let i=e[n];!i&&!(n in t)||(e[n]=i&&"value"in i?{...i,value:void 0}:{configurable:i?.configurable??!0,enumerable:i?.enumerable??!1,writable:!1,value:void 0})}}function hJ(e){let t=e.source??{type:e.type,...e.type==="function"?{function:{}}:{}},r=Object.getOwnPropertyDescriptors(t);if(r.type=kd(r.type,e.type),e.type!=="function"||!e.function)return r.function&&(r.function=kd(r.function,void 0)),jT(r,t,["$brand","$parseRaw","$callback"]),Object.create(Object.getPrototypeOf(t),r);let n=r.function,i=n&&"value"in n&&typeof n.value=="object"&&n.value!==null?n.value:{},o=Object.getOwnPropertyDescriptors(i);return o.name=kd(o.name,e.function.name),o.strict=kd(o.strict,e.function.strict),r.function=kd(n,Object.create(Object.getPrototypeOf(i),o)),e.function.schemaMatches||jT(r,t,["$brand","$parseRaw","$callback"]),Object.create(Object.getPrototypeOf(t),r)}function gJ(e){let t=e.source??{type:e.type},r=Object.getOwnPropertyDescriptors(t);return r.type=kd(r.type,e.type),(e.type!=="json_schema"||!e.source||!e.schemaMatches)&&jT(r,t,["$brand","$parseRaw"]),Object.create(Object.getPrototypeOf(t),r)}function RT(e,t){let r=Object.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;let{value:n}=r;return typeof n=="object"&&n!==null?n:void 0}function yJ(e,t,r){let n=new WeakMap,i=new WeakMap;if(e.tools)for(let f=0;f<e.tools.length&&f<ma;f+=1){let m=RT(e.tools,String(f)),h=t.tools?.[f];if(m&&h){n.set(m,h);let y=RT(h,"function");y&&kL(i,h,y,"parameters")}}t.response_format&&kL(i,t.response_format,t.response_format,"json_schema");let o,s,a,c,u=[],l=new WeakMap,d=new Map,p=new WeakMap;return i4(e,{value(f,m,h){if(!o&&m===""&&typeof h=="object"&&h!==null){o=h,s=void 0,a=void 0,c=void 0,u=[],l=new WeakMap,d=new Map,p=new WeakMap;return}if(f===o&&m==="response_format"){typeof h=="object"&&h!==null&&(a=h,c={source:RT(f,m)===e.response_format?t.response_format:void 0,schemaMatches:!1});return}if(f===o&&m==="tools")return Array.isArray(h)?(s=new Proxy(h,{get(_,b){let I=Reflect.get(_,b,_);if(typeof b=="string"){let $=Number(b);Number.isSafeInteger($)&&$>=0&&$<ma&&String($)===b&&d.set($,typeof I=="object"&&I!==null?I:void 0)}return I}}),s):void 0;if(f===s){let _=Number(m);if(!Number.isSafeInteger(_)||_<0||_>=ma||typeof h!="object"||h===null)return;let b=d.get(_),$={source:b?n.get(b):void 0};u[_]=$,l.set(h,$);return}let y=l.get(f);if(y){if(m==="type"&&typeof h=="string")y.type=h;else if(m==="function"&&typeof h=="object"&&h!==null){let _={source:y.source,schemaMatches:!1};y.function=_,p.set(h,_)}return}if(f===a&&c){m==="type"&&typeof h=="string"?c.type=h:m==="json_schema"&&(c.schemaMatches=IL(i,c.source,f,m,h));return}let w=p.get(f);w&&(m==="name"&&typeof h=="string"?w.name=h:m==="strict"&&typeof h=="boolean"?w.strict=h:m==="parameters"&&(w.schemaMatches=IL(i,w.source,f,m,h)))},complete(){if(!o)return;let f=Oh(t);if(s){let m=[];for(let h=0;h<u.length;h+=1){let y=u[h];y&&(m[h]=hJ(y))}f.tools=m}else delete f.tools;c?f.response_format=gJ(c):delete f.response_format,r(f),o=void 0,s=void 0,a=void 0,c=void 0,u=[],l=new WeakMap,d=new Map,p=new WeakMap}})}var nu=class e extends eu{constructor(t){super(),yt.add(this),Vt.set(this,void 0),fa.set(this,void 0),tu.set(this,void 0),Ur.set(this,void 0),Fn.set(this,void 0),gn.set(this,void 0),j(this,Vt,t,"f"),j(this,fa,new Set,"f"),j(this,tu,[],"f"),j(this,Fn,!1,"f");let r=t?.tools,n=r&&Object.getOwnPropertyDescriptor(r,"length"),i=n&&"value"in n?n.value:void 0;if(r&&typeof i=="number"&&Number.isSafeInteger(i)&&i>=0)for(let o=0;o<Math.min(i,ma);o+=1){let s=Object.getOwnPropertyDescriptor(r,String(o));if(!s||!("value"in s))continue;let a=s.value;if(co(a)&&(gi(a)||a.function.strict===!0)){j(this,Fn,!0,"f");break}}j(this,gn,{bytes:0,fragments:0,work:0},"f")}get currentChatCompletionSnapshot(){return g(this,Ur,"f")}static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}static createChatCompletion(t,r,n){let i=new e(r);return i._run(()=>i._runChatCompletion(t,{...r,stream:!0},{...n,__metadata:{...n?.__metadata,helperMethod:"stream"}})),i}async _createChatCompletion(t,r,n){this._listenForAbort(n?.signal);let i={...r,stream:!0};j(this,Vt,i,"f"),g(this,yt,"m",IT).call(this);let o=pJ(i);j(this,Vt,o,"f"),j(this,Fn,o.tools?.some(c=>co(c)&&(gi(c)||c.function.strict===!0))??!1,"f");let s=i.tools||i.response_format?yJ(i,o,c=>{j(this,Vt,c,"f"),j(this,Fn,c.tools?.some(u=>co(u)&&(gi(u)||u.function.strict===!0))??!1,"f")}):void 0,a=await t.chat.completions.create(i,{...n,signal:this.controller.signal}).finally(s);this._connected();for await(let c of a)g(this,yt,"m",ST).call(this,c);if(a.controller.signal?.aborted)throw new De;return this._addChatCompletion(g(this,yt,"m",Ih).call(this))}async _fromReadableStream(t,r){this._listenForAbort(r?.signal),g(this,yt,"m",IT).call(this),this._connected();let n=Yr.fromReadableStream(t,this.controller),i;for await(let s of n){if(cJ(s)){let c=uJ(s);if(g(this,Ur,"f")){let u=g(this,Ur,"f").choices[0]?.message.tool_calls;for(let[l,d]of c.tool_call_ids?.entries()??[]){let p=u?.[l];p&&d&&(p.id=d)}this._addChatCompletion(g(this,yt,"m",Ih).call(this)),i=void 0}this._addMessage(c.message);continue}let a=s;i&&a.id&&i!==a.id&&this._addChatCompletion(g(this,yt,"m",Ih).call(this)),g(this,yt,"m",ST).call(this,a),a.id&&(i=a.id)}if(n.controller.signal?.aborted)throw new De;if(g(this,Ur,"f"))return this._addChatCompletion(g(this,yt,"m",Ih).call(this));let o=this._chatCompletions[this._chatCompletions.length-1];if(o)return o;throw new A("request ended without sending any chunks")}[(Vt=new WeakMap,fa=new WeakMap,tu=new WeakMap,Ur=new WeakMap,Fn=new WeakMap,gn=new WeakMap,yt=new WeakSet,IT=function(){this.ended||(j(this,fa,new Set,"f"),j(this,Ur,void 0,"f"),j(this,gn,{bytes:0,fragments:0,work:0},"f"))},wd=function(r){let n=g(this,tu,"f")[r.index];return n||(n={content_done:!1,content_parse_state:void 0,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null,tool_call_parse_states:new Map,tool_call_identities:new Map},g(this,tu,"f")[r.index]=n,n)},ST=function(r){if(this.ended)return;let n=new WeakMap,i=g(this,yt,"m",_L).call(this,r,n);this._emit("chunk",r,i);for(let o of r.choices){let s=n.get(o),a=i.choices[s?.index??o.index],c=s?.tool_calls??[],{delta:u}=o,l=uo(g(this,Vt,"f")?.response_format),d=l||g(this,Fn,"f"),p=d?Sh(a):a.message,f=d?Bn(p,"refusal"):p.refusal,h=!f&&l?Bn(p,"content"):p.content;u?.content!=null&&p.role==="assistant"&&h&&(this._emit("content",u.content,h),this._emit("content.delta",{delta:u.content,snapshot:h,parsed:p.parsed})),u?.refusal!=null&&p.role==="assistant"&&f&&this._emit("refusal.delta",{delta:u.refusal,snapshot:f}),o.logprobs?.content!=null&&p.role==="assistant"&&this._emit("logprobs.content.delta",{content:o.logprobs?.content,snapshot:a.logprobs?.content??[]}),o.logprobs?.refusal!=null&&p.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:o.logprobs?.refusal,snapshot:a.logprobs?.refusal??[]});let y=g(this,yt,"m",wd).call(this,a);a.finish_reason&&(g(this,yt,"m",OT).call(this,a),y.current_tool_call_index!=null&&g(this,yt,"m",AT).call(this,a,y.current_tool_call_index));for(let w of c)y.current_tool_call_index!==w.index&&(g(this,yt,"m",OT).call(this,a),y.current_tool_call_index!=null&&g(this,yt,"m",AT).call(this,a,y.current_tool_call_index)),y.current_tool_call_index=w.index;for(let w of c){let _=p.tool_calls?.[w.index];if(_?.type)if(_.type==="function"){let b=y.tool_call_identities.get(w.index),I;if(b?.parseable){let $=Bn(_.function,"arguments");if(typeof $!="string")throw new A("Chat completion stream contains an unsafe structured JSON snapshot");I=$}else I=_.function.arguments;this._emit("tool_calls.function.arguments.delta",{name:_.function.name,index:w.index,arguments:I,parsed_arguments:_.function.parsed_arguments,arguments_delta:w.arguments_delta})}else _.type!=="custom"&&_}}},AT=function(r,n){let i=g(this,yt,"m",wd).call(this,r);if(i.done_tool_calls.has(n))return;let s=(g(this,Fn,"f")?Sh(r):r.message).tool_calls?.[n];if(!s)throw new Error("no tool call snapshot");let a=i.tool_call_identities.get(n);if(a&&TT(s,a),!s.type)throw new Error("tool call snapshot missing `type`");if(s.type==="function"){let c=g(this,Vt,"f")?.tools?.find(p=>co(p)&&p.function.name===s.function.name),u=null,l=gi(c)||c?.function.strict===!0,d;if(l){g(this,Ur,"f")&&g(this,yt,"m",xd).call(this,g(this,Ur,"f"));let p=Bn(s.function,"arguments");if(typeof p!="string")throw new A("Chat completion stream contains an unsafe structured JSON snapshot");d=p}else d=s.function.arguments;gi(c)?u=c.$parseRaw(ru(d)):c?.function.strict&&(u=hi({type:"json_schema",$parseRaw:void 0},ru(d))),this._emit("tool_calls.function.arguments.done",{name:s.function.name,index:n,arguments:d,parsed_arguments:u})}else s.type!=="custom"&&s},OT=function(r){let n=g(this,yt,"m",wd).call(this,r),i=uo(g(this,Vt,"f")?.response_format),o=i||g(this,Fn,"f"),s=o?Sh(r):r.message,a=o?Bn(s,"refusal"):s.refusal,c=!a&&i,u=c?Bn(s,"content"):s.content;u!=null&&(u!==""||!a&&!s.tool_calls?.length&&!s.function_call)&&!n.content_done&&(c&&g(this,Ur,"f")&&g(this,yt,"m",xd).call(this,g(this,Ur,"f")),n.content_done=!0,this._emit("content.done",{content:u,parsed:a?null:hi(g(this,Vt,"f")?.response_format,c?ru(u):u)})),a&&!n.refusal_done&&(n.refusal_done=!0,this._emit("refusal.done",{refusal:a})),r.logprobs?.content&&!n.logprobs_content_done&&(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:r.logprobs.content})),r.logprobs?.refusal&&!n.logprobs_refusal_done&&(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:r.logprobs.refusal}))},xd=function(r){let n={bytes:0,fragments:0,work:0},i=uo(g(this,Vt,"f")?.response_format),o=new WeakMap,s=wL(r,"choices",xb,"choice");if(!s)throw new A("Chat completion stream contains an unsafe snapshot choice collection");for(let a=0;a<s.length;a+=1){let c=$T(s,a);if(!c)continue;let u=Sh(c),l=Bn(u,"refusal"),d=Bn(u,"content"),p=new Map,f=wL(u,"tool_calls",ma,"tool-call");o.set(c,Object.freeze({message:u,content:d,refusal:l,toolCallCollection:f,toolCalls:p}));let m=g(this,tu,"f")[c.index];i&&!l&&typeof d=="string"&&ru(d,n,g(this,gn,"f"));for(let[h,y]of m?.tool_call_identities??[]){let w=f&&$T(f,h);if(!w)throw new A("Chat completion stream contains a changed tool call identity");TT(w,y)}if(g(this,Fn,"f"))for(let h=0;h<(f?.length??0);h+=1){let y=$T(f,h);if(!y)continue;let w=kb(y);if(!w){let $=Object.getOwnPropertyDescriptor(y,"type");if($&&!("value"in $))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");if($?.value!=="function")continue;let P=Object.getOwnPropertyDescriptor(y,"function");if(P&&!("value"in P))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");if(P&&typeof P.value=="object"&&P.value!==null){let C=Object.getOwnPropertyDescriptor(P.value,"name");if(C&&!("value"in C))throw new A("Chat completion stream contains an unsafe structured JSON snapshot")}continue}if(!ab(g(this,Vt,"f"),{type:w.type,function:{name:w.name}}))continue;let _=Object.getOwnPropertyDescriptor(y,"function");if(!_||!("value"in _))throw new A("Chat completion stream contains an unsafe structured JSON snapshot");let b=_.value,I=Bn(b,"arguments");if(typeof I!="string")throw new A("Chat completion stream contains an unsafe structured JSON snapshot");ru(I,n,g(this,gn,"f")),p.set(h,Object.freeze({tool:y,function:b,type:w.type,name:w.name,arguments:I}))}}return o},Ih=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let r=g(this,Ur,"f");if(!r)throw new A("request ended without sending any chunks");let n=g(this,yt,"m",xd).call(this,r),i=g(this,fa,"f");return j(this,fa,new Set,"f"),j(this,Ur,void 0,"f"),j(this,tu,[],"f"),_J(r,g(this,Vt,"f"),i,n)},_L=function(r,n){var i,o,s,a,c;let u=g(this,Ur,"f"),{choices:l,obfuscation:d,...p}=r;if(u)r.id&&Ah(u,p);else{let h={...p,choices:[]};j(this,Ur,h,"f"),u=h}let f=g(this,Vt,"f")?.n,m=typeof f=="number"&&Number.isSafeInteger(f)&&f>0?Math.min(f,xb):xb;for(let h of r.choices){let{delta:y,finish_reason:w,index:_,logprobs:b=null,...I}=h,$=[];if(n.set(h,Object.freeze({index:_,tool_calls:$})),!Number.isSafeInteger(_)||_<0||_>=m)throw new A(`Chat completion stream contains an invalid choice index: ${_}`);let P=u.choices[_];if(!P){let ne={finish_reason:w,index:_,message:{},logprobs:null,...I};u.choices[_]=ne,P=ne}if((uo(g(this,Vt,"f")?.response_format)||g(this,Fn,"f"))&&Bn(Sh(P),"refusal"),b)if(P.logprobs){let{content:ne,refusal:X,...Q}=b;Ah(P.logprobs,Q),ne&&((i=P.logprobs).content??(i.content=[]),P.logprobs.content.push(...ne)),X&&((o=P.logprobs).refusal??(o.refusal=[]),P.logprobs.refusal.push(...X))}else P.logprobs={...b},b.content&&(P.logprobs.content=[...b.content]),b.refusal&&(P.logprobs.refusal=[...b.refusal]);if(w&&(P.finish_reason=w,g(this,Vt,"f")&&cT(g(this,Vt,"f")))){if(w==="length")throw new aa;if(w==="content_filter")throw new ca}if(Ah(P,I),!y){Object.freeze($);continue}g(this,fa,"f").delete(_);let{audio:C,content:x,refusal:D,function_call:M,role:R,...B}=y,{tool_calls:K,...re}=B,We=pe(B,"tool_calls")?K:y.tool_calls;if(Ah(P.message,re),C?.expires_at!=null&&C.id==null&&C.data==null&&C.transcript==null&&x==null&&D==null&&M==null&&R==null&&We==null&&Object.keys(re).length===0&&g(this,fa,"f").add(_),D&&(P.message.refusal=(P.message.refusal||"")+D),R&&(P.message.role=R),C){let ne=(s=P.message).audio??(s.audio={});C.id!=null&&(ne.id=C.id),C.data!=null&&(ne.data=(ne.data??"")+C.data),C.transcript!=null&&(ne.transcript=(ne.transcript??"")+C.transcript),C.expires_at!=null&&(ne.expires_at=C.expires_at)}if(M&&(P.message.function_call?(M.name&&(P.message.function_call.name=M.name),M.arguments&&((a=P.message.function_call).arguments??(a.arguments=""),P.message.function_call.arguments+=M.arguments)):P.message.function_call=M),x!=null)if(!P.message.refusal&&uo(g(this,Vt,"f")?.response_format)){let ne=g(this,yt,"m",wd).call(this,P),X=ne.content_parse_state??(ne.content_parse_state=NT()),Q=MT(X,g(this,gn,"f"),x);P.message.content=(Bn(P.message,"content")||"")+x,X.has_non_whitespace?Q&&zT(X,g(this,gn,"f"))?(g(this,yt,"m",xd).call(this,u),P.message.parsed=vL(ru(P.message.content))):x.length>0&&(P.message.parsed=null):P.message.parsed=null}else P.message.content=(P.message.content||"")+x;if(We){let ne=(c=P.message).tool_calls??(c.tool_calls=[]);for(let X of We){let{index:Q,id:ae,type:ce,function:$e,custom:bt,...yn}=X;if(!Number.isSafeInteger(Q)||Q<0||Q>=ma)throw new A(`Chat completion stream contains an invalid tool call index: ${Q}`);let Et="",Xe=ne[Q]??(ne[Q]={}),k=$e?.name,v=g(this,Fn,"f")?g(this,yt,"m",wd).call(this,P):void 0,U=v?.tool_call_identities.get(Q);if(U&&(TT(Xe,U),ce!==void 0&&ce!==U.type||k!==void 0&&k!==U.name))throw new A("Chat completion stream contains a changed tool call identity");if(Ah(Xe,yn),ae&&(Xe.id=ae),ce&&(Xe.type=ce),bt){let T=Xe.custom??(Xe.custom={name:bt.name??"",input:""});bt.name&&(T.name=bt.name),bt.input&&(T.input+=bt.input)}if($e){let T=Xe.function??(Xe.function={name:k??"",arguments:""});if(k&&(T.name=k),v&&!U){let Pe=kb(Xe),wt=Pe&&g(this,Vt,"f")?.tools?.find(He=>co(He)&&He.function.name===Pe.name);if(Pe&&(U={...Pe,parseable:wt!==void 0&&ab(g(this,Vt,"f"),{type:Pe.type,function:{name:Pe.name}})},v.tool_call_identities.set(Q,U),!U.parseable)){let He=v.tool_call_parse_states.get(Q);He&&(g(this,gn,"f").bytes-=He.bytes,g(this,gn,"f").fragments-=He.fragments,g(this,gn,"f").work-=He.work,v.tool_call_parse_states.delete(Q))}}let xe=$e.arguments;if(xe!=null)if(Et=xe,v&&U?.parseable!==!1){let Pe=v.tool_call_parse_states.get(Q);Pe||(Pe=NT(),v.tool_call_parse_states.set(Q,Pe));let wt=MT(Pe,g(this,gn,"f"),xe),He=Bn(T,"arguments");if(typeof He!="string")throw new A("Chat completion stream contains an unsafe structured JSON snapshot");T.arguments=He+xe,wt&&U?.parseable===!0&&zT(Pe,g(this,gn,"f"))?(g(this,yt,"m",xd).call(this,u),T.parsed_arguments=vL(ru(T.arguments))):xe.length>0&&pe(T,"parsed_arguments")&&(T.parsed_arguments=void 0)}else T.arguments+=xe}$.push(Object.freeze({index:Q,arguments_delta:Et}))}}Object.freeze($)}return u},Symbol.asyncIterator)](){return this._createIterator(t=>{let r=n=>t(n);return this.on("chunk",r),()=>this.off("chunk",r)},{onReturn:()=>this.abort()})}toReadableStream(){return new Yr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function _J(e,t,r,n){let{id:i,choices:o,created:s,model:a,system_fingerprint:c,...u}=e,l={...u,id:i,choices:xL(o,xb,"choice",d=>{let p=n.get(d);if(!p)throw new A("Chat completion stream contains an unsafe structured JSON snapshot");let f=new Proxy(d,{get(B,K,re){return K==="message"?p.message:Reflect.get(B,K,re)}}),{message:m,finish_reason:h,index:y,logprobs:w,..._}=f,b=new Proxy(m,{get(B,K,re){return K==="content"?p.content:K==="refusal"?p.refusal:K==="tool_calls"?p.toolCallCollection:Reflect.get(B,K,re)}}),{content:I=null,function_call:$,tool_calls:P,audio:C,...x}=b,D=h??(r.has(y)&&vJ(C)?"stop":null);if(!D)throw new A(`missing finish_reason for choice ${y}`);let M=C?{audio:C}:{},R=b.role;if(!R)throw new A(`missing role for choice ${y}`);if($){let{arguments:B,name:K}=$;if(B==null)throw new A(`missing function_call.arguments for choice ${y}`);if(!K)throw new A(`missing function_call.name for choice ${y}`);return{..._,message:{...M,content:I,function_call:{arguments:B,name:K},role:R,refusal:b.refusal??null},finish_reason:D,index:y,logprobs:w}}return P?{..._,index:y,finish_reason:D,logprobs:w,message:{...x,...M,role:R,content:I,refusal:b.refusal??null,tool_calls:xL(P,ma,"tool-call",(B,K)=>{let re=p.toolCalls.get(K);if(!re){let Et=kb(B);if(Et&&ab(t,{type:Et.type,function:{name:Et.name}}))throw new A("Chat completion stream contains an unsafe structured JSON snapshot")}if(re&&re.tool!==B)throw new A("Chat completion stream contains a changed tool call identity");let We=re&&new Proxy(re.function,{get(Et,Xe,k){return Xe==="arguments"?re.arguments:Xe==="name"?re.name:Reflect.get(Et,Xe,k)}}),ne=re&&We?new Proxy(B,{get(Et,Xe,k){return Xe==="type"?re.type:Xe==="function"?We:Reflect.get(Et,Xe,k)}}):B;if(ne.type==null)throw new A(`missing choices[${y}].tool_calls[${K}].type`);if(ne.type==="custom"){let{custom:Et,type:Xe,id:k,...v}=ne,{input:U="",name:T,...xe}=Et||{};if(T==null)throw new A(`missing choices[${y}].tool_calls[${K}].custom.name`);return{...v,id:k||`call_${Ys()}`,type:Xe,custom:{...xe,name:T,input:U}}}let{function:X,type:Q,id:ae,...ce}=ne,{arguments:$e,name:bt,...yn}=X||{};if(bt==null)throw new A(`missing choices[${y}].tool_calls[${K}].function.name`);if($e==null)throw new A(`missing choices[${y}].tool_calls[${K}].function.arguments`);return{...ce,id:ae||`call_${Ys()}`,type:Q,function:{...yn,name:bt,arguments:$e}}})}}:{..._,message:{...x,...M,content:I,role:R,refusal:b.refusal??null},finish_reason:D,index:y,logprobs:w}}),created:s,model:a,object:"chat.completion",...c?{system_fingerprint:c}:{}};return Q4(l,t)}function vJ(e){return e?.id!=null&&e.data!=null&&e.transcript!=null&&e.expires_at!=null}var $h=class e extends nu{static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}toReadableStream(){let t,r,n=this._createIterator(o=>{let s=c=>{t=c,o(c)},a=c=>{if(Xo(c)){r=c.tool_calls?.map(u=>u.id);return}if(fh(c)){if(!t)throw new A("cannot serialize a tool message before receiving any chunks");o(SL(t,c,r))}};return this.on("chunk",s),this.on("message",a),()=>{this.off("chunk",s),this.off("message",a)}},{onReturn:()=>this.abort()});return new Yr(()=>n,this.controller).toReadableStream()}static runTools(t,r,n){let i=new e(r),o={...n,__metadata:{...n?.__metadata,helperMethod:"runTools"}};return i._run(()=>i._runTools(t,r,i,o)),i}};var Yo=class extends O{constructor(){super(...arguments),this.messages=new Xc(this._client)}create(t,r){return this._client.post("/chat/completions",{body:t,...r,stream:t.stream??!1,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/chat/completions/${t}`,{...r,__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/chat/completions/${t}`,{body:r,...n,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/chat/completions",ve,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/chat/completions/${t}`,{...r,__security:{bearerAuth:!0}})}parse(t,r){return eL(t.tools),this._client.chat.completions.create(t,{...r,__metadata:{...r?.__metadata,helperMethod:"chat.completions.parse"}})._thenUnwrap(n=>ph(n,t))}runTools(t,r){return t.stream?$h.runTools(this._client,t,r):xh.runTools(this._client,t,r)}stream(t,r){return nu.createChatCompletion(this._client,t,r)}};Yo.Messages=Xc;var ha=class extends O{constructor(){super(...arguments),this.completions=new Yo(this._client)}};ha.Completions=Yo;var Id=class extends O{create(t,r){return this._client.post("/organization/admin_api_keys",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/admin_api_keys/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/admin_api_keys",ve,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/admin_api_keys/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Sd=class extends O{list(t={},r){return this._client.getAPIList("/organization/audit_logs",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}};var Ad=class extends O{create(t,r){return this._client.post("/organization/certificates",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r={},n){return this._client.get(S`/organization/certificates/${t}`,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/certificates/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/certificates",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/certificates/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}activate(t,r){return this._client.getAPIList("/organization/certificates/activate",Ir,{body:t,method:"post",...r,__security:{adminAPIKeyAuth:!0}})}deactivate(t,r){return this._client.getAPIList("/organization/certificates/deactivate",Ir,{body:t,method:"post",...r,__security:{adminAPIKeyAuth:!0}})}};var Od=class extends O{retrieve(t){return this._client.get("/organization/data_retention",{...t,__security:{adminAPIKeyAuth:!0}})}update(t,r){return this._client.post("/organization/data_retention",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}};var $d=class extends O{create(t,r){return this._client.post("/organization/invites",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/invites/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/invites",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/invites/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Td=class extends O{create(t,r){return this._client.post("/organization/roles",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/roles/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/roles/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/roles",Bt,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/roles/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Ed=class extends O{create(t,r){return this._client.post("/organization/spend_alerts",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/spend_alerts/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/spend_alerts/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/spend_alerts",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/spend_alerts/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Pd=class extends O{retrieve(t){return this._client.get("/organization/spend_limit",{...t,__security:{adminAPIKeyAuth:!0}})}update(t,r){return this._client.post("/organization/spend_limit",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t){return this._client.delete("/organization/spend_limit",{...t,__security:{adminAPIKeyAuth:!0}})}};var Cd=class extends O{audioSpeeches(t,r){return this._client.get("/organization/usage/audio_speeches",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions(t,r){return this._client.get("/organization/usage/audio_transcriptions",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions(t,r){return this._client.get("/organization/usage/code_interpreter_sessions",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}completions(t,r){return this._client.get("/organization/usage/completions",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}costs(t,r){return this._client.get("/organization/costs",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}embeddings(t,r){return this._client.get("/organization/usage/embeddings",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}fileSearchCalls(t,r){return this._client.get("/organization/usage/file_search_calls",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}images(t,r){return this._client.get("/organization/usage/images",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}moderations(t,r){return this._client.get("/organization/usage/moderations",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}vectorStores(t,r){return this._client.get("/organization/usage/vector_stores",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}webSearchCalls(t,r){return this._client.get("/organization/usage/web_search_calls",{query:t,...r,__security:{adminAPIKeyAuth:!0}})}};var Rd=class extends O{create(t,r,n){return this._client.post(S`/organization/groups/${t}/roles`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{group_id:i}=r;return this._client.get(S`/organization/groups/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/groups/${t}/roles`,Bt,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{group_id:i}=r;return this._client.delete(S`/organization/groups/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var Nd=class extends O{create(t,r,n){return this._client.post(S`/organization/groups/${t}/users`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{group_id:i}=r;return this._client.get(S`/organization/groups/${i}/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/groups/${t}/users`,Bt,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{group_id:i}=r;return this._client.delete(S`/organization/groups/${i}/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var ga=class extends O{constructor(){super(...arguments),this.users=new Nd(this._client),this.roles=new Rd(this._client)}create(t,r){return this._client.post("/organization/groups",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/groups/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/groups/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/groups",Bt,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/groups/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};ga.Users=Nd;ga.Roles=Rd;var Md=class extends O{retrieve(t,r,n){let{project_id:i}=r;return this._client.get(S`/organization/projects/${i}/api_keys/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/api_keys`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/organization/projects/${i}/api_keys/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var zd=class extends O{list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/certificates`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}activate(t,r,n){return this._client.getAPIList(S`/organization/projects/${t}/certificates/activate`,Ir,{body:r,method:"post",...n,__security:{adminAPIKeyAuth:!0}})}deactivate(t,r,n){return this._client.getAPIList(S`/organization/projects/${t}/certificates/deactivate`,Ir,{body:r,method:"post",...n,__security:{adminAPIKeyAuth:!0}})}};var jd=class extends O{retrieve(t,r){return this._client.get(S`/organization/projects/${t}/data_retention`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/projects/${t}/data_retention`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}};var Dd=class extends O{retrieve(t,r){return this._client.get(S`/organization/projects/${t}/hosted_tool_permissions`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/projects/${t}/hosted_tool_permissions`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}};var Ud=class extends O{retrieve(t,r){return this._client.get(S`/organization/projects/${t}/model_permissions`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/projects/${t}/model_permissions`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/projects/${t}/model_permissions`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Ld=class extends O{listRateLimits(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/rate_limits`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}updateRateLimit(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/organization/projects/${i}/rate_limits/${t}`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}};var Fd=class extends O{create(t,r,n){return this._client.post(S`/projects/${t}/roles`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i}=r;return this._client.get(S`/projects/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/projects/${i}/roles/${t}`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/projects/${t}/roles`,Bt,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/projects/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var Bd=class extends O{create(t,r,n){return this._client.post(S`/organization/projects/${t}/spend_alerts`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i}=r;return this._client.get(S`/organization/projects/${i}/spend_alerts/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/organization/projects/${i}/spend_alerts/${t}`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/spend_alerts`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/organization/projects/${i}/spend_alerts/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var Zd=class extends O{retrieve(t,r){return this._client.get(S`/organization/projects/${t}/spend_limit`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/projects/${t}/spend_limit`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/projects/${t}/spend_limit`,{...r,__security:{adminAPIKeyAuth:!0}})}};var Vd=class extends O{create(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/projects/${i}/groups/${t}/roles`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i,group_id:o}=r;return this._client.get(S`/projects/${i}/groups/${o}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r,n){let{project_id:i,...o}=r;return this._client.getAPIList(S`/projects/${i}/groups/${t}/roles`,Bt,{query:o,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i,group_id:o}=r;return this._client.delete(S`/projects/${i}/groups/${o}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var iu=class extends O{constructor(){super(...arguments),this.roles=new Vd(this._client)}create(t,r,n){return this._client.post(S`/organization/projects/${t}/groups`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i,...o}=r;return this._client.get(S`/organization/projects/${i}/groups/${t}`,{query:o,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/groups`,Bt,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/organization/projects/${i}/groups/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};iu.Roles=Vd;var Wd=class extends O{create(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/organization/projects/${i}/service_accounts/${t}/api_keys`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}};var ou=class extends O{constructor(){super(...arguments),this.apiKeys=new Wd(this._client)}create(t,r,n){return this._client.post(S`/organization/projects/${t}/service_accounts`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i}=r;return this._client.get(S`/organization/projects/${i}/service_accounts/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/organization/projects/${i}/service_accounts/${t}`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/service_accounts`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/organization/projects/${i}/service_accounts/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};ou.APIKeys=Wd;var qd=class extends O{create(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/projects/${i}/users/${t}/roles`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i,user_id:o}=r;return this._client.get(S`/projects/${i}/users/${o}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r,n){let{project_id:i,...o}=r;return this._client.getAPIList(S`/projects/${i}/users/${t}/roles`,Bt,{query:o,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i,user_id:o}=r;return this._client.delete(S`/projects/${i}/users/${o}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var su=class extends O{constructor(){super(...arguments),this.roles=new qd(this._client)}create(t,r,n){return this._client.post(S`/organization/projects/${t}/users`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{project_id:i}=r;return this._client.get(S`/organization/projects/${i}/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){let{project_id:i,...o}=r;return this._client.post(S`/organization/projects/${i}/users/${t}`,{body:o,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/projects/${t}/users`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{project_id:i}=r;return this._client.delete(S`/organization/projects/${i}/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};su.Roles=qd;var ur=class extends O{constructor(){super(...arguments),this.users=new su(this._client),this.serviceAccounts=new ou(this._client),this.apiKeys=new Md(this._client),this.rateLimits=new Ld(this._client),this.modelPermissions=new Ud(this._client),this.hostedToolPermissions=new Dd(this._client),this.groups=new iu(this._client),this.roles=new Fd(this._client),this.dataRetention=new jd(this._client),this.spendLimit=new Zd(this._client),this.spendAlerts=new Bd(this._client),this.certificates=new zd(this._client)}create(t,r){return this._client.post("/organization/projects",{body:t,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r){return this._client.get(S`/organization/projects/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/projects/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/projects",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}archive(t,r){return this._client.post(S`/organization/projects/${t}/archive`,{...r,__security:{adminAPIKeyAuth:!0}})}};ur.Users=su;ur.ServiceAccounts=ou;ur.APIKeys=Md;ur.RateLimits=Ld;ur.ModelPermissions=Ud;ur.HostedToolPermissions=Dd;ur.Groups=iu;ur.Roles=Fd;ur.DataRetention=jd;ur.SpendLimit=Zd;ur.SpendAlerts=Bd;ur.Certificates=zd;var Kd=class extends O{create(t,r,n){return this._client.post(S`/organization/users/${t}/roles`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r,n){let{user_id:i}=r;return this._client.get(S`/organization/users/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/organization/users/${t}/roles`,Bt,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{user_id:i}=r;return this._client.delete(S`/organization/users/${i}/roles/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var au=class extends O{constructor(){super(...arguments),this.roles=new Kd(this._client)}retrieve(t,r){return this._client.get(S`/organization/users/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}update(t,r,n){return this._client.post(S`/organization/users/${t}`,{body:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t={},r){return this._client.getAPIList("/organization/users",qe,{query:t,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,r){return this._client.delete(S`/organization/users/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};au.Roles=Kd;var lr=class extends O{constructor(){super(...arguments),this.auditLogs=new Sd(this._client),this.adminAPIKeys=new Id(this._client),this.usage=new Cd(this._client),this.invites=new $d(this._client),this.users=new au(this._client),this.groups=new ga(this._client),this.roles=new Td(this._client),this.dataRetention=new Od(this._client),this.spendLimit=new Pd(this._client),this.spendAlerts=new Ed(this._client),this.certificates=new Ad(this._client),this.projects=new ur(this._client)}};lr.AuditLogs=Sd;lr.AdminAPIKeys=Id;lr.Usage=Cd;lr.Invites=$d;lr.Users=au;lr.Groups=ga;lr.Roles=Td;lr.DataRetention=Od;lr.SpendLimit=Pd;lr.SpendAlerts=Ed;lr.Certificates=Ad;lr.Projects=ur;var ya=class extends O{constructor(){super(...arguments),this.organization=new lr(this._client)}};ya.Organization=lr;var Gd=class extends O{create(t,r){return this._client.post("/audio/speech",{body:t,...r,headers:L([{Accept:"application/octet-stream"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}};var Hd=class extends O{create(t,r){return this._client.post("/audio/transcriptions",Zt({body:t,...r,stream:t.stream??!1,__metadata:{model:t.model},__security:{bearerAuth:!0}},this._client))}};var Jd=class extends O{create(t,r){return this._client.post("/audio/translations",Zt({body:t,...r,__metadata:{model:t.model},__security:{bearerAuth:!0}},this._client))}};var po=class extends O{constructor(){super(...arguments),this.transcriptions=new Hd(this._client),this.translations=new Jd(this._client),this.speech=new Gd(this._client)}};po.Transcriptions=Hd;po.Translations=Jd;po.Speech=Gd;var cu=class extends O{create(t,r){return this._client.post("/batches",{body:t,...r,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/batches/${t}`,{...r,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/batches",ve,{query:t,...r,__security:{bearerAuth:!0}})}cancel(t,r){return this._client.post(S`/batches/${t}/cancel`,{...r,__security:{bearerAuth:!0}})}};var Xd=class extends O{create(t,r){return this._client.post("/assistants",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/assistants/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/assistants/${t}`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/assistants",ve,{query:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/assistants/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}};var Yd=class extends O{create(t,r){return this._client.post("/realtime/sessions",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}};var Qd=class extends O{create(t,r){return this._client.post("/realtime/transcription_sessions",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}};var _a=class extends O{constructor(){super(...arguments),this.sessions=new Yd(this._client),this.transcriptionSessions=new Qd(this._client)}};_a.Sessions=Yd;_a.TranscriptionSessions=Qd;var ep=class extends O{create(t,r){return this._client.post("/chatkit/sessions",{body:t,...r,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers]),__security:{bearerAuth:!0}})}cancel(t,r){return this._client.post(S`/chatkit/sessions/${t}/cancel`,{...r,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers]),__security:{bearerAuth:!0}})}};var tp=class extends O{retrieve(t,r){return this._client.get(S`/chatkit/threads/${t}`,{...r,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers]),__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/chatkit/threads",qe,{query:t,...r,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/chatkit/threads/${t}`,{...r,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers]),__security:{bearerAuth:!0}})}listItems(t,r={},n){return this._client.getAPIList(S`/chatkit/threads/${t}/items`,qe,{query:r,...n,headers:L([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers]),__security:{bearerAuth:!0}})}};var va=class extends O{constructor(){super(...arguments),this.sessions=new ep(this._client),this.threads=new tp(this._client)}};va.Sessions=ep;va.Threads=tp;var rp=class extends O{list(t,r={},n){let{betas:i,...o}=r??{};return this._client.getAPIList(S`/responses/${t}/input_items?beta=true`,ve,{query:o,...n,headers:L([{...i?.toString()!=null?{"openai-beta":i?.toString()}:void 0},n?.headers]),__security:{bearerAuth:!0}})}};var np=class extends O{count(t={},r){let{betas:n,...i}=t??{};return this._client.post("/responses/input_tokens?beta=true",{body:i,...r,headers:L([{...n?.toString()!=null?{"openai-beta":n?.toString()}:void 0},r?.headers]),__security:{bearerAuth:!0}})}};var ba=class extends O{constructor(){super(...arguments),this.inputItems=new rp(this._client),this.inputTokens=new np(this._client)}create(t,r){let{betas:n,...i}=t;return this._client.post("/responses?beta=true",{body:i,...r,headers:L([{...n?.toString()!=null?{"openai-beta":n?.toString()}:void 0},r?.headers]),stream:t.stream??!1,__security:{bearerAuth:!0}})}retrieve(t,r={},n){let{betas:i,...o}=r??{};return this._client.get(S`/responses/${t}?beta=true`,{query:o,...n,headers:L([{...i?.toString()!=null?{"openai-beta":i?.toString()}:void 0},n?.headers]),stream:r?.stream??!1,__security:{bearerAuth:!0}})}delete(t,r={},n){let{betas:i}=r??{};return this._client.delete(S`/responses/${t}?beta=true`,{...n,headers:L([{Accept:"*/*",...i?.toString()!=null?{"openai-beta":i?.toString()}:void 0},n?.headers]),__security:{bearerAuth:!0}})}cancel(t,r={},n){let{betas:i}=r??{};return this._client.post(S`/responses/${t}/cancel?beta=true`,{...n,headers:L([{...i?.toString()!=null?{"openai-beta":i?.toString()}:void 0},n?.headers]),__security:{bearerAuth:!0}})}compact(t,r){let{betas:n,...i}=t;return this._client.post("/responses/compact?beta=true",{body:i,...r,headers:L([{...n?.toString()!=null?{"openai-beta":n?.toString()}:void 0},r?.headers]),__security:{bearerAuth:!0}})}};ba.InputItems=rp;ba.InputTokens=np;var ip=class extends O{create(t,r,n){return this._client.post(S`/threads/${t}/messages`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r,n){let{thread_id:i}=r;return this._client.get(S`/threads/${i}/messages/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){let{thread_id:i,...o}=r;return this._client.post(S`/threads/${i}/messages/${t}`,{body:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/threads/${t}/messages`,ve,{query:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}delete(t,r,n){let{thread_id:i}=r;return this._client.delete(S`/threads/${i}/messages/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}};var op=class extends O{retrieve(t,r,n){let{thread_id:i,run_id:o,...s}=r;return this._client.get(S`/threads/${i}/runs/${o}/steps/${t}`,{query:s,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t,r,n){let{thread_id:i,...o}=r;return this._client.getAPIList(S`/threads/${i}/runs/${t}/steps`,ve,{query:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}};var Ib=e=>{if(typeof globalThis.Buffer<"u"){let t=globalThis.Buffer.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(typeof atob<"u"){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}throw new A("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")},$L=e=>{if(typeof Buffer<"u"){let t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return Array.from(new Float32Array(n.buffer))}};var Zn=e=>{try{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()||void 0}catch{return}};var EL=1024,f8=65536;function m8(e){switch(e){case"value":case"arguments":case"input":case"text":case"content":case"annotations":case"metadata":case"name":case"role":case"status":case"tool_calls":case"step_details":return e;default:return"unknown"}}var Th=new WeakMap,wa=new WeakSet;function PL(e){return{arrays:new Map,cacheArrays:e,records:new WeakMap}}function CL(e){for(let[t,r]of e.arrays)r.cacheable&&!wa.has(t)?Th.set(t,{length:r.length,ownEntryCount:r.ownEntryCount}):Th.delete(t)}function TL(e){return typeof e=="string"||typeof e=="number"}function RL(e,t){return t.every(TL)&&e.every(TL)}function h8(e){let t=0;for(let r of Object.keys(e)){let n=Number(r);Number.isSafeInteger(n)&&n>=0&&n<e.length&&String(n)===r&&(t+=1)}return t}function g8(e,t,r){return t?r?.length===e.length?r.ownEntryCount:h8(e):0}function y8(e,t,r){let{index:n}=e;if(t==="array"&&n==null)throw new Error("Expected array delta entry to have an `index` property");if(t==="array"&&typeof n!="number")throw new TypeError("Expected array delta entry `index` property to be a number but got an invalid value");if(!Number.isSafeInteger(n)||n<0||n>=r+EL||n>=f8){let i=typeof n=="number"?n:"unknown";throw new A(`Assistant stream delta contains an invalid ${t} index: ${i}`)}return n}function NL(e,t,r,n,i){let o=n.arrays.get(e);if(!o){let s=n.cacheArrays&&!wa.has(e),a=s?Th.get(e):void 0;o={baselineLength:e.length,cacheable:s,enforceSparseHoleBudget:s,entries:new Map,length:e.length,ownEntryCount:g8(e,s,a)},n.arrays.set(e,o)}for(let s of t){if(!zn(s))throw new Error("Expected array delta entry to be an object but got an invalid value");let a=y8(s,r,o.baselineLength),c;o.entries.has(a)?c=o.entries.get(a):pe(e,a)?(c=e[a],c==null&&o.entries.set(a,s)):(o.entries.set(a,s),o.ownEntryCount+=1);let u=Math.max(o.length,a+1);if(o.enforceSparseHoleBudget&&u-o.ownEntryCount>EL)throw new A(`Assistant stream delta contains an invalid ${r} index: ${a}`);zn(c)&&i(c,s,n),o.length=u}}function Sb(e,t,r){let n=r.records.get(e);for(let[i,o]of Object.entries(t)){if(i==="index"||i==="type")continue;let s;if(n?.has(i)?s=n.get(i):pe(e,i)&&(s=e[i]),s==null){n||(n=new Map,r.records.set(e,n)),n.set(i,o);continue}zn(s)&&zn(o)?Sb(s,o,r):Array.isArray(s)&&Array.isArray(o)&&!RL(s,o)&&NL(s,o,"array",r,Sb)}}function Ab(e){return(zn(e)||Array.isArray(e))&&wa.has(e)}function _i(e){if(!(!zn(e)&&!Array.isArray(e)||wa.has(e))){wa.add(e),Array.isArray(e)&&Th.delete(e);for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r&&"value"in r&&_i(r.value)}}}function FT(e,t,r){wa.has(e)&&_i(r),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0})}function _8(e){let{index:t}=e;if(t==null)throw new Error("Expected array delta entry to have an `index` property");if(typeof t!="number")throw new TypeError("Expected array delta entry `index` property to be a number but got an invalid value");return t}function v8(e,t,r){if(RL(e,t)){e.push(...t),Th.delete(e);return}for(let n of t){if(!zn(n))throw new Error("Expected array delta entry to be an object but got an invalid value");let i=_8(n);if(pe(e,i)){let o=e[i];o==null?(wa.has(e)&&_i(n),e[i]=n):e[i]=r(o,n)}else FT(e,i,n)}}function LT(e,t){let r=wa.has(e);for(let[n,i]of Object.entries(t)){if(n==="__proto__"||n==="constructor"||n==="prototype")throw new A(`Assistant stream delta contains an unsafe property: ${n}`);if(!pe(e,n)){r&&_i(i),e[n]=i;continue}let o=e[n];if(o==null){r&&_i(i),e[n]=i;continue}if(n==="index"||n==="type"){e[n]=i;continue}if(typeof o=="string"&&typeof i=="string")o+=i;else if(typeof o=="number"&&typeof i=="number")o+=i;else if(zn(o)&&zn(i))o=LT(o,i);else if(Array.isArray(o)&&Array.isArray(i)){v8(o,i,LT);continue}else throw new TypeError(`Unhandled record type: ${m8(n)}`);e[n]=o}return e}function Eh(e){if(!(!zn(e)&&!Array.isArray(e)))for(let[t,r]of Object.entries(e)){if(t==="__proto__"||t==="constructor"||t==="prototype")throw new A(`Assistant stream delta contains an unsafe property: ${t}`);Eh(r)}}function Ob(e,t,r=!1){Eh(t);let n=e,i=t,o=PL(r&&!Ab(e));return Sb(n,i,o),LT(n,i),CL(o),e}function ML(e,t,r,n=!0){Eh(t);let i=PL(n&&!Ab(e));return NL(e,t,r,i,Sb),()=>CL(i)}var Se,Lr,xa,Vn,cp,ap,en,Qo,lu,ka,es,uu,Qr,Ph,Ch,Ia,Rh,Nh,zL,sp,jL,$b,DL,UL,Wt,LL,FL,BL,ZL,VL;function b8(e){let t=Object.getOwnPropertyDescriptor(e,"event"),r=Object.getOwnPropertyDescriptor(e,"data"),n=Reflect.get(e,"event",e),i=Reflect.get(e,"data",e),o=i;if(n==="thread.message.created"||n==="thread.message.in_progress"||n==="thread.message.delta"||n==="thread.message.completed"||n==="thread.message.incomplete"||n==="thread.run.step.created"||n==="thread.run.step.in_progress"||n==="thread.run.step.delta"||n==="thread.run.step.completed"||n==="thread.run.step.failed"||n==="thread.run.step.cancelled"||n==="thread.run.step.expired"){let c=Object.getOwnPropertyDescriptor(i,"id");if(c&&"value"in c&&Reflect.get(i,"id",i)!==c.value){let u=c.value;o=new Proxy(i,{get(l,d){return d==="id"?u:Reflect.get(l,d,l)}})}}let s=Object.freeze({event:n,data:o}),a=t!==void 0&&"value"in t&&t.value===n&&r!==void 0&&"value"in r&&r.value===i&&o===i;return{event:s,exposedEvent:a?e:{event:n,data:o}}}var Sa=class e extends pa{constructor(){super(...arguments),Se.add(this),Lr.set(this,Object.create(null)),xa.set(this,new Map),Vn.set(this,void 0),cp.set(this,Object.create(null)),ap.set(this,new Map),en.set(this,void 0),Qo.set(this,void 0),lu.set(this,void 0),ka.set(this,void 0),es.set(this,void 0),uu.set(this,void 0),Qr.set(this,void 0),Ph.set(this,void 0),Ch.set(this,void 0),Ia.set(this,void 0)}[(Lr=new WeakMap,xa=new WeakMap,Vn=new WeakMap,cp=new WeakMap,ap=new WeakMap,en=new WeakMap,Qo=new WeakMap,lu=new WeakMap,ka=new WeakMap,es=new WeakMap,uu=new WeakMap,Qr=new WeakMap,Ph=new WeakMap,Ch=new WeakMap,Ia=new WeakMap,Se=new WeakSet,Symbol.asyncIterator)](){return this._createIterator(t=>{let r=n=>t(structuredClone(n));return this.on("event",r),()=>this.off("event",r)},{onReturn:()=>this.abort()})}static fromReadableStream(t){let r=new e;return r._run(()=>r._fromReadableStream(t)),r}async _fromReadableStream(t,r){this._listenForAbort(r?.signal),this._connected();let n=Yr.fromReadableStream(t,this.controller);for await(let i of n)g(this,Se,"m",Rh).call(this,i);if(n.controller.signal?.aborted)throw new De;return this._addRun(g(this,Se,"m",Nh).call(this))}toReadableStream(){return new Yr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(t,r,n,i){let o=new e;return o._run(()=>o._runToolAssistantStream(t,r,n,{...i,__metadata:{...i?.__metadata,helperMethod:"stream"}})),o}async _createToolAssistantStream(t,r,n,i){this._listenForAbort(i?.signal);let o={...n,stream:!0},s=await t.submitToolOutputs(r,o,{...i,signal:this.controller.signal});this._connected();for await(let a of s)g(this,Se,"m",Rh).call(this,a);if(s.controller.signal?.aborted)throw new De;return this._addRun(g(this,Se,"m",Nh).call(this))}static createThreadAssistantStream(t,r,n){let i=new e;return i._run(()=>i._threadAssistantStream(t,r,{...n,__metadata:{...n?.__metadata,helperMethod:"stream"}})),i}static createAssistantStream(t,r,n,i){let o=new e;return o._run(()=>o._runAssistantStream(t,r,n,{...i,__metadata:{...i?.__metadata,helperMethod:"stream"}})),o}currentEvent(){return _i(g(this,Ph,"f")),g(this,Ph,"f")}currentRun(){return _i(g(this,Ch,"f")),g(this,Ch,"f")}currentMessageSnapshot(){return _i(g(this,en,"f")),g(this,en,"f")}currentRunStepSnapshot(){return _i(g(this,Ia,"f")),g(this,Ia,"f")}async finalRunSteps(){return await this.done(),Object.values(g(this,Lr,"f"))}async finalMessages(){return await this.done(),Object.values(g(this,cp,"f"))}async finalRun(){if(await this.done(),!g(this,lu,"f"))throw new Error("Final run was not received.");return g(this,lu,"f")}async _createThreadAssistantStream(t,r,n){this._listenForAbort(n?.signal);let i={...r,stream:!0},o=await t.createAndRun(i,{...n,signal:this.controller.signal});this._connected();for await(let s of o)g(this,Se,"m",Rh).call(this,s);if(o.controller.signal?.aborted)throw new De;return this._addRun(g(this,Se,"m",Nh).call(this))}async _createAssistantStream(t,r,n,i){this._listenForAbort(i?.signal);let o={...n,stream:!0},s=await t.create(r,o,{...i,signal:this.controller.signal});this._connected();for await(let a of s)g(this,Se,"m",Rh).call(this,a);if(s.controller.signal?.aborted)throw new De;return this._addRun(g(this,Se,"m",Nh).call(this))}static accumulateDelta(t,r){return Ob(t,r)}_addRun(t){return g(this,Se,"m",Wt).call(this,"run",t),t}async _threadAssistantStream(t,r,n){return await this._createThreadAssistantStream(r,t,n)}async _runAssistantStream(t,r,n,i){return await this._createAssistantStream(r,t,n,i)}async _runToolAssistantStream(t,r,n,i){return await this._createToolAssistantStream(r,t,n,i)}};Rh=function(t){if(this.ended)return;let{event:r,exposedEvent:n}=b8(t),i,o,s,a;switch(r.event){case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":{i=g(this,Se,"m",jL).call(this,r),o=r.data;break}case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":{s=g(this,Se,"m",zL).call(this,r),a=r.data;break}}switch(j(this,Ph,n,"f"),g(this,Se,"m",LL).call(this,n),i!==void 0&&o!==void 0&&g(this,Se,"m",$b).call(this,o,i),s!==void 0&&a!==void 0&&g(this,Se,"m",sp).call(this,a,s),s===void 0&&g(this,Vn,"f")!==void 0&&g(this,Ia,"f")&&g(this,Se,"m",sp).call(this,g(this,Ia,"f"),g(this,Vn,"f")),r.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":{g(this,Se,"m",VL).call(this,r);break}case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":{if(s===void 0)throw new A("Received assistant run-step event without a canonical run-step ID");let c=g(this,Lr,"f")[s];c&&g(this,Se,"m",sp).call(this,c,s),g(this,Se,"m",UL).call(this,r,s),g(this,Se,"m",sp).call(this,r.data,s);let u=g(this,Lr,"f")[s];u&&g(this,Se,"m",sp).call(this,u,s);break}case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":{if(g(this,Se,"m",DL).call(this,r),i!==void 0){g(this,Se,"m",$b).call(this,r.data,i);let c=g(this,cp,"f")[i];c&&g(this,Se,"m",$b).call(this,c,i)}break}case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:}},Nh=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");if(!g(this,lu,"f"))throw new Error("Final run has not been received");return g(this,lu,"f")},zL=function(t){let r=Object.getOwnPropertyDescriptor(t.data,"id"),n=r&&"value"in r?r.value:void 0;if(typeof n!="string"||n.length===0)throw new A("Received assistant run-step event with an invalid run-step ID");if(t.event==="thread.run.step.created"){if(g(this,Vn,"f")!==void 0)throw new A(`Received run-step creation for "${n}" before the active run step "${g(this,Vn,"f")}" reached a terminal state`);if(pe(g(this,Lr,"f"),n)||g(this,xa,"f").has(n))throw new A(`Received run-step creation for run step "${n}", which has already been created`);return j(this,Vn,n,"f"),g(this,xa,"f").set(n,n),n}if(g(this,Vn,"f")!==void 0){if(n!==g(this,Vn,"f"))throw new A(`Received ${t.event} for run step "${n}", which does not match the active run step "${g(this,Vn,"f")}"`);return n}if(t.event==="thread.run.step.delta")throw pe(g(this,Lr,"f"),n)?new A(`Received run-step delta for "${n}" with no active run step`):new A("Received a RunStepDelta before creation of a snapshot");if(pe(g(this,Lr,"f"),n)||g(this,xa,"f").has(n))throw new A(`Received run-step event for run step "${n}", which has already been created`);return g(this,xa,"f").set(n,n),t.event==="thread.run.step.in_progress"&&j(this,Vn,n,"f"),n},sp=function(t,r){let n=Object.getOwnPropertyDescriptor(t,"id"),i=n&&"value"in n?n.value:void 0;if(typeof i!="string"||i.length===0)throw new A("Received assistant run-step event with an invalid run-step ID");let o=g(this,xa,"f").get(i);if(o!==void 0&&o!==r)throw new A(`Received run-step creation for run step "${i}", which has already been created`);g(this,xa,"f").set(i,r)},jL=function(t){let r=Object.getOwnPropertyDescriptor(t.data,"id"),n=r&&"value"in r?r.value:void 0;if(typeof n!="string"||n.length===0)throw new A("Received assistant message event with an invalid message ID");if(t.event==="thread.message.created"){if(g(this,en,"f"))throw new A(`Received message creation for "${n}" before the active message "${g(this,Qo,"f")}" reached a terminal state`);if(pe(g(this,cp,"f"),n)||g(this,ap,"f").has(n))throw new A(`Received message creation for message "${n}", which has already been created`);return j(this,Qo,n,"f"),g(this,ap,"f").set(n,n),n}if(!g(this,en,"f"))throw t.event==="thread.message.delta"?new A("Received a delta with no existing snapshot (there should be one from message creation)"):new A("Received thread message event with no existing snapshot");if(n!==g(this,Qo,"f"))throw new A(`Received ${t.event} for message "${n}", which does not match the active message "${g(this,Qo,"f")}"`);return n},$b=function(t,r){let n=Object.getOwnPropertyDescriptor(t,"id"),i=n&&"value"in n?n.value:void 0;if(typeof i!="string"||i.length===0)throw new A("Received assistant message event with an invalid message ID");let o=g(this,ap,"f").get(i);if(o!==void 0&&o!==r)throw new A(`Received message creation for message "${i}", which has already been created`);g(this,ap,"f").set(i,r)},DL=function(t){let[r,n]=g(this,Se,"m",BL).call(this,t,g(this,en,"f"));if(j(this,en,r,"f"),!g(this,Qo,"f"))throw new A("Received thread message event with no active message ID");g(this,cp,"f")[g(this,Qo,"f")]=r;for(let i of n){let o=r.content[i.index];o?.type==="text"&&g(this,Se,"m",Wt).call(this,"textCreated",o.text)}switch(t.event){case"thread.message.created":{j(this,ka,void 0,"f"),j(this,es,void 0,"f"),g(this,Se,"m",Wt).call(this,"messageCreated",t.data);break}case"thread.message.in_progress":break;case"thread.message.delta":{if(g(this,Se,"m",Wt).call(this,"messageDelta",t.data.delta,r),t.data.delta.content)for(let i of t.data.delta.content){if(i.type==="text"&&i.text){let o=i.text,s=r.content[i.index];if(s&&s.type==="text")g(this,Se,"m",Wt).call(this,"textDelta",o,s.text);else throw new Error("The snapshot associated with this text delta is not text or missing")}if(i.index!==g(this,ka,"f")){if(g(this,es,"f"))switch(g(this,es,"f").type){case"text":{g(this,Se,"m",Wt).call(this,"textDone",g(this,es,"f").text,g(this,en,"f"));break}case"image_file":{g(this,Se,"m",Wt).call(this,"imageFileDone",g(this,es,"f").image_file,g(this,en,"f"));break}}j(this,ka,i.index,"f")}j(this,es,r.content[i.index],"f")}break}case"thread.message.completed":case"thread.message.incomplete":{if(g(this,ka,"f")!==void 0){let i=t.data.content[g(this,ka,"f")];if(i)switch(i.type){case"image_file":{g(this,Se,"m",Wt).call(this,"imageFileDone",i.image_file,g(this,en,"f"));break}case"text":{g(this,Se,"m",Wt).call(this,"textDone",i.text,g(this,en,"f"));break}}}g(this,en,"f")&&g(this,Se,"m",Wt).call(this,"messageDone",t.data),j(this,ka,void 0,"f"),j(this,es,void 0,"f"),j(this,en,void 0,"f"),j(this,Qo,void 0,"f")}}},UL=function(t,r){let n=g(this,Se,"m",FL).call(this,t,r);switch(j(this,Ia,n,"f"),t.event){case"thread.run.step.created":{j(this,uu,void 0,"f"),j(this,Qr,void 0,"f"),g(this,Se,"m",Wt).call(this,"runStepCreated",t.data);break}case"thread.run.step.delta":{let i=t.data.delta;if(i.step_details&&i.step_details.type==="tool_calls"&&i.step_details.tool_calls&&n.step_details.type==="tool_calls")for(let o of i.step_details.tool_calls)o.index===g(this,uu,"f")?g(this,Se,"m",Wt).call(this,"toolCallDelta",o,n.step_details.tool_calls[o.index]):(g(this,Qr,"f")&&g(this,Se,"m",Wt).call(this,"toolCallDone",g(this,Qr,"f")),j(this,uu,o.index,"f"),j(this,Qr,n.step_details.tool_calls[o.index],"f"),g(this,Qr,"f")&&g(this,Se,"m",Wt).call(this,"toolCallCreated",g(this,Qr,"f")));g(this,Se,"m",Wt).call(this,"runStepDelta",t.data.delta,n);break}case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":{j(this,Ia,void 0,"f"),j(this,Vn,void 0,"f"),t.data.step_details.type==="tool_calls"&&g(this,Qr,"f")&&g(this,Se,"m",Wt).call(this,"toolCallDone",g(this,Qr,"f")),g(this,Se,"m",Wt).call(this,"runStepDone",t.data,n),j(this,uu,void 0,"f"),j(this,Qr,void 0,"f");break}case"thread.run.step.in_progress":break}},Wt=function(t,...r){if(this._hasListeners(t))for(let n of r)_i(n);this._emit(t,...r)},LL=function(t){g(this,Se,"m",Wt).call(this,"event",t)},FL=function(t,r){switch(t.event){case"thread.run.step.created":return g(this,Lr,"f")[r]=t.data,t.data;case"thread.run.step.delta":{let n=g(this,Lr,"f")[r];if(!n)throw new Error("Received a RunStepDelta before creation of a snapshot");let i=t.data;if(i.delta){let o=Ob(n,i.delta,!0);g(this,Lr,"f")[r]=o}return g(this,Lr,"f")[r]}case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":{g(this,Lr,"f")[r]=t.data;break}}if(g(this,Lr,"f")[r])return g(this,Lr,"f")[r];throw new Error("No snapshot available")},BL=function(t,r){let n=[];switch(t.event){case"thread.message.created":return[t.data,n];case"thread.message.delta":{if(!r)throw new Error("Received a delta with no existing snapshot (there should be one from message creation)");let i=t.data;if(i.delta.content){Eh(i.delta);let o=!Ab(r),s=ML(r.content,i.delta.content,"content",o);for(let a of i.delta.content)if(pe(r.content,a.index)){let c=r.content[a.index];r.content[a.index]=g(this,Se,"m",ZL).call(this,a,c,o)}else FT(r.content,a.index,a),n.push(a);s()}return[r,n]}case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":{if(r)return[r,n];throw new Error("Received thread message event with no existing snapshot")}}throw new Error("Tried to accumulate a non-message event")},ZL=function(t,r,n){return Ob(r,t,n)},VL=function(t){switch(j(this,Ch,t.data,"f"),t.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":{j(this,lu,t.data,"f"),g(this,Qr,"f")&&g(this,Se,"m",Wt).call(this,"toolCallDone",g(this,Qr,"f")),j(this,uu,void 0,"f"),j(this,Qr,void 0,"f");break}case"thread.run.cancelling":break}};function w8(e,t){return new Promise((r,n)=>{let i,o,s=!1,a=l=>{try{t.removeEventListener("abort",l)}catch{}},c=()=>{if(i!==void 0&&(clearTimeout(i),i=void 0),o){let l=o;o=void 0,a(l)}},u=()=>{if(!s){s=!0,c();try{let l=new De;Object.defineProperty(l,"cause",{value:t.reason,writable:!0,configurable:!0}),n(l)}catch(l){n(l)}}};if(t.aborted){u();return}i=setTimeout(()=>{s||(s=!0,c(),r())},e),o=u;try{t.addEventListener("abort",u,{once:!0}),s?a(u):t.aborted&&u()}catch(l){s?a(u):(s=!0,c(),n(l))}})}async function Mh(e,t,r,n){let i=L([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:s}=await e(i).withResponse(),{status:a}=o;if(t.includes(a)){let c=5e3;if(n?.pollIntervalMs)c=n.pollIntervalMs;else{let l=s.headers.get("openai-poll-after-ms");if(l){let d=Number.parseInt(l);Number.isNaN(d)||(c=d)}}let u=n&&Object.prototype.propertyIsEnumerable.call(n,"signal")?n.signal:void 0;await(u?w8(c,u):md(c))}else if(r.includes(a))return o}}function WL(e,t,r,n){return Mh(i=>e.retrieve(t,r,{...n,headers:{...n?.headers,...i}}),["queued","in_progress","cancelling"],["requires_action","incomplete","cancelled","completed","failed","expired"],n)}var du=class extends O{constructor(){super(...arguments),this.steps=new op(this._client)}create(t,r,n){let{include:i,...o}=r;return this._client.post(S`/threads/${t}/runs`,{query:{include:i},body:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve(t,r,n){let{thread_id:i}=r;return this._client.get(S`/threads/${i}/runs/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){let{thread_id:i,...o}=r;return this._client.post(S`/threads/${i}/runs/${t}`,{body:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/threads/${t}/runs`,ve,{query:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}cancel(t,r,n){let{thread_id:i}=r;return this._client.post(S`/threads/${i}/runs/${t}/cancel`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(t,r,n){let i=await this.create(t,r,n);return await this.poll(i.id,{thread_id:t},n)}createAndStream(t,r,n){return Sa.createAssistantStream(t,this._client.beta.threads.runs,r,n)}async poll(t,r,n){return await WL(this,t,r,n)}stream(t,r,n){return Sa.createAssistantStream(t,this._client.beta.threads.runs,r,n)}submitToolOutputs(t,r,n){let{thread_id:i,...o}=r;return this._client.post(S`/threads/${i}/runs/${t}/submit_tool_outputs`,{body:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async submitToolOutputsAndPoll(t,r,n){let i=await this.submitToolOutputs(t,r,n);return await this.poll(i.id,r,n)}submitToolOutputsStream(t,r,n){return Sa.createToolAssistantStream(t,this._client.beta.threads.runs,r,n)}};du.Steps=op;var Aa=class extends O{constructor(){super(...arguments),this.runs=new du(this._client),this.messages=new ip(this._client)}create(t={},r){return this._client.post("/threads",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/threads/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/threads/${t}`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/threads/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}createAndRun(t,r){return this._client.post("/threads/runs",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async createAndRunPoll(t,r){let n=await this.createAndRun(t,r);return await this.runs.poll(n.id,{thread_id:n.thread_id},r)}createAndRunStream(t,r){return Sa.createThreadAssistantStream(t,this._client.beta.threads,r)}};Aa.Runs=du;Aa.Messages=ip;var Wn=class extends O{constructor(){super(...arguments),this.realtime=new _a(this._client),this.responses=new ba(this._client),this.chatkit=new va(this._client),this.assistants=new Xd(this._client),this.threads=new Aa(this._client)}};Wn.Realtime=_a;Wn.Responses=ba;Wn.ChatKit=va;Wn.Assistants=Xd;Wn.Threads=Aa;var pu=class extends O{create(t,r){return this._client.post("/completions",{body:t,...r,stream:t.stream??!1,__security:{bearerAuth:!0}})}};var up=class extends O{retrieve(t,r,n){let{container_id:i}=r;return this._client.get(S`/containers/${i}/files/${t}/content`,{...n,headers:L([{Accept:"application/binary"},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}};var fu=class extends O{constructor(){super(...arguments),this.content=new up(this._client)}create(t,r,n){return this._client.post(S`/containers/${t}/files`,la({body:r,...n,__security:{bearerAuth:!0}},this._client))}retrieve(t,r,n){let{container_id:i}=r;return this._client.get(S`/containers/${i}/files/${t}`,{...n,__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/containers/${t}/files`,ve,{query:r,...n,__security:{bearerAuth:!0}})}delete(t,r,n){let{container_id:i}=r;return this._client.delete(S`/containers/${i}/files/${t}`,{...n,headers:L([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}};fu.Content=up;var Oa=class extends O{constructor(){super(...arguments),this.files=new fu(this._client)}create(t,r){return this._client.post("/containers",{body:t,...r,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/containers/${t}`,{...r,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/containers",ve,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/containers/${t}`,{...r,headers:L([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}};Oa.Files=fu;var mu=class extends O{create(t,r){return this._client.post("/content_provenance_checks",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}};var lp=class extends O{create(t,r,n){let{include:i,...o}=r;return this._client.post(S`/conversations/${t}/items`,{query:{include:i},body:o,...n,__security:{bearerAuth:!0}})}retrieve(t,r,n){let{conversation_id:i,...o}=r;return this._client.get(S`/conversations/${i}/items/${t}`,{query:o,...n,__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/conversations/${t}/items`,qe,{query:r,...n,__security:{bearerAuth:!0}})}delete(t,r,n){let{conversation_id:i}=r;return this._client.delete(S`/conversations/${i}/items/${t}`,{...n,__security:{bearerAuth:!0}})}};var $a=class extends O{constructor(){super(...arguments),this.items=new lp(this._client)}create(t={},r){return this._client.post("/conversations",{body:t,...r,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/conversations/${t}`,{...r,__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/conversations/${t}`,{body:r,...n,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/conversations/${t}`,{...r,__security:{bearerAuth:!0}})}};$a.Items=lp;function qL(e,t,r){let n=!!t.encoding_format,i=n?t.encoding_format:"base64";n&&Mt(e).debug("embeddings/user defined encoding_format:",t.encoding_format);let o=e.post("/embeddings",{body:{...t,encoding_format:i},...r,__security:{bearerAuth:!0}});return n?o:(Mt(e).debug("embeddings/decoding base64 embeddings from base64"),o._thenUnwrap(s=>{if(s&&s.data){let a=s.data,{length:c}=a;for(let u=0;u<c;u+=1)if(u in a){let l=a[u],d=l.embedding;l.embedding=$L(d)}}return s}))}var hu=class extends O{create(t,r){return qL(this._client,t,r)}};var dp=class extends O{retrieve(t,r,n){let{eval_id:i,run_id:o}=r;return this._client.get(S`/evals/${i}/runs/${o}/output_items/${t}`,{...n,__security:{bearerAuth:!0}})}list(t,r,n){let{eval_id:i,...o}=r;return this._client.getAPIList(S`/evals/${i}/runs/${t}/output_items`,ve,{query:o,...n,__security:{bearerAuth:!0}})}};var gu=class extends O{constructor(){super(...arguments),this.outputItems=new dp(this._client)}create(t,r,n){return this._client.post(S`/evals/${t}/runs`,{body:r,...n,__security:{bearerAuth:!0}})}retrieve(t,r,n){let{eval_id:i}=r;return this._client.get(S`/evals/${i}/runs/${t}`,{...n,__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/evals/${t}/runs`,ve,{query:r,...n,__security:{bearerAuth:!0}})}delete(t,r,n){let{eval_id:i}=r;return this._client.delete(S`/evals/${i}/runs/${t}`,{...n,__security:{bearerAuth:!0}})}cancel(t,r,n){let{eval_id:i}=r;return this._client.post(S`/evals/${i}/runs/${t}`,{...n,__security:{bearerAuth:!0}})}};gu.OutputItems=dp;var Ta=class extends O{constructor(){super(...arguments),this.runs=new gu(this._client)}create(t,r){return this._client.post("/evals",{body:t,...r,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/evals/${t}`,{...r,__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/evals/${t}`,{body:r,...n,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/evals",ve,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/evals/${t}`,{...r,__security:{bearerAuth:!0}})}};Ta.Runs=gu;async function KL(e,t,r,n){let i=new Set(["processed","error","deleted"]),o=Date.now(),s=await e.retrieve(t);for(;!s.status||!i.has(s.status);)if(await md(r),s=await e.retrieve(t),Date.now()-o>n)throw new Tt({message:`Giving up on waiting for file ${t} to finish processing after ${n} milliseconds.`});return s}var yu=class extends O{create(t,r){return this._client.post("/files",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}retrieve(t,r){return this._client.get(S`/files/${t}`,{...r,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/files",ve,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/files/${t}`,{...r,__security:{bearerAuth:!0}})}content(t,r){return this._client.get(S`/files/${t}/content`,{...r,headers:L([{Accept:"application/binary"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}async waitForProcessing(t,{pollInterval:r=5e3,maxWait:n=1800*1e3}={}){return await KL(this,t,r,n)}};var pp=class extends O{};var fp=class extends O{run(t,r){return this._client.post("/fine_tuning/alpha/graders/run",{body:t,...r,__security:{bearerAuth:!0}})}validate(t,r){return this._client.post("/fine_tuning/alpha/graders/validate",{body:t,...r,__security:{bearerAuth:!0}})}};var _u=class extends O{constructor(){super(...arguments),this.graders=new fp(this._client)}};_u.Graders=fp;var mp=class extends O{create(t,r,n){return this._client.getAPIList(S`/fine_tuning/checkpoints/${t}/permissions`,Ir,{body:r,method:"post",...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,r={},n){return this._client.get(S`/fine_tuning/checkpoints/${t}/permissions`,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/fine_tuning/checkpoints/${t}/permissions`,qe,{query:r,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,r,n){let{fine_tuned_model_checkpoint:i}=r;return this._client.delete(S`/fine_tuning/checkpoints/${i}/permissions/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};var vu=class extends O{constructor(){super(...arguments),this.permissions=new mp(this._client)}};vu.Permissions=mp;var hp=class extends O{list(t,r={},n){return this._client.getAPIList(S`/fine_tuning/jobs/${t}/checkpoints`,ve,{query:r,...n,__security:{bearerAuth:!0}})}};var bu=class extends O{constructor(){super(...arguments),this.checkpoints=new hp(this._client)}create(t,r){return this._client.post("/fine_tuning/jobs",{body:t,...r,__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/fine_tuning/jobs/${t}`,{...r,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/fine_tuning/jobs",ve,{query:t,...r,__security:{bearerAuth:!0}})}cancel(t,r){return this._client.post(S`/fine_tuning/jobs/${t}/cancel`,{...r,__security:{bearerAuth:!0}})}listEvents(t,r={},n){return this._client.getAPIList(S`/fine_tuning/jobs/${t}/events`,ve,{query:r,...n,__security:{bearerAuth:!0}})}pause(t,r){return this._client.post(S`/fine_tuning/jobs/${t}/pause`,{...r,__security:{bearerAuth:!0}})}resume(t,r){return this._client.post(S`/fine_tuning/jobs/${t}/resume`,{...r,__security:{bearerAuth:!0}})}};bu.Checkpoints=hp;var vi=class extends O{constructor(){super(...arguments),this.methods=new pp(this._client),this.jobs=new bu(this._client),this.checkpoints=new vu(this._client),this.alpha=new _u(this._client)}};vi.Methods=pp;vi.Jobs=bu;vi.Checkpoints=vu;vi.Alpha=_u;var gp=class extends O{};var Ea=class extends O{constructor(){super(...arguments),this.graderModels=new gp(this._client)}};Ea.GraderModels=gp;var wu=class extends O{createVariation(t,r){return this._client.post("/images/variations",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}edit(t,r){return this._client.post("/images/edits",Zt({body:t,...r,stream:t.stream??!1,__metadata:{...r?.__metadata,...t.model==null?{}:{model:t.model}},__security:{bearerAuth:!0}},this._client))}generate(t,r){return this._client.post("/images/generations",{body:t,...r,stream:t.stream??!1,__security:{bearerAuth:!0}})}};var xu=class extends O{retrieve(t,r){return this._client.get(S`/models/${t}`,{...r,__security:{bearerAuth:!0}})}list(t){return this._client.getAPIList("/models",Ir,{...t,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/models/${t}`,{...r,__security:{bearerAuth:!0}})}};var ku=class extends O{create(t,r){return this._client.post("/moderations",{body:t,...r,__security:{bearerAuth:!0}})}};async function GL(e,t,r,n=null){if(e.body===null||typeof e.body!="object"||Array.isArray(e.body))throw new TypeError("Multipart request body must be an object");let i=Object.fromEntries(Object.entries(e.body).filter(([,c])=>c!==void 0));if(n!==null&&Object.keys(i).length===1&&Object.prototype.hasOwnProperty.call(i,n)){let c=i[n];if(typeof c!="string")throw new TypeError("Raw multipart alternative must be a string");return{...e,body:c,headers:L([e.headers,{"content-type":r[n].content_type}])}}let o=[];for(let[c,u]of Object.entries(r)){if(!Object.prototype.hasOwnProperty.call(i,c))continue;let l=i[c],d=u.json?JSON.stringify(l):l;if(typeof d!="string")throw new TypeError(`Multipart field ${c} must encode as a string`);o.push([c,Jo([d],"",{type:u.content_type})]),delete i[c]}let a=(await Zt({...e,body:i},t)).body;if(!(a instanceof FormData))throw await a.cancel(),new TypeError("Unexpected streaming upload in typed multipart request body");for(let[c,u]of o)a.append(c,u,"");return{...e,body:a,headers:L([e.headers,{"content-type":null}])}}var yp=class extends O{create(t,r){return this._client.post("/realtime/calls",GL({body:t,...r,headers:L([{Accept:"application/sdp"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0},this._client,{sdp:{content_type:"application/sdp",json:!1},session:{content_type:"application/json",json:!0}},"sdp"))}accept(t,r,n){return this._client.post(S`/realtime/calls/${t}/accept`,{body:r,...n,headers:L([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}hangup(t,r){return this._client.post(S`/realtime/calls/${t}/hangup`,{...r,headers:L([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}refer(t,r,n){return this._client.post(S`/realtime/calls/${t}/refer`,{body:r,...n,headers:L([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}reject(t,r={},n){return this._client.post(S`/realtime/calls/${t}/reject`,{body:r,...n,headers:L([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}};var _p=class extends O{create(t,r){return this._client.post("/realtime/client_secrets",{body:t,...r,__security:{bearerAuth:!0}})}};var ts=class extends O{constructor(){super(...arguments),this.clientSecrets=new _p(this._client),this.calls=new yp(this._client)}};ts.ClientSecrets=_p;ts.Calls=yp;function HL(e,t){if(!t||!L8(t)){let r={...e,output_parsed:null,output:e.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:n.type==="message"?{...n,content:n.content.map(i=>({...i,parsed:null}))}:n)};return XL(e,r)&&vp(r),r}return BT(e,t)}function BT(e,t){let r=!e.status||e.status==="completed",n=e.output.map(o=>{if(o.type==="function_call")return r?B8(t,o):{...o,parsed_arguments:null};if(o.type==="message"){let s=o.content.map(a=>a.type==="output_text"?{...a,parsed:r?U8(t,a.text):null}:a);return{...o,content:s}}return o}),i={...e,output:n};return XL(e,i)&&vp(i),Object.defineProperty(i,"output_parsed",{enumerable:!0,get(){for(let o of i.output)if(o.type==="message"){for(let s of o.content)if(s.type==="output_text"&&s.parsed!==null)return s.parsed}return null}}),i}function U8(e,t){return hi(e.text?.format,t)}function L8(e){return uo(e.text?.format)?!0:Array.isArray(e.tools)&&e.tools.some(t=>JL(t)||t.type==="function"&&t.strict===!0)}function JL(e){return e?.$brand==="auto-parseable-tool"}function F8(e,t){return e.find(r=>r.type==="function"&&r.name===t)}function B8(e,t){let r=F8(e.tools??[],t.name),n=null;return JL(r)?n=r.$parseRaw(t.arguments):r?.strict&&(n=hi({type:"json_schema",$parseRaw:void 0},t.arguments)),{...t,parsed_arguments:n}}function XL(e,t){return!Object.getOwnPropertyDescriptor(e,"output_text")||t.output_text==null}function vp(e){let t=[];for(let r of e.output)if(r.type==="message")for(let n of r.content)n.type==="output_text"&&t.push(n.text);e.output_text=t.join("")}var bp=class{constructor(){this.capacity=1,this.values=[0,0],this.size=0}get length(){return this.size}append(t){this.size===this.capacity&&this.grow();let r=this.size;this.size+=1,this.update(r,t)}update(t,r){if(!Number.isSafeInteger(t)||t<0||t>=this.size)throw new RangeError(`missing output at index ${t}`);let n=this.capacity+t,i=r-(this.values[n]??0);if(i!==0)for(;n>=1;)this.values[n]=(this.values[n]??0)+i,n=Math.floor(n/2)}prefixSum(t){if(!Number.isSafeInteger(t)||t<0||t>this.size)throw new RangeError(`missing output at index ${t}`);let r=this.capacity,n=this.capacity+t,i=0;for(;r<n;)r%2===1&&(i+=this.values[r]??0,r+=1),n%2===1&&(n-=1,i+=this.values[n]??0),r=Math.floor(r/2),n=Math.floor(n/2);return i}grow(){let t=this.capacity;this.capacity*=2;let r=Array.from({length:this.capacity*2},()=>0);for(let n=0;n<this.size;n+=1)r[this.capacity+n]=this.values[t+n]??0;for(let n=this.capacity-1;n>0;n-=1)r[n]=(r[n*2]??0)+(r[n*2+1]??0);this.values=r}};function ZT(){return{canonicalSnapshot:void 0,outputTextLengths:new WeakMap,outputTextIndex:new bp}}function wp(e,t){if(t.type!=="message")return"";let r="";for(let n of t.content)n.type==="output_text"&&(r+=n.text);return e.outputTextLengths.set(t,r.length),r}function Pa(e,t){if(e.canonicalSnapshot===t)return;let r=new bp,n="";for(let i of t.output){let o=wp(e,i);n+=o,r.append(o.length)}t.output_text=n,e.outputTextIndex=r,e.canonicalSnapshot=t}function QL(e,t){e.canonicalSnapshot=void 0,e.outputTextLengths=new WeakMap,e.outputTextIndex=new bp;let r=structuredClone(t);return!Object.getOwnPropertyDescriptor(r,"output_text")||r.output_text===null||r.output_text===void 0?Pa(e,r):r.output.length===0&&r.output_text===""&&(e.canonicalSnapshot=r),r}function zh(e,t,r,n,i){let o=e.outputTextLengths.get(t);if(o!==void 0){let s=o-n.length+i.length;e.outputTextLengths.set(t,s),e.outputTextIndex.update(r,s)}}function YL(e,t,r){if(t.length===0){e.output_text+=r;return}e.output_text=e.output_text.slice(0,e.output_text.length-t.length)+r}function Z8(e,t,r,n){if(r===void 0||t?.type!=="message")return 0;if(r<t.content.length-r-1){let s=0;for(let a=0;a<r;a+=1){let c=t.content[a];c?.type==="output_text"&&(s+=c.text.length)}return s}let i=0;for(let s=r+1;s<t.content.length;s+=1){let a=t.content[s];a?.type==="output_text"&&(i+=a.text.length)}return(e.outputTextLengths.get(t)??wp(e,t).length)-i-n.length}function xp(e,t,r,n,i,o){if(n===i)return;let s=t.output[r];if(r===t.output.length-1&&(o===void 0||s?.type==="message"&&o===s.content.length-1)){YL(t,n,i);return}let a=Z8(e,s,o,i),c=e.outputTextIndex.prefixSum(r)+a;if(c+n.length===t.output_text.length){YL(t,n,i);return}t.output_text=t.output_text.slice(0,c)+i+t.output_text.slice(c+n.length)}var VT=new WeakMap;function Ca(e,t,r,n=!1){if(!Number.isSafeInteger(t)||t<0||t>e.length||(t===e.length?!n||t in e:!pe(e,t)))throw new A(`missing ${r} at index ${t}`)}function Eb(e,t,r){if(t!==e.length)throw new A(`missing ${r} at index ${t}`);Ca(e,t,r,!0)}function Oe(e,t){Ca(e.output,t,"output");let r=e.output[t];if(!r)throw new A(`missing output at index ${t}`);return r}function WT(e){return e.type==="function_call"||e.type==="custom_tool_call"||e.type==="shell_call"||e.type==="shell_call_output"}function Pb(e,t){if(!pe(e,"type")||typeof e.type!="string")throw new A(`expected an own output item type for ${t}`);let r=e.type==="function_call"||e.type==="custom_tool_call",n=[];if(pe(e,"id")){if(typeof e.id!="string"||e.id.length===0)throw new A(`expected a non-empty output item id for ${t}`);n.push(`id:${e.id}`)}else if(!r)throw new A(`expected a non-empty output item id for ${t}`);if(WT(e)){if(!pe(e,"call_id")||typeof e.call_id!="string"||e.call_id.length===0)throw new A(`expected a non-empty output item call_id for ${t}`);n.push(`call:${e.type}:${e.call_id}`)}return n}function r2(e,t){for(let r of t)if(e.has(r))throw new A(`duplicate output item identity '${r}'`)}function n2(e,t){r2(e,t);for(let r of t)e.add(r)}function i2(e){let t={snapshot:e,output:e.output,length:e.output.length,identities:new Set};for(let r=0;r<e.output.length;r+=1){let n=Oe(e,r);n2(t.identities,Pb(n,"response snapshot"))}return t}function V8(e,t){let r=VT.get(e);if(r&&r.snapshot===t&&r.output===t.output&&r.length===t.output.length)return r;let n=i2(t);return VT.set(e,n),n}function e2(e,t){let r=ZT(),n=QL(r,t),i=i2(n);return e.canonicalSnapshot=r.canonicalSnapshot,e.outputTextLengths=r.outputTextLengths,e.outputTextIndex=r.outputTextIndex,VT.set(e,i),n}var qT={"response.output_text.delta":"message","response.output_text.done":"message","response.output_text.annotation.added":"message","response.refusal.delta":"message","response.refusal.done":"message","response.function_call_arguments.delta":"function_call","response.function_call_arguments.done":"function_call","response.custom_tool_call_input.delta":"custom_tool_call","response.custom_tool_call_input.done":"custom_tool_call","response.mcp_call_arguments.delta":"mcp_call","response.mcp_call_arguments.done":"mcp_call","response.mcp_call.in_progress":"mcp_call","response.mcp_call.completed":"mcp_call","response.mcp_call.failed":"mcp_call","response.shell_call_output_content.delta":"shell_call_output","response.shell_call_output_content.done":"shell_call_output","response.reasoning_text.delta":"reasoning","response.reasoning_text.done":"reasoning","response.reasoning_summary_part.added":"reasoning","response.reasoning_summary_part.done":"reasoning","response.reasoning_summary_text.delta":"reasoning","response.reasoning_summary_text.done":"reasoning","response.code_interpreter_call_code.delta":"code_interpreter_call","response.code_interpreter_call_code.done":"code_interpreter_call","response.code_interpreter_call.in_progress":"code_interpreter_call","response.code_interpreter_call.interpreting":"code_interpreter_call","response.code_interpreter_call.completed":"code_interpreter_call","response.file_search_call.in_progress":"file_search_call","response.file_search_call.searching":"file_search_call","response.file_search_call.completed":"file_search_call","response.web_search_call.in_progress":"web_search_call","response.web_search_call.searching":"web_search_call","response.web_search_call.completed":"web_search_call","response.image_generation_call.in_progress":"image_generation_call","response.image_generation_call.generating":"image_generation_call","response.image_generation_call.completed":"image_generation_call","response.image_generation_call.partial_image":"image_generation_call","response.mcp_list_tools.in_progress":"mcp_list_tools","response.mcp_list_tools.completed":"mcp_list_tools","response.mcp_list_tools.failed":"mcp_list_tools"};function W8(e){return e.type==="response.content_part.added"||e.type==="response.content_part.done"?e.part.type==="reasoning_text"?"reasoning":"message":qT[e.type]}function q8(e,t){let r=Oe(t,e.output_index),n=e.item;if(Pb(r,e.type),Pb(n,e.type),!pe(n,"type")||r.type!==n.type)throw new A(`expected output item type '${r.type}', got '${n.type}'`);let i=pe(r,"id")?r.id:void 0,o=pe(n,"id")?n.id:void 0;if(i!==o)throw new A(`expected output item id '${i}', got '${o}'`);if(WT(r)&&WT(n)&&r.call_id!==n.call_id)throw new A(`expected output item call_id '${r.call_id}', got '${n.call_id}'`)}function K8(e,t,r){if(e.type==="response.output_item.done"){q8(e,t);return}if(r&&(e.type==="response.shell_call_command.added"||e.type==="response.shell_call_command.delta"||e.type==="response.shell_call_command.done")){let a=Oe(t,e.output_index);if(!pe(a,"type")||a.type!=="shell_call")throw new A(`expected output item type 'shell_call', got '${a.type}'`);return}if(e.type!=="response.content_part.added"&&e.type!=="response.content_part.done"&&!pe(qT,e.type))return;let n=e;if(!pe(e,"item_id")||typeof n.item_id!="string"||n.item_id.length===0)throw new A(`expected a non-empty item_id for ${e.type}`);let i=Oe(t,n.output_index),o=pe(i,"id")?i.id:void 0;if(o!==n.item_id)throw new A(`expected item_id '${o}', got '${n.item_id}'`);let s=W8(n);if(i.type!==s)throw new A(`expected output item type '${s}', got '${i.type}'`)}function tn(e,t){Ca(e,t,"content");let r=e[t];if(!r)throw new A(`missing content at index ${t}`);return r}function t2(e,t,r){let n=e.output.find(i=>i.type==="shell_call"&&i.call_id===t.call_id);for(n?Ca(n.action.commands,r,"command"):Ca(t.output,r,"content",!0);t.output.length<=r;)t.output.push({stdout:"",stderr:"",outcome:{type:"exit",exit_code:0}});return tn(t.output,r)}function G8(e){return new Set(e)}var H8=G8(["response.output_item.added","response.output_item.done","response.content_part.added","response.content_part.done","response.output_text.delta","response.output_text.done","response.output_text.annotation.added","response.refusal.delta","response.refusal.done","response.function_call_arguments.delta","response.function_call_arguments.done","response.custom_tool_call_input.delta","response.custom_tool_call_input.done","response.mcp_call_arguments.delta","response.mcp_call_arguments.done","response.shell_call_command.added","response.shell_call_command.done","response.shell_call_command.delta","response.shell_call_output_content.delta","response.shell_call_output_content.done","response.reasoning_text.delta","response.reasoning_text.done","response.reasoning_summary_part.added","response.reasoning_summary_part.done","response.reasoning_summary_text.delta","response.reasoning_summary_text.done","response.code_interpreter_call_code.delta","response.code_interpreter_call_code.done","response.code_interpreter_call.in_progress","response.code_interpreter_call.interpreting","response.code_interpreter_call.completed","response.file_search_call.in_progress","response.file_search_call.searching","response.file_search_call.completed","response.web_search_call.in_progress","response.web_search_call.searching","response.web_search_call.completed","response.image_generation_call.in_progress","response.image_generation_call.generating","response.image_generation_call.completed","response.mcp_call.in_progress","response.mcp_call.completed","response.mcp_call.failed","response.created","response.queued","response.in_progress","response.completed","response.failed","response.incomplete","response.audio.delta","response.audio.done","response.audio.transcript.delta","response.audio.transcript.done","response.image_generation_call.partial_image","response.mcp_list_tools.in_progress","response.mcp_list_tools.completed","response.mcp_list_tools.failed","keepalive","error"]);function Tb(e){throw new A("Unhandled response stream event: unknown")}var J8=["item_id","output_index","content_index","annotation_index","command_index","summary_index"];function X8(e){let t;try{t=Object.getOwnPropertyDescriptor(e,"type")}catch{return Tb(e)}let r=t?.value;if(typeof r!="string"||!H8.has(r))return Tb(e);let n=new Map([["type",r]]);if(r==="response.output_item.added"||r==="response.output_item.done"||r==="response.content_part.added"||r==="response.content_part.done"||r==="response.shell_call_command.added"||r==="response.shell_call_command.delta"||r==="response.shell_call_command.done"||pe(qT,r))try{for(let o of J8){let s=Object.getOwnPropertyDescriptor(e,o);n.set(o,s?Reflect.get(e,o,e):void 0)}r==="response.output_item.done"?n.set("item",structuredClone(Reflect.get(e,"item",e))):(r==="response.content_part.added"||r==="response.content_part.done")&&n.set("part",structuredClone(Reflect.get(e,"part",e)))}catch{return Tb(e)}return new Proxy(e,{get(o,s){return n.has(s)?n.get(s):Reflect.get(o,s,o)}})}function Y8(e,t,r){switch(e.type){case"response.output_item.added":{Eb(t.output,e.output_index,"output");let n=V8(r,t),i=structuredClone(e.item),o=Pb(i,e.type);r2(n.identities,o),i.type==="message"&&Pa(r,t),t.output.push(i),n2(n.identities,o),n.length=t.output.length;let s=wp(r,i);return r.canonicalSnapshot===t&&r.outputTextIndex.append(s.length),s&&(t.output_text+=s),!0}case"response.output_item.done":{let n=Oe(t,e.output_index),i=wp(r,n),o=e.item;(n.type==="message"||o.type==="message")&&Pa(r,t),t.output[e.output_index]=o;let s=wp(r,o);return r.canonicalSnapshot===t&&r.outputTextIndex.update(e.output_index,s.length),xp(r,t,e.output_index,i,s),!0}default:return!1}}function Q8(e,t,r){switch(e.type){case"response.content_part.added":{let n=Oe(t,e.output_index),{type:i}=n,{part:o}=e;if(i==="message"&&o.type!=="reasoning_text"){Eb(n.content,e.content_index,"content");let s=o;s.type==="output_text"&&Pa(r,t),n.content.push(s),s.type==="output_text"&&(zh(r,n,e.output_index,"",s.text),xp(r,t,e.output_index,"",s.text,e.content_index))}else if(i==="reasoning"&&o.type==="reasoning_text"){let s=n.content??[];Eb(s,e.content_index,"content"),n.content||(n.content=s),s.push(o)}return!0}default:return!1}}function eX(e,t,r){switch(e.type){case"response.content_part.done":{let n=Oe(t,e.output_index),{part:i}=e;if(n.type==="message"&&i.type!=="reasoning_text"){let o=tn(n.content,e.content_index),s=o.type==="output_text"?o.text:"",a=i;(o.type==="output_text"||a.type==="output_text")&&Pa(r,t),n.content[e.content_index]=a;let c=a.type==="output_text"?a.text:"";zh(r,n,e.output_index,s,c),xp(r,t,e.output_index,s,c,e.content_index)}else if(n.type==="reasoning"&&i.type==="reasoning_text"){let{content:o}=n;if(!o)throw new A(`missing content at index ${e.content_index}`);tn(o,e.content_index),o[e.content_index]=i}return!0}default:return!1}}function tX(e,t,r){switch(e.type){case"response.output_text.delta":{let n=Oe(t,e.output_index);if(n.type==="message"){let i=tn(n.content,e.content_index);if(i.type!=="output_text")throw new A(`expected content to be 'output_text', got ${i.type}`);let o=i.text;Pa(r,t),i.text=o+e.delta,zh(r,n,e.output_index,o,i.text),e.output_index===t.output.length-1&&e.content_index===n.content.length-1?t.output_text+=e.delta:xp(r,t,e.output_index,o,i.text,e.content_index)}return!0}case"response.output_text.done":{let n=Oe(t,e.output_index);if(n.type==="message"){let i=tn(n.content,e.content_index);if(i.type!=="output_text")throw new A(`expected content to be 'output_text', got ${i.type}`);let o=i.text;Pa(r,t),i.text=e.text,zh(r,n,e.output_index,o,e.text),xp(r,t,e.output_index,o,e.text,e.content_index)}return!0}case"response.output_text.annotation.added":{let n=Oe(t,e.output_index);if(n.type==="message"){let i=tn(n.content,e.content_index);if(i.type!=="output_text")throw new A(`expected content to be 'output_text', got ${i.type}`);Ca(i.annotations,e.annotation_index,"annotation",!0),i.annotations[e.annotation_index]=structuredClone(e.annotation)}return!0}default:return!1}}function rX(e,t){switch(e.type){case"response.refusal.delta":{let r=Oe(t,e.output_index);if(r.type==="message"){let n=tn(r.content,e.content_index);if(n.type!=="refusal")throw new A(`expected content to be 'refusal', got ${n.type}`);n.refusal+=e.delta}return!0}case"response.refusal.done":{let r=Oe(t,e.output_index);if(r.type==="message"){let n=tn(r.content,e.content_index);if(n.type!=="refusal")throw new A(`expected content to be 'refusal', got ${n.type}`);n.refusal=e.refusal}return!0}case"response.function_call_arguments.delta":{let r=Oe(t,e.output_index);return r.type==="function_call"&&(r.arguments+=e.delta),!0}case"response.function_call_arguments.done":{let r=Oe(t,e.output_index);return r.type==="function_call"&&(r.arguments=e.arguments),!0}case"response.custom_tool_call_input.delta":{let r=Oe(t,e.output_index);return r.type==="custom_tool_call"&&(r.input+=e.delta),!0}case"response.custom_tool_call_input.done":{let r=Oe(t,e.output_index);return r.type==="custom_tool_call"&&(r.input=e.input),!0}case"response.mcp_call_arguments.delta":{let r=Oe(t,e.output_index);return r.type==="mcp_call"&&(r.arguments+=e.delta),!0}case"response.mcp_call_arguments.done":{let r=Oe(t,e.output_index);return r.type==="mcp_call"&&(r.arguments=e.arguments),!0}default:return!1}}function nX(e,t){switch(e.type){case"response.shell_call_command.added":case"response.shell_call_command.done":{let r=Oe(t,e.output_index);if(r.type==="shell_call"){let n=e.type==="response.shell_call_command.added";Ca(r.action.commands,e.command_index,"command",n),r.action.commands[e.command_index]=e.command}return!0}case"response.shell_call_command.delta":{let r=Oe(t,e.output_index);return r.type==="shell_call"&&(Ca(r.action.commands,e.command_index,"command"),r.action.commands[e.command_index]+=e.delta),!0}case"response.shell_call_output_content.delta":{let r=Oe(t,e.output_index);if(r.type==="shell_call_output"){let n=t2(t,r,e.command_index);n.stdout+=e.delta.stdout??"",n.stderr+=e.delta.stderr??""}return!0}case"response.shell_call_output_content.done":{let r=Oe(t,e.output_index);if(r.type==="shell_call_output"){let n=tn(e.output,0);t2(t,r,e.command_index),r.output[e.command_index]=structuredClone(n)}return!0}default:return!1}}function iX(e,t){switch(e.type){case"response.reasoning_text.delta":{let r=Oe(t,e.output_index);if(r.type==="reasoning"){if(!r.content)throw new A(`missing content at index ${e.content_index}`);let n=tn(r.content,e.content_index);if(n.type!=="reasoning_text")throw new A(`expected content to be 'reasoning_text', got ${n.type}`);n.text+=e.delta}return!0}case"response.reasoning_text.done":{let r=Oe(t,e.output_index);if(r.type==="reasoning"){if(!r.content)throw new A(`missing content at index ${e.content_index}`);let n=tn(r.content,e.content_index);if(n.type!=="reasoning_text")throw new A(`expected content to be 'reasoning_text', got ${n.type}`);n.text=e.text}return!0}case"response.reasoning_summary_part.added":{let r=Oe(t,e.output_index);return r.type==="reasoning"&&(Eb(r.summary,e.summary_index,"content"),r.summary.push(structuredClone(e.part))),!0}case"response.reasoning_summary_part.done":{let r=Oe(t,e.output_index);return r.type==="reasoning"&&(tn(r.summary,e.summary_index),r.summary[e.summary_index]=structuredClone(e.part)),!0}case"response.reasoning_summary_text.delta":{let r=Oe(t,e.output_index);if(r.type==="reasoning"){let n=tn(r.summary,e.summary_index);n.text+=e.delta}return!0}case"response.reasoning_summary_text.done":{let r=Oe(t,e.output_index);if(r.type==="reasoning"){let n=tn(r.summary,e.summary_index);n.text=e.text}return!0}default:return!1}}function oX(e,t){switch(e.type){case"response.code_interpreter_call_code.delta":{let r=Oe(t,e.output_index);return r.type==="code_interpreter_call"&&(r.code=(r.code??"")+e.delta),!0}case"response.code_interpreter_call_code.done":{let r=Oe(t,e.output_index);return r.type==="code_interpreter_call"&&(r.code=e.code),!0}case"response.code_interpreter_call.in_progress":{let r=Oe(t,e.output_index);return r.type==="code_interpreter_call"&&(r.status="in_progress"),!0}case"response.code_interpreter_call.interpreting":{let r=Oe(t,e.output_index);return r.type==="code_interpreter_call"&&(r.status="interpreting"),!0}case"response.code_interpreter_call.completed":{let r=Oe(t,e.output_index);return r.type==="code_interpreter_call"&&(r.status="completed"),!0}default:return!1}}function sX(e,t){switch(e.type){case"response.file_search_call.in_progress":{let r=Oe(t,e.output_index);return r.type==="file_search_call"&&(r.status="in_progress"),!0}case"response.file_search_call.searching":{let r=Oe(t,e.output_index);return r.type==="file_search_call"&&(r.status="searching"),!0}case"response.file_search_call.completed":{let r=Oe(t,e.output_index);return r.type==="file_search_call"&&(r.status="completed"),!0}case"response.web_search_call.in_progress":{let r=Oe(t,e.output_index);return r.type==="web_search_call"&&(r.status="in_progress"),!0}case"response.web_search_call.searching":{let r=Oe(t,e.output_index);return r.type==="web_search_call"&&(r.status="searching"),!0}case"response.web_search_call.completed":{let r=Oe(t,e.output_index);return r.type==="web_search_call"&&(r.status="completed"),!0}default:return!1}}function aX(e,t){switch(e.type){case"response.image_generation_call.in_progress":{let r=Oe(t,e.output_index);return r.type==="image_generation_call"&&(r.status="in_progress"),!0}case"response.image_generation_call.generating":{let r=Oe(t,e.output_index);return r.type==="image_generation_call"&&(r.status="generating"),!0}case"response.image_generation_call.completed":{let r=Oe(t,e.output_index);return r.type==="image_generation_call"&&(r.status="completed"),!0}case"response.mcp_call.in_progress":{let r=Oe(t,e.output_index);return r.type==="mcp_call"&&(r.status="in_progress"),!0}case"response.mcp_call.completed":{let r=Oe(t,e.output_index);return r.type==="mcp_call"&&(r.status="completed"),!0}case"response.mcp_call.failed":{let r=Oe(t,e.output_index);return r.type==="mcp_call"&&(r.status="failed"),!0}default:return!1}}function cX(e){switch(e.type){case"response.created":case"response.queued":case"response.in_progress":case"response.completed":case"response.failed":case"response.incomplete":return!0;default:return!1}}function uX(e){switch(e.type){case"response.audio.delta":case"response.audio.done":case"response.audio.transcript.delta":case"response.audio.transcript.done":case"response.image_generation_call.partial_image":case"response.mcp_list_tools.in_progress":case"response.mcp_list_tools.completed":case"response.mcp_list_tools.failed":case"keepalive":case"error":return!0;default:return!1}}function Cb(){return ZT()}function o2(e,t,r,n=!1,i){let o=X8(e);if(i&&o.type!=="keepalive"&&i(o),!t){if(o.type!=="response.created")throw new A(`When snapshot hasn't been set yet, expected 'response.created' event, got ${o.type}`);return e2(r,o.response)}return K8(o,t,n),Y8(o,t,r)||Q8(o,t,r)||eX(o,t,r)||tX(o,t,r)||rX(o,t)||nX(o,t)||iX(o,t)||oX(o,t)||sX(o,t)||aX(o,t)?t:cX(o)?e2(r,o.response):uX(o)?t:Tb(o)}var Ra,Rb,Iu,Nb,jh,KT,GT,HT,Mb=class e extends pa{constructor(t){super(),Ra.add(this),Rb.set(this,void 0),Iu.set(this,void 0),Nb.set(this,void 0),jh.set(this,Cb()),j(this,Rb,t,"f")}static createResponse(t,r,n){let i=new e(r);return i._run(()=>i._createOrRetrieveResponse(t,r,{...n,__metadata:{...n?.__metadata,helperMethod:"stream"}})),i}static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}async _createOrRetrieveResponse(t,r,n){this._listenForAbort(n?.signal),g(this,Ra,"m",KT).call(this);let i,o=null;"response_id"in r?(i=await t.responses.retrieve(r.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),o=r.starting_after??null):i=await t.responses.create({...r,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let s of i)g(this,Ra,"m",GT).call(this,s,o);if(i.controller.signal?.aborted)throw new De;return g(this,Ra,"m",HT).call(this)}async _fromReadableStream(t,r){this._listenForAbort(r?.signal),g(this,Ra,"m",KT).call(this),this._connected();let n=Yr.fromReadableStream(t,this.controller);for await(let i of n)g(this,Ra,"m",GT).call(this,i,null);if(n.controller.signal?.aborted)throw new De;return g(this,Ra,"m",HT).call(this)}[(Rb=new WeakMap,Iu=new WeakMap,Nb=new WeakMap,jh=new WeakMap,Ra=new WeakSet,KT=function(){this.ended||(j(this,Iu,void 0,"f"),j(this,jh,Cb(),"f"))},GT=function(r,n){if(this.ended)return;let i=(a,c)=>{(n==null||c.sequence_number>n)&&this._emit(a,c)};if(r.type==="error"){let a="error"in r&&typeof r.error=="object"&&r.error!==null?r.error:r;throw new pt(void 0,a,r.message,void 0)}let o=r,s=o2(r,g(this,Iu,"f"),g(this,jh,"f"),!0,a=>{o=a});switch(j(this,Iu,s,"f"),i("event",r),o.type){case"response.output_text.delta":{let a=s.output[o.output_index];if(!a)throw new A(`missing output at index ${o.output_index}`);if(a.type==="message"){let c=a.content[o.content_index];if(!c)throw new A(`missing content at index ${o.content_index}`);if(c.type!=="output_text")throw new A(`expected content to be 'output_text', got ${c.type}`);i("response.output_text.delta",{...o,type:o.type,item_id:o.item_id,output_index:o.output_index,content_index:o.content_index,snapshot:c.text})}break}case"response.function_call_arguments.delta":{let a=s.output[o.output_index];if(!a)throw new A(`missing output at index ${o.output_index}`);a.type==="function_call"&&i("response.function_call_arguments.delta",{...o,type:o.type,item_id:o.item_id,output_index:o.output_index,snapshot:a.arguments});break}default:{i(o.type,r);break}}},HT=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let r=g(this,Iu,"f");if(!r)throw new A("request ended without sending any events");j(this,Iu,void 0,"f"),j(this,jh,Cb(),"f");let n=lX(r,g(this,Rb,"f"));return j(this,Nb,n,"f"),n},Symbol.asyncIterator)](){return this._createIterator(t=>{let r=n=>t(n);return this.on("event",r),()=>this.off("event",r)},{onReturn:()=>this.abort()})}async finalResponse(){await this.done();let t=g(this,Nb,"f");if(!t)throw new A("stream ended without producing a Response");return t}};function lX(e,t){return HL(e,t)}var kp=class extends O{list(t,r={},n){return this._client.getAPIList(S`/responses/${t}/input_items`,ve,{query:r,...n,__security:{bearerAuth:!0}})}};var Ip=class extends O{count(t={},r){return this._client.post("/responses/input_tokens",{body:t,...r,__security:{bearerAuth:!0}})}};var fo=class extends O{constructor(){super(...arguments),this.inputItems=new kp(this._client),this.inputTokens=new Ip(this._client)}create(t,r){return this._client.post("/responses",{body:t,...r,stream:t.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(n=>("object"in n&&n.object==="response"&&vp(n),n))}retrieve(t,r={},n){return this._client.get(S`/responses/${t}`,{query:r,...n,stream:r?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(i=>("object"in i&&i.object==="response"&&vp(i),i))}delete(t,r){return this._client.delete(S`/responses/${t}`,{...r,headers:L([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}parse(t,r){return this._client.responses.create(t,r)._thenUnwrap(n=>BT(n,t))}stream(t,r){return Mb.createResponse(this._client,t,r)}cancel(t,r){return this._client.post(S`/responses/${t}/cancel`,{...r,__security:{bearerAuth:!0}})}compact(t,r){return this._client.post("/responses/compact",{body:t,...r,__security:{bearerAuth:!0}})}};fo.InputItems=kp;fo.InputTokens=Ip;var Sp=class extends O{retrieve(t,r){return this._client.get(S`/safety/alerts/${t}`,{...r,__security:{bearerAuth:!0}})}};var Na=class extends O{constructor(){super(...arguments),this.alerts=new Sp(this._client)}};Na.Alerts=Sp;var Ap=class extends O{retrieve(t,r){return this._client.get(S`/skills/${t}/content`,{...r,headers:L([{Accept:"application/binary"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}};var Op=class extends O{retrieve(t,r,n){let{skill_id:i}=r;return this._client.get(S`/skills/${i}/versions/${t}/content`,{...n,headers:L([{Accept:"application/binary"},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}};var Su=class extends O{constructor(){super(...arguments),this.content=new Op(this._client)}create(t,r={},n){return this._client.post(S`/skills/${t}/versions`,la({body:r,...n,__security:{bearerAuth:!0}},this._client,{stripFilenames:!1}))}retrieve(t,r,n){let{skill_id:i}=r;return this._client.get(S`/skills/${i}/versions/${t}`,{...n,__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/skills/${t}/versions`,ve,{query:r,...n,__security:{bearerAuth:!0}})}delete(t,r,n){let{skill_id:i}=r;return this._client.delete(S`/skills/${i}/versions/${t}`,{...n,__security:{bearerAuth:!0}})}};Su.Content=Op;var rs=class extends O{constructor(){super(...arguments),this.content=new Ap(this._client),this.versions=new Su(this._client)}create(t={},r){return this._client.post("/skills",la({body:t,...r,__security:{bearerAuth:!0}},this._client,{stripFilenames:!1}))}retrieve(t,r){return this._client.get(S`/skills/${t}`,{...r,__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/skills/${t}`,{body:r,...n,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/skills",ve,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/skills/${t}`,{...r,__security:{bearerAuth:!0}})}};rs.Content=Ap;rs.Versions=Su;var $p=class extends O{create(t,r,n){return this._client.post(S`/uploads/${t}/parts`,Zt({body:r,...n,__security:{bearerAuth:!0}},this._client))}};var Ma=class extends O{constructor(){super(...arguments),this.parts=new $p(this._client)}create(t,r){return this._client.post("/uploads",{body:t,...r,__security:{bearerAuth:!0}})}cancel(t,r){return this._client.post(S`/uploads/${t}/cancel`,{...r,__security:{bearerAuth:!0}})}complete(t,r,n){return this._client.post(S`/uploads/${t}/complete`,{body:r,...n,__security:{bearerAuth:!0}})}};Ma.Parts=$p;function s2(e,t,r,n){return Mh(i=>e.retrieve(r,{vector_store_id:t},{...n,headers:i}),["in_progress"],["failed","completed"],n)}function a2(e,t,r,n){return Mh(i=>e.retrieve(r,{vector_store_id:t},{...n,headers:i}),["in_progress"],["failed","cancelled","completed"],n)}var c2=async e=>{let t=await Promise.allSettled(e),r=t.filter(i=>i.status==="rejected");if(r.length)throw Object.defineProperty(new Error(`${r.length} promise(s) failed`),"rejections",{configurable:!0,value:r.map(({reason:i})=>i),writable:!0});let n=[];for(let i of t)i.status==="fulfilled"&&n.push(i.value);return n};async function u2(e,t,r,n,i,o){if(n==null||n.length===0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let s=o?.maxConcurrency??5,a=Math.min(s,n.length),c=n.values(),u=[...i];async function l(p){for(let f of p){let m=await t.files.create({file:f,purpose:"assistants"},o);u.push(m.id)}}let d=[];d.length=a;for(let p=0;p<d.length;p+=1)d[p]=l(c);return await c2(d),await e.createAndPoll(r,{file_ids:u},o)}var Tp=class extends O{create(t,r,n){return this._client.post(S`/vector_stores/${t}/file_batches`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r,n){let{vector_store_id:i}=r;return this._client.get(S`/vector_stores/${i}/file_batches/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}cancel(t,r,n){let{vector_store_id:i}=r;return this._client.post(S`/vector_stores/${i}/file_batches/${t}/cancel`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(t,r,n){let i=await this.create(t,r,n);return await this.poll(t,i.id,n)}listFiles(t,r,n){let{vector_store_id:i,...o}=r;return this._client.getAPIList(S`/vector_stores/${i}/file_batches/${t}/files`,ve,{query:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}async poll(t,r,n){return await a2(this,t,r,n)}async uploadAndPoll(t,{files:r,fileIds:n=[]},i){return await u2(this,this._client,t,r,n,i)}};var Ep=class extends O{create(t,r,n){return this._client.post(S`/vector_stores/${t}/files`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r,n){let{vector_store_id:i}=r;return this._client.get(S`/vector_stores/${i}/files/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){let{vector_store_id:i,...o}=r;return this._client.post(S`/vector_stores/${i}/files/${t}`,{body:o,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t,r={},n){return this._client.getAPIList(S`/vector_stores/${t}/files`,ve,{query:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}delete(t,r,n){let{vector_store_id:i}=r;return this._client.delete(S`/vector_stores/${i}/files/${t}`,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(t,r,n){let i=await this.create(t,r,n);return await this.poll(t,i.id,n)}async poll(t,r,n){return await s2(this,t,r,n)}async upload(t,r,n){let i=await this._client.files.create({file:r,purpose:"assistants"},n);return this.create(t,{file_id:i.id},n)}async uploadAndPoll(t,r,n){let i=await this.upload(t,r,n);return await this.poll(t,i.id,n)}content(t,r,n){let{vector_store_id:i}=r;return this._client.getAPIList(S`/vector_stores/${i}/files/${t}/content`,Ir,{...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}};var ns=class extends O{constructor(){super(...arguments),this.files=new Ep(this._client),this.fileBatches=new Tp(this._client)}create(t,r){return this._client.post("/vector_stores",{body:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,r){return this._client.get(S`/vector_stores/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}update(t,r,n){return this._client.post(S`/vector_stores/${t}`,{body:r,...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/vector_stores",ve,{query:t,...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/vector_stores/${t}`,{...r,headers:L([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}search(t,r,n){return this._client.getAPIList(S`/vector_stores/${t}/search`,Ir,{body:r,method:"post",...n,headers:L([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}};ns.Files=Ep;ns.FileBatches=Tp;var Au=class extends O{create(t,r){return this._client.post("/videos",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}retrieve(t,r){return this._client.get(S`/videos/${t}`,{...r,__security:{bearerAuth:!0}})}list(t={},r){return this._client.getAPIList("/videos",qe,{query:t,...r,__security:{bearerAuth:!0}})}delete(t,r){return this._client.delete(S`/videos/${t}`,{...r,__security:{bearerAuth:!0}})}createCharacter(t,r){return this._client.post("/videos/characters",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}downloadContent(t,r={},n){return this._client.get(S`/videos/${t}/content`,{query:r,...n,headers:L([{Accept:"application/binary"},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit(t,r){return this._client.post("/videos/edits",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}extend(t,r){return this._client.post("/videos/extensions",Zt({body:t,...r,__security:{bearerAuth:!0}},this._client))}getCharacter(t,r){return this._client.get(S`/videos/characters/${t}`,{...r,__security:{bearerAuth:!0}})}remix(t,r,n){return this._client.post(S`/videos/${t}/remix`,la({body:r,...n,__security:{bearerAuth:!0}},this._client))}};var l2=32,bX=32;function JT(e){return e.split(" ",l2+1).length>l2}function*XT(e){let t=0;for(;t<=e.length;){let r=e.indexOf(" ",t),n=e.slice(t,r===-1?void 0:r);if(yield n.startsWith("v1,")?n.slice(3):n,r===-1)break;t=r+1}}function d2(e){try{let t=Ib(e);return t.byteLength===bX?t:void 0}catch{return}}function wX(e){for(let t of XT(e)){let r=d2(t);if(r)return r}}function xX(e,t,r){let n=r;for(let i of XT(e)){let o=d2(i);if(!o)continue;let s=0;for(let[a,c]of o.entries())s|=c^(t[a]??0);s===0&&(n=o)}return n}async function p2(e,t,r,n,i,o){let s=Number.parseInt(r,10);if(Number.isNaN(s))throw new Xr("Invalid webhook timestamp format");let a=Math.floor(Date.now()/1e3);if(a-s>o)throw new Xr("Webhook timestamp is too old");if(s>a+o)throw new Xr("Webhook timestamp is too new");let c=JT(t),u=c?wX(t):void 0;if(c&&!u)throw new Xr("The given webhook signature does not match the expected signature");let l=Uint8Array.from(i.startsWith("whsec_")?Ib(i.slice(6)):pr(i)),d=n?`${n}.${r}.${e}`:`${r}.${e}`,p=Uint8Array.from(pr(d)),f=await crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!1,c?["sign","verify"]:["verify"]);if(c&&u){let m=new Uint8Array(await crypto.subtle.sign("HMAC",f,p)),h=xX(t,m,u);try{if(await crypto.subtle.verify("HMAC",f,Uint8Array.from(h),p))return}catch{}throw new Xr("The given webhook signature does not match the expected signature")}for(let m of XT(t))try{let h=Uint8Array.from(Ib(m));if(await crypto.subtle.verify("HMAC",f,h,p))return}catch{}throw new Xr("The given webhook signature does not match the expected signature")}var Pp,f2,zb,Ou=class extends O{constructor(){super(...arguments),Pp.add(this)}async unwrap(t,r,n=this._client.webhookSecret,i=300){return await this.verifySignature(t,r,n,i),JSON.parse(t)}async verifySignature(t,r,n=this._client.webhookSecret,i=300){if(typeof crypto>"u"||typeof crypto.subtle?.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");g(this,Pp,"m",f2).call(this,n);let o=L([r]).values,s=g(this,Pp,"m",zb).call(this,o,"webhook-signature"),a=g(this,Pp,"m",zb).call(this,o,"webhook-timestamp"),c=g(this,Pp,"m",zb).call(this,o,"webhook-id");if(JT(s)&&typeof crypto.subtle.sign!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");return await p2(t,s,a,c,n,i)}};Pp=new WeakSet,f2=function(t){if(typeof t!="string"||t.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},zb=function(t,r){if(!t)throw new Error("Headers are required");let n=t.get(r);if(n==null)throw new Error(`Missing required header: ${r}`);return n};var h2=Symbol.for("openai.node.providerDefinitions.v1"),g2=globalThis,y2=g2[h2],_2=y2??new WeakMap;y2||Object.defineProperty(g2,h2,{value:_2});function v2(e){let t=_2.get(e);if(!t)throw new Error("Invalid provider. Providers must be created with createProvider().");return t.configure()}var YT,bi,Dh,vt,jb,is,Lh,Uh,k2;function b2(){if(r4())return!0;let e=globalThis;return typeof e.WorkerGlobalScope=="function"&&e instanceof e.WorkerGlobalScope&&typeof e.WorkerNavigator=="function"&&e.navigator instanceof e.WorkerNavigator&&typeof e.navigator?.userAgent=="string"&&e.navigator.userAgent!=="Cloudflare-Workers"&&e.process?.versions?.node===void 0&&e.Deno===void 0&&e.Bun===void 0&&e.EdgeRuntime===void 0&&e.WebSocketPair===void 0}var kX="workload-identity-auth",w2=Symbol("inheritedDataResidencySelection"),fe=class{constructor(t={}){YT.add(this),Dh.set(this,void 0),vt.set(this,void 0),jb.set(this,void 0),is.set(this,void 0),Lh.set(this,!1),Uh.set(this,new WeakMap),this.completions=new pu(this),this.chat=new ha(this),this.embeddings=new hu(this),this.files=new yu(this),this.images=new wu(this),this.contentProvenanceChecks=new mu(this),this.audio=new po(this),this.moderations=new ku(this),this.models=new xu(this),this.fineTuning=new vi(this),this.graders=new Ea(this),this.vectorStores=new ns(this),this.safety=new Na(this),this.webhooks=new Ou(this),this.beta=new Wn(this),this.batches=new cu(this),this.uploads=new Ma(this),this.admin=new ya(this),this.responses=new fo(this),this.realtime=new ts(this),this.conversations=new $a(this),this.evals=new Ta(this),this.containers=new Oa(this),this.skills=new rs(this),this.videos=new Au(this);let{credential:r,options:n}=L4(t);t=n;let i=q$(t),o=t.provider,{baseURL:s=o?null:Zn("OPENAI_BASE_URL"),dataResidency:a,[w2]:c=!1,apiKey:u=o?null:Zn("OPENAI_API_KEY")??null,adminAPIKey:l=o?null:Zn("OPENAI_ADMIN_KEY")??null,organization:d=o?null:Zn("OPENAI_ORG_ID")??null,project:p=o?null:Zn("OPENAI_PROJECT_ID")??null,webhookSecret:f=Zn("OPENAI_WEBHOOK_SECRET")??null,workloadIdentity:m,x509Transport:h,credential:y,...w}=t;if(o){let D=["apiKey","adminAPIKey","workloadIdentity","x509Transport","baseURL","dataResidency"].filter(M=>(M==="workloadIdentity"?m:t[M])!=null);if(D.length)throw new A(`The \`provider\` option cannot be used with ${D.map(M=>`\`${M}\``).join(", ")}. Configure authentication and the base URL through the provider instead.`)}let _=rb(m)?{x509:m,legacy:void 0}:{x509:void 0,legacy:m},b=_.x509,I=b!==void 0,$=o?v2(o):void 0,P={apiKey:u,adminAPIKey:l,organization:d,project:p,webhookSecret:f,workloadIdentity:m,x509Transport:h,provider:o,...w,baseURL:$?.baseURL??i??(s||(I?_4:"https://api.openai.com/v1"))};if(h&&!I)throw new A("An X.509 transport requires an X.509 workload identity.");if(I){if(i!==void 0||c)throw new A("X.509 workload identity does not support data residency selection.");if(t.fetch!==void 0)throw new A("X.509 workload identity does not support a custom fetch implementation.");if(gd(P.baseURL),ah(P.fetchOptions),this.fetchWithAuth!==bi.prototype.fetchWithAuth||this.fetchWithTimeout!==bi.prototype.fetchWithTimeout)throw new A("X.509 workload identity does not support overridden fetch dispatch hooks.")}if(u&&m)throw new A("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!$&&!u&&!l&&!m)throw new A("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!P.dangerouslyAllowBrowser&&b2())throw new A(`It looks like you're running in a browser-like environment.
|
|
323
|
-
|
|
324
|
-
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
325
|
-
If you understand the risks and have appropriate mitigations in place,
|
|
326
|
-
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
327
|
-
|
|
328
|
-
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
329
|
-
|
|
330
|
-
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
331
|
-
`);this.baseURL=P.baseURL,j(this,Lh,i!==void 0||c,"f"),this.timeout=P.timeout??bi.DEFAULT_TIMEOUT,this.logger=P.logger??console;let C="warn";this.logLevel=C,this.logLevel=D$(P.logLevel,"ClientOptions.logLevel",this)??D$(Zn("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??C,this.fetchOptions=P.fetchOptions,this.maxRetries=P.maxRetries??2,this.fetch=P.fetch??Xm(),j(this,Dh,o4,"f");let x=o||r?void 0:Zn("OPENAI_CUSTOM_HEADERS");if(x){let D={};for(let M of x.split(`
|
|
332
|
-
`)){let R=M.indexOf(":");R>=0&&(D[M.substring(0,R).trim()]=M.substring(R+1).trim())}P.defaultHeaders=L([D,P.defaultHeaders])}if(this._options=P,this._provider=$,b){let D=new Sr(b,h,d,p);this._workloadIdentityAuth=D,j(this,vt,D,"f"),j(this,jb,r,"f"),j(this,is,D.fetch(),"f"),this.fetch=g(this,is,"f"),$4(this)}else _.legacy&&(this._workloadIdentityAuth=new Xv(_.legacy,this.fetch));this.apiKey=typeof u=="string"?u:null,this.adminAPIKey=l,this.organization=d,this.project=p,this.webhookSecret=f}withOptions(t){let r=q$(t),n=g(this,vt,"f"),i={...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:g(this,vt,"f")?void 0:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:n?.identitySnapshot()??this._options.workloadIdentity,x509Transport:this._options.x509Transport,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret},{credential:o,provider:s}=F4(i,t,g(this,jb,"f"),n!==void 0);r!==void 0&&delete i.baseURL;let a={...i,...t,credential:o,provider:s,[w2]:g(this,Lh,"f")&&r===void 0&&!pe(t,"baseURL")&&t.credential===void 0&&!s},c=new this.constructor(a);return s&&new URL(c.baseURL).origin!==new URL(this.baseURL).origin&&(Object.assign(c._options,{defaultHeaders:t.defaultHeaders,defaultQuery:t.defaultQuery,fetchOptions:t.fetchOptions,fetch:t.fetch}),c.fetchOptions=t.fetchOptions,c.fetch=t.fetch??Xm(),c.organization=t.organization??null,c.project=t.project??null),g(this,vt,"f")&&g(c,vt,"f")&&this.baseURL===c.baseURL&&g(this,vt,"f").matches(g(c,vt,"f"))&&(c._workloadIdentityAuth=g(this,vt,"f"),j(c,vt,g(this,vt,"f"),"f"),j(c,is,g(this,is,"f"),"f")),c}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(t.get("authorization")||t.get("api-key"))&&!(r.has("authorization")||r.has("api-key"))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw new Error('Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted')}async authHeaders(t,r={bearerAuth:!0,adminAPIKeyAuth:!0}){return(g(this,vt,"f")??this._workloadIdentityAuth)instanceof Sr&&r.adminAPIKeyAuth&&this.adminAPIKey!==null?await this.adminAPIKeyAuth(t):L([r.bearerAuth?await this.bearerAuth(t):null,r.adminAPIKeyAuth?await this.adminAPIKeyAuth(t):null])}async bearerAuth(t){let r=g(this,vt,"f")??this._workloadIdentityAuth;if(r){if(r instanceof Sr){if(r===this._workloadIdentityAuth&&(this.fetchWithAuth!==bi.prototype.fetchWithAuth||this.fetchWithTimeout!==bi.prototype.fetchWithTimeout))throw new A("X.509 workload identity does not support overridden fetch dispatch hooks.");let i=r.headerSnapshots();if(!Sr.shouldAuthenticate(t,i.defaultHeaders,i.requestHeaders))return}let n=r instanceof Sr?await r.getToken(t,{apiURL:r.requestAPIURL(),...r.headerSnapshots(),...r.requestSnapshot(),signal:r.effectiveSignal(),...r.tenantSnapshot()}):await r.getToken();return L([{Authorization:`Bearer ${n}`}])}if(this.apiKey!=null)return L([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(t){if(this.adminAPIKey!=null)return L([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(t){return g4(t)}getUserAgent(){return`${this.constructor.name}/JS ${ua}`}defaultIdempotencyKey(){return`stainless-node-retry-${Ys()}`}makeStatusError(t,r,n,i){let o=r&&typeof r=="object"&&r.error==null?{error:r}:r;return pt.generate(t,o,n,i)}async _callApiKey(){if(this._provider)return!1;let t=this._options.apiKey;if(typeof t!="function")return!1;let r;try{r=await t()}catch(n){throw n instanceof A?n:new A(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new A(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(t,r,n){let i=!g(this,YT,"m",k2).call(this)&&n||this.baseURL,o=FU(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!N$(s)||!N$(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(t){if(this._provider)return;(t.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(t,{url:r,options:n}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,n){return this.request(Promise.resolve(n).then(i=>({method:t,path:r,...i})))}request(t,r=null){let n=g(this,vt,"f")??this._workloadIdentityAuth,i=n instanceof Sr?Promise.resolve(t).then(o=>n.runRequest(()=>this.makeRequest(o,r,void 0),this)):this.makeRequest(t,r,void 0);return this.responsePromise(i)}responsePromise(t,r=(n,i)=>this.parseResponseWithTimeout(n,i)){let n=new qc(this,t,(i,o)=>{let s=g(this,Uh,"f").get(o.controller)?.continueRequest;return s?s(()=>r(i,o)):r(i,o)});return n.withResponse=async()=>{let i=await n,{response:o}=await t;return{data:i,response:o,request_id:o.headers.get("x-request-id")}},n._thenUnwrap=i=>this.responsePromise(t,async(o,s)=>nh(i(await r(o,s),s),s.response)),n}async parseResponseWithTimeout(t,r){if(r.options.stream||r.options.__binaryResponse||r.response.status===204||r.response.headers.get("content-length")==="0")return Wc(t,r);for(;;){let n=g(this,Uh,"f").get(r.controller),i=n?.timeout??r.options.timeout??this.timeout,o=n?.authentication,s=o?r.controller.signal:r.options.signal,a=()=>o&&s?this._makeUserAbortError(s):new De,c;try{c=o?.remainingTimeout(r.options,i)??Math.max(0,r.startTime+i-Date.now())}catch(p){let f=s?.aborted?a():void 0;throw r.controller.abort(),Wo(r.response.body).catch(()=>{}),f??p}let u,l,d=!1;try{if(s?.aborted&&n?.helperMethod!=="runTools")throw a();let p=new Promise((f,m)=>{u=setTimeout(()=>{d=!0,r.controller.abort(),m(new Tt)},c),s&&(l=()=>{d||m(a())},s.addEventListener("abort",l,{once:!0}))});return await Promise.race([Wc(t,r),p])}catch(p){if(s?.aborted&&!d)throw a();if(!d)throw o&&p instanceof SyntaxError?new SyntaxError("X.509 workload identity API response contains invalid JSON."):o&&!(p instanceof A)?new Nn({message:"X.509 workload identity API response body could not be read."}):p;let f=n?.retriesRemaining??0;if(!f||n?.hasStreamingBody||r.options.__metadata?.hasStreamingBody||globalThis.ReadableStream&&r.options.body instanceof globalThis.ReadableStream||typeof r.options.body=="object"&&r.options.body!==null&&(Symbol.asyncIterator in r.options.body||Symbol.iterator in r.options.body&&"next"in r.options.body&&typeof r.options.body.next=="function"))throw new Tt;u!==void 0&&clearTimeout(u),l&&s?.removeEventListener("abort",l),l=void 0;let m=await this.retryRequest(r.options,f,r.retryOfRequestLogID??r.requestLogID);Object.assign(r,m)}finally{u!==void 0&&clearTimeout(u),l&&s?.removeEventListener("abort",l)}}}async readX509ResponseError(t,r,n,i,o){let s=new AbortController,a=i.signal,c=!1,u=()=>s.abort(a.reason);a.addEventListener("abort",u,{once:!0}),a.aborted&&u();try{let l=o.remainingTimeout(r,n),d=o.waitForRetry(l,s.signal).then(()=>{throw new Tt}),p=await Promise.race([t.text().catch(()=>"X.509 workload identity API response body could not be read."),d]);if(a.aborted)throw this._makeUserAbortError(a);return p}catch(l){throw l instanceof Tt&&(c=!a.aborted,i.abort(),Wo(t.body).catch(()=>{})),a.aborted&&!c?this._makeUserAbortError(a):l}finally{a.removeEventListener("abort",u),s.abort()}}async makeRequest(t,r,n){let i=await t,o=i.maxRetries??this.maxRetries;r==null&&(r=o);let s=g(this,vt,"f");s?.beginRequestPreparation(),await this.prepareOptions(i),s?.beginRequestPlanning();let a;try{let D=await this.buildRequest(i,{retryCount:o-r});if(a={req:D.req,url:D.url,timeout:D.timeout},s){M$("timeout",a.timeout),s.authorizePlannedRequest(a.url,a.req,a.timeout),Sr.isStreamingRequestBody(a.req.body)&&(i.__metadata={...i.__metadata,hasStreamingBody:!0}),await this.prepareRequest(a.req,{url:a.url,options:i}),await this._provider?.prepareRequest?.(a.req,{url:a.url,options:i}),s.beginRequestPlanning(),s.authorizePlannedRequest(a.url,a.req,a.timeout,!0),Sr.isStreamingRequestBody(a.req.body)&&(i.__metadata={...i.__metadata,hasStreamingBody:!0});let M=s.requestSnapshot().signal;if(M?.aborted||a.req.signal?.aborted)throw this._makeUserAbortError(M?.aborted?M:a.req.signal);s.setEffectiveSignal(a.req.signal||M?x2(a.req.signal??M,M).signal:void 0),s.beginRequestNetwork();let R=i.__security??{bearerAuth:!0},B=await this.authHeaders(i,R),K=s.headerSnapshots(),re=L([K.defaultHeaders,K.requestHeaders]);for(let[We,ne]of B?.values??[])!re.nulls.has(We)&&!a.req.headers.has(We)&&a.req.headers.set(We,ne);this.validateHeaders(L([re,a.req.headers]),R)}}catch(D){if(s?.retireRequestBody(),s&&r&&!i.__metadata?.hasStreamingBody&&Sr.isRetryableFailure(D))return await this.retryRequest(i,r,n??"x509-token-exchange",Sr.retryHeaders(D));throw D}let{req:c,url:u}=a,l=s?Math.min(a.timeout,s.requestSnapshot().timeout):a.timeout;s?.bindRequest(i,c,this.adminAPIKey);let d=i.__metadata?.hasStreamingBody===!0;s||(await this.prepareRequest(c,{url:u,options:i}),await this._provider?.prepareRequest?.(c,{url:u,options:i})),s?.adoptRequestHeaders(c),s&&Sr.isStreamingRequestBody(c.body)&&(d=!0);let p="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=n===void 0?"":`, retryOf: ${n}`,m=s?.requestStartedAt(i)??Date.now();Mt(this).debug(`[${p}] sending request`,qo({retryOfRequestLogID:n,method:i.method,url:u,options:s?{body:c.body,...s.requestSnapshot()}:i,headers:c.headers}));let h=s?s.requestSnapshot().signal:i.signal;if(h?.aborted||c.signal?.aborted)throw this._makeUserAbortError(h?.aborted?h:c.signal);let y=i.__security??{bearerAuth:!0},w=s||this.fetchWithTimeout===bi.prototype.fetchWithTimeout?x2(c.signal??(s?h:void 0),s?h:void 0):new AbortController,_=s?.remainingTimeout(i,l)??l,b=s?bi.prototype.fetchWithAuth:this.fetchWithAuth;s?.releaseRequestBody(c.body);let I=await b.call(this,u,c,_,w,y).catch(Jm),$=Date.now();if(I instanceof globalThis.Error){let D=`retrying, ${r} attempts remaining`;if(h?.aborted||c.signal?.aborted)throw this._makeUserAbortError(h?.aborted?h:c.signal);let M=Vo(I)||/timed? ?out/i.test(String(I)+("cause"in I?String(I.cause):""));if(r&&!d&&(!s||Qv(I)))return Mt(this).info(`[${p}] connection ${M?"timed out":"failed"} - ${D}`),Mt(this).debug(`[${p}] connection ${M?"timed out":"failed"} (${D})`,qo({retryOfRequestLogID:n,url:u,durationMs:$-m,message:s?"X.509 workload identity API connection failed.":I.message})),this.retryRequest(i,r,n??p);let R=d?"error; streaming body cannot be retried":"error; no more retries left";if(Mt(this).info(`[${p}] connection ${M?"timed out":"failed"} - ${R}`),Mt(this).debug(`[${p}] connection ${M?"timed out":"failed"} (${R})`,qo({retryOfRequestLogID:n,url:u,durationMs:$-m,message:s?"X.509 workload identity API connection failed.":I.message})),I instanceof Mn||I instanceof Bc)throw I;if(M){let B="cause"in I?I.cause:void 0,re=typeof B=="object"&&B!==null&&"code"in B&&B.code==="UND_ERR_HEADERS_TIMEOUT"?new Tt({message:"Request timed out. Node.js fetch timed out waiting for response headers; configure a matching undici fetch and fetchOptions.dispatcher with an Agent whose headersTimeout is at least the SDK timeout."}):new Tt;throw s?new Tt:Object.assign(re,{cause:I})}throw s?new Nn({message:"X.509 workload identity API connection failed."}):new Nn({message:IX(I),cause:I})}let P=[...I.headers.entries()].filter(([D])=>D==="x-request-id").map(([D,M])=>", "+D+": "+JSON.stringify(M)).join(""),C=`[${p}${f}${P}] ${c.method} ${Gv(u)} ${I.ok?"succeeded":"failed"} with status ${I.status} in ${$-m}ms`;if(!I.ok){let D=I.status===401&&s&&y.bearerAuth&&s.usedWorkloadToken(i);if(D&&s.invalidateToken(),I.status===401&&(s||this._workloadIdentityAuth)&&y.bearerAuth&&(!s||s.usedWorkloadToken(i))&&(!s||r>0)&&!d&&!i.__metadata?.workloadIdentityTokenRefreshed){s?Wo(I.body).catch(()=>{}):(await Wo(I.body),this._workloadIdentityAuth?.invalidateToken());let ne={...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}};return this.makeRequest(ne,s?r-1:r,n??p)}let M=D&&i.__metadata?.workloadIdentityTokenRefreshed?!1:await this.shouldRetry(I);if(r&&M&&!d){let ne=`retrying, ${r} attempts remaining`;return s?Wo(I.body).catch(()=>{}):await Wo(I.body),Mt(this).info(`${C} - ${ne}`),Mt(this).debug(`[${p}] response error (${ne})`,qo({retryOfRequestLogID:n,url:I.url,status:I.status,headers:I.headers,durationMs:$-m})),this.retryRequest(i,r,n??p,I.headers)}let R=M?d?"error; streaming body cannot be retried":"error; no more retries left":"error; not retryable";Mt(this).info(`${C} - ${R}`);let B=s?await this.readX509ResponseError(I,i,l,w,s):await I.text().catch(ne=>Jm(ne).message),K=BU(B),re=K?void 0:B;throw Mt(this).debug(`[${p}] response error (${R})`,qo({retryOfRequestLogID:n,url:I.url,status:I.status,headers:I.headers,message:re,durationMs:Date.now()-m})),this.makeStatusError(I.status,K,re,I.headers)}Mt(this).info(C),Mt(this).debug(`[${p}] response start`,qo({retryOfRequestLogID:n,url:I.url,status:I.status,headers:I.headers,durationMs:$-m}));let x=s?.continuation();return s?.releaseRequestCredentials(),g(this,Uh,"f").set(w,{timeout:l,retriesRemaining:r,hasStreamingBody:d,...s?{authentication:s}:{},helperMethod:i.__metadata?.helperMethod,...x?{continueRequest:x}:{}}),{response:I,options:i,controller:w,requestLogID:p,retryOfRequestLogID:n,startTime:m}}getAPIList(t,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:t,...i})):{method:"get",path:t,...n})}requestAPIList(t,r){let n=g(this,vt,"f")??this._workloadIdentityAuth,i=n instanceof Sr?Promise.resolve(r).then(a=>n.runRequest(()=>this.makeRequest(a,null,void 0),this)):this.makeRequest(r,null,void 0),o=new sh(this,i,t),s=this.responsePromise(i,async(a,c)=>{let u=await this.parseResponseWithTimeout(a,c);return new t(a,c.response,u,c.options)});return o.then=s.then.bind(s),o.catch=s.catch.bind(s),o.finally=s.finally.bind(s),o.withResponse=s.withResponse.bind(s),o._thenUnwrap=s._thenUnwrap.bind(s),o}async fetchWithAuth(t,r,n,i,o={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&!g(this,is,"f")&&o.bearerAuth){let c=r.headers,u=c.get("Authorization");if(!u||u===`Bearer ${kX}`){let l=await this._workloadIdentityAuth.getToken();c.set("Authorization",`Bearer ${l}`)}}return await(g(this,is,"f")?bi.prototype.fetchWithTimeout:this.fetchWithTimeout).call(this,t,r,n,i)}async fetchWithTimeout(t,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i),u=!!o&&I2.get(i)===o;o&&!u&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),d=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,p={signal:i.signal,...d?{duplex:"half"}:{},method:"GET",...a};s&&(p.method=s.toUpperCase());try{return await(g(this,is,"f")??this.fetch).call(void 0,t,p)}catch(f){throw o&&!u&&o.removeEventListener("abort",c),f}finally{clearTimeout(l)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let u=parseFloat(s);Number.isNaN(u)||(o=u)}let a=i?.get("retry-after");if(a&&o===void 0){let u=parseFloat(a);Number.isNaN(u)?o=Date.parse(a)-Date.now():o=u*1e3}if(o===void 0||!Number.isFinite(o)||o<0||o>60*1e3){let u=t.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,u)}let c=g(this,vt,"f");if(c){let u=c.remainingTimeout(t,c.requestSnapshot().timeout);if(o>=u)throw new Tt}return c?await c.waitForRetry(o,c.effectiveSignal()):await md(o),this.makeRequest(t,r-1,n)}calculateDefaultRetryTimeoutMillis(t,r){let o=r-t,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(t,{retryCount:r=0}={}){if(g(this,vt,"f")&&!g(this,vt,"f").inRequest(this)){let I=g(this,vt,"f");return await I.runRequest(async()=>{let $=await bi.prototype.buildRequest.call(this,t,{retryCount:r});return I.releaseRequestBody($.req.body),$},this)}let n={...t},i=g(this,vt,"f"),o=i?.snapshotTenant(this.organization,this.project),s=i?.snapshotHeaders(this._options.defaultHeaders,n.headers);s&&(n.headers=s.requestHeaders);let a=i?Q$(this.fetchOptions):void 0,c=i?Q$(n.fetchOptions):void 0,{method:u,path:l,query:d,defaultBaseURL:p}=n,f=this.buildURL(l,d,p);i?.snapshotAPIURL(f);let m="timeout"in n;if(m&&M$("timeout",n.timeout),n.timeout=n.timeout??this.timeout,i&&c&&i.snapshotRequest(n.signal,n.timeout,c),i){let I=i.requestSnapshot();n.timeout=I.timeout,I.signal===void 0?delete n.signal:n.signal=I.signal}let{bodyHeaders:h,body:y,isStreamingBody:w}=this.buildBody({options:n});w&&(t.__metadata={...t.__metadata,hasStreamingBody:!0},i?.ownRequestBody(y,n.body));let _=await this.buildHeaders({options:t,method:u,bodyHeaders:h,retryCount:r,x509Headers:s,x509Timeout:m?n.timeout:void 0,x509Tenant:o});return{req:{method:u,headers:_,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&y instanceof globalThis.ReadableStream&&{duplex:"half"},...y&&{body:y},...(i?a:this.fetchOptions)??{},...(i?c:n.fetchOptions)??{}},url:f,timeout:n.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:n,retryCount:i,x509Headers:o,x509Timeout:s,x509Tenant:a}){let c={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),c[this.idempotencyHeader]=t.idempotencyKey);let u=t.__metadata?.helperMethod,l=o?s:t.timeout,d=L([c,{Accept:"application/json",...b2()?void 0:{"User-Agent":this.getUserAgent()},"X-Stainless-Retry-Count":String(i),...l?{"X-Stainless-Timeout":String(Math.trunc(l/1e3))}:{},...n4(),...typeof u=="string"?{"X-Stainless-Helper-Method":u}:{},"OpenAI-Organization":a?a.organization:this.organization,"OpenAI-Project":a?a.project:this.project},this._provider||g(this,vt,"f")?.isPlanningRequest()?void 0:await this.authHeaders(t,t.__security??{bearerAuth:!0}),o?.defaultHeaders??this._options.defaultHeaders,n,o?.requestHeaders??t.headers]);return!this._provider&&!g(this,vt,"f")?.isPlanningRequest()&&this.validateHeaders(d,t.__security??{bearerAuth:!0}),d.values}_makeAbort(t){return()=>t.abort()}_makeUserAbortError(t){let r=new De;return Object.defineProperty(r,"cause",{value:t.reason,writable:!0,configurable:!0}),r}buildBody({options:t}){let{body:r,headers:n}=t;if(!r)return r===void 0&&"body"in t?{...g(this,Dh,"f").call(this,{body:r,headers:L([n])}),isStreamingBody:!1}:{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let i=L([n]),o=typeof globalThis.ReadableStream<"u"&&r instanceof globalThis.ReadableStream,s=!o&&(typeof r=="string"||r instanceof ArrayBuffer||ArrayBuffer.isView(r)||typeof globalThis.Blob<"u"&&r instanceof globalThis.Blob||r instanceof URLSearchParams||r instanceof FormData);return ArrayBuffer.isView(r)||r instanceof ArrayBuffer||r instanceof DataView||typeof r=="string"&&i.values.has("content-type")||globalThis.Blob&&r instanceof globalThis.Blob||r instanceof FormData||r instanceof URLSearchParams||o?{bodyHeaders:void 0,body:r,isStreamingBody:!s}:typeof r=="object"&&(Symbol.asyncIterator in r||Symbol.iterator in r&&"next"in r&&typeof r.next=="function")?{bodyHeaders:void 0,body:Ym(r),isStreamingBody:!0}:typeof r=="object"&&i.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(r),isStreamingBody:!1}:{...g(this,Dh,"f").call(this,{body:r,headers:i}),isStreamingBody:!1}}};bi=fe,Dh=new WeakMap,vt=new WeakMap,jb=new WeakMap,is=new WeakMap,Lh=new WeakMap,Uh=new WeakMap,YT=new WeakSet,k2=function(){return g(this,Lh,"f")||this._provider!==void 0||this.baseURL!=="https://api.openai.com/v1"};fe.OpenAI=bi;fe.DEFAULT_TIMEOUT=6e5;fe.OpenAIError=A;fe.APIError=pt;fe.APIConnectionError=Nn;fe.APIConnectionTimeoutError=Tt;fe.APIUserAbortError=De;fe.NotFoundError=ra;fe.ConflictError=na;fe.RateLimitError=oa;fe.BadRequestError=Qs;fe.AuthenticationError=ea;fe.InternalServerError=sa;fe.PermissionDeniedError=ta;fe.UnprocessableEntityError=ia;fe.InvalidWebhookSignatureError=Xr;fe.toFile=dh;fe.toStreamingFile=ib;fe.Completions=pu;fe.Chat=ha;fe.Embeddings=hu;fe.Files=yu;fe.Images=wu;fe.ContentProvenanceChecks=mu;fe.Audio=po;fe.Moderations=ku;fe.Models=xu;fe.FineTuning=vi;fe.Graders=Ea;fe.VectorStores=ns;fe.Safety=Na;fe.Webhooks=Ou;fe.Beta=Wn;fe.Batches=cu;fe.Uploads=Ma;fe.Admin=ya;fe.Responses=fo;fe.Realtime=ts;fe.Conversations=$a;fe.Evals=Ta;fe.Containers=Oa;fe.Skills=rs;fe.Videos=Au;var I2=new WeakMap;function x2(e,t){let r=new AbortController;if(!e)return r;let n=globalThis.AbortSignal;if(typeof n?.any!="function"||!(e instanceof n))return r;try{let i=[r.signal,e];t&&t!==e&&i.push(t);let o=n.any(i);Object.defineProperty(r,"signal",{value:o,configurable:!0}),I2.set(r,e)}catch{}return r}function IX(e){if(SX(e))return"Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });"}function SX(e){let t=e;for(let r=0;r<8&&t&&typeof t=="object";r++){let n=t;if(n.code==="UND_ERR_INVALID_ARG"&&typeof n.message=="string"&&n.message.includes("invalid onRequestStart method"))return!0;t=n.cause}return!1}var S2=Symbol.for("openai.privateBedrockClient");var OX;OX=S2;function $X(e){return!!(String(e).includes("context_length_exceeded")||"message"in e&&typeof e.message=="string"&&(e.message.includes("Input tokens exceed the configured limit")||e.message.includes("exceeds the context window")||e.message.includes("maximum context length")))}function qn(e){if(!e||typeof e!="object")return e;let t;return e.constructor.name===Tt.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="TimeoutError",nn(t,!0)):e.constructor.name===De.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="AbortError",nn(t,!1)):$X(e)?t=eP.fromError(e):"status"in e&&e.status===400&&"message"in e&&typeof e.message=="string"&&e.message.includes("tool_calls")?t=nn(Hm(e,"INVALID_TOOL_RESULTS"),!1):"status"in e&&e.status===401?t=nn(Hm(e,"MODEL_AUTHENTICATION"),!1):"status"in e&&e.status===429?t=nn(Hm(e,"MODEL_RATE_LIMIT"),!0):"status"in e&&e.status===404?t=nn(Hm(e,"MODEL_NOT_FOUND"),!1):t=e,t}var wi=e=>e();function os(e){return e?!!(/^o\d/.test(e??"")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat")):!1}function TX(e){return e.role!=="system"&&e.role!=="developer"&&e.role!=="assistant"&&e.role!=="user"&&e.role!=="function"&&e.role!=="tool"&&console.warn(`Unknown message role: ${e.role}`),e.role}function Db(e){return e.metadata?.filename??e.metadata?.name??e.metadata?.title}var EX="LC_AUTOGENERATED";function $u(e){let t=e.metadata?.filename??e.metadata?.name??e.metadata?.title;return t||(console.warn("OpenAI may require a filename for file uploads. Specify a filename in the content block metadata, e.g.: { type: 'file', mimeType: '...', data: '...', metadata: { filename: 'my-file.pdf' } }. Using placeholder filename 'LC_AUTOGENERATED'."),EX)}function ss(e){let t=e._getType();switch(t){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!vn.isInstance(e))throw new Error("Invalid generic chat message");return TX(e);default:throw new Error(`Unknown message type: ${t}`)}}function A2(e){return!!(e.includes("gpt-5.2-pro")||e.includes("gpt-5.4-pro")||e.includes("gpt-5.5-pro")||e.includes("codex"))}function as(e){let{azureOpenAIApiDeploymentName:t,azureOpenAIApiInstanceName:r,azureOpenAIApiKey:n,azureOpenAIBasePath:i,baseURL:o,azureADTokenProvider:s,azureOpenAIEndpoint:a}=e;if((n||s)&&i&&t)return`${i}/${t}`;if((n||s)&&a&&t)return`${a}/openai/deployments/${t}`;if(n||s){if(!r)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!t)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${r}.openai.azure.com/openai/deployments/${t}`}return o}function eE(e){return typeof Headers<"u"&&e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Headers]"}function O2(e){let t=wi(()=>{if(eE(e))return e;if(Array.isArray(e))return new Headers(e);if(typeof e=="object"&&e!==null&&"values"in e&&eE(e.values))return e.values;if(typeof e=="object"&&e!==null){let r=Object.entries(e).filter(([,n])=>typeof n=="string").map(([n,i])=>[n,i]);return new Headers(r)}return new Headers});return Object.fromEntries(t.entries())}function $2(){let e=XE();return(e==="node"||e==="deno")&&(e=`(${e}/${process.version}; ${process.platform}; ${process.arch})`),e}function cs(e,t=!1,r="1.0.0"){let n=O2(e),i=$2(),o=`langchainjs${t?"-azure":""}-openai`;return{...n,"User-Agent":n["User-Agent"]?`${o}/${r} (${i})${n["User-Agent"]}`:`${o}/${r} (${i})`}}function T2(e,t){let r;return zo(e)?r=NO(e):r=e,t?.strict!==void 0&&(r.function.strict=t.strict),r}function PX(e){return e.anyOf!==void 0&&Array.isArray(e.anyOf)}function E2(e){let t=["namespace functions {",""];for(let r of e)r.description&&t.push(`// ${r.description}`),Object.keys(r.parameters.properties??{}).length>0?(t.push(`type ${r.name} = (_: {`),t.push(P2(r.parameters,0)),t.push("}) => any;")):t.push(`type ${r.name} = () => any;`),t.push("");return t.push("} // namespace functions"),t.join(`
|
|
333
|
-
`)}function P2(e,t){let r=[];for(let[n,i]of Object.entries(e.properties??{}))i.description&&t<2&&r.push(`// ${i.description}`),e.required?.includes(n)?r.push(`${n}: ${Ub(i,t)},`):r.push(`${n}?: ${Ub(i,t)},`);return r.map(n=>" ".repeat(t)+n).join(`
|
|
334
|
-
`)}function Ub(e,t){if(PX(e))return e.anyOf.map(r=>Ub(r,t)).join(" | ");switch(e.type){case"string":return e.enum?e.enum.map(r=>`"${r}"`).join(" | "):"string";case"number":return e.enum?e.enum.map(r=>`${r}`).join(" | "):"number";case"integer":return e.enum?e.enum.map(r=>`${r}`).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",P2(e,t+2),"}"].join(`
|
|
335
|
-
`);case"array":return e.items?`${Ub(e.items,t)}[]`:"any[]";default:return""}}function Lb(e){if(e)return e==="any"||e==="required"?"required":e==="auto"?"auto":e==="none"?"none":typeof e=="string"?{type:"function",function:{name:e}}:e}function Cp(e){return"type"in e&&e.type!=="function"}function C2(e){return typeof e=="object"&&e!==null&&"extras"in e&&typeof e.extras=="object"&&e.extras!==null&&"providerToolDefinition"in e.extras&&typeof e.extras.providerToolDefinition=="object"&&e.extras.providerToolDefinition!==null}function R2(e){return e!=null&&typeof e=="object"&&"type"in e&&e.type!=="function"}function Tu(e){return typeof e=="object"&&e!==null&&"metadata"in e&&typeof e.metadata=="object"&&e.metadata!==null&&"customTool"in e.metadata&&typeof e.metadata.customTool=="object"&&e.metadata.customTool!==null}function Fb(e){return"type"in e&&e.type==="custom"&&"custom"in e&&typeof e.custom=="object"&&e.custom!==null}function N2(e){if(e.type==="custom_tool_call")return{...e,type:"tool_call",call_id:e.id,id:e.call_id,name:e.name,isCustomTool:!0,args:{input:e.input}}}function M2(e){if(e.type==="computer_call")return{...e,type:"tool_call",call_id:e.id,id:e.call_id,name:"computer_use",isComputerTool:!0,args:{action:e.action}}}function z2(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_call"&&"isComputerTool"in e&&e.isComputerTool===!0}function j2(e,t){return typeof e!="object"||e===null||!("type"in e)||e.type!=="tool_call"?!1:!!("isCustomTool"in e&&e.isCustomTool===!0||t&&"id"in e&&typeof e.id=="string"&&e.id in t)}function D2(e){let t=()=>{if(e.custom.format){if(e.custom.format.type==="grammar")return{type:"grammar",definition:e.custom.format.grammar.definition,syntax:e.custom.format.grammar.syntax};if(e.custom.format.type==="text")return{type:"text"}}};return{type:"custom",name:e.custom.name,description:e.custom.description,format:t()}}function U2(e){let t=()=>{if(e.format){if(e.format.type==="grammar")return{type:"grammar",grammar:{definition:e.format.definition,syntax:e.format.syntax}};if(e.format.type==="text")return{type:"text"}}};return{type:"custom",custom:{name:e.name,description:e.description,format:t()}}}function L2(){return{}}function tE(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ke(e,t,r,n,i){e[t]=r,tE(e,t,n,i)}function F2(e,t){let r={type:"array"};return(e.type?._def?.typeName!==z.ZodAny||t.openaiStrictMode)&&(r.items=_e(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ke(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ke(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ke(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ke(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function B2(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":{t.target==="jsonSchema7"?n.inclusive?Ke(r,"minimum",n.value,n.message,t):Ke(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ke(r,"minimum",n.value,n.message,t));break}case"max":{t.target==="jsonSchema7"?n.inclusive?Ke(r,"maximum",n.value,n.message,t):Ke(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ke(r,"maximum",n.value,n.message,t));break}case"multipleOf":{Ke(r,"multipleOf",n.value,n.message,t);break}}return r}function Z2(){return{type:"boolean"}}function V2(e,t,r){return _e(e.type._def,t,r)}var W2=(e,t,r)=>_e(e.innerType._def,t,r);function rE(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>rE(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return CX(e,t)}}var CX=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":{Ke(r,"minimum",n.value,n.message,t);break}case"max":{Ke(r,"maximum",n.value,n.message,t);break}}return r};function q2(e,t,r){return{..._e(e.innerType._def,t,r),default:e.defaultValue()}}function K2(e,t,r){return t.effectStrategy==="input"?_e(e.schema._def,t,r):{}}function G2(e){return{type:"string",enum:[...e.values]}}var RX=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function H2(e,t){let r=[_e(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),_e(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];for(let o of r)if(RX(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;s=c}else n=void 0;i.push(s)}return i.length?{allOf:i,...n}:void 0}function Bb(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}function J2(e,t){if(e.value===null)return t.target==="openApi3"?Bb(t):{type:"null",const:null};let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var nE,Eu={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:()=>{if(nE===void 0){let e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";nE=new RegExp(e,"u")}return nE},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])$/,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})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function Zb(e,t){let r={type:"string"};function n(i){return t.patternStrategy==="escape"?NX(i):i}if(e.checks)for(let i of e.checks)switch(i.kind){case"min":{Ke(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break}case"max":{Ke(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break}case"email":{switch(t.emailStrategy){case"format:email":{xi(r,"email",i.message,t);break}case"format:idn-email":{xi(r,"idn-email",i.message,t);break}case"pattern:zod":{ki(r,Eu.email,i.message,t);break}}break}case"url":{xi(r,"uri",i.message,t);break}case"uuid":{xi(r,"uuid",i.message,t);break}case"regex":{ki(r,i.regex,i.message,t);break}case"cuid":{ki(r,Eu.cuid,i.message,t);break}case"cuid2":{ki(r,Eu.cuid2,i.message,t);break}case"startsWith":{ki(r,new RegExp(`^${n(i.value)}`),i.message,t);break}case"endsWith":{ki(r,new RegExp(`${n(i.value)}$`),i.message,t);break}case"datetime":{xi(r,"date-time",i.message,t);break}case"date":{xi(r,"date",i.message,t);break}case"time":{xi(r,"time",i.message,t);break}case"duration":{xi(r,"duration",i.message,t);break}case"length":{Ke(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Ke(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break}case"includes":{ki(r,new RegExp(n(i.value)),i.message,t);break}case"ip":{i.version!=="v6"&&xi(r,"ipv4",i.message,t),i.version!=="v4"&&xi(r,"ipv6",i.message,t);break}case"emoji":{ki(r,Eu.emoji,i.message,t);break}case"ulid":{ki(r,Eu.ulid,i.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{xi(r,"binary",i.message,t);break}case"contentEncoding:base64":{Ke(r,"contentEncoding","base64",i.message,t);break}case"pattern:zod":{ki(r,Eu.base64,i.message,t);break}}break}case"nanoid":{ki(r,Eu.nanoid,i.message,t);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}var NX=e=>[...e].map(t=>/[a-zA-Z0-9]/.test(t)?t:`\\${t}`).join(""),xi=(e,t,r,n)=>{e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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,...r&&n.errorMessages&&{errorMessage:{format:r}}})):Ke(e,"format",t,r,n)},ki=(e,t,r,n)=>{e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:X2(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Ke(e,"pattern",X2(t,n),r,n)},X2=(e,t)=>{let r=typeof e=="function"?e():e;if(!t.applyRegexFlags||!r.flags)return r.source;let n={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},i=n.i?r.source.toLowerCase():r.source,o="",s=!1,a=!1,c=!1;for(let u=0;u<i.length;u++){if(s){o+=i[u],s=!1;continue}if(n.i){if(a){if(/[a-z]/.test(i[u])){c?(o+=i[u],o+=`${i[u-2]}-${i[u]}`.toUpperCase(),c=!1):i[u+1]==="-"&&i[u+2]?.match(/[a-z]/)?(o+=i[u],c=!0):o+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(/[a-z]/.test(i[u])){o+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(n.m){if(i[u]==="^"){o+=`(^|(?<=[\r
|
|
336
|
-
]))`;continue}else if(i[u]==="$"){o+=`($|(?=[\r
|
|
337
|
-
]))`;continue}}if(n.s&&i[u]==="."){o+=a?`${i[u]}\r
|
|
338
|
-
`:`[${i[u]}\r
|
|
339
|
-
]`;continue}o+=i[u],i[u]==="\\"?s=!0:a&&i[u]==="]"?a=!1:!a&&i[u]==="["&&(a=!0)}try{let u=new RegExp(o)}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`),r.source}return o};function Vb(e,t){if(t.target==="openApi3"&&e.keyType?._def.typeName===z.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:Object.fromEntries(e.keyType._def.values.map(n=>[n,_e(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}])),additionalProperties:!1};let r={type:"object",additionalProperties:_e(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===z.ZodString&&e.keyType._def.checks?.length){let n=Object.fromEntries(Object.entries(Zb(e.keyType._def,t)).filter(([i])=>i!=="type"));return{...r,propertyNames:n}}else if(e.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};return r}function Y2(e,t){if(t.mapStrategy==="record")return Vb(e,t);let r=_e(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},n=_e(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Q2(e){let t=e.values,n=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),i=[...new Set(n.map(s=>typeof s))],o=["string","number"];return i.length===1&&(o=i[0]==="string"?"string":"number"),{type:o,enum:n}}function eF(){return{not:{}}}var Fh={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function rF(e,t){if(t.target==="openApi3")return tF(e,t);let r=e.options instanceof Map?[...e.options.values()]:e.options;if(r.every(n=>n._def.typeName in Fh&&(!n._def.checks||!n._def.checks.length))){let n=[];for(let i of r){let o=Fh[i._def.typeName];o&&!n.includes(o)&&n.push(o)}return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=[];for(let i of r){let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":{n.push(o);break}case"bigint":{n.push("integer");break}case"object":{i._def.value===null&&n.push("null");break}}}if(n.length===r.length){let i=n.filter((s,a,c)=>c.indexOf(s)===a),o=[];for(let s of r)o.includes(s._def.value)||o.push(s._def.value);return{type:i.length>1?i:i[0],enum:o}}}else if(r.every(n=>n._def.typeName==="ZodEnum")){let n=[];for(let i of r)for(let o of i._def.values)n.includes(o)||n.push(o);return{type:"string",enum:n}}return tF(e,t)}var tF=(e,t)=>{let r=(e.options instanceof Map?[...e.options.values()]:e.options).map((n,i)=>_e(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function nF(e,t,r){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"||t.nullableStrategy==="property"?{type:Fh[e.innerType._def.typeName],nullable:!0}:{type:[Fh[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let i=_e(e.innerType._def,{...t,currentPath:[...t.currentPath]},r);return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let n=_e(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function iF(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":{r.type="integer",tE(r,"type",n.message,t);break}case"min":{t.target==="jsonSchema7"?n.inclusive?Ke(r,"minimum",n.value,n.message,t):Ke(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ke(r,"minimum",n.value,n.message,t));break}case"max":{t.target==="jsonSchema7"?n.inclusive?Ke(r,"maximum",n.value,n.message,t):Ke(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ke(r,"maximum",n.value,n.message,t));break}case"multipleOf":{Ke(r,"multipleOf",n.value,n.message,t);break}}return r}function MX(e,t){return t.removeAdditionalStrategy==="strict"?e.catchall._def.typeName==="ZodNever"?e.unknownKeys!=="strict":_e(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:e.catchall._def.typeName==="ZodNever"?e.unknownKeys==="passthrough":_e(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function oF(e,t){let r={},n=[];for(let[o,s]of Object.entries(e.shape())){if(s===void 0||s._def===void 0)continue;let a=[...t.currentPath,"properties",o];if(o==="__proto__")throw new Error(`Zod field at \`${a.join("/")}\` uses unsupported property name \`__proto__\`, which Zod omits from parsed output.`);let c=_e(s._def,{...t,currentPath:a,propertyPath:a});if(c!==void 0){if(t.openaiStrictMode&&s.isOptional()&&!s.isNullable()&&s._def?.defaultValue===void 0)throw new Error(`Zod field at \`${a.join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);r[o]=c,(!s.isOptional()||t.openaiStrictMode)&&n.push(o)}}let i={type:"object",properties:r,required:n,additionalProperties:MX(e,t)};return i.required.length||delete i.required,i}var sF=(e,t,r)=>{if(t.propertyPath&&t.currentPath.slice(0,t.propertyPath.length).toString()===t.propertyPath.toString())return _e(e.innerType._def,{...t,currentPath:t.currentPath},r);let n=_e(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]},r);return n?{anyOf:[{not:{}},n]}:{}};var aF=(e,t,r)=>{if(t.pipeStrategy==="input")return _e(e.in._def,t,r);if(t.pipeStrategy==="output")return _e(e.out._def,t,r);let n=_e(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),i=_e(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,i].filter(o=>o!==void 0)}};function cF(e,t,r){return _e(e.type._def,t,r)}function uF(e,t){let n={type:"array",uniqueItems:!0,items:_e(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ke(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ke(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function lF(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>_e(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).filter(r=>r!==void 0),additionalItems:_e(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>_e(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).filter(r=>r!==void 0)}}function dF(){return{not:{}}}function pF(){return{}}var fF=(e,t,r)=>_e(e.innerType._def,t,r);var hF=Symbol("Let zodToJsonSchema decide on which parser to use"),mF={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},gF=e=>{let t=typeof e=="string"?{...mF,basePath:["#"],definitions:{},name:e}:{...mF,basePath:["#"],definitions:{},...e};return typeof e!="string"&&e?.definitions&&t.$refStrategy==="extract-to-root"&&t.nameStrategy==="duplicate-ref"&&(t.definitions={...e.definitions}),t};var Pu=e=>"_def"in e?e._def:e;function yF(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t,r=!1){let n=t.seen.get(e);if(t.override){let o=t.override?.(e,t,n,r);if(o!==hF)return o}if(n&&!r){let o=zX(n,t);if(o!==void 0)return"$ref"in o&&t.seenRefs.add(o.$ref),o}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);try{let o=UX(e,e.typeName,t,r);return o&&LX(e,t,o),i.jsonSchema=o,o}finally{r&&n&&t.seen.set(e,n)}}var zX=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":{let r=e.path.slice(t.basePath.length+1).map((o,s)=>s===0?o:jX(o)).join("_"),n=r;if(!(n===t.name&&e.path.length===t.basePath.length+2&&e.path[t.basePath.length]===t.definitionPath)&&t.nameStrategy==="duplicate-ref"){let o=a=>{if(!pe(t.definitions,a))return!1;let c=t.definitions[a];return c===void 0||Pu(c)!==e.def},s=0;for(;n===t.name||o(n);)s+=1,n=`${r}_${s}`;pe(t.definitions,n)||(t.definitions[n]=e.def)}return{$ref:[...t.basePath,t.definitionPath,n].join("/")}}case"relative":return{$ref:DX(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):t.$refStrategy==="seen"?{}:void 0}},_F="_x_",jX=e=>{if(/^[A-Za-z0-9_-]*$/.test(e)&&!e.startsWith(_F))return e;let t=_F;for(let r=0;r<e.length;r++)t+=e.charCodeAt(r).toString(16).padStart(4,"0");return t},DX=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},UX=(e,t,r,n)=>{switch(t){case z.ZodString:return Zb(e,r);case z.ZodNumber:return iF(e,r);case z.ZodObject:return oF(e,r);case z.ZodBigInt:return B2(e,r);case z.ZodBoolean:return Z2();case z.ZodDate:return rE(e,r);case z.ZodUndefined:return dF();case z.ZodNull:return Bb(r);case z.ZodArray:return F2(e,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return rF(e,r);case z.ZodIntersection:return H2(e,r);case z.ZodTuple:return lF(e,r);case z.ZodRecord:return Vb(e,r);case z.ZodLiteral:return J2(e,r);case z.ZodEnum:return G2(e);case z.ZodNativeEnum:return Q2(e);case z.ZodNullable:return nF(e,r,n);case z.ZodOptional:return sF(e,r,n);case z.ZodMap:return Y2(e,r);case z.ZodSet:return uF(e,r);case z.ZodLazy:return _e(e.getter()._def,r,n);case z.ZodPromise:return cF(e,r,n);case z.ZodNaN:case z.ZodNever:return eF();case z.ZodEffects:return K2(e,r,n);case z.ZodAny:return L2();case z.ZodUnknown:return pF();case z.ZodDefault:return q2(e,r,n);case z.ZodBranded:return V2(e,r,n);case z.ZodReadonly:return fF(e,r,n);case z.ZodCatch:return W2(e,r,n);case z.ZodPipeline:return aF(e,r,n);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(i=>{})(t)}},LX=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var vF=e=>{let t=gF(e),r=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:r,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[Pu(i),{def:Pu(i),path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function FX(e,t,r){if(e===null||typeof e!="object")throw new TypeError("Root schema must be a plain JSON-schema record");let n=Object.getPrototypeOf(e);if(![null,Object.prototype].includes(n))throw new TypeError("Root schema must be a plain JSON-schema record");let i={};for(let[c,u]of Object.entries(Object.getOwnPropertyDescriptors(e))){if(!u.enumerable)continue;if(!("value"in u))throw new TypeError(`Root schema property '${c}' must be a data property`);let l=u.value;if(c==="toJSON"&&typeof l=="function")throw new TypeError("Root schema cannot contain a callable 'toJSON' property");["undefined","function","symbol"].includes(typeof l)||Object.defineProperty(i,c,{configurable:!0,enumerable:!0,value:l,writable:!0})}let{type:o,nullable:s,$ref:a}=i;if(!["undefined","boolean"].includes(typeof s))throw new TypeError("Root schema 'nullable' must be a boolean");if(o!=="object"||s===!0){let c;throw typeof o=="string"?c=s===!0?`${o},null`:o:Array.isArray(o)&&(c=o.join(",")),new Error(`Root schema must have type: 'object' but got type: ${c?`'${c}'`:"undefined"}`)}if(a!==void 0)throw new Error("Root schema must be a concrete object and cannot contain '$ref'");if(t!==void 0&&r!=="duplicate-ref")throw new Error("Root schema must have type: 'object' but got type: undefined");return i}var iE=(e,t)=>{let r=vF(t);r.openaiStrictMode&&(r.definitions={...r.definitions});let n;typeof t=="string"?n=t:t?.nameStrategy!=="title"&&(n=t?.name);let i=_e(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},r.openaiStrictMode===!0)??{},o=r.openaiStrictMode?FX(i,n,r.nameStrategy):i,s=r.nameStrategy==="title"?r.name:void 0;s!==void 0&&(o.title=s);let a=(()=>{if(yF(r.definitions))return;let u={},l=new Set;for(let d=0;d<500;d++){let p=Object.entries(r.definitions).filter(([f])=>!l.has(f));if(p.length===0)break;for(let[f,m]of p)u[f]=_e(Pu(m),{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0)??{},l.add(f)}return u})(),c;return n===void 0?c=a?{...o,[r.definitionPath]:a}:o:r.nameStrategy==="duplicate-ref"?c={...o,...a||r.seenRefs.size?{[r.definitionPath]:{...a,...r.seenRefs.size?{[n]:o}:void 0}}:void 0}:c={$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...a,[n]:o}},r.target==="jsonSchema7"?c.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),c};var Ii=new Set(["$comment","default","description","examples","readOnly","title","writeOnly"]),Ru=new Set(["$id","$schema"]),cE=new Set(["additionalProperties","dependencies","maxProperties","minProperties","patternProperties","properties","propertyNames","required"]),xF=["additionalItems","additionalProperties","contains","contentSchema","else","if","not","propertyNames","then","unevaluatedItems","unevaluatedProperties"],kF=["allOf","anyOf","items","oneOf","prefixItems"],IF=["$defs","definitions","dependentSchemas","dependencies","patternProperties","properties"],BX=new Set(["$anchor","$dynamicAnchor","$dynamicRef","$recursiveAnchor","$recursiveRef","allOf","contains","contentEncoding","contentMediaType","contentSchema","dependentRequired","dependentSchemas","dependencies","else","if","maxContains","maxProperties","minContains","minProperties","not","patternProperties","prefixItems","propertyNames","then","unevaluatedItems","unevaluatedProperties","uniqueItems"]),bF=new Set([...Ii,"additionalProperties","properties","required","type"]);function Rp(e,...t){for(let r of t)Object.prototype.propertyIsEnumerable.call(r,"__proto__")&&!pe(e,"__proto__")&&Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0}),Object.assign(e,r);return e}function rn(e,t,r){let n=e;for(let i of xF)i in n&&r(n[i],[...t,i],i);for(let i of kF){let o=n[i];if(Array.isArray(o))for(let[s,a]of o.entries())r(a,[...t,i,String(s)],i);else o!==void 0&&r(o,[...t,i],i)}for(let i of IF){let o=n[i];if(Fe(o))for(let[s,a]of Object.entries(o))i==="dependencies"&&!Np(a)||r(a,[...t,i,s],i)}}function SF(e){let t=structuredClone(e);if(AF(t),OF(t),r7(t),ZX(t),t.type!=="object")throw new Error(`Root schema must have type: 'object' but got type: ${t.type?`'${t.type}'`:"undefined"}`);if(t.anyOf!==void 0)throw new Error("Root schema must not use `anyOf` because strict Structured Outputs requires a root object without a union.");qb(t,[],t),EF(t),qb(t,[],t),i7(t),Gb(t,[],t);let r=Wb(t,[],t);return qb(r,[],r),r}function AF(e,t=new Set){if(typeof e=="boolean"||!Fe(e)||t.has(e))return;t.add(e);let r=e;for(let n of Object.keys(r))r[n]===void 0&&delete r[n];rn(e,[],n=>{AF(n,t)})}function ZX(e){let t=new Set;for(;;){if(typeof e.$ref=="string"){if(t.has(e.$ref))throw new Error("Cyclic local $ref at `<root>` is not supported: "+JSON.stringify(e.$ref));t.add(e.$ref)}VX(e),EF(e,!0),WX(e);let r=qX(e);if(e.$ref===void 0&&!r)return}}function VX(e){let t=e.$ref;if(t===void 0)return;if(wF(t),!HX(e))throw new Error("Schema $ref at `<root>` has non-metadata siblings that Draft 7 ignores and cannot be represented in strict Structured Outputs.");let r=new Set,n=Object.fromEntries(Object.entries(e).filter(([l])=>Ii.has(l))),i;for(;;){if(r.has(t))throw new Error("Cyclic local $ref at `<root>` is not supported: "+JSON.stringify(t));r.add(t);let l=za(e,t);if(l===void 0)throw new Error("Local $ref at `<root>` does not resolve to an object or boolean schema: "+JSON.stringify(t));if(typeof l=="boolean")throw new TypeError("Expected object schema but got boolean; path=<root>");let d=l.$ref;if(d===void 0){i=l;break}if(wF(d),r.has(d))throw new Error("Cyclic local $ref at `<root>` is not supported: "+JSON.stringify(d));if(!Mp(l))throw new Error("Schema $ref in root chain has non-annotation siblings that Draft 7 ignores and cannot be represented in strict Structured Outputs.");for(let p of Ii)!(p in n)&&p in l&&(n[p]=l[p]);t=d}let o=e.$defs,s=e.definitions,a=Object.fromEntries(Object.entries(e).filter(([l])=>Ii.has(l)||Ru.has(l))),c=structuredClone(i);for(let l of["$defs","definitions"])e[l]!==void 0&&c[l]!==void 0&&delete c[l];let u=e;for(let l of Object.keys(e))delete u[l];Rp(e,c,n,a),o!==void 0&&(e.$defs=o),s!==void 0&&(e.definitions=s)}function WX(e){for(;e.allOf!==void 0;){if(Array.isArray(e.allOf))for(let[s,a]of e.allOf.entries())Gb(a,["allOf",String(s)],e);if(dE(e,[],e))continue;let t=e.allOf;if(!Array.isArray(t)||t.length!==1||!JX(e))return;let r=t[0];if(typeof r=="boolean"||!Fe(r))return;let n={...e};delete n.allOf;let i=structuredClone(r),o=e;for(let s of Object.keys(e))delete o[s];Rp(e,i,n)}}function qX(e){let t=e.anyOf;if(!Array.isArray(t)||!XX(e))return!1;let r=t.map((u,l)=>({branch:u,index:l})).filter(({branch:u})=>u!==!1);if(r.length!==1)return!1;let{branch:n,index:i}=r[0];if(typeof n=="boolean"||!Fe(n)||!Kb(n,e))return!1;let o=KX(e,n);GX(e,i,o);let s={...e};delete s.anyOf;let a=structuredClone(n);for(let u of["$defs","definitions"]){let l=e[u],d=a[u];if(!Fe(l)||!Fe(d))continue;let p=o.get(u),f={...l};for(let[m,h]of Object.entries(d))Object.defineProperty(f,p?.get(m)??m,{value:h,writable:!0,enumerable:!0,configurable:!0});a[u]=f,delete s[u]}let c=e;for(let u of Object.keys(e))delete c[u];return Rp(e,a,s),!0}function KX(e,t){let r=new Map;for(let n of["$defs","definitions"]){let i=e[n],o=t[n];if(!Fe(i)||!Fe(o))continue;let s=new Set([...Object.keys(i),...Object.keys(o)]),a=new Map,c=0;for(let[u,l]of Object.entries(o)){if(!pe(i,u)||Zh(i[u],l))continue;let d="__openai_strict_anyOf_definition_"+c++;for(;s.has(d);)d="__openai_strict_anyOf_definition_"+c++;s.add(d),a.set(u,d)}a.size>0&&r.set(n,a)}return r}function GX(e,t,r){let n=o=>{let s=Nu(o);if(s===void 0||s[0]!=="anyOf"||s[1]!==String(t))return o;let a=s.slice(2),c=a[0];if(a.length>1&&(c==="$defs"||c==="definitions")){let u=r.get(c)?.get(a[1]);u!==void 0&&(a[1]=u)}return a.length===0?"#":"#/"+a.map(TF).join("/")},i=o=>{typeof o=="boolean"||!Fe(o)||(typeof o.$ref=="string"&&(o.$ref=n(o.$ref)),rn(o,[],s=>{i(s)}))};i(e)}function wF(e){if(typeof e!="string")throw new TypeError("Received non-string $ref - "+String(e)+"; path=<root>");if(!e.startsWith("#"))throw new Error("External $ref at `<root>` is not supported in strict Structured Outputs: "+JSON.stringify(e))}function HX(e){return Object.keys(e).every(t=>t==="$ref"||t==="$defs"||t==="definitions"||Ru.has(t)||Ii.has(t))}function OF(e){typeof e=="boolean"||!Fe(e)||(Array.isArray(e.type)&&e.type.length===1&&(e.type=e.type[0]),rn(e,[],t=>{OF(t)}))}function Bh(e,t,r=new Set){if(typeof e=="boolean")return e;let n=e.$ref;if(n!==void 0){if(typeof n!="string"||!Mp(e)||r.has(n))return!1;let i=za(t,n);return i===void 0?!1:Bh(i,t,new Set([...r,n]))}return!(e.type!==void 0&&e.type!=="null"&&!(Array.isArray(e.type)&&e.type.includes("null"))||"const"in e&&e.const!==null||e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.includes(null))||e.allOf!==void 0&&(!Array.isArray(e.allOf)||!e.allOf.every(i=>Bh(i,t)))||e.anyOf!==void 0&&(!Array.isArray(e.anyOf)||!e.anyOf.some(i=>Bh(i,t)))||e.oneOf!==void 0&&(!Array.isArray(e.oneOf)||e.oneOf.filter(i=>Bh(i,t)).length!==1)||e.not!==void 0||e.if!==void 0||e.then!==void 0||e.else!==void 0)}function Wb(e,t,r){if(typeof e=="boolean")throw new TypeError(`Expected object schema but got boolean; path=${t.join("/")}`);if(!Fe(e))throw new TypeError(`Expected ${JSON.stringify(e)} to be an object; path=${t.join("/")}`);if(dE(e,t,r))return Wb(e,t,r);if(t7(e),QX(e,t,r),aE(e)){if(!pe(e,"additionalProperties"))e.additionalProperties=!1;else if(e.additionalProperties!==!1)throw new Error(`Object schema at \`${t.join("/")||"<root>"}\` must set \`additionalProperties: false\` to be compatible with strict Structured Outputs.`)}let n=e.required??[];if(!Array.isArray(n)||n.some(d=>typeof d!="string"))throw new TypeError(`Expected \`required\` to be an array of strings; path=${t.join("/")||"<root>"}`);let i=e.properties;if(aE(e)){for(let d of n)if(!Fe(i)||!pe(i,d))throw new Error(`Object schema at \`${t.join("/")||"<root>"}\` requires property \`${d}\` but does not declare it in \`properties\`.`)}if(Fe(i)){for(let[d,p]of Object.entries(i))if(!Bh(p,r)&&!n.includes(d))throw new Error(`Schema field at \`${[...t,"properties",d].join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);e.required=Object.keys(i)}let o=e.items,s=e.additionalItems;if(Array.isArray(o))throw new TypeError(`Schema at \`${t.join("/")||"<root>"}\` uses tuple-form \`items\`, which cannot be represented in strict Structured Outputs.`);if(s!==void 0)throw new Error(`Schema at \`${t.join("/")||"<root>"}\` uses unsupported keyword \`additionalItems\` and cannot be represented in strict Structured Outputs.`);let a=e.allOf;if(Array.isArray(a)&&a.length===1&&uE(e,"allOf")){let d=a[0];if(d===!1)throw new Error(`Schema at \`${t.join("/")||"<root>"}\` uses \`allOf: [false]\`, which cannot be represented in strict Structured Outputs.`);if(d===!0)delete e.allOf;else{let p=Wb(d,[...t,"allOf","0"],r),f={...e};delete f.allOf,Rp(e,p,f),delete e.allOf}}e7(e,r);let c=e;for(let d of BX){if(c[d]!==void 0)throw new Error(`Schema at \`${t.join("/")||"<root>"}\` uses unsupported keyword \`${d}\` and cannot be represented in strict Structured Outputs.`);delete c[d]}let u=e.type,l=e.items;if((u==="array"||Array.isArray(u)&&u.includes("array"))&&l===void 0)throw new Error(`Schema at \`${t.join("/")||"<root>"}\` declares an array without \`items\`, which cannot be represented in strict Structured Outputs.`);return rn(e,t,(d,p,f)=>{typeof d=="boolean"&&(f==="additionalProperties"||f==="additionalItems")||Wb(d,p,r)}),e.default===null&&delete e.default,e}function Nu(e){if(!e.startsWith("#"))return;let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(t==="")return[];if(!t.startsWith("/"))return;let r=[];for(let n of t.slice(1).split("/")){if(/~(?:[^01]|$)/.test(n))return;r.push(n.replace(/~1/g,"/").replace(/~0/g,"~"))}return r}function Cu(e,t){if(Array.isArray(e)){if(!/^(?:0|[1-9]\d*)$/.test(t))return;let r=Number(t);return pe(e,r)?e[r]:void 0}if(!(!Fe(e)||!pe(e,t)))return e[t]}function za(e,t){let r=Nu(t);if(r===void 0)return;let n=e;for(let i=0;i<r.length;){if(!Fe(n))return;let o=r[i];if(xF.includes(o)){n=Cu(n,o),i+=1;continue}if(kF.includes(o)){if(n=Cu(n,o),i+=1,Array.isArray(n)){if(i>=r.length)return;n=Cu(n,r[i]),i+=1}continue}if(IF.includes(o)){let s=Cu(n,o);if(i+=1,!Fe(s)||i>=r.length||(n=Cu(s,r[i]),o==="dependencies"&&!Np(n)))return;i+=1;continue}return}return Np(n)?n:void 0}function Fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Np(e){return typeof e=="boolean"||Fe(e)}function Kb(e,t,r=new Set){if(typeof e=="boolean"||!Fe(e))return!1;if(e.$ref!==void 0){if(typeof e.$ref!="string"||!Mp(e)||r.has(e.$ref))return!1;let n=za(t,e.$ref);return n===void 0?!1:Kb(n,t,new Set([...r,e.$ref]))}if(e.allOf!==void 0){if(!Array.isArray(e.allOf)||e.allOf.length!==1||!uE(e,"allOf"))return!1;let n=e.allOf[0];return n!==void 0&&n!==!0&&n!==!1?Kb(n,t,r):!1}return e.type==="object"||Array.isArray(e.type)&&e.type.length===1&&e.type[0]==="object"}function sE(e,t,r=new Set){if(typeof e=="boolean"||!Fe(e))return!1;if(e.$ref!==void 0){if(typeof e.$ref!="string"||!Mp(e)||r.has(e.$ref))return!1;let n=za(t,e.$ref);return n===void 0?!1:sE(n,t,new Set([...r,e.$ref]))}if(e.allOf!==void 0){if(!Array.isArray(e.allOf)||e.allOf.length!==1||!uE(e,"allOf"))return!1;let n=e.allOf[0];return n!==void 0&&n!==!0&&n!==!1?sE(n,t,r):!1}return e.type==="array"||Array.isArray(e.type)&&e.type.length===1&&e.type[0]==="array"}function Mp(e){return Object.keys(e).every(t=>t==="$ref"||t==="$defs"||t==="definitions"||Ii.has(t))}function uE(e,t){let r=e;return Object.keys(e).every(n=>n===t||(n==="$defs"||n==="definitions")&&Fe(r[n])||Ii.has(n))}function JX(e){return Object.keys(e).every(t=>t==="allOf"||t==="$defs"||t==="definitions"||Ru.has(t)||Ii.has(t))}function XX(e){return Object.keys(e).every(t=>t==="anyOf"||t==="$defs"||t==="definitions"||t==="type"&&e.type==="object"||Ru.has(t)||Ii.has(t))}function YX(e){return Object.keys(e).some(t=>cE.has(t))}function aE(e){let t=e.type;return t==="object"||Array.isArray(t)&&t.includes("object")||t===void 0&&YX(e)}function $F(e,t){return e===t||Array.isArray(e)&&e.length===2&&e.includes(t)&&e.includes("null")}function QX(e,t,r){if(e.anyOf===void 0)return;let n=Fe(e.properties)&&Object.keys(e.properties).length===0,i=Array.isArray(e.required)&&e.required.length===0;if(n&&delete e.properties,i&&delete e.required,!aE(e))return;let o=Object.keys(e).some(s=>cE.has(s));if($F(e.type,"object")&&!o&&Array.isArray(e.anyOf)&&e.anyOf.every(s=>Kb(s,r))){delete e.type;return}throw new Error("Object anyOf schema at `"+(t.join("/")||"<root>")+"` cannot be represented in strict Structured Outputs without changing Draft 7 validation.")}function e7(e,t){$F(e.type,"array")&&e.items===void 0&&Array.isArray(e.anyOf)&&e.anyOf.every(r=>sE(r,t))&&delete e.type}function t7(e){if(!Array.isArray(e.anyOf))return;let t=e.anyOf.filter(r=>r!==!1);t.length>0&&t.length!==e.anyOf.length&&(e.anyOf=t)}function r7(e){let t=(r,n)=>{if(!(typeof r=="boolean"||!Fe(r))){if(n.length>0&&r.$id!==void 0)throw new Error("Nested $id at "+JSON.stringify(n.join("/"))+" establishes a separate JSON Schema resource scope and cannot be represented in strict Structured Outputs.");rn(r,n,(i,o)=>{t(i,o)})}};t(e,[])}function n7(e,t){let r=Nu(t);if(r===void 0)return!1;let n=e;for(let[i,o]of r.entries()){if(o==="allOf"&&Fe(n)&&Array.isArray(n.allOf)&&i<r.length-1)return!0;if(n=Cu(n,o),n===void 0)return!1}return!1}function lE(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function TF(e){return encodeURIComponent(lE(e)).replace(/%24/g,"$")}function i7(e){let t=n=>{let i=Nu(n);if(i===void 0||i.length===0)return n;let o=[...i],s=e,a=!1;for(let[c,u]of i.entries()){let l=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:void 0;if(u==="anyOf"&&c<i.length-1&&l!==void 0&&Array.isArray(l.anyOf)){let d=l.anyOf,p=i[c+1];if(!/^(?:0|[1-9]\d*)$/.test(p))return n;let f=Number(p);if(!pe(d,f))return n;let m=d.filter(h=>h!==!1);if(m.length>0&&m.length!==d.length){if(d[f]===!1)return n;let h=d.slice(0,f).filter(y=>y!==!1).length;h!==f&&(o[c+1]=String(h),a=!0)}}if(s=Cu(s,u),s===void 0)return n}return a?"#/"+o.map(TF).join("/"):n},r=n=>{typeof n=="boolean"||!Fe(n)||(typeof n.$ref=="string"&&(n.$ref=t(n.$ref)),rn(n,[],i=>{r(i)}))};r(e)}function EF(e,t=!1){let r=new Set,n=c=>{if(!(typeof c=="boolean"||!Fe(c))){if(typeof c.$ref=="string"&&n7(e,c.$ref)){let u=Nu(c.$ref);(!t||u?.[0]==="allOf")&&r.add(c.$ref)}rn(c,[],u=>{n(u)})}};if(n(e),r.size===0)return;if(e.$defs!==void 0&&!Fe(e.$defs))throw new Error("Root schema has invalid $defs and cannot preserve local allOf references.");let i=e.$defs??(e.$defs={}),o=new Map,s=0;for(let c of r){let u=za(e,c);if(!Np(u)){if(t)continue;throw new Error("Local $ref cannot be preserved before allOf flattening: "+JSON.stringify(c))}let l="__openai_strict_allOf_ref_"+s++;for(;pe(i,l);)l="__openai_strict_allOf_ref_"+s++;i[l]=structuredClone(u),o.set(c,"#/$defs/"+lE(l))}let a=c=>{typeof c=="boolean"||!Fe(c)||(typeof c.$ref=="string"&&(c.$ref=o.get(c.$ref)??c.$ref),rn(c,[],u=>{a(u)}))};a(e)}function o7(e,t){if(t.length===0)return;let r=new Set,n=c=>{if(!(typeof c=="boolean"||!Fe(c))){if(typeof c.$ref=="string"){let u=Nu(c.$ref);u!==void 0&&t.some(l=>u.length>=l.length&&l.every((d,p)=>u[p]===d))&&r.add(c.$ref)}rn(c,[],u=>{n(u)})}};if(n(e),r.size===0)return;if(e.$defs!==void 0&&!Fe(e.$defs))throw new Error("Root schema has invalid $defs and cannot preserve discarded allOf properties.");let i=e.$defs??(e.$defs={}),o=new Map,s=0;for(let c of r){let u=za(e,c);if(!Np(u))throw new Error("Local $ref cannot be preserved before allOf property removal: "+JSON.stringify(c));let l="__openai_strict_allOf_property_ref_"+s++;for(;pe(i,l);)l="__openai_strict_allOf_property_ref_"+s++;i[l]=structuredClone(u),o.set(c,"#/$defs/"+lE(l))}let a=c=>{typeof c=="boolean"||!Fe(c)||(typeof c.$ref=="string"&&(c.$ref=o.get(c.$ref)??c.$ref),rn(c,[],u=>{a(u)}))};a(e)}function qb(e,t,r){if(typeof e=="boolean"||!Fe(e))return;let n=e.$ref;if(n!==void 0){if(typeof n!="string")throw new TypeError(`Received non-string $ref - ${n}; path=${t.join("/")}`);if(!n.startsWith("#"))throw new Error(`External $ref at \`${t.join("/")||"<root>"}\` is not supported in strict Structured Outputs: ${JSON.stringify(n)}`);let i=za(r,n);if(i===void 0||!Np(i))throw new Error(`Local $ref at \`${t.join("/")||"<root>"}\` does not resolve to an object or boolean schema: ${JSON.stringify(n)}`);if(typeof i=="boolean")throw new TypeError(`Expected object schema but got boolean; path=${t.join("/")}`);if(!Mp(e))throw new Error(`Schema $ref at \`${t.join("/")||"<root>"}\` has non-annotation siblings that Draft 7 ignores and cannot be represented in strict Structured Outputs.`)}rn(e,t,(i,o)=>{qb(i,o,r)})}function s7(e,t,r){let n=[e],i=new Set,o=e,s=[];for(;;){for(;o.$ref!==void 0;){let a=o.$ref;if(typeof a!="string"||!Mp(o)||i.has(a))return;i.add(a);let c=za(t,a);if(typeof c=="boolean"||!Fe(c))return;let u=Nu(a);if(u===void 0)return;o=c,s=u,n.push(o)}if(o.allOf!==void 0&&!r.has(o)){let a=o.allOf;if(Gb(o,s,t,r),o.$ref!==void 0||o.allOf!==a)continue}return{schema:o,refChain:n}}}function Gb(e,t,r,n=new Set){if(!(typeof e=="boolean"||!Fe(e))&&!n.has(e)){n.add(e);try{for(;;)if(rn(e,t,(i,o)=>{Gb(i,o,r,n)}),!dE(e,t,r,n))return}finally{n.delete(e)}}}function dE(e,t,r,n=new Set){let i=e.allOf;if(!Array.isArray(i)||i.length===0)return!1;let o=i.filter((R,B)=>!i.slice(0,B).some(K=>Zh(K,R)));if(o.length!==i.length)return e.allOf=o,!0;let s=i.filter(R=>R!==!0);if(s.length!==i.length)return s.length===0?delete e.allOf:e.allOf=s,!0;let a=oE(e),c=i.map(R=>Fe(R)?s7(R,r,n):void 0),u=c.map(R=>R?.schema).filter(R=>R!==void 0&&oE(R));if(!a&&u.length===0||!a&&i.length===1)return!1;let l=()=>{throw new Error(`Object allOf at \`${t.join("/")||"<root>"}\` cannot be merged without changing Draft 7 validation.`)};!a&&["additionalProperties","properties","required","type"].some(R=>R in e)&&l();for(let R of Object.keys(e))R!=="allOf"&&R!=="$defs"&&R!=="definitions"&&!(t.length===0&&Ru.has(R))&&!bF.has(R)&&l();let d=[];a&&d.push({schema:e,sourcePath:t});for(let[R,B]of i.entries()){Fe(B)||l();let K=c[R];if(K===void 0)return l();let re=K.schema;oE(re)?d.push({schema:re,sourcePath:re===B?[...t,"allOf",String(R)]:void 0}):a7(re)||l()}let p={};for(let R of["$defs","definitions"])e[R]!==void 0&&(p[R]=e[R]);if(t.length===0)for(let R of Ru)R in e&&(p[R]=e[R]);let f=Object.create(null),m=new Set,h=[],y=[],w=!1,_=!1,b=!1,I=!1,$=R=>{for(let B of Ii)B in R&&(B in p||(p[B]=R[B]))};$(e);for(let R of c)if(R!==void 0)for(let B of R.refChain)$(B);for(let{schema:R,sourcePath:B}of d){for(let K of Object.keys(R))K==="allOf"&&R===e||(K==="$defs"||K==="definitions")&&Fe(R[K])||R===e&&t.length===0&&Ru.has(K)||bF.has(K)||l();if(R.type!==void 0&&(PF(R.type)||l(),R.type==="object"?b=!0:I=!0),R.properties!==void 0){Fe(R.properties)||l(),w=!0;for(let[K,re]of Object.entries(R.properties))y.push({key:K,propertySchema:re,sourcePath:B===void 0?void 0:[...B,"properties",K]})}if(R.required!==void 0){(!Array.isArray(R.required)||R.required.some(K=>typeof K!="string"))&&l(),_=!0;for(let K of R.required)m.add(K)}"additionalProperties"in R&&(R.additionalProperties!==!1&&l(),h.push(new Set(Object.keys(R.properties??{}))))}let P;if(h.length>0){P=new Set(h[0]);for(let R of h.slice(1))for(let B of P)R.has(B)||P.delete(B)}let C=P,x=C!==void 0&&[...m].some(R=>!C.has(R)),D=x&&!b&&I,M=y.filter(({key:R,sourcePath:B})=>B!==void 0&&(D||P!==void 0&&!P.has(R))).map(({sourcePath:R})=>R);if(o7(r,M),e===r&&r.$defs!==void 0&&(p.$defs=r.$defs),x){if(D){p.type="null";for(let R of Object.keys(e))delete e[R];return Rp(e,p),!0}l()}for(let{key:R,propertySchema:B}of y)P!==void 0&&!P.has(R)||(pe(f,R)&&!Zh(f[R],B)&&l(),f[R]=B);(b||I)&&(p.type=b?"object":["object","null"]),w&&(p.properties=Object.fromEntries(Object.entries(f))),_&&(p.required=[...m]),h.length>0&&(p.additionalProperties=!1);for(let R of Object.keys(e))delete e[R];return Rp(e,p),!0}function oE(e){return e.type!==void 0?PF(e.type):Object.keys(e).some(t=>cE.has(t))}function a7(e){let t=e;return Object.keys(e).every(r=>Ii.has(r)||(r==="$defs"||r==="definitions")&&Fe(t[r]))}function PF(e){return e==="object"||Array.isArray(e)&&e.length===2&&e.includes("object")&&e.includes("null")}function Zh(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((s,a)=>Zh(s,t[a]));if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;let r=e,n=t,i=Object.keys(r),o=Object.keys(n);return i.sort(),o.sort(),i.length!==o.length?!1:i.every((s,a)=>s===o[a]&&Zh(r[s],n[s]))}var c7={ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean",ZodNull:"null",ZodObject:"object",ZodArray:"array"},u7=new Set(["ZodOptional","ZodNullable","ZodDefault","ZodReadonly"]),l7=new Set(["ZodString","ZodNumber","ZodBoolean","ZodNull","ZodEnum","ZodNativeEnum","ZodAny","ZodUnknown","ZodLiteral"]),d7=new Map([["ZodBigInt","encode integers as decimal strings and convert with BigInt after parsing"],["ZodDate","native dates do not have a synchronous JSON representation"],["ZodMap","native maps do not have a synchronous JSON representation"],["ZodSet","native sets do not have a synchronous JSON representation"],["ZodPromise","asynchronous values do not have a synchronous JSON representation"],["ZodEffects","custom transformations and refinements are opaque to JSON Schema"],["ZodPipeline","custom pipelines are opaque to JSON Schema"],["ZodIntersection","intersections cannot prove that both branches produce the same value"],["ZodCatch","catch fallbacks cannot be proven to produce JSON-native values"],["ZodTuple","tuple schemas require unsupported array-valued items"],["ZodRecord","open-ended record schemas require unsupported additionalProperties"]]),p7=new Set(["trim","toLowerCase","toUpperCase"]),f7=new Set(["regex","cuid","cuid2","startsWith","endsWith","includes","emoji","ulid","nanoid"]);function us(e,t,r){throw new Error(`Zod schema field \`${e}\` uses \`${t}\`, which cannot be represented by strict Structured Outputs: ${r}`)}function Hb(e){if(e===null)return{type:"null",values:new Set([null])};if(typeof e=="string")return{type:"string",values:new Set([e])};if(typeof e=="boolean")return{type:"boolean",values:new Set([e])};if(typeof e=="number"&&Number.isFinite(e))return{type:"number",values:new Set([e])}}function CF(e){let t=e.values;if(!t||Array.isArray(t))return[];let r=t,n=Object.keys(r).filter(i=>{let o=r[i];return(typeof o=="string"||typeof o=="number")&&typeof r[String(o)]!="number"}).map(i=>r[i]).filter(i=>typeof i=="string"||typeof i=="number"&&Number.isFinite(i));return["string","number"].map(i=>({type:i,values:new Set(n.filter(o=>typeof o===i))})).filter(i=>i.values.size>0)}function RF(e){let t=Array.isArray(e.values)?e.values.filter(r=>typeof r=="string"):[];return{type:"string",values:new Set(t)}}function m7(e){if(e.typeName==="ZodLiteral"){let t=Hb(e.value);return t?[t]:[]}return e.typeName==="ZodEnum"?[RF(e)]:e.typeName==="ZodNativeEnum"?CF(e):[]}function h7(e){let t=new Map;for(let[r,n]of Object.entries(e.shape())){let i=m7(n._def);i.length>0&&i.every(({values:o})=>o!==void 0&&o.size>0)&&t.set(r,i)}return{type:"object",discriminators:t}}function zp(e,t=new Set){let r=e._def;if(t.has(r))return[{type:"unknown"}];if(t.add(r),r.typeName==="ZodObject")return[h7(r)];let n=c7[r.typeName];if(n!==void 0)return[{type:n}];if(r.typeName==="ZodLiteral"){let i=Hb(r.value);return i?[i]:[{type:"unknown"}]}return r.typeName==="ZodEnum"?[RF(r)]:r.typeName==="ZodNativeEnum"?CF(r):r.typeName==="ZodUnion"||r.typeName==="ZodDiscriminatedUnion"?[...r.options.values()].flatMap(i=>zp(i,new Set(t))):r.typeName==="ZodNullable"?[...zp(r.innerType,new Set(t)),{type:"null"}]:u7.has(r.typeName)?zp(r.innerType,t):r.typeName==="ZodBranded"?zp(r.type,t):r.typeName==="ZodLazy"?zp(r.getter(),t):[{type:"unknown"}]}function NF(e,t){if(e.type==="unknown"||t.type==="unknown")return!0;if(e.type!==t.type)return!1;if(e.discriminators&&t.discriminators)for(let[n,i]of e.discriminators){let o=t.discriminators.get(n);if(o&&!i.some(s=>o.some(a=>NF(s,a))))return!1}let r=t.values;return!e.values||!r?!0:[...e.values].some(n=>r.has(n))}function g7(e,t){let r=e.map(n=>zp(n));for(let[n,i]of r.entries())for(let o of r.slice(n+1))i.some(s=>o.some(a=>NF(s,a)))&&us(t,"ZodUnion","ambiguous union branches overlap; use disjoint JSON types, distinct literals, or a discriminated union")}function y7(e,t){switch(e.typeName){case"ZodObject":{let r=Object.entries(e.shape()).map(([n,i])=>({schema:i,path:`${t}.${n}`}));return e.catchall&&e.catchall._def.typeName!=="ZodNever"&&r.push({schema:e.catchall,path:`${t}.<catchall>`}),r}case"ZodArray":return[{schema:e.type,path:`${t}[]`}];case"ZodUnion":case"ZodDiscriminatedUnion":return[...e.options.values()].map((r,n)=>({schema:r,path:`${t}[${n}]`}));case"ZodOptional":case"ZodNullable":case"ZodDefault":case"ZodReadonly":return[{schema:e.innerType,path:t}];case"ZodBranded":return[{schema:e.type,path:t}];case"ZodLazy":return[{schema:e.getter(),path:t}];default:return}}function MF(e){let t=e.checks??[];return t.some(({kind:r})=>r==="finite"||r==="int")?!0:t.some(({kind:r,value:n})=>r==="min"&&typeof n=="number"&&Number.isFinite(n))&&t.some(({kind:r,value:n})=>r==="max"&&typeof n=="number"&&Number.isFinite(n))}function _7(e,t,r){return e.unknownKeys!=="passthrough"&&(e.catchall===void 0||e.catchall._def.typeName==="ZodNever")&&Object.values(e.shape()).every(n=>r(n,new Set(t)))}function Mu(e,t=new Set){let r=e._def;if(t.has(r))return!0;switch(t.add(r),r.typeName){case"ZodString":case"ZodBoolean":case"ZodNull":case"ZodEnum":case"ZodNativeEnum":return!0;case"ZodLiteral":return Hb(r.value)!==void 0;case"ZodNumber":return MF(r);case"ZodArray":return Mu(r.type,t);case"ZodObject":return _7(r,t,Mu);case"ZodUnion":case"ZodDiscriminatedUnion":return[...r.options.values()].every(n=>Mu(n,new Set(t)));case"ZodNullable":case"ZodDefault":case"ZodReadonly":return Mu(r.innerType,t);case"ZodBranded":return Mu(r.type,t);case"ZodLazy":return Mu(r.getter(),t);default:return!1}}function v7(e,t){let r=d7.get(e.typeName);r&&us(t,e.typeName,r),e.typeName==="ZodLiteral"&&!Hb(e.value)&&us(t,e.typeName,"literal values must be finite JSON primitives"),e.typeName==="ZodNumber"&&e.coerce===!0&&!MF(e)&&us(t,e.typeName,"number coercion must prove its parsed output is finite"),e.typeName==="ZodDefault"&&!Mu(e.innerType)&&us(t,e.typeName,"default factory output is not independently guaranteed to be finite and JSON-native; it may contain bigint"),e.typeName==="ZodString"&&e.checks?.some(({kind:n})=>p7.has(n))&&us(t,e.typeName,"value-changing string checks are not represented in JSON Schema"),e.typeName==="ZodString"&&(e.checks?.filter(({kind:n})=>f7.has(n)).length??0)>1&&us(t,e.typeName,"multiple pattern-producing checks require unsupported allOf")}function pE(e,t,r){let n=e._def;if(r.has(n)||(r.add(n),n.typeName==="ZodIntersection"&&t==="$"))return;v7(n,t);let i=y7(n,t);if(!i){l7.has(n.typeName)||us(t,n.typeName,"this Zod schema is outside the documented JSON-native subset");return}for(let o of i)pE(o.schema,o.path,r);n.typeName==="ZodObject"&&(n.unknownKeys==="passthrough"||n.catchall!==void 0&&n.catchall._def.typeName!=="ZodNever")&&us(t,n.typeName,"open object schemas require additionalProperties: false"),n.typeName==="ZodUnion"&&t!=="$"&&g7(i.map(({schema:o})=>o),t)}function zF(e,t){let r=new Set;pE(e,"$",r);for(let[n,i]of Object.entries(t??{}))pE(i,`$.definitions.${n}`,r)}function b7(e,t){for(let r=e;r!==null;r=Object.getPrototypeOf(r)){let n=Object.getOwnPropertyDescriptor(r,"toJSON");if(n){if(!("value"in n)||typeof n.value=="function")throw new Error(`Strict Structured Outputs schema field \`${t}\` contains an unsupported \`toJSON\` serialization hook`);return}}}function w7(e,t){if(Object.is(e,-0))throw new TypeError(`Strict Structured Outputs schema field \`${t}\` contains negative zero, which cannot round-trip through JSON`)}function Vh(e,t="$",r=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"&&Number.isFinite(e)){w7(e,t);return}if(typeof e!="object")throw new TypeError(`Strict Structured Outputs schema field \`${t}\` contains a non-JSON ${typeof e} value`);if(r.has(e))throw new Error(`Strict Structured Outputs schema field \`${t}\` contains a circular JSON value`);let n=Object.getPrototypeOf(e);if(!Array.isArray(e)&&n!==Object.prototype&&n!==null)throw new Error(`Strict Structured Outputs schema field \`${t}\` contains a non-JSON native object`);if(b7(e,t),r.add(e),Array.isArray(e))for(let i=0;i<e.length;i+=1){let o=Object.getOwnPropertyDescriptor(e,String(i));if(!o)throw new Error(`Strict Structured Outputs schema field \`${t}[${i}]\` contains a sparse array`);if(!("value"in o))throw new Error(`Strict Structured Outputs schema field \`${t}[${i}]\` contains an array accessor`);Vh(o.value,`${t}[${i}]`,r)}else for(let i of Object.keys(e)){let o=Object.getOwnPropertyDescriptor(e,i);if(!o||!("value"in o))throw new Error(`Strict Structured Outputs schema field \`${t}.${i}\` contains an accessor`);Vh(o.value,`${t}.${i}`,r)}r.delete(e)}function x7(e){return encodeURIComponent(e.replace(/~/g,"~0").replace(/\//g,"~1"))}function k7(e){if(e&&pe(e,"__proto__"))throw new Error('schemaDefinitions cannot include "__proto__" as a definition name')}function jF(e,t){let r=new Map(Object.keys(t??{}).map(o=>[`#/definitions/${o}`,`#/definitions/${x7(o)}`]));if(r.size===0)return e;let n=new Set,i=o=>{if(!o||typeof o!="object"||Array.isArray(o)||n.has(o))return;n.add(o);let s=o,a=s.$ref;if(typeof a=="string"){let c=r.get(a);c!==void 0&&c!==a&&(s.$ref=c)}rn(s,[],i)};return i(e),e}function I7(e,t){if(!t)return e;let r=e;for(;pe(t,r);)r=`${r}_root`;return r}function S7(e,t){zF(e,t.schemaDefinitions);let r=I7(t.name,t.schemaDefinitions),n=iE(e,{openaiStrictMode:!0,name:r,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property",...t.schemaDefinitions?{definitions:t.schemaDefinitions}:void 0}),i=jF(n,t.schemaDefinitions);return Vh(i),i}function A7(e,t={}){let r=t.schemaDefinitions?ul():void 0;for(let[o,s]of Object.entries(t.schemaDefinitions??{}))r?.add(s,{id:o});let n=So(e,{target:"draft-7",...r?{metadata:r}:void 0,override:({zodSchema:o,jsonSchema:s})=>{let a=o._zod.def;if(a.type==="union"&&"discriminator"in a&&Array.isArray(s.oneOf)){if(s.anyOf!==void 0)throw new Error("Zod discriminated union generated both `anyOf` and `oneOf`, which cannot be represented in an OpenAI strict schema");s.anyOf=s.oneOf,delete s.oneOf}}}),i=jF(n,t.schemaDefinitions);return SF(i)}function DF(e){return"_zod"in e}function O7(e,t){let r=hi({type:"json_schema",$parseRaw:void 0},t),n=e.parse;if(typeof n=="function"){let i=n.call(e,r);return DF(e)||Vh(i),i}return wm(e,r)}function UF(e,t,r){let n=e,{schemaDefinitions:i,...o}=r??{};return k7(i),Y4({type:"json_schema",json_schema:{...o,name:t,strict:!0,schema:DF(n)?A7(n,{schemaDefinitions:i}):S7(n,{name:t,schemaDefinitions:i})}},s=>O7(e,s))}var LF=["jsonSchema","functionCalling","jsonMode"];function FF(e,t){if(typeof t<"u"&&!LF.includes(t))throw new Error(`Invalid method: ${t}. Supported methods are: ${LF.join(", ")}`);let r=!e.startsWith("gpt-3")&&!e.startsWith("gpt-4-")&&e!=="gpt-4";if(r&&!t)return"jsonSchema";if(!r&&t==="jsonSchema")throw new Error(`JSON Schema is not supported for model "${e}". Please use a different method, e.g. "functionCalling" or "jsonMode".`);return t??"functionCalling"}function $7(e,t){let r={...e};return Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}function BF(e,t,r){if(_t(e))return UF(e,t,r);if(it(e))return $7({type:"json_schema",json_schema:{...r,name:t,strict:!0,schema:ht(e,{cycles:"ref",reused:"ref",override(n){n.jsonSchema.title=t}})}},n=>ji(e,JSON.parse(n)));throw new Error("Unsupported schema response format")}function ZF(e,t){if(t&&typeof t=="object"&&"images"in t&&Array.isArray(t.images)){let r=t.images.filter(n=>typeof n?.image_url?.url=="string").map(n=>({type:"image",url:n.image_url.url}));return[{type:"text",text:e},...r]}return e}var VF={"gpt-4o-2024-11-20":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.3-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-pro":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:272e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-mini":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-ada-002":{maxInputTokens:8192,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1536,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-chat-latest":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"codex-mini-latest":{maxInputTokens:2e5,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-codex-max":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-2024-05-13":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-chat-latest":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-deep-research":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},o1:{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o4-mini-deep-research":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.3-codex-spark":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},o3:{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-3-small":{maxInputTokens:8191,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1536,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1-nano":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-3-large":{maxInputTokens:8191,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-3.5-turbo":{maxInputTokens:16385,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1,imageUrlInputs:!1,pdfToolMessage:!1,imageToolMessage:!1,toolChoice:!0},"gpt-5.1-codex-mini":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-pro":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4-turbo":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o4-mini":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1-mini":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.4":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-preview":{maxInputTokens:128e3,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.4-pro":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.5":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:13e4,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.5-pro":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-pro":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-pro":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-mini":{maxInputTokens:2e5,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-2024-08-06":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-mini":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-chat-latest":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4":{maxInputTokens:8192,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-nano":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-mini":{maxInputTokens:128e3,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0}};var Jb="**REDACTED**";function jp(e,t){return typeof e=="string"?{model:e,...t??{}}:e??t}var zu=class extends Hi{temperature;topP;frequencyPenalty;presencePenalty;n;logitBias;model="gpt-3.5-turbo";modelKwargs;stop;stopSequences;user;timeout;streaming=!1;streamUsage=!0;maxTokens;logprobs;topLogprobs;apiKey;organization;__includeRawResponse;client;clientConfig;supportsStrictToolCalling;audio;modalities;reasoning;zdrEnabled;service_tier;promptCacheKey;promptCacheRetention;verbosity;defaultOptions;_llmType(){return"openai"}static lc_name(){return"ChatOpenAI"}get callKeys(){return[...super.callKeys,"options","function_call","functions","tools","tool_choice","promptIndex","response_format","seed","reasoning","reasoning_effort","service_tier"]}lc_serializable=!0;get lc_secrets(){return{apiKey:"OPENAI_API_KEY",organization:"OPENAI_ORGANIZATION"}}get lc_aliases(){return{apiKey:"openai_api_key",modelName:"model"}}get lc_serializable_keys(){return["configuration","logprobs","topLogprobs","prefixMessages","supportsStrictToolCalling","modalities","audio","temperature","maxTokens","topP","frequencyPenalty","presencePenalty","n","logitBias","user","streaming","streamUsage","model","modelName","modelKwargs","stop","stopSequences","timeout","apiKey","cache","maxConcurrency","maxRetries","verbose","callbacks","tags","metadata","disableStreaming","zdrEnabled","reasoning","promptCacheKey","promptCacheRetention","verbosity"]}getLsParams(e){let t=this.invocationParams(e);return{ls_provider:"openai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:t.temperature??void 0,ls_max_tokens:t.max_tokens??void 0,ls_stop:e.stop}}_getInvocationParamsForTracing(e){let t=this.invocationParams(e);return Array.isArray(t.tools)?{...t,tools:t.tools.map(r=>{if(r?.type!=="mcp")return r;let n={...r};return"headers"in n&&(n.headers=Jb),"authorization"in n&&(n.authorization=Jb),n})}:t}_getCallOptionsForTracing(e,t){return Array.isArray(e.tools)?{...e,tools:e.tools.map(r=>{if(typeof r!="object"||r===null||!("type"in r)||r.type!=="mcp")return r;let n={...r};return"headers"in n&&(n.headers=Jb),"authorization"in n&&(n.authorization=Jb),n})}:e}_identifyingParams(){return{model_name:this.model,...this.invocationParams(),...this.clientConfig}}identifyingParams(){return this._identifyingParams()}constructor(e){super(e??{});let t=typeof e?.configuration?.apiKey=="string"||typeof e?.configuration?.apiKey=="function"?e?.configuration?.apiKey:void 0,r=MO({baseURL:e?.configuration?.baseURL??(Ct("OPENAI_API_BASE")||Ct("OPENAI_BASE_URL")||void 0),providerPath:"openai/v1"});this.apiKey=e?.apiKey??t??r.apiKey??Ct("OPENAI_API_KEY"),this.organization=e?.configuration?.organization??Ct("OPENAI_ORGANIZATION"),this.model=e?.model??e?.modelName??this.model,this.modelKwargs=e?.modelKwargs??{},this.timeout=e?.timeout,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.logprobs=e?.logprobs,this.topLogprobs=e?.topLogprobs,this.n=e?.n??this.n,this.logitBias=e?.logitBias,this.stop=e?.stopSequences??e?.stop,this.stopSequences=this.stop,this.user=e?.user,this.__includeRawResponse=e?.__includeRawResponse,this.audio=e?.audio,this.modalities=e?.modalities,this.reasoning=e?.reasoning,this.maxTokens=e?.maxCompletionTokens??e?.maxTokens,this.promptCacheKey=e?.promptCacheKey??this.promptCacheKey,this.promptCacheRetention=e?.promptCacheRetention??this.promptCacheRetention,this.verbosity=e?.verbosity??this.verbosity,this.disableStreaming=e?.disableStreaming===!0,this.streaming=e?.streaming===!0,this.disableStreaming&&(this.streaming=!1),e?.streaming===!1&&(this.disableStreaming=!0),this.streamUsage=e?.streamUsage??this.streamUsage,this.disableStreaming&&(this.streamUsage=!1),this.clientConfig={apiKey:this.apiKey,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration,baseURL:r.baseURL},e?.supportsStrictToolCalling!==void 0&&(this.supportsStrictToolCalling=e.supportsStrictToolCalling),e?.service_tier!==void 0&&(this.service_tier=e.service_tier),this.zdrEnabled=e?.zdrEnabled??!1,this._addVersion("@langchain/openai","1.5.11")}_getReasoningParams(e){if(!os(this.model))return;let t;return this.reasoning!==void 0&&(t={...t,...this.reasoning}),e?.reasoning!==void 0&&(t={...t,...e.reasoning}),e?.reasoningEffort!==void 0&&t?.effort===void 0&&(t={...t,effort:e.reasoningEffort}),t}_getResponseFormat(e){return e&&e.type==="json_schema"&&e.json_schema.schema&&Ht(e.json_schema.schema)?BF(e.json_schema.schema,e.json_schema.name,{description:e.json_schema.description}):e}_combineCallOptions(e){return{...this.defaultOptions,...e??{}}}_getClientOptions(e){if(!this.client){let t={baseURL:this.clientConfig.baseURL},r=as(t),n={...this.clientConfig,baseURL:r,timeout:this.timeout,maxRetries:0};n.baseURL||delete n.baseURL,n.defaultHeaders=cs(n.defaultHeaders),this.client=new fe(n)}return{...this.clientConfig,...e}}_convertChatOpenAIToolToCompletionsTool(e,t){return Tu(e)?U2(e.metadata.customTool):Kf(e)?t?.strict!==void 0?{...e,function:{...e.function,strict:t.strict}}:e:T2(e,t)}bindTools(e,t){let r;return t?.strict!==void 0?r=t.strict:this.supportsStrictToolCalling!==void 0&&(r=this.supportsStrictToolCalling),this.withConfig({tools:e.map(n=>{if(Cp(n)||Tu(n))return n;if(C2(n))return n.extras.providerToolDefinition;let i=this._convertChatOpenAIToolToCompletionsTool(n,{strict:r});return zo(n)&&n.extras?.defer_loading===!0?{...i,defer_loading:!0}:i}),...t})}async stream(e,t){return super.stream(e,this._combineCallOptions(t))}async invoke(e,t){return super.invoke(e,this._combineCallOptions(t))}_combineLLMOutput(...e){return e.reduce((t,r)=>(r&&r.tokenUsage&&(t.tokenUsage.completionTokens+=r.tokenUsage.completionTokens??0,t.tokenUsage.promptTokens+=r.tokenUsage.promptTokens??0,t.tokenUsage.totalTokens+=r.tokenUsage.totalTokens??0),t),{tokenUsage:{completionTokens:0,promptTokens:0,totalTokens:0}})}async getNumTokensFromMessages(e){let t=0,r=0,n=0;this.model==="gpt-3.5-turbo-0301"?(r=4,n=-1):(r=3,n=1);let i=await Promise.all(e.map(async o=>{let[s,a]=await Promise.all([this.getNumTokens(o.content),this.getNumTokens(ss(o))]),c=o.name!==void 0?n+await this.getNumTokens(o.name):0,u=s+r+a+c,l=o;if(l._getType()==="function"&&(u-=2),l.additional_kwargs?.function_call&&(u+=3),l?.additional_kwargs.function_call?.name&&(u+=await this.getNumTokens(l.additional_kwargs.function_call?.name)),l.additional_kwargs.function_call?.arguments)try{u+=await this.getNumTokens(JSON.stringify(JSON.parse(l.additional_kwargs.function_call?.arguments)))}catch(d){console.error("Error parsing function arguments",d,JSON.stringify(l.additional_kwargs.function_call)),u+=await this.getNumTokens(l.additional_kwargs.function_call?.arguments)}return t+=u,u}));return t+=3,{totalCount:t,countPerMessage:i}}async _getNumTokensFromGenerations(e){return(await Promise.all(e.map(async t=>t.message.additional_kwargs?.function_call?(await this.getNumTokensFromMessages([t.message])).countPerMessage[0]:await this.getNumTokens(t.message.content)))).reduce((t,r)=>t+r,0)}async _getEstimatedTokenCountFromPrompt(e,t,r){let n=(await this.getNumTokensFromMessages(e)).totalCount;if(t&&r!=="auto"){let i=E2(t);n+=await this.getNumTokens(i),n+=9}return t&&e.find(i=>i._getType()==="system")&&(n-=4),r==="none"?n+=1:typeof r=="object"&&(n+=await this.getNumTokens(r.name)+4),n}async moderateContent(e,t){let r=this._getClientOptions(t?.options),n={input:e,model:t?.model??"omni-moderation-latest"};return this.caller.call(async()=>{try{return await this.client.moderations.create(n,r)}catch(i){throw qn(i)}})}get profile(){return VF[this.model]??{}}_getStructuredOutputMethod(e){let t={...e};if(!this.model.startsWith("gpt-3")&&!this.model.startsWith("gpt-4-")&&this.model!=="gpt-4"){if(t?.method===void 0)return"jsonSchema"}else t.method==="jsonSchema"&&console.warn(`[WARNING]: JSON Schema is not supported for model "${this.model}". Falling back to tool calling.`);return t.method}withStructuredOutput(e,t){let r,n,{schema:i,name:o,includeRaw:s}={...t,schema:e};if(t?.strict!==void 0&&t.method==="jsonMode")throw new Error("Argument `strict` is only supported for `method` = 'function_calling'");let a=FF(this.model,t?.method);if(a==="jsonMode"){n=s_(i);let c=ht(i);r=this.withConfig({outputVersion:"v0",response_format:{type:"json_object"},ls_structured_output_format:{kwargs:{method:"json_mode"},schema:{title:o??"extract",...c}}})}else if(a==="jsonSchema"){let c=ht(i),u={name:o??"extract",description:ti(c),schema:Ht(i)?i:c,strict:t?.strict};if(r=this.withConfig({outputVersion:"v0",response_format:{type:"json_schema",json_schema:u},ls_structured_output_format:{kwargs:{method:"json_schema"},schema:{title:u.name,description:u.description,...c}}}),Ht(i)||zi(i)){let l=s_(i);n=ir.from(async d=>"parsed"in d.additional_kwargs?d.additional_kwargs.parsed:l.invoke(d.content))}else n=new Ll}else{let c=o??"extract",u=ht(i),l;Ht(i)||zi(i)?l={name:c,description:u.description,parameters:u}:typeof i.name=="string"&&typeof i.parameters=="object"&&i.parameters!=null?(l=i,c=i.name):(c=i.title??c,l={name:c,description:i.description??"",parameters:i}),r=this.withConfig({outputVersion:"v0",tools:[{type:"function",function:l}],tool_choice:{type:"function",function:{name:c}},ls_structured_output_format:{kwargs:{method:"function_calling"},schema:{title:c,...u}},...t?.strict!==void 0?{strict:t.strict}:{}}),n=FA(i,c)}return Xf(r,n,s)}};var Wh={providerName:"ChatOpenAI",fromStandardTextBlock(e){return{type:"text",text:e.text}},fromStandardImageBlock(e){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};if(e.source_type==="base64")return{type:"image_url",image_url:{url:`data:${e.mime_type??""};base64,${e.data}`,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};throw new Error(`Image content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardAudioBlock(e){if(e.source_type==="url"){let t=qp({dataUrl:e.url});if(!t)throw new Error(`URL audio blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);let r=t.mime_type||e.mime_type||"",n;try{n=Wp(r)}catch{throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(n.type!=="audio"||n.subtype!=="wav"&&n.subtype!=="mp3")throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:"input_audio",input_audio:{format:n.subtype,data:t.data}}}if(e.source_type==="base64"){let t;try{t=Wp(e.mime_type??"")}catch{throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(t.type!=="audio"||t.subtype!=="wav"&&t.subtype!=="mp3")throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:"input_audio",input_audio:{format:t.subtype,data:e.data}}}throw new Error(`Audio content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardFileBlock(e){if(e.source_type==="url"){let t=qp({dataUrl:e.url}),r=$u(e);if(!t)throw new Error(`URL file blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);return{type:"file",file:{file_data:e.url,filename:r}}}if(e.source_type==="base64"){let t=$u(e);return{type:"file",file:{file_data:`data:${e.mime_type??""};base64,${e.data}`,filename:t}}}if(e.source_type==="id")return{type:"file",file:{file_id:e.id}};throw new Error(`File content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)}},Xb=({message:e,rawResponse:t,includeRawResponse:r})=>{let n=e.tool_calls,i=e.reasoning_content;switch(e.role){case"assistant":{let o=[],s=[];for(let l of n??[])try{o.push(Ec(l,{returnId:!0}))}catch(d){s.push(Ls(l,d.message))}let a={function_call:e.function_call,tool_calls:n};r!==void 0&&(a.__raw_response=t),i!==void 0&&(a.reasoning_content=i);let c={model_provider:"openai",model_name:t.model,usage:{...t.usage},...t.system_fingerprint?{system_fingerprint:t.system_fingerprint}:{}};e.audio&&(a.audio=e.audio);let u=ZF(e.content||"",t.choices?.[0]?.message);return new Re({content:u,tool_calls:o,invalid_tool_calls:s,additional_kwargs:a,response_metadata:c,id:t.id})}default:return new vn(e.content||"",e.role??"unknown")}},Yb=({delta:e,rawResponse:t,includeRawResponse:r,defaultRole:n})=>{let i=e.role??n,o=e.content??"",s;e.function_call?s={function_call:e.function_call}:e.tool_calls?s={tool_calls:e.tool_calls}:s={},r&&(s.__raw_response=t),e.reasoning_content!==void 0&&(s.reasoning_content=e.reasoning_content),e.audio&&(s.audio={...e.audio,index:t.choices[0].index});let a={model_provider:"openai",usage:{...t.usage}};if(i==="user")return new Za({content:o,response_metadata:a});if(i==="assistant"){let c=[];if(Array.isArray(e.tool_calls))for(let u of e.tool_calls)c.push({name:u.function?.name,args:u.function?.arguments,id:u.id,index:u.index,type:"tool_call_chunk"});return new ct({content:o,tool_call_chunks:c,additional_kwargs:s,id:t.id,response_metadata:a})}else return i==="system"?new $i({content:o,response_metadata:a}):i==="developer"?new $i({content:o,response_metadata:a,additional_kwargs:{__openai_role__:"developer"}}):i==="function"?new Ba({content:o,additional_kwargs:s,name:e.name,response_metadata:a}):i==="tool"?new Ua({content:o,additional_kwargs:s,tool_call_id:e.tool_call_id,response_metadata:a}):new Fa({content:o,role:i,response_metadata:a})},fE=e=>{if(e.type==="image"){if(e.url)return{type:"image_url",image_url:{url:e.url}};if(e.data)return{type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}}}if(e.type==="audio"&&e.data){let t=tg(()=>{let[,r]=e.mimeType.split("/");return r==="wav"||r==="mp3"?r:"wav"});return{type:"input_audio",input_audio:{data:e.data.toString(),format:t}}}if(e.type==="file"){if(e.data){let t=$u(e);return{type:"file",file:{file_data:`data:${e.mimeType};base64,${e.data}`,filename:t}}}if(e.fileId)return{type:"file",file:{file_id:e.fileId}}}},mE=({message:e,model:t})=>{let r=ss(e);if(r==="system"&&os(t)&&(r="developer"),r==="developer")return{role:"developer",content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="system")return{role:"system",content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="assistant"){let i={role:"assistant",content:e.contentBlocks.filter(o=>o.type==="text")};return Re.isInstance(e)&&e.tool_calls?.length?i.tool_calls=e.tool_calls.map(Jf):e.additional_kwargs.tool_calls!=null&&(i.tool_calls=e.additional_kwargs.tool_calls),Array.isArray(i.content)&&i.content.length===0&&i.tool_calls!=null&&(i.content=null),i}else{if(r==="tool"&&qt.isInstance(e))return{role:"tool",tool_call_id:e.tool_call_id,content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="function")return{role:"function",name:e.name??"",content:e.contentBlocks.filter(i=>i.type==="text").join("")}}function*n(i){for(let o of i){o.type==="text"&&(yield{type:"text",text:o.text});let s=fE(o);s&&(yield s)}}return{role:"user",content:Array.from(n(e.contentBlocks))}},ju=({messages:e,model:t})=>e.flatMap(r=>{if("output_version"in r.response_metadata&&r.response_metadata?.output_version==="v1")return mE({message:r});let n=ss(r);n==="system"&&os(t)&&(n="developer");let i=typeof r.content=="string"?r.content:r.content.flatMap(s=>Zu(s)?Vu(s,Wh):typeof s=="object"&&s!==null&&"type"in s&&(s.type==="tool_use"||s.type==="tool_call"||s.type==="functionCall"||s.type==="reasoning"||s.type==="reasoning_content"||s.type==="thinking")?[]:s),o={role:n,content:i};return r.name!=null&&(o.name=r.name),r.additional_kwargs.function_call!=null&&(o.function_call=r.additional_kwargs.function_call),Re.isInstance(r)&&r.tool_calls?.length?o.tool_calls=r.tool_calls.map(Jf):(r.additional_kwargs.tool_calls!=null&&(o.tool_calls=r.additional_kwargs.tool_calls),qt.isInstance(r)&&r.tool_call_id!=null&&(o.tool_call_id=r.tool_call_id)),r.additional_kwargs.audio&&typeof r.additional_kwargs.audio=="object"&&"id"in r.additional_kwargs.audio?[o,{role:"assistant",audio:{id:r.additional_kwargs.audio.id}}]:o});var Qb=class extends zu{constructor(e,t){super(jp(e,t))}invocationParams(e,t){let r;e?.strict!==void 0?r=e.strict:this.supportsStrictToolCalling!==void 0&&(r=this.supportsStrictToolCalling),!(this.streaming||t?.streaming)&&e?.response_format?.type==="json_schema"&&r!==!1&&(r=!0);let n={};e?.stream_options!==void 0?n={stream_options:e.stream_options}:this.streamUsage&&(this.streaming||t?.streaming)&&(n={stream_options:{include_usage:!0}});let i={model:this.model,temperature:this.temperature,top_p:this.topP,frequency_penalty:this.frequencyPenalty,presence_penalty:this.presencePenalty,logprobs:this.logprobs,top_logprobs:this.topLogprobs,n:this.n,logit_bias:this.logitBias,stop:e?.stop??this.stopSequences,user:this.user,stream:this.streaming,functions:e?.functions,function_call:e?.function_call,tools:e?.tools?.length?e.tools.map(s=>this._convertChatOpenAIToolToCompletionsTool(s,{strict:r})):void 0,tool_choice:Lb(e?.tool_choice),response_format:this._getResponseFormat(e?.response_format),seed:e?.seed,...n,parallel_tool_calls:e?.parallel_tool_calls,...this.audio||e?.audio?{audio:this.audio||e?.audio}:{},...this.modalities||e?.modalities?{modalities:this.modalities||e?.modalities}:{},...this.modelKwargs,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,verbosity:e?.verbosity??this.verbosity};e?.prediction!==void 0&&(i.prediction=e.prediction),this.service_tier!==void 0&&(i.service_tier=this.service_tier),e?.service_tier!==void 0&&(i.service_tier=e.service_tier);let o=this._getReasoningParams(e);return o!==void 0&&o.effort!==void 0&&(i.reasoning_effort=o.effort),os(i.model)?i.max_completion_tokens=this.maxTokens===-1?void 0:this.maxTokens:i.max_tokens=this.maxTokens===-1?void 0:this.maxTokens,i}async _generate(e,t,r){t.signal?.throwIfAborted();let n={},i=this.invocationParams(t),o=ju({messages:e,model:this.model});if(i.stream){let s=this._streamResponseChunks(e,t,r),a={};for await(let f of s){f.message.response_metadata={...f.generationInfo,...f.message.response_metadata};let m=f.generationInfo?.completion??0;a[m]===void 0?a[m]=f:a[m]=a[m].concat(f)}let c=Object.entries(a).sort(([f],[m])=>parseInt(f,10)-parseInt(m,10)).map(([f,m])=>m),{functions:u,function_call:l}=this.invocationParams(t),d=await this._getEstimatedTokenCountFromPrompt(e,u,l),p=await this._getNumTokensFromGenerations(c);return n.input_tokens=d,n.output_tokens=p,n.total_tokens=d+p,{generations:c,llmOutput:{estimatedTokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}else{let s=await this.completionWithRetry({...i,stream:!1,messages:o},{signal:t?.signal,maxRetries:t?.maxRetries,...t?.options}),{completion_tokens:a,prompt_tokens:c,total_tokens:u,prompt_tokens_details:l,completion_tokens_details:d}=s?.usage??{};a&&(n.output_tokens=(n.output_tokens??0)+a),c&&(n.input_tokens=(n.input_tokens??0)+c),u&&(n.total_tokens=(n.total_tokens??0)+u),(l?.audio_tokens!==null||l?.cached_tokens!==null||l?.cache_write_tokens!=null)&&(n.input_token_details={...l?.audio_tokens!==null&&{audio:l?.audio_tokens},...l?.cached_tokens!==null&&{cache_read:l?.cached_tokens},...l?.cache_write_tokens!=null&&{cache_creation:l?.cache_write_tokens}}),(d?.audio_tokens!==null||d?.reasoning_tokens!==null)&&(n.output_token_details={...d?.audio_tokens!==null&&{audio:d?.audio_tokens},...d?.reasoning_tokens!==null&&{reasoning:d?.reasoning_tokens}});let p=[];for(let f of s?.choices??[]){let m={text:f.message?.content??"",message:this._convertCompletionsMessageToBaseMessage(f.message??{role:"assistant"},s)};m.generationInfo={...f.finish_reason?{finish_reason:f.finish_reason}:{},...f.logprobs?{logprobs:f.logprobs}:{}},go(m.message)&&(m.message.usage_metadata=n),m.message=new Re(Object.fromEntries(Object.entries(m.message).filter(([h])=>!h.startsWith("lc_")))),p.push(m)}return{generations:p,llmOutput:{tokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}}async*_streamChatModelEvents(e,t,r){let n=ju({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:n,stream:!0},o=await this.completionWithRetry(i,t),s=this.streamUsage??t.streamUsage;yield*em(async function*(c,u){for await(let l of c){if(u?.aborted)return;yield l}}(o,t.signal),{streamUsage:s??!0,provider:this.streamEventProvider})}get streamEventProvider(){return"openai"}async*_streamResponseChunks(e,t,r){let n=ju({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:n,stream:!0},o,s=await this.completionWithRetry(i,t),a;for await(let c of s){if(t.signal?.aborted)return;let u=c?.choices?.[0];if(c.usage&&(a=c.usage),!u)continue;let{delta:l}=u;if(!l)continue;let d=this._convertCompletionsDeltaToBaseMessageChunk(l,c,o);o=l.role??o;let p={prompt:t.promptIndex??0,completion:u.index??0};if(typeof d.content!="string"){console.log("[WARNING]: Received non-string content from OpenAI. This is currently not supported.");continue}let f={...p};u.finish_reason!=null&&(f.finish_reason=u.finish_reason,f.system_fingerprint=c.system_fingerprint,f.model_name=c.model,f.service_tier=c.service_tier),this.logprobs&&(f.logprobs=u.logprobs);let m=new un({message:d,text:d.content,generationInfo:f});yield m,await r?.handleLLMNewToken(m.text??"",p,void 0,void 0,void 0,{chunk:m})}if(a){let c={...a.prompt_tokens_details?.audio_tokens!==null&&{audio:a.prompt_tokens_details?.audio_tokens},...a.prompt_tokens_details?.cached_tokens!==null&&{cache_read:a.prompt_tokens_details?.cached_tokens},...a.prompt_tokens_details?.cache_write_tokens!=null&&{cache_creation:a.prompt_tokens_details?.cache_write_tokens}},u={...a.completion_tokens_details?.audio_tokens!==null&&{audio:a.completion_tokens_details?.audio_tokens},...a.completion_tokens_details?.reasoning_tokens!==null&&{reasoning:a.completion_tokens_details?.reasoning_tokens}},l=new un({message:new ct({content:"",response_metadata:{usage:{...a}},usage_metadata:{input_tokens:a.prompt_tokens,output_tokens:a.completion_tokens,total_tokens:a.total_tokens,...Object.keys(c).length>0&&{input_token_details:c},...Object.keys(u).length>0&&{output_token_details:u}}}),text:""});yield l,await r?.handleLLMNewToken(l.text??"",{prompt:0,completion:0},void 0,void 0,void 0,{chunk:l})}if(t.signal?.aborted)throw new Error("AbortError")}async completionWithRetry(e,t){let{maxRetries:r,...n}=t??{},i=this._getClientOptions(n),o=e.response_format&&e.response_format.type==="json_schema";return this.caller.callWithOptions({maxRetries:r},async()=>{try{return o&&!e.stream?await this.client.chat.completions.parse(e,i):await this.client.chat.completions.create(e,i)}catch(s){throw qn(s)}})}_convertCompletionsDeltaToBaseMessageChunk(e,t,r){return Yb({delta:e,rawResponse:t,includeRawResponse:this.__includeRawResponse,defaultRole:r})}_convertCompletionsMessageToBaseMessage(e,t){return Xb({message:e,rawResponse:t,includeRawResponse:this.__includeRawResponse})}};var ew="__openai_function_call_ids__",tw="__openai_custom_tool_call_ids__";function XF(e){return e.type==="url_citation"?{type:"citation",source:"url_citation",url:e.url,title:e.title,startIndex:e.start_index,endIndex:e.end_index}:e.type==="file_citation"?{type:"citation",source:"file_citation",title:e.filename,startIndex:e.index,file_id:e.file_id}:e.type==="container_file_citation"?{type:"citation",source:"container_file_citation",title:e.filename,startIndex:e.start_index,endIndex:e.end_index,file_id:e.file_id,container_id:e.container_id}:e.type==="file_path"?{type:"citation",source:"file_path",startIndex:e.index,file_id:e.file_id}:{type:"non_standard",value:e}}function E7(e){if(e.type==="url_citation"||e.type==="file_citation"||e.type==="container_file_citation"||e.type==="file_path")return e;if(e.type==="citation"){let t=e;if(t.source==="url_citation")return{type:"url_citation",url:t.url??"",title:t.title??"",start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source==="file_citation")return{type:"file_citation",file_id:t.file_id??"",filename:t.title??"",index:t.startIndex??0};if(t.source==="container_file_citation")return{type:"container_file_citation",file_id:t.file_id??"",filename:t.title??"",container_id:t.container_id??"",start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source==="file_path")return{type:"file_path",file_id:t.file_id??"",index:t.startIndex??0}}return e.type==="non_standard"?e.value:e}var Dp=e=>{let t={...e?.input_tokens_details?.cached_tokens!=null&&{cache_read:e?.input_tokens_details?.cached_tokens},...e?.input_tokens_details?.cache_write_tokens!=null&&{cache_creation:e?.input_tokens_details?.cache_write_tokens}},r={...e?.output_tokens_details?.reasoning_tokens!=null&&{reasoning:e?.output_tokens_details?.reasoning_tokens}};return{input_tokens:e?.input_tokens??0,output_tokens:e?.output_tokens??0,total_tokens:e?.total_tokens??0,input_token_details:t,output_token_details:r}},qh=e=>{if(e.error){let a=new Error(e.error.message);throw a.name=e.error.code,a}let t=[],r=[],n=[],i=e.output.map(a=>{if(a.type==="function_call"&&"parsed_arguments"in a){let c={...a};return delete c.parsed_arguments,c}return a}),o={model_provider:"openai",model:e.model,created_at:e.created_at,id:e.id,incomplete_details:e.incomplete_details,metadata:e.metadata,object:e.object,output:i,status:e.status,user:e.user,service_tier:e.service_tier,model_name:e.model},s={};for(let a of e.output)if(a.type==="message")t.push(...a.content.flatMap(c=>c.type==="output_text"?("parsed"in c&&c.parsed!=null&&(s.parsed=c.parsed),{type:"text",text:c.text,annotations:c.annotations.map(XF),...a.phase!==null?{phase:a.phase}:{}}):c.type==="refusal"?(s.refusal=c.refusal,[]):c));else if(a.type==="function_call"){let c={function:{name:a.name,arguments:a.arguments},id:a.call_id};try{r.push(Ec(c,{returnId:!0}))}catch(u){let l;typeof u=="object"&&u!=null&&"message"in u&&typeof u.message=="string"&&(l=u.message),n.push(Ls(c,l))}s[ew]??={},a.id&&(s[ew][a.call_id]=a.id)}else if(a.type==="reasoning"){s.reasoning=a;let c=a.summary?.map(u=>u.text).filter(Boolean).join("");c&&t.push({type:"reasoning",reasoning:c})}else if(a.type==="custom_tool_call"){let c=N2(a);c?(r.push(c),s[tw]??={},a.id&&a.call_id&&(s[tw][a.call_id]=a.id)):n.push(Ls(a,"Malformed custom tool call"))}else if(a.type==="computer_call"){let c=M2(a);c?r.push(c):n.push(Ls(a,"Malformed computer call"))}else a.type==="image_generation_call"?(a.result&&t.push({type:"image",mimeType:"image/png",data:a.result,id:a.id,metadata:{status:a.status}}),s.tool_outputs??=[],s.tool_outputs.push(a)):(s.tool_outputs??=[],s.tool_outputs.push(a));return new Re({id:e.id,content:t,tool_calls:r,invalid_tool_calls:n,usage_metadata:Dp(e.usage),additional_kwargs:s,response_metadata:o})},hE=e=>{let t=(e.summary.length>1?e.summary.reduce((r,n)=>{let i=r[r.length-1];return i.index===n.index?i.text+=n.text:r.push(n),r},[{...e.summary[0]}]):e.summary).map(r=>Object.fromEntries(Object.entries(r).filter(([n])=>n!=="index")));return{...e,summary:t}},rw=e=>{let t=[],r={},n,i=[],o={model_provider:"openai"},s={},a;if(e.type==="response.output_text.delta")t.push({type:"text",text:e.delta,index:e.content_index});else if(e.type==="response.output_text.annotation.added")t.push({type:"text",text:"",annotations:[XF(e.annotation)],index:e.content_index});else if(e.type==="response.output_item.added"&&e.item.type==="message"){let c="phase"in e.item?e.item.phase:void 0;c&&t.push({type:"text",text:"",phase:c,index:0})}else if(e.type==="response.output_item.added"&&e.item.type==="function_call")i.push({type:"tool_call_chunk",name:e.item.name,args:e.item.arguments,id:e.item.call_id,index:e.output_index}),s[ew]={[e.item.call_id]:e.item.id};else if(e.type==="response.output_item.added"&&e.item.type==="custom_tool_call")i.push({type:"tool_call_chunk",isCustomTool:!0,name:e.item.name,args:e.item.input,id:e.item.call_id,index:e.output_index}),s[tw]={[e.item.call_id]:e.item.id};else if(e.type==="response.output_item.done"&&e.item.type==="reasoning"&&e.item.encrypted_content)s.reasoning={encrypted_content:e.item.encrypted_content};else if(e.type==="response.output_item.done"&&e.item.type==="computer_call")i.push({type:"tool_call_chunk",name:"computer_use",args:JSON.stringify({action:e.item.action}),id:e.item.call_id,index:e.output_index}),s.tool_outputs=[e.item];else if(e.type==="response.output_item.done"&&e.item.type==="image_generation_call")e.item.result&&t.push({type:"image",mimeType:"image/png",data:e.item.result,id:e.item.id,metadata:{status:e.item.status}}),s.tool_outputs=[e.item];else if(e.type==="response.output_item.done"&&["web_search_call","file_search_call","code_interpreter_call","shell_call","local_shell_call","mcp_call","mcp_list_tools","mcp_approval_request","custom_tool_call","tool_search_call","tool_search_output"].includes(e.item.type))s.tool_outputs=[e.item];else if(e.type==="response.created")a=e.response.id,o.id=e.response.id,o.model_name=e.response.model,o.model=e.response.model;else if(e.type==="response.completed"||e.type==="response.incomplete"){a=e.response.id;let c=qh(e.response);if(n=Dp(e.response.usage),e.response.text?.format?.type==="json_schema"&&c.text)try{s.parsed??=JSON.parse(c.text)}catch{}for(let[u,l]of Object.entries(e.response))u!=="id"&&(u==="output"?o[u]=c.response_metadata.output:o[u]=l)}else if(e.type==="response.function_call_arguments.delta"||e.type==="response.custom_tool_call_input.delta")i.push({type:"tool_call_chunk",args:e.delta,index:e.output_index,...e.type==="response.custom_tool_call_input.delta"?{isCustomTool:!0}:{}});else if(e.type==="response.web_search_call.in_progress"||e.type==="response.web_search_call.searching"||e.type==="response.web_search_call.completed"||e.type==="response.file_search_call.in_progress"||e.type==="response.file_search_call.searching"||e.type==="response.file_search_call.completed"||e.type==="response.image_generation_call.in_progress"||e.type==="response.image_generation_call.generating"||e.type==="response.image_generation_call.completed"){let[,c,u]=e.type.match(/^response\.(.*)\.([^.]+)$/)??["","",""];r={tool_outputs:{id:e.item_id,type:c,status:u}}}else if(e.type==="response.refusal.done")s.refusal=e.refusal;else if(e.type==="response.output_item.added"&&"item"in e&&e.item.type==="reasoning"){let c=e.item.summary?e.item.summary.map((l,d)=>({...l,index:d})):void 0;s.reasoning={id:e.item.id,type:e.item.type,...c?{summary:c}:{}};let u=e.item.summary?.map(l=>l.text).filter(Boolean).join("");u&&t.push({type:"reasoning",reasoning:u})}else if(e.type==="response.reasoning_summary_part.added")s.reasoning={type:"reasoning",summary:[{...e.part,index:e.summary_index}]},e.part.text&&t.push({type:"reasoning",reasoning:e.part.text,index:e.summary_index});else if(e.type==="response.reasoning_summary_text.delta")s.reasoning={type:"reasoning",summary:[{text:e.delta,type:"summary_text",index:e.summary_index}]},e.delta&&t.push({type:"reasoning",reasoning:e.delta,index:e.summary_index});else return e.type==="response.image_generation_call.partial_image",null;return new un({text:t.map(c=>c.text).join(""),message:new ct({id:a,content:t,tool_call_chunks:i,usage_metadata:n,additional_kwargs:s,response_metadata:o}),generationInfo:r})},gE=e=>{let t=Re.isInstance(e)&&e.response_metadata?.model_provider==="openai";function*r(){let n=wi(()=>{try{let _=ss(e);return _==="system"||_==="developer"||_==="assistant"||_==="user"?_:"assistant"}catch{return"assistant"}}),i=_=>n==="assistant"?{type:"output_text",text:_,annotations:[]}:{type:"input_text",text:_},o,s=new Set,a=new Set,c=new Map,u=new Map;function*l(){if(!o)return;let _=o.content;(typeof _=="string"&&_.length>0||Array.isArray(_)&&_.length>0)&&(yield o),o=void 0}let d=(_,b)=>{o||(o={type:"message",role:n,content:[],...b?{phase:b}:{}}),typeof o.content=="string"?o.content=o.content.length>0?[i(o.content),..._]:[..._]:o.content.push(..._)},p=_=>{if(typeof _=="string")return _;try{return JSON.stringify(_??{})}catch{return"{}"}},f=_=>{let b=wi(()=>{let I=_.metadata?.detail;return I==="low"||I==="high"||I==="auto"?I:"auto"});if(_.fileId)return{type:"input_image",detail:b,file_id:_.fileId};if(_.url)return{type:"input_image",detail:b,image_url:_.url};if(_.data){let I=typeof _.data=="string"?_.data:Buffer.from(_.data).toString("base64");return{type:"input_image",detail:b,image_url:`data:${_.mimeType??"image/png"};base64,${I}`}}},m=_=>{if(_.fileId){let b=Db(_);return{type:"input_file",file_id:_.fileId,...b?{filename:b}:{}}}if(_.url){let b=Db(_);return{...b?{filename:b}:{},type:"input_file",file_url:_.url}}if(_.data){let b=$u(_),I=typeof _.data=="string"?_.data:Buffer.from(_.data).toString("base64");return{type:"input_file",file_data:`data:${_.mimeType??"application/octet-stream"};base64,${I}`,filename:b}}},h=_=>{let b=wi(()=>{if(Array.isArray(_.summary)){let $=_.summary?.map(P=>P?.text).filter(P=>typeof P=="string")??[];if($.length>0)return $}return _.reasoning?[_.reasoning]:[]}),I=b.length>0?b.map($=>({type:"summary_text",text:$})):[{type:"summary_text",text:""}];return{type:"reasoning",..._.id?{id:_.id}:{},summary:I}},y=_=>({type:"function_call",name:_.name??"",call_id:_.id??"",arguments:p(_.args)}),w=_=>{let b=p(_.output),I=_.status==="success"?"completed":_.status==="error"?"incomplete":void 0;return{type:"function_call_output",call_id:_.toolCallId??"",output:b,...I?{status:I}:{}}};for(let _ of e.contentBlocks)if(_.type==="text"){let b=wi(()=>{if("extras"in _&&typeof _.extras=="object"&&_.extras!==null&&"phase"in _.extras)return _.extras.phase});d([i(_.text)],b)}else if(_.type!=="invalid_tool_call"){if(_.type==="reasoning")yield*l(),yield h(_);else if(_.type==="tool_call"){yield*l();let b=_.id??"";b&&(s.add(b),c.delete(b)),yield y(_)}else if(_.type==="tool_call_chunk"){if(_.id){let b=c.get(_.id)??{name:_.name,args:[]};_.name&&(b.name=_.name),_.args&&b.args.push(_.args),c.set(_.id,b)}}else if(_.type==="server_tool_call"){yield*l();let b=_.id??"";b&&(a.add(b),u.delete(b)),yield y(_)}else if(_.type==="server_tool_call_chunk"){if(_.id){let b=u.get(_.id)??{name:_.name,args:[]};_.name&&(b.name=_.name),_.args&&b.args.push(_.args),u.set(_.id,b)}}else if(_.type==="server_tool_call_result")yield*l(),yield w(_);else if(_.type!=="audio")if(_.type==="file"){let b=m(_);b&&d([b])}else if(_.type==="image"){let b=f(_);b&&d([b])}else if(_.type==="video"){let b=m(_);b&&d([b])}else _.type==="text-plain"?_.text&&d([i(_.text)]):_.type==="non_standard"&&t&&(yield*l(),yield _.value)}yield*l();for(let[_,b]of c){if(!_||s.has(_))continue;let I=b.args.join("");!b.name&&!I||(yield{type:"function_call",call_id:_,name:b.name??"",arguments:I})}for(let[_,b]of u){if(!_||a.has(_))continue;let I=b.args.join("");!b.name&&!I||(yield{type:"function_call",call_id:_,name:b.name??"",arguments:I})}}return Array.from(r())},Up=({messages:e,zdrEnabled:t,model:r})=>e.flatMap(n=>{let i=n.response_metadata;if(i?.output_version==="v1")return gE(n);let o=n.additional_kwargs,s=ss(n);if(s==="system"&&os(r)&&(s="developer"),s==="function")throw new Error("Function messages are not supported in Responses API");if(s==="tool"){let a=n;if(o?.type==="computer_call_output")return{type:"computer_call_output",output:(()=>{if(typeof a.content=="string")return{type:"input_image",image_url:a.content};if(Array.isArray(a.content)){let u=a.content.find(p=>p.type==="input_image");if(u)return u;let l=a.content.find(p=>p.type==="computer_screenshot");if(l)return l;let d=a.content.find(p=>p.type==="image_url");if(d)return{type:"input_image",image_url:typeof d.image_url=="string"?d.image_url:d.image_url.url}}throw new Error("Invalid computer call output")})(),call_id:a.tool_call_id};if(a.additional_kwargs?.customTool)return{type:"custom_tool_call_output",call_id:a.tool_call_id,output:a.content};let c=Array.isArray(a.content)&&a.content.every(u=>typeof u=="object"&&u!==null&&"type"in u&&(u.type==="input_file"||u.type==="input_image"||u.type==="input_text"));return{type:"function_call_output",call_id:a.tool_call_id,id:a.id?.startsWith("fc_")?a.id:void 0,output:c?a.content:typeof a.content!="string"?JSON.stringify(a.content):a.content}}if(s==="assistant"){if(!t&&i?.output!=null&&Array.isArray(i?.output)&&i?.output.length>0&&i?.output.every(h=>"type"in h))return i?.output;let a=[],c=o?.reasoning,u=!!c?.encrypted_content;if(c&&(!t||u)){let h=hE(c);a.push(h)}let{content:l}=n;if(o?.refusal&&(typeof l=="string"&&(l=[{type:"output_text",text:l,annotations:[]}]),l=[...l,{type:"refusal",refusal:o.refusal}]),typeof l=="string"||l.length>0){let h={type:"message",role:"assistant",...n.id&&!t&&n.id.startsWith("msg_")?{id:n.id}:{},content:wi(()=>typeof l=="string"?l:l.flatMap(y=>{if(y.type==="text"){let w=y;return{type:"output_text",text:w.text,annotations:(w.annotations??[]).map(E7)}}return y.type==="output_text"||y.type==="refusal"?y:[]})),phase:wi(()=>{if(Array.isArray(l))return l.find(y=>"phase"in y&&typeof y.phase=="string")?.phase})};a.push(h)}let d=o?.[ew],p=o?.[tw];Re.isInstance(n)&&n.tool_calls?.length?a.push(...n.tool_calls.map(h=>j2(h,p)?{type:"custom_tool_call",id:"call_id"in h&&typeof h.call_id=="string"?h.call_id:p?.[h.id??""]??"",call_id:h.id??"",input:h.args.input,name:h.name}:z2(h)?{type:"computer_call",id:h.call_id,call_id:h.id??"",action:h.args.action}:{type:"function_call",name:h.name,arguments:JSON.stringify(h.args),call_id:h.id,...t?{}:{id:d?.[h.id]}})):o?.tool_calls&&a.push(...o.tool_calls.map(h=>({type:"function_call",name:h.function.name,call_id:h.id,arguments:h.function.arguments,...t?{}:{id:d?.[h.id]}})));let f=i?.output?.length?i?.output:o.tool_outputs,m=["computer_call","mcp_call","code_interpreter_call","image_generation_call","shell_call","local_shell_call"];if(f!=null){let h=f?.filter(y=>m.includes(y.type));h.length>0&&a.push(...h)}return a}if(s==="user"||s==="system"||s==="developer"){if(typeof n.content=="string")return{type:"message",role:s,content:n.content};let a=[],c=n.content.flatMap(u=>{if(u.type==="mcp_approval_response"&&a.push({type:"mcp_approval_response",approval_request_id:u.approval_request_id,approve:u.approve}),Zu(u)){if(u.type==="file"){let l=Db(u);if(u.source_type==="url")return{type:"input_file",file_url:u.url,...l?{filename:l}:{}};if(u.source_type==="id")return{type:"input_file",file_id:u.id,...l?{filename:l}:{}};if(u.source_type==="base64")return{type:"input_file",file_data:`data:${u.mime_type??""};base64,${u.data}`,filename:$u(u)}}return Vu(u,Wh)}return u.type==="text"?{type:"input_text",text:u.text}:u.type==="image_url"?{type:"input_image",image_url:wi(()=>{if(typeof u.image_url=="string")return u.image_url;if(typeof u.image_url=="object"&&u.image_url!==null&&"url"in u.image_url)return u.image_url.url}),detail:wi(()=>{if(typeof u.image_url=="string")return"auto";if(typeof u.image_url=="object"&&u.image_url!==null&&"detail"in u.image_url)return u.image_url.detail})}:u.type==="input_text"||u.type==="input_image"||u.type==="input_file"?u:[]});return c.length>0&&a.push({type:"message",role:s,content:c}),a}return console.warn(`Unsupported role found when converting to OpenAI Responses API: ${s}`),[]});async function*yE(e,t={}){let r=t.streamUsage??!0,n=t.provider??"openai",i=new Map,o=new Map,s=0,a=!1,c,u,l,d,p=new Set,f=(y,w)=>{let _=o.get(y);if(_!==void 0)return{index:_,isNew:!1};let b=s++;return o.set(y,b),i.set(b,{...w}),{index:b,isNew:!0}},m=function*(){a||(a=!0,yield{event:"message-start",id:c})},h=function*(y){if(p.has(y))return;let w=i.get(y);w&&(p.add(y),yield{event:"content-block-finish",index:y,content:Bl(w)})};for await(let y of e){if(y.type==="response.created"){c=y.response.id,yield*m(),yield{event:"provider",provider:n,name:"response.created",payload:{model:y.response.model,id:y.response.id}};continue}if(y.type==="response.output_text.delta"){yield*m();let{index:w,isNew:_}=f(`text:${y.output_index}:${y.content_index}`,{type:"text",text:""});_&&(yield{event:"content-block-start",index:w,content:{type:"text",text:""}});let b=i.get(w);b.text=(b.text??"")+y.delta,yield{event:"content-block-delta",index:w,delta:{type:"text-delta",text:y.delta}};continue}if(y.type==="response.reasoning_summary_text.delta"){yield*m();let{index:w,isNew:_}=f(`reasoning:${y.output_index}:${y.summary_index}`,{type:"reasoning",reasoning:""});_&&(yield{event:"content-block-start",index:w,content:{type:"reasoning",reasoning:""}});let b=i.get(w);b.reasoning=(b.reasoning??"")+y.delta,yield{event:"content-block-delta",index:w,delta:{type:"reasoning-delta",reasoning:y.delta}};continue}if(y.type==="response.output_item.added"&&(y.item.type==="function_call"||y.item.type==="custom_tool_call")){yield*m();let w=`tool:${y.output_index}`,_=y.item.type==="custom_tool_call",b=y.item.type==="function_call"?y.item.arguments??"":y.item.input??"",{index:I,isNew:$}=f(w,{type:"tool_call_chunk",id:y.item.call_id,name:y.item.name,args:b,index:y.output_index,..._?{isCustomTool:!0}:{}});if($&&(yield{event:"content-block-start",index:I,content:{type:"tool_call_chunk",id:y.item.call_id,name:y.item.name,args:b,index:y.output_index}}),b){let P=i.get(I);yield{event:"content-block-delta",index:I,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...P.id!=null?{id:P.id}:{},...P.name!=null?{name:P.name}:{},args:P.args}}}}continue}if(y.type==="response.function_call_arguments.delta"||y.type==="response.custom_tool_call_input.delta"){yield*m();let{index:w,isNew:_}=f(`tool:${y.output_index}`,{type:"tool_call_chunk",args:"",index:y.output_index,...y.type==="response.custom_tool_call_input.delta"?{isCustomTool:!0}:{}});_&&(yield{event:"content-block-start",index:w,content:{type:"tool_call_chunk",args:"",index:y.output_index}});let b=i.get(w);b.args=(b.args??"")+y.delta,yield{event:"content-block-delta",index:w,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...b.id!=null?{id:b.id}:{},...b.name!=null?{name:b.name}:{},args:b.args}}};continue}if(y.type==="response.output_item.done"&&(y.item.type==="function_call"||y.item.type==="custom_tool_call")){yield*m();let w=`tool:${y.output_index}`,_=y.item.type==="function_call"?y.item.arguments??"":y.item.input??"",{index:b,isNew:I}=f(w,{type:"tool_call_chunk",id:y.item.call_id,name:y.item.name,args:_,index:y.output_index});if(I)yield{event:"content-block-start",index:b,content:{type:"tool_call_chunk",id:y.item.call_id,name:y.item.name,args:_,index:y.output_index}};else{let $=i.get(b);$.args=_,$.id=y.item.call_id,$.name=y.item.name}yield*h(b);continue}if(y.type==="response.completed"||y.type==="response.incomplete"){yield*m(),c=y.response.id,l=P7(y.response.status,y.type),d={model_provider:n,id:y.response.id,model:y.response.model,status:y.response.status},r&&y.response.usage&&(u=Dp(y.response.usage),yield{event:"usage",usage:u});continue}y.type!=="response.image_generation_call.partial_image"&&(yield*m(),yield{event:"provider",provider:n,name:y.type,payload:y})}a||(yield{event:"message-start"});for(let[y]of i)p.has(y)||(yield*h(y));yield{event:"message-finish",reason:l,...u?{usage:u}:{},...d?{responseMetadata:d}:{}}}function P7(e,t){return t==="response.incomplete"?"length":e==="completed"?"stop":e==="incomplete"?"length":"stop"}var nw=class extends zu{constructor(e,t){super(jp(e,t))}invocationParams(e){let t;e?.strict!==void 0&&(t=e.strict),t===void 0&&this.supportsStrictToolCalling!==void 0&&(t=this.supportsStrictToolCalling);let r={model:this.model,temperature:this.temperature,top_p:this.topP,user:this.user,service_tier:this.service_tier,stream:this.streaming,previous_response_id:e?.previous_response_id,truncation:e?.truncation,include:e?.include,tools:e?.tools?.length?this._reduceChatOpenAITools(e.tools,{stream:this.streaming,strict:t}):void 0,tool_choice:R2(e?.tool_choice)?e?.tool_choice:(()=>{let i=Lb(e?.tool_choice);if(typeof i=="object"&&"type"in i){if(i.type==="function")return{type:"function",name:i.function.name};if(i.type==="allowed_tools")return{type:"allowed_tools",mode:i.allowed_tools.mode,tools:i.allowed_tools.tools};if(i.type==="custom")return{type:"custom",name:i.custom.name}}})(),text:(()=>{if(e?.text)return e.text;let i=this._getResponseFormat(e?.response_format);return i?.type==="json_schema"?i.json_schema.schema!=null?{format:{type:"json_schema",schema:i.json_schema.schema,description:i.json_schema.description,name:i.json_schema.name,strict:i.json_schema.strict},verbosity:e?.verbosity}:void 0:{format:i,verbosity:e?.verbosity}})(),parallel_tool_calls:e?.parallel_tool_calls,max_output_tokens:this.maxTokens===-1?void 0:this.maxTokens,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,...this.zdrEnabled?{store:!1}:{},...this.modelKwargs},n=this._getReasoningParams(e);return n!==void 0&&(r.reasoning=n),r}async _generate(e,t,r){t.signal?.throwIfAborted();let n=this.invocationParams(t);if(n.stream){let i=this._streamResponseChunks(e,t,r),o;for await(let s of i)s.message.response_metadata={...s.generationInfo,...s.message.response_metadata},o=o?.concat(s)??s;return{generations:o?[o]:[],llmOutput:{estimatedTokenUsage:o?.message?.usage_metadata}}}else{let i=await this.completionWithRetry({input:Up({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),...n,stream:!1},{signal:t?.signal,maxRetries:t?.maxRetries,...t?.options});return{generations:[{text:i.output_text,message:qh(i)}],llmOutput:{id:i.id,estimatedTokenUsage:i.usage?{promptTokens:i.usage.input_tokens,completionTokens:i.usage.output_tokens,totalTokens:i.usage.total_tokens}:void 0}}}}async*_streamChatModelEvents(e,t,r){let n=await this.completionWithRetry({...this.invocationParams(t),input:Up({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t),i=this.streamUsage??t.streamUsage;yield*yE(async function*(s,a){for await(let c of s){if(a?.aborted)return;yield c}}(n,t.signal),{streamUsage:i??!0,provider:this.streamEventProvider})}get streamEventProvider(){return"openai"}async*_streamResponseChunks(e,t,r){let n=await this.completionWithRetry({...this.invocationParams(t),input:Up({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t);try{for await(let i of n){if(t.signal?.aborted)return;let o=rw(i);o!=null&&(yield o,await r?.handleLLMNewToken(o.text||"",{prompt:t.promptIndex??0,completion:0},void 0,void 0,void 0,{chunk:o}))}}catch(i){throw qn(i)}}async completionWithRetry(e,t){let{maxRetries:r,...n}=t??{},i=this._getClientOptions(n);return this.caller.callWithOptions({maxRetries:r},async()=>{try{return e.text?.format?.type==="json_schema"&&!e.stream?await this.client.responses.parse(e,i):await this.client.responses.create(e,i)}catch(o){throw qn(o)}})}_reduceChatOpenAITools(e,t){let r=[];for(let n of e)if(Cp(n))n.type==="image_generation"&&t?.stream&&(n.partial_images=1),r.push(n);else if(Tu(n)){let i=n.metadata.customTool;r.push({type:"custom",name:i.name,description:i.description,format:i.format})}else if(Kf(n)){let i={};for(let[o,s]of Object.entries(n))o!=="type"&&o!=="function"&&(i[o]=s);r.push({type:"function",name:n.function.name,parameters:n.function.parameters,description:n.function.description,strict:t?.strict??null,...i})}else Fb(n)&&r.push(D2(n));return r}};var iw=class YF extends zu{useResponsesApi=!1;responses;completions;get lc_serializable_keys(){return[...super.lc_serializable_keys,"useResponsesApi"]}get callKeys(){return[...super.callKeys,"useResponsesApi"]}fields;constructor(t,r){let n=jp(t,r);super(n),this.fields=n,this.useResponsesApi=n?.useResponsesApi??!1,this.responses=n?.responses??new nw(n),this.completions=n?.completions??new Qb(n)}_useResponsesApi(t){let r=t?.tools?.some(Cp),n=t?.previous_response_id!=null||t?.text!=null||t?.truncation!=null||t?.include!=null||t?.reasoning?.summary!=null||this.reasoning?.summary!=null,i=t?.tools?.some(Fb)||t?.tools?.some(Tu);return this.useResponsesApi||r||n||i||A2(this.model)}getLsParams(t){let r=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.getLsParams(r):this.completions.getLsParams(r)}invocationParams(t){let r=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.invocationParams(r):this.completions.invocationParams(r)}async _generate(t,r,n){return this._useResponsesApi(r)?this.responses._generate(t,r,n):this.completions._generate(t,r,n)}async*_streamChatModelEvents(t,r,n){if(this._useResponsesApi(r)){yield*this.responses._streamChatModelEvents(t,this._combineCallOptions(r),n);return}yield*this.completions._streamChatModelEvents(t,this._combineCallOptions(r),n)}async*_streamResponseChunks(t,r,n){if(this._useResponsesApi(r)){yield*this.responses._streamResponseChunks(t,this._combineCallOptions(r),n);return}yield*this.completions._streamResponseChunks(t,this._combineCallOptions(r),n)}withConfig(t){let r=new YF(this.fields);return r.defaultOptions={...this.defaultOptions,...t},r}};var ow=class extends zl{model="text-embedding-ada-002";modelName;batchSize=512;stripNewLines=!0;dimensions;timeout;organization;encodingFormat;client;clientConfig;apiKey;constructor(e){let t={maxConcurrency:2,...e};super(t);let r=t?.apiKey??t?.openAIApiKey??Ct("OPENAI_API_KEY");this.organization=t?.configuration?.organization??Ct("OPENAI_ORGANIZATION"),this.model=t?.model??t?.modelName??this.model,this.modelName=this.model,this.batchSize=t?.batchSize??this.batchSize,this.stripNewLines=t?.stripNewLines??this.stripNewLines,this.timeout=t?.timeout,this.dimensions=t?.dimensions,this.encodingFormat=t?.encodingFormat,this.clientConfig={apiKey:r,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration}}async embedDocuments(e){let t=Q_(this.stripNewLines?e.map(o=>o.replace(/\n/g," ")):e,this.batchSize),r=t.map(o=>{let s={model:this.model,input:o};return this.dimensions&&(s.dimensions=this.dimensions),this.encodingFormat&&(s.encoding_format=this.encodingFormat),this.embeddingWithRetry(s)}),n=await Promise.all(r),i=[];for(let o=0;o<n.length;o+=1){let s=t[o],{data:a}=n[o];for(let c=0;c<s.length;c+=1)i.push(a[c].embedding)}return i}async embedQuery(e){let t={model:this.model,input:this.stripNewLines?e.replace(/\n/g," "):e};this.dimensions&&(t.dimensions=this.dimensions),this.encodingFormat&&(t.encoding_format=this.encodingFormat);let{data:r}=await this.embeddingWithRetry(t);return r[0].embedding}async embeddingWithRetry(e){if(!this.client){let r={baseURL:this.clientConfig.baseURL},n=as(r),i={...this.clientConfig,baseURL:n,timeout:this.timeout,maxRetries:0};i.baseURL||delete i.baseURL,i.defaultHeaders=cs(i.defaultHeaders),this.client=new fe(i)}let t={};return this.caller.call(async()=>{try{return await this.client.embeddings.create(e,t)}catch(r){throw qn(r)}})}};var M7=Y.object({type:Y.literal("screenshot")}),z7=Y.object({type:Y.literal("click"),x:Y.number(),y:Y.number(),button:Y.enum(["left","right","wheel","back","forward"]).default("left")}),j7=Y.object({type:Y.literal("double_click"),x:Y.number(),y:Y.number(),button:Y.enum(["left","right","wheel","back","forward"]).default("left")}),D7=Y.object({type:Y.literal("drag"),path:Y.array(Y.object({x:Y.number(),y:Y.number()}))}),U7=Y.object({type:Y.literal("keypress"),keys:Y.array(Y.string())}),L7=Y.object({type:Y.literal("move"),x:Y.number(),y:Y.number()}),F7=Y.object({type:Y.literal("scroll"),x:Y.number(),y:Y.number(),scroll_x:Y.number(),scroll_y:Y.number()}),B7=Y.object({type:Y.literal("type"),text:Y.string()}),Z7=Y.object({type:Y.literal("wait"),duration:Y.number().optional()}),V7=Y.union([M7,z7,j7,D7,U7,L7,F7,B7,Z7]),BZe=Y.object({action:V7});var W7=Y.object({type:Y.literal("exec"),command:Y.array(Y.string()),env:Y.record(Y.string(),Y.string()).optional(),working_directory:Y.string().optional(),timeout_ms:Y.number().optional(),user:Y.string().optional()}),qZe=Y.union([W7]);var JZe=Y.object({commands:Y.array(Y.string()).describe("Array of shell commands to execute"),timeout_ms:Y.number().optional().describe("Optional timeout in milliseconds for the commands"),max_output_length:Y.number().optional().describe("Optional maximum number of characters to return from each command")});var q7=Y.object({type:Y.literal("create_file"),path:Y.string(),diff:Y.string()}),K7=Y.object({type:Y.literal("update_file"),path:Y.string(),diff:Y.string()}),G7=Y.object({type:Y.literal("delete_file"),path:Y.string()}),e9e=Y.union([q7,K7,G7]);var vE={advanced:"gpt-6-astra",default:"gpt-6-sol",fast:"gpt-6-luna"},bE={default:"text-embedding-ada-002"},_E=new Map,sw=null,Y7=()=>{let e=QF.getDefault().helperServices;if(!e?.aiModels?.url)throw new Error("AI Models Service URL is not defined in the portal's helper services.");return e.aiModels.url},t6=async e=>{let t=Y7();_E.size===0&&(sw||(sw=(async()=>{try{(await e6(`${t}/models`)).data.models.forEach(n=>_E.set(n.name,n))}catch(n){throw sw=null,n}})()),await sw);let r=_E.get(e);if(!r)throw new Error(`Model '${e}' is not available in the discovery service.`);return r.endpoint},r6=async(e="default")=>await t6(vE[e]),n6=async(e="default")=>await t6(bE[e]),Q7=e=>typeof e=="string"&&e.length>0?e:void 0,eY=()=>zE(),tY=e=>typeof e!="string"||e.trim().length===0?"MapsSDK":`MapsSDK - ${e.trim()}`,rY=e=>{let t=e?.configurable;return{conversationId:Q7(t?.thread_id),abortSignal:e?.signal,requestId:eY(),requestSource:tY(X7.applicationName)}},nY=e=>{if(e==null||typeof e=="string"||e instanceof FormData||e instanceof HTMLFormElement)return e;if(e instanceof URLSearchParams)return e.toString();throw new TypeError(`Unsupported request body type: ${Object.prototype.toString.call(e)}`)},aw=async({config:e,withCredentials:t})=>{let r=QF.getDefault(),n=await J7.getCredential(`${r.url}/sharing`);return async(i,o)=>{let{conversationId:s,abortSignal:a,requestId:c,requestSource:u}=rY(e),l=new Headers(o?.headers);for(let f of[...l.keys()]){let m=f.toLowerCase();(m==="authorization"||m==="api-key"||m.startsWith("x-stainless-"))&&l.delete(f)}let d=n?.token;d&&d.length>0&&l.set("X-Esri-Authorization",`Bearer ${d}`),r.isPortal||(u&&u.length>0&&l.set("X-Esri-Request-Source",u),s&&s.length>0&&l.set("X-Esri-Conversation-Id",s),c.length>0&&l.set("X-Esri-Request-Id",c));let p=a&&o?.signal?AbortSignal.any([a,o.signal]):o?.signal??a;return(await e6(i instanceof Request?i.url:i.toString(),{body:nY(o?.body),headers:Object.fromEntries(l),responseType:"native",withCredentials:t,signal:p})).data}};var Lp=async(e={})=>{let{modelTier:t="default",config:r}=e,n=vE[t],i=await r6(t);return new iw({modelName:n,apiKey:"dummy-key",useResponsesApi:!0,zdrEnabled:!0,configuration:{baseURL:i,fetch:await aw({config:r,withCredentials:!0})}})};var iY=(e,t)=>{let r=um.fromTemplate(e);return Pn.fromMessages([r,...t])};var Si=async e=>{let{promptText:t,modelTier:r="default",messages:n,inputVariables:i,schema:o,config:s}=e,a=iY(t,n??[]),c=(await Lp({modelTier:r,config:s})).withStructuredOutput(o);return await a.pipe(c).invoke(i??{},s)};var It=async(e,t)=>{let{dispatchCustomEvent:r}=await import("./4TQWZ2KF.js");await r("trace_message",e,t)},cw=async(e,t)=>{let{dispatchCustomEvent:r}=await import("./4TQWZ2KF.js");await r("graph_ux_suggestion",e,t)};var H=Y;var uw=(e,t)=>t,oY=(e,t)=>({...e,...t}),sY=(e="",t)=>{let r=typeof t=="string"?t.trim():"";if(!r)return e;let n=e.trim();if(!n)return r;if(n===r)return e;let i=n.split(`
|
|
340
|
-
|
|
341
|
-
`);return i[i.length-1]?.trim()===r?e:`${e}
|
|
342
|
-
|
|
343
|
-
${r}`},i6=()=>({userRequest:"",inputParts:[],assignedTask:"",messages:[],priorSteps:[],sharedState:{},sharedResources:[]}),Du=()=>({agentExecutionContext:tt({reducer:oY,default:i6}),outputMessage:tt({reducer:sY,default:()=>""}),summary:tt({reducer:uw,default:()=>""}),status:tt({reducer:uw}),sharedStatePatch:tt({reducer:uw}),sharedResourceAdditions:tt({reducer:uw})});var aY=async(e={})=>{let{tier:t="default",config:r}=e,n=bE[t],i=await n6(t);return new ow({modelName:n,apiKey:"dummy-key",configuration:{baseURL:i,fetch:await aw({config:r})},batchSize:2048,maxConcurrency:10})},o6=async e=>{try{return await(await aY()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}};var P6=e=>{let{portal:t,user:r}=e??{};return!!e&&!!t&&!!r};function Lu(e){if(!P6(e))throw new Error("Invalid context: PortalAssistantContext with portal and user is required.")}var uY=`
|
|
344
|
-
Write a concise, friendly success message for adding members to a group.
|
|
345
|
-
|
|
346
|
-
Rules:
|
|
347
|
-
- Keep it to 1-2 short sentences.
|
|
348
|
-
- Use plain text only.
|
|
349
|
-
- If there is no notAddedMembers, confirm that all requested members were added successfully.
|
|
350
|
-
- If there are notAddedMembers, acknowledge that some members could not be added and list the added and not added members separately then mention why based on the context
|
|
351
|
-
- Make sure to bold the usernames
|
|
352
|
-
|
|
353
|
-
Added members:
|
|
354
|
-
{addedMembers}
|
|
355
|
-
|
|
356
|
-
Not added members:
|
|
357
|
-
{notAddedMembers}
|
|
358
|
-
`,lY=e=>e.map(t=>`"${t}"`).join(", "),dY=H.object({successMessage:H.string().default("")}),c6="portal-group-creation",u6="approveAddMembers",pY=async(e,t)=>{if(e.intentParams.intent!=="addMembers")return{status:"success",outputMessage:"Use @mention usernames for the members you want to add."};let r=e.agentExecutionContext.sharedState.createdGroupId?.value;if(!r)return{status:"success",outputMessage:"Create a group first, then add members using @mention usernames."};let n=e.intentParams.memberInfo.memberIdentifiers.map(d=>d.trim()).filter(Boolean);if(!n.length)return{status:"success",outputMessage:"Use @mention usernames for the members you want to add."};let i=`The following member(s) will be added to the newly created group:
|
|
359
|
-
|
|
360
|
-
${n.map(d=>`- **@${d}**`).join(`
|
|
361
|
-
`)}
|
|
362
|
-
|
|
363
|
-
Do you want to continue?`,{hitlResponse:o}=t?.configurable??{};if(o?.agentId!==c6||o.id!==u6){let d={agentId:c6,id:u6,kind:"booleanChoice",message:i,metadata:{action:"addMembers",groupId:r,members:[...n]}};throw new ys(d)}if(o.payload!==!0)return{status:"success",outputMessage:"Okay, I cancelled adding members to the group."};await It({text:`Adding members ${lY(n)}...`,agentName:"group-creation"},t);let s=t?.configurable?.context;Lu(s);let{result:a,error:c}=await LP(s.portal,r,n);if(c||!a)return{status:"success",outputMessage:"I could not add members to that group. Please confirm group access and user accounts, then try again."};let{addedUsernames:u,notAddedUsers:l}=a;try{let d=(await Si({promptText:uY,schema:dY,modelTier:"fast",inputVariables:{addedMembers:u.join(", "),notAddedMembers:JSON.stringify(l.map(p=>({username:p.username,reason:p.error.message})))}})).successMessage;if(d)return{status:"success",outputMessage:d}}catch(d){console.error("Error generating add-members success message:",d)}return{}},fY=`
|
|
364
|
-
Write a concise, friendly success message after creating a portal group.
|
|
365
|
-
|
|
366
|
-
Rules:
|
|
367
|
-
- Mention that the group was created successfully.
|
|
368
|
-
- Mention that the user can add members by using @mention usernames.
|
|
369
|
-
- Keep it to 1-2 short sentences.
|
|
370
|
-
- Make sure to bold the group title in the message.
|
|
371
|
-
|
|
372
|
-
Group title:
|
|
373
|
-
{groupTitle}
|
|
374
|
-
`,mY=`
|
|
375
|
-
Write a concise, friendly failure message after an attempt to create a portal group.
|
|
376
|
-
|
|
377
|
-
Rules:
|
|
378
|
-
- Keep it to 1-2 short sentences.
|
|
379
|
-
- Use plain text only.
|
|
380
|
-
- Mention that group creation failed.
|
|
381
|
-
- Include the failure reason in user-friendly language.
|
|
382
|
-
- End with a clear next step the user can try.
|
|
383
|
-
|
|
384
|
-
Group title:
|
|
385
|
-
{groupTitle}
|
|
386
|
-
|
|
387
|
-
Failure reason:
|
|
388
|
-
{failureReason}
|
|
389
|
-
`,l6="portal-group-creation",d6="approveCreateGroup",hY=H.object({successMessage:H.string().default("")}),gY=H.object({failureMessage:H.string().default("")}),yY=async(e,t)=>{if(e.intentParams.intent!=="create")return{status:"success",outputMessage:"Tell me the group title you want to use."};let r=e.intentParams.title.trim();if(!r)return{status:"success",outputMessage:"What title would you like for the new group?"};let n=`A group with the title **${r}** will be created. Do you want to continue?`,{hitlResponse:i}=t?.configurable;if(i?.agentId!==l6||i.id!==d6){let u={agentId:l6,id:d6,kind:"booleanChoice",message:n,metadata:{action:"createGroup",title:r,access:"private"}};throw new ys(u)}if(i.payload!==!0)return{status:"success",outputMessage:`Okay, I cancelled creating **${r}**.`};await It({text:`Creating group "${r}"...`,agentName:"group-creation"},t);let o=t?.configurable?.context;Lu(o);let{result:s,error:a}=await UP(o.portal,{title:r,access:"private"});if(a||!s){let u=a?.message?.trim()||"No additional details were provided.";try{let l=(await Si({promptText:mY,schema:gY,modelTier:"fast",inputVariables:{groupTitle:r,failureReason:u}})).failureMessage.trim();if(l)return{status:"success",outputMessage:l}}catch(l){console.error("Error generating create-group failure message:",l)}return{status:"success",outputMessage:"I could not create that group. Please confirm your permissions and try again with the group title."}}let c=s.id;try{let u=(await Si({promptText:fY,schema:hY,modelTier:"fast",inputVariables:{groupTitle:r}})).successMessage.trim();if(u)return{status:"success",outputMessage:u,sharedStatePatch:{createdGroupId:{value:c}},createdGroupId:c}}catch(u){console.error("Error generating create-group success message:",u)}return{}},mo=e=>{for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r.type!=="human")continue;let n=r.content;if(typeof n=="string")return n;if(Array.isArray(n))return n.map(i=>typeof i=="string"?i:"text"in i&&typeof i.text=="string"?i.text:"").join(" ").trim()}return""},_Y=`
|
|
390
|
-
You classify whether a user is asking to create a new ArcGIS Portal group or add members to an existing group.
|
|
391
|
-
|
|
392
|
-
Rules:
|
|
393
|
-
- Set intent="create" when the user asks to create a group and a title can be identified.
|
|
394
|
-
- Set intent="addMembers" when the user asks to add one or more members to a group.
|
|
395
|
-
- Set intent="clarify" when required data is missing or the request is ambiguous.
|
|
396
|
-
- For create requests, extract title only.
|
|
397
|
-
- For add-members requests, extract memberIdentifiers as ArcGIS usernames only (no @ prefix), but if you're returning a hint text asking for missing members, include the @ prefix.
|
|
398
|
-
- If the user includes mentions like @jsmith, return "jsmith" in memberIdentifiers.
|
|
399
|
-
- Do not extract group ids or group titles; add-members is a follow-up action that targets the most recently created group.
|
|
400
|
-
- When intent="clarify", provide a concise clarifyMessage describing exactly what is missing.
|
|
401
|
-
- If the user gives the title in quotes, extract exactly that title.
|
|
402
|
-
- If the user says create group <title> without quotes, extract only the title text after the create-group wording.
|
|
403
|
-
- If the user message looks like only a potential title (short phrase, not a question), treat it as the title and set intent="create".
|
|
404
|
-
- Return only extracted values. Do not add helper text into title or memberIdentifiers.
|
|
405
|
-
- Make sure to match the user's tone and texting style
|
|
406
|
-
|
|
407
|
-
Examples:
|
|
408
|
-
- help me create a new group "<title>" => intent="create", title="<title>", memberIdentifiers=[]
|
|
409
|
-
- add @<username1> and @<username2> => intent="addMembers", memberIdentifiers=["<username1>","<username2>"]
|
|
410
|
-
- add <member> => intent="addMembers", memberIdentifiers=["<member>"]
|
|
411
|
-
- help me create a new group => intent="clarify" with a question for missing title
|
|
412
|
-
|
|
413
|
-
User message:
|
|
414
|
-
{userMessage}
|
|
415
|
-
`,vY=H.object({intent:H.enum(["clarify","create","addMembers"]).default("clarify"),title:H.string().default(""),memberIdentifiers:H.array(H.string()).default([]),clarifyMessage:H.string().default("")}),bY=async(e,t)=>{await It({text:"Thinking about groups...",agentName:"group-creation"},t);let r=mo(e.agentExecutionContext.messages).trim(),n=await Si({promptText:_Y,schema:vY,modelTier:"default",inputVariables:{userMessage:r}}),i=n.title.trim(),o=n.memberIdentifiers.filter(Boolean),s=n.clarifyMessage.trim(),a=n.intent==="create"&&!!i,c=n.intent==="addMembers"&&o.length>0;return{intentParams:a?{intent:"create",title:i}:c?{intent:"addMembers",memberInfo:{memberIdentifiers:o}}:{intent:"clarify"},status:"success",outputMessage:!a&&!c?s:""}},wY=["general","about","homePage","gallery","aiAssistants","map","items","groups","webhooks","utilityServices","agol","esriContent","livingAtlas","servers","memberRoles","newMemberDefaults","marketplace","collaborations","credits","security","openData","hub","orgExtensions"],xY=["newItem","createLayer","developerCredentials","url","application","tileLayer","sceneLayer","locator","dataStore"],kY=["favorites","group","living-atlas","org"],IY=["featured","my","organization"],SY=["overview","content","members","settings"],AY=["licenses","members","overview","reports","settings","status"],OY=H.object({destinationType:H.literal("portal-content"),hash:H.enum(kY).optional(),queryParams:H.object({newItem:H.enum(xY).optional()}).optional()}),$Y=H.object({destinationType:H.literal("portal-groups"),hash:H.enum(IY).optional()}),TY=H.object({destinationType:H.literal("portal-org"),hash:H.enum(AY).optional(),queryParams:H.object({tab:H.enum(wY).optional(),section:H.string().optional(),subsection:H.string().optional(),period:H.string().optional(),startTime:H.string().optional(),endTime:H.string().optional()}).optional()}),EY=H.object({destinationType:H.literal("portal-item"),itemId:H.string().trim().min(1)}),PY=H.object({destinationType:H.literal("portal-group"),groupId:H.string().trim().min(1),hash:H.enum(SY).optional(),queryParams:H.record(H.string(),H.string()).optional()}),CY=H.union([OY,H.object({destinationType:H.literal("portal-gallery")}),PY,$Y,EY,H.object({destinationType:H.literal("portal-map-viewer")}),H.object({destinationType:H.literal("portal-notebooks")}),TY,H.object({destinationType:H.literal("portal-scene-viewer")})]),C6="portal-navigation",mw=async(e,t)=>{let r=t?.configurable?.context;!P6(r)||!r.navigationTargetMap?.[e.destinationType]||await cw({type:C6,data:{...e}},t)},RY=async(e,t)=>{let r=e.createdGroupId??e.agentExecutionContext.sharedState.createdGroupId?.value;return r?(await It({text:"Preparing navigation...",agentName:"group-creation"},t),await mw({destinationType:"portal-group",groupId:r},t),{}):{}},p6=(e,t)=>t??e,R6=tt.Root({...Du(),intentParams:tt({reducer:p6,default:()=>({intent:"clarify"})}),createdGroupId:tt({reducer:p6,default:()=>""})}),NY=()=>new Xs(R6).addNode("detectGroupCreationIntent",bY).addNode("createPortalGroup",yY).addNode("addMembersToPortalGroup",pY).addNode("suggestCreatedGroupNavigation",RY).addEdge(Ye,"detectGroupCreationIntent").addConditionalEdges("detectGroupCreationIntent",e=>{switch(e.intentParams.intent){case"create":return"createPortalGroup";case"addMembers":return"addMembersToPortalGroup";default:return Ze}}).addEdge("createPortalGroup","suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup","suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation",Ze),MY=String.raw`- **portal-group-creation** - Portal group creation assistant:
|
|
416
|
-
- creates a new ArcGIS Portal group for the signed-in user
|
|
417
|
-
- adds users to the newly created group using @mention usernames
|
|
418
|
-
`,zY={id:"portal-group-creation",name:"Portal Group Creation",description:MY,createGraph:NY,workspace:R6},N6="portalDocAssistantMemory",jY=()=>({conversationId:""}),DY=e=>{let t=e?.[N6]?.value;if(!t||typeof t!="object")return jY();let r=t;return{conversationId:typeof r.conversationId=="string"?r.conversationId:""}},UY=e=>({[N6]:{value:e}}),LY={pipeline:{follow_up:{allow:!1}}};function FY(e){return{kind:"DocAIAssistantRequest",filters:{...LY,persona:{persona:e}}}}var BY="https://www.arcgis.com/sharing/rest";async function ZY({portal:e,question:t,persona:r,previousConversationId:n,useProdDocAssistant:i,signal:o,skillId:s}){s??="doc_ai_assistant";let a=FY(r),c=await VY({portal:e,skillId:s,message:t,options:{context:a,previousConversationId:n,useProdDocAssistant:i,signal:o}});return{reply:WY(c,s),conversationId:c[0]?.conversationId??""}}async function VY({portal:e,skillId:t,message:r,options:n}){let i=e.helperServices.aiAssistantServices.url,o=`${n.useProdDocAssistant?"https://aiservices-beta.arcgis.com":i}/skills/${t}/chat`,s={"Content-Type":"application/json",token:n.useProdDocAssistant?(await s6.getCredential(BY,{oAuthPopupConfirmation:!1})).token:s6.findCredential(e.url)?.token??""},a=await a6(o,{method:"post",body:JSON.stringify({message:r,context:n.context,conversationId:n.previousConversationId}),headers:s,signal:n.signal});if(a.httpStatus!==200)throw new Error(`Doc assistant chat failed (${a.httpStatus})`,{cause:a.data});let c=a.data,u=[c],{conversationId:l,inquiryId:d}=c,p=async(f,m)=>{if(!m)return;await UE(500);let h=await a6(o,{method:"post",body:JSON.stringify({conversationId:l,inquiryId:d,ackSequenceNumber:f}),headers:s,signal:n.signal});if(h.httpStatus!==200)throw new Error(`Doc assistant poll failed (${h.httpStatus})`,{cause:h.data});let y=h.data;u.push(y),await p(y.sequenceNumber,y.hasMore)};return c.hasMore&&await p(c.sequenceNumber,c.hasMore),u}function WY(e,t){switch(t){case"doc_chat":return e.find(r=>r.message!=null)?.message??"";case"doc_ai_assistant":for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n.context?.kind==="DocAIAssistantContext"){let i=n.context.results?.[0]?.reply;if(i)return i}}return"";default:return Zp(t)}}var qY=async(e,t)=>{let r=performance.now();try{await It({text:"Asking documentation assistant...",agentName:"doc-assistant"},t);let n=mo(e.agentExecutionContext.messages).trim();if(!n)return{status:"success",outputMessage:"Please share your question and I can help with ArcGIS and Portal documentation."};let i=t?.configurable?.context;Lu(i);let o=DY(e.agentExecutionContext.sharedState),{reply:s,conversationId:a}=await ZY({portal:i.portal,question:n,previousConversationId:o.conversationId||void 0,skillId:"doc_ai_assistant",persona:"doc-online",useProdDocAssistant:i.useProdDocAssistant});return{status:"success",outputMessage:s.trim()||"I could not retrieve a response from the documentation assistant.",sharedStatePatch:UY({conversationId:a||o.conversationId})}}finally{console.info("[arcgis-portal-ai-assistant] node timing",{agent:"portal-doc-assistant",node:"answerDocQuestion",durationMs:Number((performance.now()-r).toFixed(1))})}},KY={schemaVersion:"1.0",capabilities:[{id:"portal-content",title:"My content",description:"Browse, discover, search, and filter ArcGIS content\u2014including maps, apps, datasets, and other items\u2014that you own or can access.",hints:["view my content","show my content","my content"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"content"}}},{id:"portal-content-new-item-feature-layer",title:"Create feature layer",description:"Generate an editable feature layer by copying fields from templates or existing layers.",hints:["add a feature layer","make a feature layer","generate a feature layer"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"createLayer"}}}},{id:"portal-content-new-item",title:"New item",description:"Open My Content with the New Item flow ready to start.",hints:["new item","create new item","upload a new item"],platforms:["online","enterprise"],buttonLabel:"Create new item",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"newItem"}}}},{id:"portal-content-new-item-developer-credentials",title:"Create developer credentials",description:"Open My Content with the New Item flow set to developer credentials.",hints:["developer credentials","new developer credentials","create api key"],platforms:["online","enterprise"],buttonLabel:"Create developer credentials",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"developerCredentials"}}}},{id:"portal-content-new-item-url",title:"Add item from URL",description:"Open My Content with the New Item flow set to add a URL-based item, such as a service endpoint.",hints:["add item from url","url item","register service url"],platforms:["online","enterprise"],buttonLabel:"Add item from URL",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"url"}}}},{id:"portal-content-new-item-application",title:"Create application item",description:"Open My Content with the New Item flow set to create an application item in content.",hints:["create application item","register app item","new application item"],platforms:["online","enterprise"],buttonLabel:"Create application item",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"application"}}}},{id:"portal-content-new-item-tile-layer",title:"Create tile layer",description:"Open My Content with the New Item flow set to publish a hosted tile layer.",hints:["create hosted tile layer","publish tile layer","new tile layer"],platforms:["online","enterprise"],buttonLabel:"Create tile layer",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"tileLayer"}}}},{id:"portal-content-new-item-scene-layer",title:"Create scene layer",description:"Open My Content with the New Item flow set to publish a hosted scene layer.",hints:["create hosted scene layer","publish scene layer","new scene layer"],platforms:["online","enterprise"],buttonLabel:"Create scene layer",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"sceneLayer"}}}},{id:"portal-content-new-item-locator",title:"Create locator",description:"Open My Content with the New Item flow set to create or publish a locator for geocoding.",hints:["create locator","publish locator","geocoding locator"],platforms:["online","enterprise"],buttonLabel:"Create locator",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"locator"}}}},{id:"portal-content-new-item-data-store",title:"Create data store item",description:"Open My Content with the New Item flow set to register a data store connection.",hints:["register data store","data store connection","new data store item"],platforms:["online","enterprise"],buttonLabel:"Create data store item",resolutions:{navigate:{routeKey:"content",queryParams:{newItem:"dataStore"}}}},{id:"create-folder",title:"Create folder",description:"Create a new folder in your ArcGIS content to organize your items.",hints:["create a folder","make a folder","set up a folder","new folder"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"content"}}}]},GY={schemaVersion:"1.0",capabilities:[{id:"portal-groups-my",title:"My groups",description:"Browse, discover, search, and filter ArcGIS content collections\u2014including maps, apps, datasets, and other items\u2014that you own, belong to, or can access.",hints:["view my groups","show my groups","my groups"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"groups"}}},{id:"create-group",title:"Create group",description:"Create a new ArcGIS Portal group owned by the signed-in user.",hints:["create a group","make a group","set up a group","new group"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"groups"}}},{id:"portal-groups-featured",title:"Featured groups",description:"Browse, discover, search, and filter ArcGIS content collections\u2014including maps, apps, datasets, and other items\u2014that organization administrators choose to highlight in ArcGIS.",hints:["view featured groups","show featured groups","highlighted groups","top groups"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"groups",hash:"featured"}}},{id:"portal-groups-organization",title:"Organization groups",description:"Browse, discover, search, and filter ArcGIS content collections\u2014including maps, apps, datasets, and other items\u2014that are specific to your organization in ArcGIS.",hints:["view organization groups","show organization groups"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"groups",hash:"organization"}}}]},HY={schemaVersion:"1.0",capabilities:[{id:"portal-org-security-multifactor-auth",title:"Multifactor Authentication (MFA)",description:"Configure organization-level multifactor authentication (MFA) settings. Administrators can enable MFA for ArcGIS logins, allow recovery codes for members, view MFA adoption status, enforce MFA requirements for all members, manage the MFA exemption list, and designate administrators who can troubleshoot MFA issues.",hints:["config MFA","set up MFA"],platforms:["online","enterprise"],resolutions:{navigate:{routeKey:"organization",queryParams:{tab:"security",subsection:"multiFactorAuthSection"},hash:"settings"}}},{id:"portal-org-security-logins",title:"Security - Logins",description:"Manage the sign-in methods available for the organization.",hints:["set up SAML single sign-on","add OpenID Connect login","sign in with Okta"],platforms:["online","enterprise"],buttonLabel:"Configure logins",resolutions:{navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security",subsection:"loginsSection"}}}},{id:"portal-org-security-custom-sign-in",title:"Security - Custom sign-in",description:"Customize how sign-in options are presented for the organization.",hints:["custom sign in","brand the sign-in page","hide the ArcGIS login option"],platforms:["online","enterprise"],buttonLabel:"Configure custom sign-in",resolutions:{navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security",subsection:"customSignInSection"}}}},{id:"portal-org-security-change-login-provider",title:"Security - Logins - Member login management",description:"Change the login provider used by an existing organization member.",hints:["change login provider","switch a member to SAML","migrate a user to SSO"],platforms:["online","enterprise"],buttonLabel:"Configure member login management",resolutions:{navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security",subsection:"changeLoginProviderSection"}}}},{id:"portal-org-security-multifactor-enforcement",title:"Security - Multifactor authentication - MFA enforcement",description:"Require multifactor authentication for all members with ArcGIS logins.",hints:["make MFA required","force all members to use MFA","MFA exemption list"],platforms:["online","enterprise"],buttonLabel:"Configure MFA enforcement",resolutions:{navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security",subsection:"multifactorEnforcementSection"}}}},{id:"portal-org-security-multifactor-designated-admins",title:"Security - Multifactor authentication - Designated administrators",description:"Choose which administrators receive and handle member MFA assistance requests.",hints:["designated MFA admins","who receives MFA help requests","MFA support administrators"],platforms:["online","enterprise"],buttonLabel:"Configure designated administrators",resolutions:{navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security",subsection:"multifactorDesignatedAdminsSection"}}}}]},JY={"contentRouteRegistry.ts":KY,"groupsRouteRegistry.ts":GY,"orgSettingsRouteRegistry.ts":HY};function f6(e){let t=[],r=new Set;for(let[n,i]of Object.entries(e))for(let o of i.capabilities){if(r.has(o.id))throw new Error(`${n}: duplicate capability id "${o.id}" across registries`);r.add(o.id),t.push(o)}return t}var lw;function Uu(e){return e?lw=f6({customCapabilities:e}):lw||(lw=f6(JY)),lw}var XY={gallery:"portal-gallery","map-viewer":"portal-map-viewer",notebooks:"portal-notebooks","scene-viewer":"portal-scene-viewer"};function Kh({capabilityId:e,navigate:t,buttonLabel:r}){let{routeKey:n}=t;switch(n){case"content":return{destinationType:"portal-content",hash:t.hash,queryParams:t.queryParams,...r?{buttonLabel:r}:{}};case"organization":return{destinationType:"portal-org",hash:t.hash,queryParams:t.queryParams,...r?{buttonLabel:r}:{}};case"groups":let{hash:i}=t;return i==="featured"?{destinationType:"portal-groups",hash:"featured",...r?{buttonLabel:r}:{}}:i==="organization"?{destinationType:"portal-groups",hash:"organization",...r?{buttonLabel:r}:{}}:e==="portal-groups-my"?{destinationType:"portal-groups",hash:"my",...r?{buttonLabel:r}:{}}:{destinationType:"portal-groups",...r?{buttonLabel:r}:{}};case"gallery":case"map-viewer":case"notebooks":case"scene-viewer":return{destinationType:XY[n],...r?{buttonLabel:r}:{}};default:return}}var M6=Bs(async({groupTitle:e},t)=>{let r=e.trim();if(!r)return null;let n=t?.configurable?.context;Lu(n);try{return(await DP(n.portal,{query:`title:${r}`,num:1}))?.results[0]?.id||null}catch(i){return console.error("Error searching for portal group by title:",i),null}},{name:"resolvePortalGroupIdByTitle",description:"Resolves an ArcGIS Portal group title to the best-match group id. Use this when a user references a group by title instead of an explicit group id.",schema:H.object({groupTitle:H.string().describe("The portal group title to resolve to a group id.")})}),z6=Bs(async({itemTitle:e},t)=>{let r=e.trim();if(!r)return null;let n=t?.configurable?.context;Lu(n);let{result:i,error:o}=await FP(n.portal,r,{num:1});return o&&console.error("Error searching for portal item by title:",o),i?.results[0]?.id||null},{name:"resolvePortalItemIdByTitle",description:'Resolves an ArcGIS Portal item title to the best-match item id. Use this when a user references an item by title (including hash mentions like #title or #"title with spaces") instead of an explicit item id.',schema:H.object({itemTitle:H.string().describe("The portal item title to resolve to an item id.")})});function Gh(e,t="#"){let r=e.match(new RegExp(`\\${t}"([^"]+)"`,"u"));if(r?.[1])return r[1].trim();let n=e.match(new RegExp(`\\${t}([^\\s"']+)`,"u"));return n?.[1]?n[1].trim():null}function YY(e){let t=Jh(e).flatMap(r=>{let n=r,i=e[r],o=[n,{description:i.description,hints:i.hints}],s=i.sections?Jh(i.sections).map(a=>{let c=i.sections?.[a];return[`${n}-${a}`,c]}):[];return[o,...s]});return Object.fromEntries(t)}function QY(e){return Object.entries(e).map(([t,{description:r,hints:n}])=>` - ${t}: ${r} (hints: ${n.join(", ")})`).join(`
|
|
419
|
-
`)}var eQ={"portal-content":{description:"The main content page of the portal.",hints:["My content","Content"]},"portal-content-favorites":{description:"The Favorites view under Content in the portal.",hints:["My favorites","Favorites","Content favorites"]},"portal-content-group":{description:"The Groups view under Content in the portal.",hints:["Content groups","Group content","My groups content"]},"portal-content-living-atlas":{description:"The Living Atlas view under Content in the portal.",hints:["Living Atlas","Content living atlas"]},"portal-content-organization":{description:"The Organization view under Content in the portal.",hints:["Organization content","Content organization","My organization content"]},"portal-gallery":{description:"The gallery page of the portal.",hints:["Gallery","Featured content","Maps and apps"]},"portal-group":{description:"A specific group page in the portal.",hints:["Group","group page"]},"portal-groups":{description:"The groups listing page of the portal.",hints:["Groups","Browse groups"]},"portal-groups-featured":{description:"The Featured groups view under Groups in the portal.",hints:["Featured groups","Groups featured"]},"portal-groups-my":{description:"The My groups view under Groups in the portal.",hints:["My groups","Groups my"]},"portal-groups-organization":{description:"The Organization groups view under Groups in the portal.",hints:["Organization groups","Groups organization","My organization groups"]},"portal-item":{description:"A specific item page in the portal.",hints:["Item","item page"]},"portal-map-viewer":{description:"The Map Viewer app of the portal.",hints:["Map Viewer","Map","Open map"]},"portal-notebooks":{description:"The Notebooks home page of the portal.",hints:["Notebooks","Notebook home","My notebooks"]},"portal-scene-viewer":{description:"The Scene Viewer app of the portal.",hints:["Scene Viewer","Scene","3D scene"]},"portal-org-security":{description:"The Organization > Settings > Security page of the portal.",hints:["Organization settings","Security","Organization > Settings > Security"],sections:{"custom-sign-in":{description:"The Organization > Settings > Security > Custom Sign In section of the portal.",hints:["Custom Sign In","Organization > Settings > Security > Custom Sign In"]},logins:{description:"The Organization > Settings > Security > Logins section of the portal.",hints:["Logins","Organization > Settings > Security > Logins"]},"change-login-provider":{description:"The Organization > Settings > Security > Change Login Provider section of the portal.",hints:["Change Login Provider","Organization > Settings > Security > Change Login Provider"]},"multifactor-auth":{description:"The Organization > Settings > Security > Multifactor Authentication section of the portal.",hints:["MFA","Multifactor Authentication","Organization > Settings > Security > MFA"]},"multifactor-enforcement":{description:"The Organization > Settings > Security > Enforce MFA section of the portal.",hints:["Enforce MFA","MFA enforcement","Organization > Settings > Security > Enforce MFA"]},"multifactor-designated-admins":{description:"The Organization > Settings > Security > Designated Admins section of the portal.",hints:["Designated admins","MFA designated admins","Organization > Settings > Security > Designated Admins"]}}},"portal-content-new-item":{description:"The Content page with the New Item flow opened.",hints:["New item","Create new item","Content > My Content > New Item"],sections:{"feature-layer":{description:"The Content page with New Item flow set to Feature Layer as the starting step.",hints:["Feature Layer","New Feature Layer","Content > My Content > New Item > Feature Layer"]},"developer-credentials":{description:"The Content page with New Item flow set to Developer Credentials as the starting step.",hints:["Developer Credentials","New developer credentials","Content > My Content > New Item > Developer Credentials"]},url:{description:"The Content page with New Item flow set to URL as the starting step for adding a URL-based item, such as a service endpoint.",hints:["URL item","Add item from URL","Register service URL","Content > My Content > New Item > URL"]},application:{description:"The Content page with New Item flow set to Application as the starting step for creating an application item in content.",hints:["Application item","Create application item","Register app item","Content > My Content > New Item > Application"]},"tile-layer":{description:"The Content page with New Item flow set to Tile Layer as the starting step for publishing a hosted tile layer.",hints:["Tile Layer","Create hosted tile layer","Publish tile layer","Content > My Content > New Item > Tile Layer"]},"scene-layer":{description:"The Content page with New Item flow set to Scene Layer as the starting step for publishing a hosted scene layer.",hints:["Scene Layer","Create hosted scene layer","Publish scene layer","Content > My Content > New Item > Scene Layer"]},locator:{description:"The Content page with New Item flow set to Locator as the starting step for creating or publishing a locator used for geocoding.",hints:["Locator","Create locator","Publish locator","Content > My Content > New Item > Locator"]},"data-store":{description:"The Content page with New Item flow set to Data Store as the starting step for registering a data store connection.",hints:["Data Store","Register data store","Data store connection","Content > My Content > New Item > Data Store"]}}}},j6=YY(eQ),tQ=Jh(j6),rQ=QY(j6),nQ=`
|
|
420
|
-
You decide whether the assistant response should include a navigation action to ArcGIS Portal.
|
|
421
|
-
|
|
422
|
-
Given the user question and assistant response:
|
|
423
|
-
- Decide if a navigation action would help the user complete the task.
|
|
424
|
-
- If yes, choose one destinationType:
|
|
425
|
-
${rQ}
|
|
426
|
-
|
|
427
|
-
Rules:
|
|
428
|
-
- Only suggest navigation when you are highly confident the destination will help complete the user's task.
|
|
429
|
-
- If confidence is below 0.85, set shouldSuggestNavigation=false and destinationType=none.
|
|
430
|
-
- If there is no clear destination from the allowed types, set shouldSuggestNavigation=false and destinationType=none.
|
|
431
|
-
- If no navigation is useful, set shouldSuggestNavigation=false and destinationType=none.
|
|
432
|
-
- Prefer the most specific destination that is clearly supported by the question and response.
|
|
433
|
-
- Use entity-level destinations over collection/root destinations when both could apply and the entity target is explicit.
|
|
434
|
-
- Use collection/root destinations only for generic browsing intent with no specific entity target.
|
|
435
|
-
- If a chosen destination requires parameters, include all required parameters.
|
|
436
|
-
- If required parameters are missing or uncertain, set shouldSuggestNavigation=false and destinationType=none.
|
|
437
|
-
- Do not invent required parameters.
|
|
438
|
-
- Always include a confidence score from 0 to 1 in the output.
|
|
439
|
-
- Confidence means confidence that a navigation suggestion should be shown to the user.
|
|
440
|
-
- If shouldSuggestNavigation=false or destinationType=none, confidence must be <= 0.5.
|
|
441
|
-
- Use confidence >= 0.85 only when shouldSuggestNavigation=true and destinationType is not none.
|
|
442
|
-
|
|
443
|
-
User question:
|
|
444
|
-
{question}
|
|
445
|
-
|
|
446
|
-
Assistant response:
|
|
447
|
-
{response}
|
|
448
|
-
`,m6=H.object({shouldSuggestNavigation:H.boolean().default(!1),destinationType:H.enum(["none",...tQ]).default("none"),itemId:H.string().default(""),groupId:H.string().default(""),confidence:H.number().min(0).max(1).default(0)}),h6;async function iQ(){return h6??=Lp({modelTier:"fast"}),await h6}var oQ=async(e,t)=>{let r=performance.now();try{await It({text:"Extracting navigation intent...",agentName:"doc-assistant"},t);let n=e.outputMessage.trim();if(!n)return{};let i=mo(e.agentExecutionContext.messages).trim(),o=await Pn.fromTemplate(nQ).format({question:i,response:n}),s=(await iQ()).withStructuredOutput(m6),a=m6.parse(await s.invoke(o));if(!a.shouldSuggestNavigation||a.destinationType==="none")return{};if(a.destinationType==="portal-item"&&!a.itemId){let u=Gh(i,"#");u&&(a.itemId=await z6.invoke({itemTitle:u},t)??"")}if(a.destinationType==="portal-group"&&!a.groupId){let u=Gh(i,"$")??Gh(i,"#");u&&(a.groupId=await M6.invoke({groupTitle:u},t)??"")}let c=sQ(a);return c?(await mw(c,t),{}):{}}finally{console.info("[arcgis-portal-ai-assistant] node timing",{agent:"portal-doc-assistant",node:"extractNavigationIntent",durationMs:Number((performance.now()-r).toFixed(1))})}};function sQ({destinationType:e,itemId:t,groupId:r}){let n=Uu().find(i=>i.id===e);if(n)return Kh({navigate:n.resolutions.navigate,buttonLabel:n.buttonLabel,capabilityId:n.id});switch(e){case"portal-gallery":case"portal-map-viewer":case"portal-notebooks":case"portal-scene-viewer":return{destinationType:e};case"portal-item":return t?{destinationType:e,itemId:t}:void 0;case"portal-group":return r?{destinationType:e,groupId:r}:void 0;case"none":return;default:switch(e){case"portal-groups":return Kh({navigate:{routeKey:"groups"}});case"portal-content-favorites":case"portal-content-group":case"portal-content-living-atlas":case"portal-content-organization":return Kh({navigate:{routeKey:"content",hash:(()=>{switch(e){case"portal-content-favorites":return"favorites";case"portal-content-group":return"group";case"portal-content-living-atlas":return"living-atlas";case"portal-content-organization":return"org";default:return Zp(e)}})()}});case"portal-org-security":return Kh({navigate:{routeKey:"organization",hash:"settings",queryParams:{tab:"security"}}});default:return}}}var D6=tt.Root({...Du()}),aQ=()=>new Xs(D6).addNode("answerDocQuestion",qY).addNode("extractNavigationIntent",oQ).addEdge(Ye,"answerDocQuestion").addEdge("answerDocQuestion","extractNavigationIntent").addEdge("extractNavigationIntent",Ze),cQ=String.raw`- **portal-doc-assistant** - General ArcGIS documentation and Portal help assistant:
|
|
449
|
-
- answers general ArcGIS, Portal, Enterprise, and JavaScript SDK questions
|
|
450
|
-
- acts as a fallback when specialized agents are not applicable
|
|
451
|
-
`,uQ={id:"portal-doc-assistant",name:"Portal Doc Assistant",description:cQ,createGraph:aQ,workspace:D6},lQ=()=>({latestGroupId:null,memory:{}}),hw=e=>{let t=e?.agentExecutionContext.sharedState.portalGroupSummaryMemory?.value;return t?{latestGroupId:t.latestGroupId,memory:t.memory}:lQ()},U6=`
|
|
452
|
-
Shared markdown formatting rules:
|
|
453
|
-
- Use clear markdown headings (##) to separate sections.
|
|
454
|
-
- Use concise bullet points for lists of facts, counts, or signals.
|
|
455
|
-
- Emphasize key metrics with bold labels (for example: **Recent items:** 4).
|
|
456
|
-
- Keep wording direct and analytical; avoid filler language but make sure the language is friendly.
|
|
457
|
-
- Do not include raw internal IDs unless explicitly requested.
|
|
458
|
-
`,dQ=`
|
|
459
|
-
You answer follow-up questions about ArcGIS group analytics.
|
|
460
|
-
|
|
461
|
-
${U6}
|
|
462
|
-
|
|
463
|
-
Ground your answer in the provided group analytics summary and context.
|
|
464
|
-
If the answer is not available from the provided context, state that clearly and suggest what to check next.
|
|
465
|
-
|
|
466
|
-
Response rules:
|
|
467
|
-
- Reply in concise markdown with this section structure:
|
|
468
|
-
1) ## Answer
|
|
469
|
-
2) ## Evidence
|
|
470
|
-
3) ## Gaps (only when data is missing)
|
|
471
|
-
- Keep the answer focused on the follow-up question.
|
|
472
|
-
- Do not include internal identifiers.
|
|
473
|
-
- Mark isRelevant=false when the question is not about this group or cannot be grounded in this group context.
|
|
474
|
-
|
|
475
|
-
Group analytics summary:
|
|
476
|
-
{summary}
|
|
477
|
-
|
|
478
|
-
Group full context:
|
|
479
|
-
{fullContext}
|
|
480
|
-
|
|
481
|
-
Question:
|
|
482
|
-
{question}
|
|
483
|
-
`,pQ=async(e,t)=>{await It({text:"Answering group follow-up...",agentName:"group-analytics"},t);let r=hw(e),n=e.groupSummaryGroupId??r.latestGroupId,i=n?r.memory[n]:void 0,o=e.groupSummaryQuestion||mo(e.agentExecutionContext.messages);return i?{status:"success",outputMessage:(await Si({promptText:dQ,schema:fQ,modelTier:"default",inputVariables:{summary:i.summary,question:o,fullContext:JSON.stringify(i.fullContext)}})).answer}:{status:"success",outputMessage:"I do not have group analytics context yet. Ask me to analyze a group first with analyze group <group id>."}},fQ=H.object({answer:H.string(),isRelevant:H.boolean()}),mQ=`
|
|
484
|
-
Classify the user's request for ArcGIS Portal group analytics.
|
|
485
|
-
|
|
486
|
-
Rules:
|
|
487
|
-
- intent="summarize" only when the user explicitly asks to summarize, analyze, overview, or recap a group.
|
|
488
|
-
- intent="followUp" for follow-up questions about a previously analyzed group.
|
|
489
|
-
- intent="navigation" when the user asks to open, go to, navigate to, or view the group page.
|
|
490
|
-
- intent="clarify" when intent or required group target is missing.
|
|
491
|
-
- groupId must be the final resolved group id.
|
|
492
|
-
- If request has explicit group id, set groupId directly.
|
|
493
|
-
- If request references group title (for example $title, $"title with spaces", or plain quoted group title), call resolvePortalGroupIdByTitle and set groupId to the tool result.
|
|
494
|
-
- Never return group titles in output fields.
|
|
495
|
-
- If intent is "followUp", set question to the user's full question/request text.
|
|
496
|
-
- If intent is "navigation", set question="".
|
|
497
|
-
- If intent is "summarize", set question="".
|
|
498
|
-
- If intent is "navigation" and no group is specified, leave groupId empty so the system can navigate to the groups listing page.
|
|
499
|
-
- If hasAnalyticsContext is true and the user asks about the same group context without an explicit summarize/analyze command, prefer "followUp".
|
|
500
|
-
|
|
501
|
-
Examples:
|
|
502
|
-
- "Analyze group 0123456789abcdef0123456789abcdef" => summarize, groupId="0123456789abcdef0123456789abcdef"
|
|
503
|
-
- "Analyze group $living atlas" => summarize, call resolvePortalGroupIdByTitle("living atlas") and set groupId to tool result
|
|
504
|
-
- "Analyze group $"living atlas basemaps"" => summarize, call resolvePortalGroupIdByTitle("living atlas basemaps") and set groupId to tool result
|
|
505
|
-
- "Is this group active?" with hasAnalyticsContext=true => followUp
|
|
506
|
-
|
|
507
|
-
hasAnalyticsContext:
|
|
508
|
-
{hasAnalyticsContext}
|
|
509
|
-
|
|
510
|
-
User message:
|
|
511
|
-
{userMessage}
|
|
512
|
-
`,hQ=async(e,t)=>{await It({text:"Analyzing group-analytics intent...",agentName:"group-analytics"},t);let r=mo(e.agentExecutionContext.messages),n=!!hw(e).latestGroupId,i=await Pn.fromTemplate(mQ).format({userMessage:r,hasAnalyticsContext:String(n)}),o=(await Lp({modelTier:"fast"})).withStructuredOutput(g6),s=g6.parse(await o.invoke(i)),a=s.groupId;if((s.intent==="summarize"||s.intent==="navigation")&&!a){let f=Gh(r,"$");f&&(a=await M6.invoke({groupTitle:f},t)??"")}let{intent:c,question:u}=s,l=c==="summarize"&&!a,d=c==="followUp"&&!(u??"").trim(),p=c==="clarify"||l||d;return{groupSummaryIntent:p?"clarify":c,groupSummaryGroupId:a||null,groupSummaryQuestion:u||"",status:"success",outputMessage:p?"Please clarify with a group id or title":""}},g6=H.object({intent:H.enum(["summarize","followUp","navigation","clarify"]),groupId:H.string().default(""),question:H.string().default("")}),gQ=async(e,t)=>{let r=hw(e),n=e.groupSummaryGroupId??r.latestGroupId;return await It({text:"Preparing navigation...",agentName:"group-analytics"},t),await mw(n?{destinationType:"portal-group",groupId:n}:{destinationType:"portal-groups"},t),{status:"success"}};function L6({timestamp:e,now:t,windowMs:r}){return e?t-e<=r:!1}var yQ=720*60*60*1e3;function _Q(e){let t=ZP(e);return{id:e.id??"",title:e.title??"",description:e.description??"",snippet:e.snippet??"",access:e.access??null,owner:e.owner??"",tags:e.tags??[],created:e.created?.getTime(),modified:e.modified?.getTime(),isInvitationOnly:e.isInvitationOnly,sourceSignals:{capabilities:VP(e),membershipAccess:WP(e),isOpenData:qP(e),isDistributedCollaborationGroup:KP(e),orgId:t.orgId,hiddenMembers:t.hiddenMembers,isViewOnly:t.isViewOnly,isReadOnly:t.isReadOnly,leavingDisallowed:t.leavingDisallowed}}}async function vQ(e){let t={owner:e.owner??"",admins:[],users:[]};try{return await e.fetchMembers()}catch(r){return console.warn("Unable to fetch group members for analytics context",r),t}}function bQ(e){return e.map(t=>({id:t.id??"",title:t.title??"Untitled",type:t.type??"Unknown",owner:t.owner??"",created:t.created?.getTime(),modified:t.modified?.getTime()}))}function wQ(e,t){return e.filter(r=>r.modified?L6({timestamp:r.modified,now:t,windowMs:yQ}):!1)}function xQ(e){let t=new Map;for(let r of e)t.set(r.type,(t.get(r.type)??0)+1);return[...t.entries()].sort((r,n)=>n[1]-r[1]||r[0].localeCompare(n[0])).slice(0,6).map(([r,n])=>({type:r,count:n}))}async function kQ(e){let t=await e.queryItems({num:20,sortField:"modified",sortOrder:"desc"}),r=bQ(t.results),n=Date.now();return{total:t.total,topItems:r,recentlyModifiedItems:wQ(r,n),topItemTypes:xQ(r)}}async function IQ(e,t){if(!t)return{error:{code:"missingGroupId",message:"Group id is required."}};try{let r=(await e.queryGroups({query:`id:${t}`,num:1})).results[0];if(!r)return{error:{code:"groupNotFound",message:`No group found for id: ${t}`}};let n=_Q(r),i=await vQ(r),o=await kQ(r);return{result:{group:n,members:i,items:o}}}catch(r){return console.error("Error fetching portal group analytics context:",r),{error:{code:"unhandledError"}}}}var SQ=`
|
|
513
|
-
You summarize ArcGIS Portal groups based on structured context and deterministic activity signals.
|
|
514
|
-
|
|
515
|
-
${U6}
|
|
516
|
-
|
|
517
|
-
Output format requirements:
|
|
518
|
-
- Return concise markdown with clear sections in this order:
|
|
519
|
-
1) Overview
|
|
520
|
-
2) Activity
|
|
521
|
-
3) Members
|
|
522
|
-
4) Content Theme
|
|
523
|
-
5) Contribution Model
|
|
524
|
-
6) Unknowns / Data Gaps
|
|
525
|
-
- Keep total response about 180-280 words unless the user asked for extra detail.
|
|
526
|
-
- Avoid internal-only implementation details and do not expose raw IDs unless user explicitly asks.
|
|
527
|
-
|
|
528
|
-
Reasoning rules:
|
|
529
|
-
- Use deterministicSignals as the source of truth for active/recent status.
|
|
530
|
-
- If group description/snippet are empty, infer purpose from tags, item title patterns, and item type distribution.
|
|
531
|
-
- For members, report owner/admin/user counts when available; if unavailable due to permission scope, explicitly say so.
|
|
532
|
-
- For contribution model, use membershipAccess, capabilities, and sourceJSON flags to characterize collaboration vs distribution behavior.
|
|
533
|
-
- Be explicit when signals are heuristic or unavailable.
|
|
534
|
-
|
|
535
|
-
Follow-up prompt rules:
|
|
536
|
-
- Generate exactly 3 follow-up prompts.
|
|
537
|
-
- Write them as direct first-person user chat prompts that can be clicked and sent as-is.
|
|
538
|
-
- Do not write meta-questions such as "Would you like..." or "Do you want me to...".
|
|
539
|
-
- Keep each prompt short, specific, and actionable.
|
|
540
|
-
- Every prompt must be answerable using only the provided group context and deterministic signals.
|
|
541
|
-
- Do not require external data, navigation, or additional fetches.
|
|
542
|
-
- Tailor each prompt to this specific group's available signals (content mix, activity, members, and contribution model).
|
|
543
|
-
- Avoid repeating phrasing from prior prompts or using generic template wording.
|
|
544
|
-
- If a signal is unavailable (for example members), do not ask follow-ups that depend on that missing signal.
|
|
545
|
-
|
|
546
|
-
Group context:
|
|
547
|
-
{context}
|
|
548
|
-
|
|
549
|
-
Deterministic signals:
|
|
550
|
-
{deterministicSignals}
|
|
551
|
-
`,AQ=2160*60*60*1e3,OQ=async(e,t)=>{let r=e.groupSummaryGroupId;if(!r)return{status:"success",outputMessage:'Please clarify with analyze group <group id>, analyze group $<title>, or analyze group $"<title with spaces>".'};await It({text:`Analyzing group ${r}...`,agentName:"group-analytics"},t);let n=t?.configurable?.context;Lu(n);let{result:i,error:o}=await IQ(n.portal,r);if(o||!i)return await It({text:"Failed to fetch group context",agentName:"group-analytics"},t),{status:"success",outputMessage:"Unable to retrieve group context for analytics."};let{group:s,items:a}=i,c=Date.now(),u=s.modified,l=u?L6({timestamp:u,now:c,windowMs:AQ}):!1,d=a.recentlyModifiedItems.length,p=d>0,f=l||p,m=await Si({promptText:SQ,schema:$Q,modelTier:"default",inputVariables:{context:JSON.stringify(i),deterministicSignals:JSON.stringify({isGroupActive:f,isGroupRecentlyModified:l,hasRecentlyAddedOrUpdatedContent:p,recentItemCount:d})}}),{followUpQuestions:h,summary:y}=m,w=hw(e),_={latestGroupId:r,memory:{...w.memory,[r]:{summary:y,followUpQuestions:h,fullContext:i}}};return h.length&&await cw({type:"suggested-prompts",data:{prompts:h}},t),{status:"success",outputMessage:y,sharedStatePatch:{portalGroupSummaryMemory:{value:_}}}},$Q=H.object({summary:H.string(),followUpQuestions:H.array(H.string()).default([])}),wE=(e,t)=>t??e,F6=tt.Root({...Du(),groupSummaryIntent:tt({reducer:wE,default:()=>"clarify"}),groupSummaryGroupId:tt({reducer:wE,default:()=>null}),groupSummaryQuestion:tt({reducer:wE,default:()=>""})}),TQ=()=>new Xs(F6).addNode("detectGroupSummaryIntent",hQ).addNode("summarizePortalGroup",OQ).addNode("answerGroupSummaryFollowUp",pQ).addNode("suggestGroupSummaryNavigation",gQ).addEdge(Ye,"detectGroupSummaryIntent").addConditionalEdges("detectGroupSummaryIntent",e=>e.groupSummaryIntent==="summarize"?"summarizePortalGroup":e.groupSummaryIntent==="followUp"?"answerGroupSummaryFollowUp":e.groupSummaryIntent==="navigation"?"suggestGroupSummaryNavigation":Ze).addEdge("summarizePortalGroup",Ze).addEdge("answerGroupSummaryFollowUp",Ze).addEdge("suggestGroupSummaryNavigation",Ze),EQ=String.raw`- **portal-group-analytics** - Portal group analytics assistant:
|
|
552
|
-
- summarizes ArcGIS portal groups from group context and sourceJSON details
|
|
553
|
-
- answers follow-up questions grounded in the summarized group
|
|
554
|
-
- suggests navigation to groups when relevant
|
|
555
|
-
`,PQ={id:"portal-group-analytics",name:"Portal Group Analytics",description:EQ,createGraph:TQ,workspace:F6},CQ=()=>({latestItemId:null,memory:{}}),$E=e=>{let t=e?.agentExecutionContext.sharedState.portalItemAnalyticsSummaryMemory?.value;return t?{latestItemId:t.latestItemId,memory:t.memory}:CQ()},y6=H.object({intent:H.enum(["summarize","followUp","clarify"]),itemId:H.string().default(""),question:H.string().default("")}),RQ=H.object({summary:H.string(),followUpQuestions:H.array(H.string()).default([])}),NQ=H.object({answer:H.string(),isRelevant:H.boolean()}),MQ=`
|
|
556
|
-
You answer follow-up questions about an ArcGIS item.
|
|
557
|
-
|
|
558
|
-
Ground your answer in the provided item context.
|
|
559
|
-
If the answer is not available from the provided context, state that clearly and suggest what to check next.
|
|
560
|
-
|
|
561
|
-
Response rules:
|
|
562
|
-
- Reply in concise markdown.
|
|
563
|
-
- Keep the answer focused on the follow-up question.
|
|
564
|
-
- Do not include internal identifiers.
|
|
565
|
-
- Mark isRelevant=false when the question is not about this item or cannot be grounded in this item context.
|
|
566
|
-
|
|
567
|
-
Item summary:
|
|
568
|
-
{summary}
|
|
569
|
-
|
|
570
|
-
Item full context
|
|
571
|
-
{fullContext}
|
|
572
|
-
|
|
573
|
-
Question:
|
|
574
|
-
{question}
|
|
575
|
-
`,zQ=async(e,t)=>{await It({text:"Answering follow-up...",agentName:"analytics"},t);let r=$E(e),n=e.analyticsItemId??r.latestItemId,i=n?r.memory[n]:void 0,o=e.analyticsQuestion||mo(e.agentExecutionContext.messages);return i?{status:"success",outputMessage:(await Si({promptText:MQ,schema:NQ,modelTier:"default",inputVariables:{summary:i.summary,question:o,fullContext:JSON.stringify(i.fullContext)}})).answer}:{status:"success",outputMessage:"I don't have enough information yet. Please ask me to summarize the item first using summarize item <item id>."}},jQ=`
|
|
576
|
-
Classify the user analytics request.
|
|
577
|
-
|
|
578
|
-
Rules:
|
|
579
|
-
- intent="summarize" only when the user explicitly asks to summarize/overview/recap an item.
|
|
580
|
-
- intent="followUp" for analytical questions about item details, including schema/fields/attributes/layers.
|
|
581
|
-
- intent="clarify" when neither summarize nor follow-up intent is clear.
|
|
582
|
-
- itemId must be the final resolved item id.
|
|
583
|
-
- If request has explicit item id, set itemId directly.
|
|
584
|
-
- If request references item title (for example #title, #"title with spaces", or plain quoted title), call resolvePortalItemIdByTitle and set itemId to the returned value.
|
|
585
|
-
- Never return item titles in output fields.
|
|
586
|
-
- If intent is "followUp", set question to the user's full question/request text.
|
|
587
|
-
- If intent is "summarize", set question="".
|
|
588
|
-
- When user asks to show/list/explain fields, schema, attributes, columns, or layer details, classify as "followUp" unless they explicitly request a summary.
|
|
589
|
-
- If hasSummaryContext is true, prefer "followUp" for detail-oriented requests that do not explicitly ask to summarize.
|
|
590
|
-
|
|
591
|
-
Examples:
|
|
592
|
-
- "Summarize item 0123456789abcdef0123456789abcdef" => summarize, itemId="0123456789abcdef0123456789abcdef"
|
|
593
|
-
- "Summarize item #california" => summarize, call resolvePortalItemIdByTitle("california") and set itemId to tool result
|
|
594
|
-
- "Summarize item #"california farmland"" => summarize, call resolvePortalItemIdByTitle("california farmland") and set itemId to tool result
|
|
595
|
-
- "Show the layer's available fields" => followUp
|
|
596
|
-
- "List attributes and explain what status means" => followUp
|
|
597
|
-
- "What fields are available?" with hasSummaryContext=true => followUp
|
|
598
|
-
- "Give me an overview of item 0123456789abcdef0123456789abcdef" => summarize
|
|
599
|
-
|
|
600
|
-
hasSummaryContext:
|
|
601
|
-
{hasSummaryContext}
|
|
602
|
-
|
|
603
|
-
User message:
|
|
604
|
-
{userMessage}
|
|
605
|
-
`,DQ=async(e,t)=>{await It({text:"Analyzing intent...",agentName:"analytics"},t);let r=mo(e.agentExecutionContext.messages),n=!!$E(e).latestItemId,i=await Pn.fromTemplate(jQ).format({userMessage:r,hasSummaryContext:String(n)}),o=(await Lp({modelTier:"fast"})).withStructuredOutput(y6),s=y6.parse(await o.invoke(i)),a=s.itemId;if(s.intent==="summarize"&&!a){let d=Gh(r,"#");d&&(a=await z6.invoke({itemTitle:d},t)??"")}let{intent:c,question:u}=s,l=c==="clarify"||c==="summarize"&&!a||c==="followUp"&&!u;return{agentExecutionContext:{...e.agentExecutionContext},analyticsIntent:l?"clarify":c,analyticsItemId:a||null,analyticsQuestion:u||"",status:"success",outputMessage:l?'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".':""}},UQ=`
|
|
606
|
-
You are a item summary tool for ArcGIS. Your job is to summarize an item's info based on the provided context.
|
|
607
|
-
Summary rules:
|
|
608
|
-
- The summary should be concise markdown, make sure to format the output nicely so it's easy to read.
|
|
609
|
-
- Target length: 80-150 words.
|
|
610
|
-
- Provide one short descriptive paragraph.
|
|
611
|
-
- Also propose 3 concise follow-up questions grounded in the item summary.
|
|
612
|
-
- Keep follow-up questions specific and actionable.
|
|
613
|
-
Follow-up questions rules:
|
|
614
|
-
- These questions should be in the format of a prompt that the user can click on.
|
|
615
|
-
- Make sure the questions are relevant to the item summary and that you can answer based solely on the provided context.
|
|
616
|
-
Do not include internal identifiers.
|
|
617
|
-
If the user asks for a detailed summary, you may expand the response up to 300 words.
|
|
618
|
-
Item context:
|
|
619
|
-
{context}
|
|
620
|
-
`,LQ=async(e,t)=>{let r=e.analyticsItemId;if(!r)return{status:"success",outputMessage:'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".'};await It({text:`Summarizing item ${r}...`,agentName:"analytics"},t);let n=t?.configurable?.context;Lu(n);let{portal:i,user:o}=n,{result:s,error:a}=await BP(o,i,r);if(a||!s)return await It({text:"Failed to get item context for summarization",agentName:"analytics"},t),{status:"success",outputMessage:"Unable to retrieve item context for summarization."};let{context:c}=s,u=await Si({promptText:UQ,schema:RQ,modelTier:"default",inputVariables:{context:JSON.stringify(c)}}),{followUpQuestions:l,summary:d}=u,p=$E(e),f={latestItemId:r,memory:{...p.memory,[r]:{summary:d,followUpQuestions:l,fullContext:c}}};return l.length&&await cw({type:"suggested-prompts",data:{prompts:l}},t),{status:"success",outputMessage:d,sharedStatePatch:{portalItemAnalyticsSummaryMemory:{value:f}}}},xE=(e,t)=>t??e,B6=tt.Root({...Du(),analyticsIntent:tt({reducer:xE,default:()=>"clarify"}),analyticsItemId:tt({reducer:xE,default:()=>null}),analyticsQuestion:tt({reducer:xE,default:()=>""})}),FQ=()=>new Xs(B6).addNode("detectAnalyticsIntent",DQ).addNode("summarizePortalItem",LQ).addNode("answerAnalyticsFollowUp",zQ).addEdge(Ye,"detectAnalyticsIntent").addConditionalEdges("detectAnalyticsIntent",e=>e.analyticsIntent==="summarize"?"summarizePortalItem":e.analyticsIntent==="followUp"?"answerAnalyticsFollowUp":Ze).addEdge("summarizePortalItem",Ze).addEdge("answerAnalyticsFollowUp",Ze),BQ=String.raw`- **portal-item-analytics** - Portal item analytics assistant:
|
|
621
|
-
- answers questions about one specific ArcGIS portal item when item context is present
|
|
622
|
-
- summarizes item details, metadata, and context grounded in that item
|
|
623
|
-
- suggests follow-up prompts grounded in the same item
|
|
624
|
-
- use for item-specific requests, not for gallery browsing, featured content, or opening Map Viewer
|
|
625
|
-
`,ZQ={id:"portal-item-analytics",name:"Portal Item Analytics",description:BQ,createGraph:FQ,workspace:B6},VQ=/^(?:take me to|navigate to|go to|show me|open)\s+(?:the\s+)?/u;function fw(e){return e.toLowerCase().replace(/[^a-z0-9]+/gu," ").trim().replace(VQ,"").trim()}var WQ=H.object({capabilityIds:H.array(H.string()).default([]),confidence:H.number().min(0).max(1).default(0),reason:H.string().default("")}),_6=.8,qQ=String.raw`You select Portal navigation capabilities for a user's request.
|
|
626
|
-
|
|
627
|
-
Select only capability IDs from the supplied candidates. Return an empty array when none fit.
|
|
628
|
-
A named surface is required: do not select a capability on another Portal surface.
|
|
629
|
-
Retrieval scores are hints only, not ground truth.
|
|
630
|
-
|
|
631
|
-
User request:
|
|
632
|
-
{userRequest}
|
|
633
|
-
|
|
634
|
-
Candidates:
|
|
635
|
-
{candidates}`,KQ=async(e,t)=>{if(e.outputMessage||e.targets.length===0)return{};let r=mo(e.agentExecutionContext.messages).trim(),n=GQ(r,e);if(n.length===1)return await It({text:`Selected navigation capability by exact match: ${n[0]}`,agentName:"navigation"},t),console.info("[arcgis-portal-ai-assistant] navigation capability selection:",{method:"exact-match",request:r,selectedCapabilityIds:n}),{chosenCapabilityIds:n};await It({text:"Choosing a navigation destination...",agentName:"navigation"},t);let i=JSON.stringify(e.targets.map(({capability:o,keywordScore:s,semanticScore:a})=>({id:o.id,title:o.title,description:o.description,route:o.resolutions.navigate,keywordScore:s,semanticScore:a})));try{let o=await Si({promptText:qQ,schema:WQ,modelTier:"fast",inputVariables:{candidates:i,userRequest:r}}),s=new Set(e.targets.map(({capability:c})=>c.id)),a=o.capabilityIds.filter(c=>s.has(c));return await It({text:`Navigation selection: ${a.join(", ")||"none"} (confidence: ${o.confidence.toFixed(2)}, reason: ${o.reason})`,agentName:"navigation"},t),console.info("[arcgis-portal-ai-assistant] navigation capability selection:",{confidence:o.confidence,method:"structured-model",reason:o.reason,request:r,selectedCapabilityIds:a}),a.length===0?{chosenCapabilityIds:[],status:"failed",summary:"Navigation selection found no matching capability; defer to the Portal Doc Assistant."}:o.confidence<_6?{chosenCapabilityIds:[],status:"failed",summary:`Navigation selection confidence ${o.confidence} is below the required ${_6}; defer to the Portal Doc Assistant.`}:{chosenCapabilityIds:a}}catch{return await It({text:"Navigation selection model unavailable; using retrieval order.",agentName:"navigation"},t),console.info("[arcgis-portal-ai-assistant] navigation capability selection:",{method:"structured-model-unavailable",request:r,selectedCapabilityIds:[]}),{chosenCapabilityIds:[]}}};function GQ(e,t){let r=fw(e);return t.targets.filter(({capability:n})=>[n.title,...n.hints].some(i=>fw(i)===r)).map(({capability:n})=>n.id)}var Z6=new Set(["1d","7d","14d","30d","3m","6m"]),HQ=H.object({period:H.string(),startTime:H.string(),endTime:H.string()}),JQ=String.raw`Extract temporal filters for an ArcGIS storage-credits query.
|
|
636
|
-
|
|
637
|
-
Return JSON only with these optional string fields:
|
|
638
|
-
- period
|
|
639
|
-
- startTime
|
|
640
|
-
- endTime
|
|
641
|
-
|
|
642
|
-
Rules:
|
|
643
|
-
- period must use <integer><unit> with unit in d,w,m (examples: 7d, 2w, 3m).
|
|
644
|
-
- If the request is a relative range and period can be determined, always include period.
|
|
645
|
-
- For "last quarter" or "previous quarter", use calendar-quarter boundaries and include period as 3m with both startTime and endTime.
|
|
646
|
-
- For "last quarter" or "previous quarter", endTime must be the UTC end of the previous quarter, not "now".
|
|
647
|
-
- If period matches one of these supported periods and the range ends today, period alone is sufficient:
|
|
648
|
-
1d, 7d, 14d, 30d, 3m, 6m.
|
|
649
|
-
- If the request implies a range not supported as period (for example 2m or 10d), include startTime and endTime.
|
|
650
|
-
- For custom date ranges (for example "last december"), provide startTime and endTime.
|
|
651
|
-
- startTime and endTime must be epoch milliseconds as strings.
|
|
652
|
-
- If the end of range is "now", set endTime to {nowEpochMs}.
|
|
653
|
-
- If temporal intent is unclear, return empty strings for all fields.
|
|
654
|
-
|
|
655
|
-
Now UTC:
|
|
656
|
-
- ISO: {nowIso}
|
|
657
|
-
- Epoch ms: {nowEpochMs}
|
|
658
|
-
|
|
659
|
-
User request:
|
|
660
|
-
{userRequest}`;async function XQ(e,t=new Date){let r=e.trim();if(!r)return{};try{let n=await Si({promptText:JQ,schema:HQ,modelTier:"fast",inputVariables:{nowEpochMs:String(t.getTime()),nowIso:t.toISOString(),userRequest:r}});return YQ(n,t)}catch(n){return console.error(n),{}}}function YQ(e,t=new Date){let r=v6(e.startTime),n=v6(e.endTime),i=QQ(e.period);if(i){if(r!==void 0&&n!==void 0&&r<n)return{period:i,startTime:String(r),endTime:String(n)};let o=Z6.has(i);if(!o||n!==void 0&&!tee(n,t.getTime())){let s=n??t.getTime(),a=eee(i,new Date(s));if(a!==void 0)return{period:i,startTime:String(a),endTime:String(s)}}return o?{period:i,...r!==void 0?{startTime:String(r)}:{},...n!==void 0?{endTime:String(n)}:{}}:{period:i}}return r!==void 0&&n!==void 0&&r<n?{startTime:String(r),endTime:String(n)}:r!==void 0?{startTime:String(r),endTime:String(t.getTime())}:{}}function QQ(e){let t=e?.trim().match(/^(\d+)\s*([dwm])$/iu);if(!t)return;let r=Number.parseInt(t[1],10);if(!Number.isFinite(r)||r<=0)return;let n=t[2].toLowerCase();if(n==="w"){let i=r*7;if(Z6.has(`${i}d`))return`${i}d`}return`${r}${n}`}function eee(e,t){let r=e.match(/^(\d+)([dwm])$/u);if(!r)return;let n=Number.parseInt(r[1],10);if(!Number.isFinite(n)||n<=0)return;let i=r[2];if(i==="d")return t.getTime()-n*24*60*60*1e3;if(i==="w")return t.getTime()-n*7*24*60*60*1e3;let o=new Date(t.getTime());return o.setUTCMonth(o.getUTCMonth()-n),o.getTime()}function v6(e){if(!e)return;let t=Number.parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return t}function tee(e,t){let r=new Date(e),n=new Date(t);return r.getUTCFullYear()===n.getUTCFullYear()&&r.getUTCMonth()===n.getUTCMonth()&&r.getUTCDate()===n.getUTCDate()}async function ree(e,t,r,n){let i=Uu().find(a=>a.id===e);if(!i)return;let o=i.resolutions.navigate,s=await iee(o.routeKey==="group"?nee(i.buttonLabel,o,n):Kh({navigate:o,buttonLabel:i.buttonLabel,capabilityId:i.id}),r);return s&&see(s,t)?{capability:i,target:s}:void 0}function nee(e,t,r){let n=r?.trim();return n?{destinationType:"portal-group",groupId:n,...t.hash?{hash:t.hash}:{},...t.queryParams?{queryParams:t.queryParams}:{},...e?{buttonLabel:e}:{}}:void 0}async function iee(e,t){if(!e||!t||!oee(e))return e;let r=await XQ(t);if(!r.period&&!r.startTime&&!r.endTime)return e;let n={...e.queryParams??{},...r.period?{period:r.period}:{},...r.startTime?{startTime:r.startTime}:{},...r.endTime?{endTime:r.endTime}:{}};return{...e,queryParams:n}}function oee(e){return e.destinationType==="portal-org"&&e.hash==="status"}function see(e,t){return!t||!!t[e.destinationType]}function b6(e){return e.match(/\b[a-f0-9]{32}\b/iu)?.[0]}var w6="navigation",x6="provideGroupId",aee=async(e,t)=>{if(e.outputMessage||e.status==="failed")return{};let r=e.targets.find(({capability:s})=>e.chosenCapabilityIds.includes(s.id))??e.targets[0];if(!r)return{outputMessage:"I couldn't find a matching Portal page. Try asking to open your content, groups, or organization settings.",sharedStatePatch:{navLastAnsweredRequest:{value:k6(e)}},status:"success",summary:"Navigation could not find a matching capability; route another agent if appropriate."};let n=k6(e),i=cee(r.capability.resolutions.navigate,n,t),o=await ree(r.capability.id,void 0,n,i);return o?(await It({text:"Preparing navigation...",agentName:"navigation"},t),await mw(o.target,t),{outputMessage:e.chosenCapabilityIds.length?r.capability.description:`The closest place to start is ${r.capability.title}. Click the button below to open it.`,status:"success",summary:`Navigation suggested ${r.capability.id}${e.retrievalDegraded?" using keyword-only retrieval":""}.`,sharedStatePatch:{navLastAnsweredRequest:{value:n}}}):(console.warn(`Navigation capability ${r.capability.id} was not found in the resolver.`),{outputMessage:"I found a possible destination, but couldn't resolve a valid Portal navigation target. Try asking to open your content, groups, or organization settings.",status:"success",summary:`Navigation resolver could not map ${r.capability.id}.`,sharedStatePatch:{navLastAnsweredRequest:{value:n}}})};function k6(e){return mo(e.agentExecutionContext.messages)||e.agentExecutionContext.userRequest}function cee(e,t,r){if(e.routeKey!=="group")return;let n=b6(t);if(n)return n;let i=uee(r);if(i?.agentId===w6&&i.id===x6){let s=typeof i.payload=="string"?b6(i.payload):void 0;if(s)return s}let o={agentId:w6,id:x6,kind:"textInput",message:"Enter the group ID to open."};throw new ys(o)}function uee(e){let t=e?.configurable;if(!t||typeof t!="object"||!("hitlResponse"in t))return;let r=t.hitlResponse;if(!r||typeof r!="object"||!("agentId"in r)||!("id"in r)||!("payload"in r))return;let{agentId:n,id:i,payload:o}=r;return typeof n=="string"&&typeof i=="string"?{agentId:n,id:i,payload:o}:void 0}async function V6(e){return e.length===0?[]:(await cY.getDefault().load(),await o6(e))}var lee=Object.freeze(Object.defineProperty({__proto__:null,generateEmbeddings:V6},Symbol.toStringTag,{value:"Module"}));function dee(e){let t=[],r=`${e.title}. ${e.description}`;r.trim().length>0&&t.push({field:"summary",text:r});let n=e.hints;if(Array.isArray(n))for(let i of n)typeof i=="string"&&i.trim().length>0&&t.push({field:"hint",text:i});return t}var dw,TE,pw=0;async function pee(e={}){let t=pw;return dw??=mee(e.embed??hee).then(r=>(t===pw&&(TE=r),r)).catch(r=>{throw t===pw&&(dw=void 0),r}),await dw}function fee(){return TE}function I6(){pw+=1,TE=void 0,dw=void 0}async function mee(e){let t=gee(),r=await e(t.map(n=>n.text));if(r.length!==t.length)throw new Error(`Expected ${t.length} vectors, got ${r.length}`);return t.map((n,i)=>({...n,vector:r[i]}))}async function hee(e){let{generateEmbeddings:t}=await Promise.resolve().then(()=>lee);return await t(e)}function gee(){return Uu().flatMap(e=>dee(e).map(({field:t,text:r})=>({capabilityId:e.id,field:t,text:r})))}var S6=1.2,A6=.75,yee=60,_ee=.65,kE={description:1,hint:2,title:3},AE;function vee(){AE=void 0}async function bee(e,t={}){let r=Iee(W6(e)),n=[],i=!1,o;if(e.trim()){let s=t.loadEmbeddings,a=fee();if(!s&&!a)i=!0,o="Capability embeddings are still loading.";else try{if(s){let[c,u]=await Promise.all([(t.embedQuery??$6)(e),s()]);n=O6(c,u)}else if(a){let c=await(t.embedQuery??$6)(e);n=O6(c,a)}}catch{i=!0,o="Semantic search is unavailable."}}return{degraded:i,...o?{degradedReason:o}:{},matches:Aee(r,n,t.topN??5)}}function wee(){return AE??=xee(Uu()),AE}function xee(e){let t=new Map,r=e.map(n=>{let i=new Map;IE(i,n.title,kE.title),IE(i,n.description,kE.description);for(let o of n.hints)IE(i,o,kE.hint);for(let o of i.keys())t.set(o,(t.get(o)??0)+1);return{capability:n,length:kee(i),termFrequencies:i}});return{averageDocumentLength:r.length?r.reduce((n,i)=>n+i.length,0)/r.length:0,documentFrequency:t,documents:r}}function IE(e,t,r){for(let n of W6(t))e.set(n,(e.get(n)??0)+r)}function kee(e){return[...e.values()].reduce((t,r)=>t+r,0)}function W6(e){return e.toLowerCase().split(/[^a-z0-9]+/u).filter(Boolean)}function Iee(e){let t=wee(),r=new Set(e),n=t.documents.length;return t.documents.map(({capability:i,length:o,termFrequencies:s})=>{let a=0;for(let c of r){let u=s.get(c),l=t.documentFrequency.get(c);if(!u||!l)continue;let d=Math.log(1+(n-l+.5)/(l+.5)),p=S6*(1-A6+A6*(o/t.averageDocumentLength));a+=d*(u*(S6+1)/(u+p))}return{capability:i,score:a}}).filter(({score:i})=>i>0).sort(q6)}function O6(e,t){let r=new Map;for(let i of t){let o=See(e,i.vector);if(o===void 0)continue;let s=r.get(i.capabilityId);(s===void 0||o>s)&&r.set(i.capabilityId,o)}let n=new Map(Uu().map(i=>[i.id,i]));return[...r.entries()].flatMap(([i,o])=>{let s=n.get(i);return s&&o>=_ee?[{capability:s,score:o}]:[]}).sort(q6)}function See(e,t){if(e.length===0||e.length!==t.length)return;let r=0,n=0,i=0;for(let s=0;s<e.length;s+=1)r+=e[s]*t[s],n+=e[s]**2,i+=t[s]**2;let o=Math.sqrt(n)*Math.sqrt(i);return o===0?void 0:r/o}async function $6(e){let[t]=await V6([e]);if(!t)throw new Error("Expected one query embedding.");return t}function Aee(e,t,r){let n=new Map;return T6(n,e,"keyword"),T6(n,t,"semantic"),[...n.values()].sort((i,o)=>o.score!==i.score?o.score-i.score:(o.semanticScore??0)!==(i.semanticScore??0)?(o.semanticScore??0)-(i.semanticScore??0):(o.keywordScore??0)!==(i.keywordScore??0)?(o.keywordScore??0)-(i.keywordScore??0):i.capability.id.localeCompare(o.capability.id)).slice(0,Math.max(0,r))}function T6(e,t,r){for(let[n,{capability:i,score:o}]of t.entries()){let s=n+1,a=e.get(i.id)??{capability:i,score:0};a.score+=1/(yee+s),r==="keyword"?(a.keywordRank=s,a.keywordScore=o):(a.semanticRank=s,a.semanticScore=o),e.set(i.id,a)}}function q6(e,t){return t.score-e.score||e.capability.id.localeCompare(t.capability.id)}var Oee=async(e,t)=>{await It({text:"Finding a place to navigate...",agentName:"navigation"},t);let r=mo(e.agentExecutionContext.messages).trim();try{let n=await bee(r,{topN:5});return await It({text:`Navigation candidates: ${Tee(n.matches)}`,agentName:"navigation"},t),console.table(n.matches.map(({capability:i,keywordRank:o,keywordScore:s,semanticRank:a,semanticScore:c,score:u})=>({capability:i.title,fusedScore:u,keywordRank:o,keywordScore:s,semanticRank:a,semanticScore:c}))),n.degradedReason&&console.info("[arcgis-portal-ai-assistant] navigation semantic search:",n.degradedReason),{chosenCapabilityIds:[],retrievalDegraded:n.degradedReason??"",targets:$ee(r,n.matches)}}catch{return{chosenCapabilityIds:[],outputMessage:"I couldn't look up a Portal page right now. Please try again.",status:"failed",targets:[]}}};function $ee(e,t){let r=fw(e),n=t.filter(({capability:o})=>[o.title,...o.hints].some(s=>fw(s)===r));if(n.length!==1)return t;let[i]=n;return[i,...t.filter(o=>o!==i)]}function Tee(e){return e.map(({capability:t,keywordScore:r,semanticScore:n})=>`${t.title} (keyword: ${E6(r)}, semantic: ${E6(n)})`).join("; ")||"none"}function E6(e){return e?.toFixed(3)??"none"}var SE=(e,t)=>t??e,K6=tt.Root({...Du(),chosenCapabilityIds:tt({reducer:SE,default:()=>[]}),retrievalDegraded:tt({reducer:SE,default:()=>""}),targets:tt({reducer:SE,default:()=>[]})}),Eee=()=>new Xs(K6).addNode("retrieveNavigationTargets",Oee).addNode("chooseNavigationTargets",KQ).addNode("respondWithNavigation",aee).addEdge(Ye,"retrieveNavigationTargets").addEdge("retrieveNavigationTargets","chooseNavigationTargets").addEdge("chooseNavigationTargets","respondWithNavigation").addEdge("respondWithNavigation",Ze);function Pee(){return String.raw`- **Navigation** — Takes the user to the portal page or app that fulfills their request. Presenting the button COMPLETES the request — no follow-up step is needed.
|
|
661
|
-
|
|
662
|
-
Route here for **navigation intent** ("take me to the map viewer", "open content", "where is X?") and for **action intent** ("publish a scene layer", "create a web map", "share this item") — for an action, Navigation takes the user to the page where that workflow starts. Navigation searches the capability registry itself, so don't rule it out because a page isn't named here.
|
|
663
|
-
|
|
664
|
-
If Navigation just asked the user for a missing value (such as an item id), route the user's short follow-up answer — often just an id like "797f6c0d300a4ddc87a8ae14cd2eeb8e" — back here so it can finish.
|
|
665
|
-
|
|
666
|
-
Do NOT route here for:
|
|
667
|
-
- An action another agent actually performs — e.g. "create group" is EXECUTED by group agent. Route it here only when the user explicitly asks to navigate ("take me to create group")
|
|
668
|
-
- Requests that mix navigation with a question or explanation ("take me there and explain how") → use Help
|
|
669
|
-
|
|
670
|
-
Do not dispatch Navigation again for the same request in the same turn: once it has responded, the task is done.`}var Cee={id:"navigation",name:"Portal Navigation",get description(){return Pee()},createGraph:Eee,workspace:K6},Ree=RE`:host{height:100%;border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.chat-entry{display:flex;flex-direction:column;gap:.75rem;width:100%}.chat-actions{display:flex;justify-content:flex-end;gap:.5rem}.header-actions{display:flex;gap:.5rem;padding-inline-start:.75rem}.navigation-block{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;margin-top:.5rem}.navigation-button{width:100%;margin-block:.25rem}.navigation-block-description{font-size:.75rem;color:var(--calcite-color-text-3)}`;function Nee(e,t){if(!t)return;let{destinationType:r}=e;switch(r){case"portal-content":return t[r]?.(e.hash,e.queryParams);case"portal-groups":return t[r]?.(e.hash);case"portal-org":return t[r]?.(e.hash,e.queryParams);case"portal-gallery":return t[r];case"portal-map-viewer":case"portal-notebooks":case"portal-scene-viewer":return t[r];case"portal-item":return t[r]?.(e.itemId);case"portal-group":return t[r]?.(e.groupId,e.hash,e.queryParams);default:return Zp(r)}}function Mee(e){let t=CY.safeParse(e);return t.success?t.data:void 0}function zee(e,t){let r=t.navigation;switch(e.destinationType){case"portal-content":switch(e.hash){case"favorites":return r.openContentFavorites;case"group":return r.openContentGroup;case"living-atlas":return r.openContentLivingAtlas;case"org":return r.openContentOrganization;default:return r.openContent}case"portal-gallery":return r.openGallery;case"portal-groups":switch(e.hash){case"featured":return r.openGroupsFeatured;case"my":return r.openGroupsMy;case"organization":return r.openGroupsOrganization;default:return r.openGroups}case"portal-map-viewer":return r.openMapViewer;case"portal-notebooks":return r.openNotebooks;case"portal-scene-viewer":return r.openSceneViewer;case"portal-org":return r.openOrgSettings;case"portal-item":return r.openItem;case"portal-group":return r.openGroup;default:return Zp(e)}}var OE=class extends jE{constructor(){super(),this.t9n=LE({blocking:!0}),this.assistantEl=Fp(),this.formEl=Fp(),this.voiceInputEl=Fp(),this.inputEl=Fp(),this.navigationSlotElements=new Map,this.handleSlottableRequest=t=>{let r=t.detail,n=r.data?.block;if(!n)return;let i=this.getNavigationAction(n);i&&this.upsertNavigationSlotElement(r.slotName,i)},this.inputText="",this.showVoiceInput=!0,this.isListening=!1,this.isVoiceInputDisabled=!1,this.autoDestroyDisabled=!1,this.defaultClosed=!1,this.useProdDocAssistant=!1,this.arcgisPortalNavigationRequest=ME(),Uu()}static{this.properties={inputText:16,showVoiceInput:16,isListening:16,isVoiceInputDisabled:16,autoDestroyDisabled:5,portal:0,user:0,config:0,navigationTargetMap:0,disabledAgents:0,defaultClosed:5,navigationCapabilities:0,useProdDocAssistant:5}}static{this.styles=Ree}async load(){await this.refreshCapabilityEmbeddings()}willUpdate(t){!this.hasUpdated||!t.has("navigationCapabilities")||this.refreshCapabilityEmbeddings()}async clearEmbeddingsCache(){I6()}isAgentEnabled(t){return!this.disabledAgents?.[t]}async refreshCapabilityEmbeddings(){try{Uu(this.navigationCapabilities),vee(),I6(),await pee()}catch(t){console.warn("[arcgis-portal-ai-assistant] embeddings warm-up failed:",t)}}getNavigationAction(t){if(t?.type!==C6)return;let r=t.data,n=Mee(r);if(!n)return;let i=Nee(r,this.navigationTargetMap);if(i)return{href:i,targetDetail:r,label:r?.buttonLabel||zee(n,this.t9n)}}upsertNavigationSlotElement(t,r){let n=this.assistantEl.value;if(!n)return;let i=`navigation:${t}`,o=this.navigationSlotElements.get(i);o||(o=document.createElement("div"),o.slot=t,this.navigationSlotElements.set(i,o),n.append(o)),NE(Oi`<div><calcite-button class="navigation-button" appearance=outline width=full .href=${r.href} icon-end=launch @click=${s=>{s.preventDefault(),this.arcgisPortalNavigationRequest.emit({href:r.href,targetDetail:r.targetDetail})}}>${r.label}</calcite-button>${r.description?Oi`<div class="navigation-block-description">${r.description}</div>`:null}</div>`,o)}render(){let{t9n:t,inputText:r,portal:n,user:i,navigationTargetMap:o,showVoiceInput:s,isListening:a,isVoiceInputDisabled:c,useProdDocAssistant:u}=this;return Oi`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${t.heading} .entryMessage=${t.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisPromptSelect=${({detail:l})=>{this.inputText=l.prompt,requestAnimationFrame(()=>{this.inputEl.value?.focusTextArea()})}} ${Bp(this.assistantEl)}><div slot=header-actions-start class="header-actions"><calcite-icon icon=effects></calcite-icon></div><form slot=chat-entry class="chat-entry" @submit=${l=>{l.preventDefault();let d=r.trim();d&&(this.assistantEl.value?.submitMessage(d),this.inputText="")}} ${Bp(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${n} .user=${i} rows=3 .popoverListLabel=${t.mentionEntities} .placeholder=${t.placeholder} .value=${r} @arcgisUserMentionableTextAreaKeyDown=${({detail:l})=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),this.formEl.value?.requestSubmit())}} @arcgisUserMentionableTextAreaChange=${({detail:l})=>{this.inputText=l??""}} ${Bp(this.inputEl)}></arcgis-portal-mentionable-text-area><div class="chat-actions"><arcgis-portal-voice-input @arcgisVoiceInputStart=${()=>{this.isListening=!0,this.isVoiceInputDisabled=!1}} @arcgisVoiceInputStop=${()=>{this.isListening=!1,this.isVoiceInputDisabled=!1}} @arcgisVoiceInputError=${l=>{l.detail.errorCode==="not-supported"&&(this.showVoiceInput=!1)}} @arcgisVoiceInputInterimTranscription=${l=>{this.inputText=l.detail.text}} ${Bp(this.voiceInputEl)}></arcgis-portal-voice-input>${s&&Oi`<calcite-button icon-start=microphone .label=${t.voiceInput} round .disabled=${c} .appearance=${a?"solid":"outline-fill"} @click=${async()=>{this.isVoiceInputDisabled=!0;let l=this.voiceInputEl.value;a?await l?.stopListening():await l?.startListening()}}></calcite-button>`||""}<calcite-button type=submit icon-start=send round .disabled=${!r.trim()} .label=${t.send}>${t.send}</calcite-button></div></form>${this.isAgentEnabled("itemAnalytics")&&Oi`<arcgis-assistant-agent .agent=${ZQ} .context=${{portal:n,user:i,navigationTargetMap:o}}></arcgis-assistant-agent>`||""}${this.isAgentEnabled("groupCreation")&&Oi`<arcgis-assistant-agent .agent=${zY} .context=${{portal:n,user:i,navigationTargetMap:o}}></arcgis-assistant-agent>`||""}${this.isAgentEnabled("docAssistant")&&Oi`<arcgis-assistant-agent .agent=${uQ} .context=${{portal:n,user:i,navigationTargetMap:o,useProdDocAssistant:u}}></arcgis-assistant-agent>`||""}${this.isAgentEnabled("groupAnalytics")&&Oi`<arcgis-assistant-agent .agent=${PQ} .context=${{portal:n,user:i,navigationTargetMap:o}}></arcgis-assistant-agent>`||""}${this.isAgentEnabled("navigation")&&Oi`<arcgis-assistant-agent .agent=${Cee} .context=${{portal:n,user:i,navigationTargetMap:o}}></arcgis-assistant-agent>`||""}</arcgis-assistant>`}};DE("arcgis-portal-ai-assistant",OE);return OE},"portal/Portal","request","identity/IdentityManager","config","identity/IdentityManager","request","portal/Portal",a,b,c)
|