@mcp-use/inspector 0.18.0 → 0.18.1
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/web/assets/{1c-D5VkXeAv.js → 1c-Bi2xm7No.js} +1 -1
- package/dist/web/assets/{abnf-D0RJ8Goy.js → abnf-CJjSK55y.js} +1 -1
- package/dist/web/assets/{accesslog-CDC6tX13.js → accesslog-BE2UOiBp.js} +1 -1
- package/dist/web/assets/{actionscript-DznOanNr.js → actionscript-j7CsuIk-.js} +1 -1
- package/dist/web/assets/{ada-C4Rs5kDr.js → ada-BlWV2LZb.js} +1 -1
- package/dist/web/assets/{angelscript-BRn5LaEB.js → angelscript-tnRXgB7Y.js} +1 -1
- package/dist/web/assets/{apache-BzcumgaJ.js → apache-Dk9fYV72.js} +1 -1
- package/dist/web/assets/{applescript-CyhKtF7f.js → applescript-DvaP3m_V.js} +1 -1
- package/dist/web/assets/{arcade-BixuE51U.js → arcade-CXD8gFOt.js} +1 -1
- package/dist/web/assets/{arduino-ffsQDV23.js → arduino-CL6zd982.js} +1 -1
- package/dist/web/assets/{armasm-B6a7c8Kr.js → armasm-D_LwoXcb.js} +1 -1
- package/dist/web/assets/{asciidoc-DdRYY4rP.js → asciidoc-CNQoG0hG.js} +1 -1
- package/dist/web/assets/{aspectj-pIeuQuXd.js → aspectj-9pMxmEXh.js} +1 -1
- package/dist/web/assets/{autohotkey-BAIgK2EZ.js → autohotkey-CuL-iT8-.js} +1 -1
- package/dist/web/assets/{autoit-DHXNYTYM.js → autoit-bUbLqpjG.js} +1 -1
- package/dist/web/assets/{avrasm-B96fgFeA.js → avrasm-DSTqLkgP.js} +1 -1
- package/dist/web/assets/{awk-CFKzxljm.js → awk-BCBRZEsw.js} +1 -1
- package/dist/web/assets/{axapta-B0CoJ3Rs.js → axapta-ModRTcqT.js} +1 -1
- package/dist/web/assets/{bash-_ZR8KQ8P.js → bash-RmjyIvEr.js} +1 -1
- package/dist/web/assets/{basic-BCUHbXQB.js → basic-BTuKuQY4.js} +1 -1
- package/dist/web/assets/{bnf-BxchC5Nb.js → bnf-Cq35odXk.js} +1 -1
- package/dist/web/assets/{brainfuck-C-oX1CkH.js → brainfuck-BDIxDvLA.js} +1 -1
- package/dist/web/assets/{browser-C3NOFINv.js → browser-D78Wybyz.js} +3 -3
- package/dist/web/assets/{c-BLzwl7PF.js → c-B9MY4sO-.js} +1 -1
- package/dist/web/assets/{c-like-_PKff7Fn.js → c-like-BLJmcZXb.js} +1 -1
- package/dist/web/assets/{cal-DW4s5A2_.js → cal-CcyCn1om.js} +1 -1
- package/dist/web/assets/{capnproto-CDt-mo74.js → capnproto-CUMz-fK2.js} +1 -1
- package/dist/web/assets/{ceylon-DfSowWJh.js → ceylon-BOhjdlID.js} +1 -1
- package/dist/web/assets/{chunk-VL2OQCWN-Ci7Z2Gkc.js → chunk-VL2OQCWN-Bq-lrj3t.js} +1 -1
- package/dist/web/assets/{clean-D5_dNemT.js → clean-wwVWhj4-.js} +1 -1
- package/dist/web/assets/{client-C2DQf_aV.js → client-D29gOwcV.js} +1 -1
- package/dist/web/assets/{clojure-DVYLiHgT.js → clojure-C2Fjxgt6.js} +1 -1
- package/dist/web/assets/{clojure-repl-G87D1-WM.js → clojure-repl-CpP27ykR.js} +1 -1
- package/dist/web/assets/{cmake-eRZ69lcU.js → cmake-Dtg8apsf.js} +1 -1
- package/dist/web/assets/{coffeescript-DZTWexIF.js → coffeescript-xBHJFlbn.js} +1 -1
- package/dist/web/assets/{coq-DXwXxSs9.js → coq-B5-oM9c9.js} +1 -1
- package/dist/web/assets/{core-CpHKJ8XJ.js → core-DrCPNbh4.js} +1 -1
- package/dist/web/assets/{cos-CeN5aFe0.js → cos-DDOr59LN.js} +1 -1
- package/dist/web/assets/{cpp-GRRtWrWX.js → cpp-BWNqgCyz.js} +1 -1
- package/dist/web/assets/{crmsh-FNGEIRFg.js → crmsh-DY9bC_Fr.js} +1 -1
- package/dist/web/assets/{crystal-DtY9ughA.js → crystal-DB0dejSI.js} +1 -1
- package/dist/web/assets/{csharp-DeIEoBta.js → csharp-C3kpozcD.js} +1 -1
- package/dist/web/assets/{csp-D9QINUlx.js → csp-B-8MulTS.js} +1 -1
- package/dist/web/assets/{css-CQcGsM8O.js → css-DJRwYnIa.js} +1 -1
- package/dist/web/assets/{d-BrdM35Ki.js → d-C1rWn1Fn.js} +1 -1
- package/dist/web/assets/{dart-DvV6DE78.js → dart-BW5L7KT6.js} +1 -1
- package/dist/web/assets/{delphi-BdaweBhN.js → delphi-BW3XuIFg.js} +1 -1
- package/dist/web/assets/{diff-B-PuGS_V.js → diff-Kc-7xY_x.js} +1 -1
- package/dist/web/assets/{display-A5IEINAP-B9AKhwWc.js → display-A5IEINAP-B_ZKKrZk.js} +2 -2
- package/dist/web/assets/{django-DyJtjJNN.js → django-Bphx4KUb.js} +1 -1
- package/dist/web/assets/{dns-5vpxCrG1.js → dns-MTqDhkwE.js} +1 -1
- package/dist/web/assets/{dockerfile-Bg0nCVWB.js → dockerfile-nmZ5l2iD.js} +1 -1
- package/dist/web/assets/{dos-D3soCbS7.js → dos-D5rSh-8c.js} +1 -1
- package/dist/web/assets/{dsconfig-DOqupkJw.js → dsconfig-CCWaK-PK.js} +1 -1
- package/dist/web/assets/{dts-DG3qVzqY.js → dts-31qDWWPl.js} +1 -1
- package/dist/web/assets/{dust-CEQJ6k_0.js → dust-Cy8daiNb.js} +1 -1
- package/dist/web/assets/{ebnf-BpGViedD.js → ebnf-VzhOw6Kd.js} +1 -1
- package/dist/web/assets/{elixir-B2B4qvcW.js → elixir-CJn-1C_6.js} +1 -1
- package/dist/web/assets/{elm-DB2EvGVw.js → elm-DZtUBbMz.js} +1 -1
- package/dist/web/assets/{embeddings-DYojZti_.js → embeddings-C-ohjac4.js} +1 -1
- package/dist/web/assets/{erb-Cszy-mcb.js → erb-C_uBEPIJ.js} +1 -1
- package/dist/web/assets/{erlang-di0D81mU.js → erlang-BwkpQUHM.js} +1 -1
- package/dist/web/assets/{erlang-repl-DyROnOFX.js → erlang-repl-DQ0gq2PX.js} +1 -1
- package/dist/web/assets/{excel-BkbemQIx.js → excel-BORh9b-5.js} +1 -1
- package/dist/web/assets/{fix-AmsbYiRi.js → fix-DNf0rSwo.js} +1 -1
- package/dist/web/assets/{flix-1H3Eoudk.js → flix-DmLg020p.js} +1 -1
- package/dist/web/assets/{fortran-CUVgDzXU.js → fortran-CGgm_ZzY.js} +1 -1
- package/dist/web/assets/{fsharp-DVLBjLkI.js → fsharp-D4-2pAFX.js} +1 -1
- package/dist/web/assets/{gams-BrIgY0S1.js → gams-CxZCWsLG.js} +1 -1
- package/dist/web/assets/{gauss-Lvj1U4wk.js → gauss-DW1gQxB_.js} +1 -1
- package/dist/web/assets/{gcode-CywcT7X1.js → gcode-DtoyJd5k.js} +1 -1
- package/dist/web/assets/{gherkin-BNBGuZmK.js → gherkin-l8017tFu.js} +1 -1
- package/dist/web/assets/{glsl-tOF-nSPK.js → glsl-B49CFlSk.js} +1 -1
- package/dist/web/assets/{gml-DKPwuGU_.js → gml-XfAfVqrf.js} +1 -1
- package/dist/web/assets/{go-CL1sm9er.js → go-CSJPkcHp.js} +1 -1
- package/dist/web/assets/{golo-nPlb57RC.js → golo-mo1-uALB.js} +1 -1
- package/dist/web/assets/{gradle-CUxrh_Gh.js → gradle-CD4MK0lf.js} +1 -1
- package/dist/web/assets/{groovy-DtVD4Caw.js → groovy-hNQztEDH.js} +1 -1
- package/dist/web/assets/{haml-BMFT9in8.js → haml-B8TF9VCz.js} +1 -1
- package/dist/web/assets/{handlebars-Bv7HEL_w.js → handlebars-DgVr19h7.js} +1 -1
- package/dist/web/assets/{haskell-BpxZfnd-.js → haskell-B-jEV9v4.js} +1 -1
- package/dist/web/assets/{haxe-D8Pvl0KA.js → haxe-CJXx9kmn.js} +1 -1
- package/dist/web/assets/{hsp-BLRXHwV5.js → hsp-CibkeXif.js} +1 -1
- package/dist/web/assets/{htmlbars-spUdcJY2.js → htmlbars-BRZIPSKN.js} +1 -1
- package/dist/web/assets/{http-Jdfkn_NC.js → http-BINXUV1p.js} +1 -1
- package/dist/web/assets/{hy-C-dsNi3a.js → hy-DthyvV_S.js} +1 -1
- package/dist/web/assets/{index-Dva6g5Hr.js → index-BJaUn1y0.js} +9 -9
- package/dist/web/assets/{index-drkUjmF5.js → index-BYv53yca.js} +1 -1
- package/dist/web/assets/{index-BvralzMN.js → index-Bkws3cEt.js} +1 -1
- package/dist/web/assets/{index-hZ0BHgb_.js → index-BxVfIMyA.js} +1 -1
- package/dist/web/assets/{index-ETs79zDb.js → index-DDfBnzRR.js} +1 -1
- package/dist/web/assets/{index-wlWrEsj3.js → index-DObBYOtL.js} +1 -1
- package/dist/web/assets/{index-DTvIqzPU.js → index-Dyh7QDFw.js} +1 -1
- package/dist/web/assets/{index-B7a6zmqU.js → index-yQ7MwS3o.js} +1 -1
- package/dist/web/assets/{inform7-BwWYFe-U.js → inform7-BArukE1F.js} +1 -1
- package/dist/web/assets/{ini-BP0LwD2a.js → ini-B5ebUFzg.js} +1 -1
- package/dist/web/assets/{irpf90-BBq85DVk.js → irpf90-y1lOr5k_.js} +1 -1
- package/dist/web/assets/{isbl-COz_84Lr.js → isbl-qcWt-21i.js} +1 -1
- package/dist/web/assets/{java-ImdjqeBf.js → java-8YUgmeXA.js} +1 -1
- package/dist/web/assets/{javascript-iXqlEx76.js → javascript-Bq1jZ1JJ.js} +1 -1
- package/dist/web/assets/{jboss-cli-BEqrHvVz.js → jboss-cli--hE5yme3.js} +1 -1
- package/dist/web/assets/{json-D0WSdil9.js → json-CKREbrR9.js} +1 -1
- package/dist/web/assets/{julia-MVNNHglU.js → julia-DmO0hGS8.js} +1 -1
- package/dist/web/assets/{julia-repl-q4MeDzHU.js → julia-repl-DV-Tli0k.js} +1 -1
- package/dist/web/assets/{kotlin-Ca3HRgP9.js → kotlin-BXkilHdT.js} +1 -1
- package/dist/web/assets/{lasso-DWWZFmNw.js → lasso-CQY14g5L.js} +1 -1
- package/dist/web/assets/{latex-Mhmhfv1E.js → latex-DLjTV63K.js} +1 -1
- package/dist/web/assets/{ldif-DBURHHI3.js → ldif-DjgUZJlI.js} +1 -1
- package/dist/web/assets/{leaf-BLJfMJt7.js → leaf-C6jrKBpC.js} +1 -1
- package/dist/web/assets/{less-D-AFfjo1.js → less-G6CMFozs.js} +1 -1
- package/dist/web/assets/{lisp-BHKp2UUl.js → lisp-D4KEdXE_.js} +1 -1
- package/dist/web/assets/{livecodeserver-DFCSjU7u.js → livecodeserver-DdAHyHP0.js} +1 -1
- package/dist/web/assets/{livescript-dMCjlDr3.js → livescript-BtmleXHj.js} +1 -1
- package/dist/web/assets/{llvm-BDh3PTe6.js → llvm-DM_Gah63.js} +1 -1
- package/dist/web/assets/{lsl-C76zVqCV.js → lsl-VgyY0L2n.js} +1 -1
- package/dist/web/assets/{lua-C_hOM7x6.js → lua-BJul0nVW.js} +1 -1
- package/dist/web/assets/{makefile-CgMLvzZx.js → makefile-PgnkDaM4.js} +1 -1
- package/dist/web/assets/{markdown-CFhKgQvq.js → markdown-Bri8uWn4.js} +1 -1
- package/dist/web/assets/{mathematica-CtEYUJnt.js → mathematica-CuMkjOZ1.js} +1 -1
- package/dist/web/assets/{matlab-B_topJyU.js → matlab-CiF-p48M.js} +1 -1
- package/dist/web/assets/{maxima-CWnUqS-o.js → maxima-nmj79uap.js} +1 -1
- package/dist/web/assets/{mel-CHd4JWo1.js → mel-CIrVgYK2.js} +1 -1
- package/dist/web/assets/{mercury-ZZkIJA0v.js → mercury-BIX0_kvz.js} +1 -1
- package/dist/web/assets/{mipsasm-o6EcrXDx.js → mipsasm-BkVCx5fz.js} +1 -1
- package/dist/web/assets/{mizar-BlrMzItF.js → mizar-B_QeMpax.js} +1 -1
- package/dist/web/assets/{mojolicious-FqwXW4Jn.js → mojolicious-mP8DxkcN.js} +1 -1
- package/dist/web/assets/{monkey-CJluJWrQ.js → monkey-cP9Iszlu.js} +1 -1
- package/dist/web/assets/{moonscript-C1zCpdoD.js → moonscript-W6ojyZ7m.js} +1 -1
- package/dist/web/assets/{n1ql-DkBtYh9I.js → n1ql-KXNMPLpE.js} +1 -1
- package/dist/web/assets/{nginx-DgBnImAK.js → nginx-Mnbx2e4v.js} +1 -1
- package/dist/web/assets/{nim-D_R4Iel3.js → nim-Bl05ghdK.js} +1 -1
- package/dist/web/assets/{nix-BhNB6HN0.js → nix-BI2MKgD9.js} +1 -1
- package/dist/web/assets/{node-repl-gGmKBMI6.js → node-repl-CuuAAfs7.js} +1 -1
- package/dist/web/assets/{nsis-J5CQFIWO.js → nsis-BO8jtPFd.js} +1 -1
- package/dist/web/assets/{objectivec-BzLXA5yf.js → objectivec-C2ceKUhh.js} +1 -1
- package/dist/web/assets/{ocaml-FfVH3xEI.js → ocaml-CF7izvk1.js} +1 -1
- package/dist/web/assets/{openscad-Bp384Jbj.js → openscad-B__EVexc.js} +1 -1
- package/dist/web/assets/{oxygene-DPY9ycw0.js → oxygene-BEnm-3cF.js} +1 -1
- package/dist/web/assets/{parser3-D4gEw04Z.js → parser3-Cha-yehR.js} +1 -1
- package/dist/web/assets/{perl-BOlaaXDe.js → perl-UcR1pT_m.js} +1 -1
- package/dist/web/assets/{pf-YU8HEWK7.js → pf-DOcMJiPa.js} +1 -1
- package/dist/web/assets/{pgsql-DIouR7UK.js → pgsql-BWxkc9dd.js} +1 -1
- package/dist/web/assets/{php-BEWcqftR.js → php-DKewMUyF.js} +1 -1
- package/dist/web/assets/{php-template-CdO4HPjp.js → php-template-BW4EXwD2.js} +1 -1
- package/dist/web/assets/{plaintext-BjumRusf.js → plaintext-B2B7CGv1.js} +1 -1
- package/dist/web/assets/{pony-DRJtJ8gZ.js → pony-cyT8JI3_.js} +1 -1
- package/dist/web/assets/{powershell-DKOx-vtB.js → powershell-9_HKD5ZI.js} +1 -1
- package/dist/web/assets/{processing-DcJA9v0m.js → processing-DqkOYeI0.js} +1 -1
- package/dist/web/assets/{profile-EucclgD7.js → profile-BcahrQJb.js} +1 -1
- package/dist/web/assets/{prolog-Dx43Cpnv.js → prolog-CMTH5oDf.js} +1 -1
- package/dist/web/assets/{properties-C7SZr3lo.js → properties-CNgRg-Qc.js} +1 -1
- package/dist/web/assets/{protobuf-BTV0UHn3.js → protobuf-DhBdh2IM.js} +1 -1
- package/dist/web/assets/{puppet-B-O6PZjk.js → puppet-Bs-jqq55.js} +1 -1
- package/dist/web/assets/{purebasic-CGVAqrY3.js → purebasic-D6NOF_zF.js} +1 -1
- package/dist/web/assets/{python-BHVLVojY.js → python-C5JmuI1q.js} +1 -1
- package/dist/web/assets/{python-repl-ByPDA8So.js → python-repl-0nLtDax7.js} +1 -1
- package/dist/web/assets/{q-DjrV3TfK.js → q-DOzbkwzA.js} +1 -1
- package/dist/web/assets/{qml-CSHbh6pH.js → qml-C1Q3smLm.js} +1 -1
- package/dist/web/assets/{r-_4IhmvDS.js → r-5WBM9KHr.js} +1 -1
- package/dist/web/assets/{reasonml-DtY2ajJZ.js → reasonml-tWfChws-.js} +1 -1
- package/dist/web/assets/{rib-BhwyNrxP.js → rib-TU3b5BFH.js} +1 -1
- package/dist/web/assets/{roboconf-Dpcw1M50.js → roboconf-B4_l1170.js} +1 -1
- package/dist/web/assets/{routeros-CQml7pwr.js → routeros-kUQTTKlk.js} +1 -1
- package/dist/web/assets/{rsl-5-c4feKg.js → rsl-CUYnw7al.js} +1 -1
- package/dist/web/assets/{ruby-_XSbpG-2.js → ruby-DUCZyqKT.js} +1 -1
- package/dist/web/assets/{ruleslanguage-CzDsQwj4.js → ruleslanguage-AGO5IgId.js} +1 -1
- package/dist/web/assets/{rust-DcPUeB6V.js → rust-B85ld-lv.js} +1 -1
- package/dist/web/assets/{sas-BVYOO8py.js → sas-BJgvP4ZQ.js} +1 -1
- package/dist/web/assets/{scala-D7oBEyhN.js → scala-BF8v2oQV.js} +1 -1
- package/dist/web/assets/{scheme-DJ_DPnnD.js → scheme-DwApkYRn.js} +1 -1
- package/dist/web/assets/{scilab-BJ2D-L9g.js → scilab-I9lGEwkL.js} +1 -1
- package/dist/web/assets/{scss-DcOHNhWH.js → scss-DuOOOEqY.js} +1 -1
- package/dist/web/assets/{shell-B_j2RbGV.js → shell-VwkIwboF.js} +1 -1
- package/dist/web/assets/{smali-Cj6pe0xZ.js → smali-5lm4r8Jl.js} +1 -1
- package/dist/web/assets/{smalltalk-DDq36hFd.js → smalltalk-B82GiryH.js} +1 -1
- package/dist/web/assets/{sml-CDMqcNGr.js → sml-g9enmpmY.js} +1 -1
- package/dist/web/assets/{sqf-D3LjUasY.js → sqf-BKidvRBd.js} +1 -1
- package/dist/web/assets/{sql-BwS3e1wr.js → sql-CYtCYbSS.js} +1 -1
- package/dist/web/assets/{sql_more-CVhQtySq.js → sql_more-C2Q4wP7v.js} +1 -1
- package/dist/web/assets/{stan-I4Giro_S.js → stan-CY1dWnHu.js} +1 -1
- package/dist/web/assets/{stata-lIBiByTT.js → stata-CRcoOa51.js} +1 -1
- package/dist/web/assets/{step21-ezaBGwMG.js → step21-BSincIa_.js} +1 -1
- package/dist/web/assets/{stylus-CAGPTcId.js → stylus-fXBtMQ88.js} +1 -1
- package/dist/web/assets/{subunit-DbMzVkjd.js → subunit-C1A4Mlh7.js} +1 -1
- package/dist/web/assets/{swift-CSXyxfdZ.js → swift-D8JfNKcP.js} +1 -1
- package/dist/web/assets/{taggerscript-IR58r71B.js → taggerscript-i3dAG7nD.js} +1 -1
- package/dist/web/assets/{tap-CZO4-vi5.js → tap-CoeP7SXL.js} +1 -1
- package/dist/web/assets/{tcl-BLA-W0Ck.js → tcl-BZ_ITiK-.js} +1 -1
- package/dist/web/assets/{thrift-D7Fz3vG3.js → thrift-C0R5G0pG.js} +1 -1
- package/dist/web/assets/{tp-CmqQfFFo.js → tp-Dc_Xqcyd.js} +1 -1
- package/dist/web/assets/{twig-Bf8O0Dg7.js → twig-aE1gKTlD.js} +1 -1
- package/dist/web/assets/{typescript-BNexk4o8.js → typescript-BlvRhi0E.js} +1 -1
- package/dist/web/assets/{vala-Dh1vvBu6.js → vala-DzP0OtGB.js} +1 -1
- package/dist/web/assets/{vbnet-l7ketSuH.js → vbnet-CKA-Gq8K.js} +1 -1
- package/dist/web/assets/{vbscript-DxQ5A-HK.js → vbscript-DLQKzP32.js} +1 -1
- package/dist/web/assets/{vbscript-html-BgBX17Jk.js → vbscript-html-Bwm5mMEw.js} +1 -1
- package/dist/web/assets/{verilog-rV108XAi.js → verilog-BI8-j2j6.js} +1 -1
- package/dist/web/assets/{vhdl-DD6p8Z8q.js → vhdl-Csphiw28.js} +1 -1
- package/dist/web/assets/{vim-vdgNbcLa.js → vim-DHWfGfWD.js} +1 -1
- package/dist/web/assets/{x86asm-BDLmr91f.js → x86asm-DJYc7sh_.js} +1 -1
- package/dist/web/assets/{xl-BSRRUq-m.js → xl-Bm8HzFdy.js} +1 -1
- package/dist/web/assets/{xml-iHXOeyLs.js → xml-TxfANkEb.js} +1 -1
- package/dist/web/assets/{xquery-BBQFu1UK.js → xquery-vpyqwwwb.js} +1 -1
- package/dist/web/assets/{yaml-BCd7PH-N.js → yaml-Ct2AIMvr.js} +1 -1
- package/dist/web/assets/{zephir-C4XF1Tp-.js → zephir-DejZrgxJ.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c5 as Ft,c6 as Bt,c7 as X,c8 as et,i as wt,c9 as H,bH as ut,_ as U,ca as Ie,cb as Se,cc as Ae,cd as Ne,ce as Oe,cf as ke,cg as Pe,ch as Me,ci as xe,cj as Re,g as Le,ck as De,cl as Fe,cm as Be,c as Ue,cn as je,co as Ve,cp as ze,cq as Ge,cr as Ze,bS as $e,cs as He,b as zt,ct as We,cu as Gt,cv as Xe,cw as Ye,cx as Je,cy as Ct,cz as Ke,cA as qe,cB as Qe,w as Zt,cC as nt,e as it,cD as $t,cE as Ht,cF as ot,bT as ta,C as bt,cG as Ut,cH as ea,cI as jt,bI as Y,bO as aa,cJ as It,bL as sa,bU as Wt,cK as na,cL as ra,cM as ia,bJ as Xt,cN as rt,j as G,cO as Yt,cP as oa,cQ as Jt,cR as ca,k as ua,m as la,cS as ha,cT as ma,cU as fa,cV as pa,cW as ga,cX as da,cY as ba,cZ as _a,bK as Vt,c_ as ya,c$ as Ta,d0 as va,o as Kt,s as qt,d1 as Ea,d2 as Tt,d3 as wa}from"./index-Dva6g5Hr.js";import{g as Ca,T as Ia}from"./chunk-VL2OQCWN-Ci7Z2Gkc.js";function Qt(t,a,n,r,c){if(a!==t){typeof a.toJSON=="function"&&(a=a.toJSON());for(var u=Ft(a),m=Ft(t),l=!1,g=m.length-1;g>=0;g--){var f=m[g],T=t[f];if(Bt(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var _=a[f];typeof T=="object"&&T!=null&&typeof _=="object"&&_!=null&&Array.isArray(T)===Array.isArray(_)?Qt(T,_,n,r+"/"+X(f),c):T!==_&&(c&&n.push({op:"test",path:r+"/"+X(f),value:et(T)}),n.push({op:"replace",path:r+"/"+X(f),value:et(_)}))}else Array.isArray(t)===Array.isArray(a)?(c&&n.push({op:"test",path:r+"/"+X(f),value:et(T)}),n.push({op:"remove",path:r+"/"+X(f)}),l=!0):(c&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&u.length==m.length))for(var g=0;g<u.length;g++){var f=u[g];!Bt(t,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+X(f),value:et(a[f])})}}}function St(t,a,n=!1){var r=[];return Qt(t,a,r,"",n),r}function te(t){return t!==void 0&&Array.isArray(t.lc_namespace)}function ee(t){return t!==void 0&&H.isRunnable(t)&&"lc_name"in t.constructor&&typeof t.constructor.lc_name=="function"&&t.constructor.lc_name()==="RunnableToolLike"}function ae(t){return!!t&&typeof t=="object"&&"name"in t&&"schema"in t&&(wt(t.schema)||t.schema!=null&&typeof t.schema=="object"&&"type"in t.schema&&typeof t.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(t.schema.type))}function se(t){return ae(t)||ee(t)||te(t)}var Sa={};U(Sa,{convertToOpenAIFunction:()=>ne,convertToOpenAITool:()=>Aa,isLangChainTool:()=>se,isRunnableToolLike:()=>ee,isStructuredTool:()=>te,isStructuredToolParams:()=>ae});function ne(t,a){const n=typeof a=="number"?void 0:a;return{name:t.name,description:t.description,parameters:ut(t.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function Aa(t,a){const n=typeof a=="number"?void 0:a;let r;return se(t)?r={type:"function",function:ne(t)}:r=t,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Na={};U(Na,{extendInteropZodObject:()=>Je,getInteropZodDefaultGetter:()=>Ye,getInteropZodObjectShape:()=>Xe,getSchemaDescription:()=>Gt,interopParse:()=>We,interopParseAsync:()=>zt,interopSafeParse:()=>He,interopSafeParseAsync:()=>$e,interopZodObjectMakeFieldsOptional:()=>Ze,interopZodObjectPartial:()=>Ge,interopZodObjectPassthrough:()=>ze,interopZodObjectStrict:()=>Ve,interopZodTransformInputSchema:()=>je,isInteropZodError:()=>Ue,isInteropZodLiteral:()=>Be,isInteropZodObject:()=>Fe,isInteropZodSchema:()=>wt,isShapelessZodSchema:()=>De,isSimpleStringZodSchema:()=>Le,isZodArrayV4:()=>Re,isZodLiteralV3:()=>xe,isZodLiteralV4:()=>Me,isZodNullableV4:()=>Pe,isZodObjectV3:()=>ke,isZodObjectV4:()=>Oe,isZodOptionalV4:()=>Ne,isZodSchema:()=>Ae,isZodSchemaV3:()=>Se,isZodSchemaV4:()=>Ie});var Oa={};U(Oa,{BasePromptValue:()=>lt,ChatPromptValue:()=>ie,ImagePromptValue:()=>ka,StringPromptValue:()=>re});var lt=class extends qe{},re=class extends lt{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(t){super({value:t}),this.value=t}toString(){return this.value}toChatMessages(){return[new Ct(this.value)]}},ie=class extends lt{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(t){Array.isArray(t)&&(t={messages:t}),super(t),this.messages=t.messages}toString(){return Ke(this.messages)}toChatMessages(){return this.messages}},ka=class extends lt{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(t){"imageUrl"in t||(t={imageUrl:t}),super(t),this.imageUrl=t.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Ct({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},p="0123456789abcdef".split(""),Pa=[-2147483648,8388608,32768,128],F=[24,16,8,0],at=[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],k=[];function B(t,a){a?(k[0]=k[16]=k[1]=k[2]=k[3]=k[4]=k[5]=k[6]=k[7]=k[8]=k[9]=k[10]=k[11]=k[12]=k[13]=k[14]=k[15]=0,this.blocks=k):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(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=t}B.prototype.update=function(t){if(!this.finalized){var a,n=typeof t;if(n!=="string"){if(n==="object"){if(t===null)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(t)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,c=0,u,m=t.length,l=this.blocks;c<m;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(u=this.start;c<m&&u<64;++c)l[u>>>2]|=t[c]<<F[u++&3];else for(u=this.start;c<m&&u<64;++c)r=t.charCodeAt(c),r<128?l[u>>>2]|=r<<F[u++&3]:r<2048?(l[u>>>2]|=(192|r>>>6)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]):r<55296||r>=57344?(l[u>>>2]|=(224|r>>>12)<<F[u++&3],l[u>>>2]|=(128|r>>>6&63)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]):(r=65536+((r&1023)<<10|t.charCodeAt(++c)&1023),l[u>>>2]|=(240|r>>>18)<<F[u++&3],l[u>>>2]|=(128|r>>>12&63)<<F[u++&3],l[u>>>2]|=(128|r>>>6&63)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]);this.lastByteIndex=u,this.bytes+=u-this.start,u>=64?(this.block=l[16],this.start=u-64,this.hash(),this.hashed=!0):this.start=u}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,a=this.lastByteIndex;t[16]=this.block,t[a>>>2]|=Pa[a&3],this.block=t[16],a>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=this.blocks,f,T,_,v,d,y,b,E,w,M,S;for(f=16;f<64;++f)d=g[f-15],T=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,d=g[f-2],_=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,g[f]=g[f-16]+T+g[f-7]+_<<0;for(S=a&n,f=0;f<64;f+=4)this.first?(this.is224?(E=300032,d=g[0]-1413257819,l=d-150054599<<0,r=d+24177077<<0):(E=704751109,d=g[0]-210244248,l=d-1521486534<<0,r=d+143694565<<0),this.first=!1):(T=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),_=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),E=t&a,v=E^t&n^S,b=c&u^~c&m,d=l+_+b+at[f]+g[f],y=T+v,l=r+d<<0,r=d+y<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),_=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&t,v=w^r&a^E,b=m&l^~m&c,d=u+_+b+at[f+1]+g[f+1],y=T+v,m=n+d<<0,n=d+y<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),_=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),M=n&r,v=M^n&t^w,b=u&m^~u&l,d=c+_+b+at[f+2]+g[f+2],y=T+v,u=a+d<<0,a=d+y<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),_=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),S=a&n,v=S^a&r^M,b=u&m^~u&l,d=c+_+b+at[f+3]+g[f+3],y=T+v,c=t+d<<0,t=d+y<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+t<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+c<<0,this.h5=this.h5+u<<0,this.h6=this.h6+m<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=p[t>>>28&15]+p[t>>>24&15]+p[t>>>20&15]+p[t>>>16&15]+p[t>>>12&15]+p[t>>>8&15]+p[t>>>4&15]+p[t&15]+p[a>>>28&15]+p[a>>>24&15]+p[a>>>20&15]+p[a>>>16&15]+p[a>>>12&15]+p[a>>>8&15]+p[a>>>4&15]+p[a&15]+p[n>>>28&15]+p[n>>>24&15]+p[n>>>20&15]+p[n>>>16&15]+p[n>>>12&15]+p[n>>>8&15]+p[n>>>4&15]+p[n&15]+p[r>>>28&15]+p[r>>>24&15]+p[r>>>20&15]+p[r>>>16&15]+p[r>>>12&15]+p[r>>>8&15]+p[r>>>4&15]+p[r&15]+p[c>>>28&15]+p[c>>>24&15]+p[c>>>20&15]+p[c>>>16&15]+p[c>>>12&15]+p[c>>>8&15]+p[c>>>4&15]+p[c&15]+p[u>>>28&15]+p[u>>>24&15]+p[u>>>20&15]+p[u>>>16&15]+p[u>>>12&15]+p[u>>>8&15]+p[u>>>4&15]+p[u&15]+p[m>>>28&15]+p[m>>>24&15]+p[m>>>20&15]+p[m>>>16&15]+p[m>>>12&15]+p[m>>>8&15]+p[m>>>4&15]+p[m&15];return this.is224||(g+=p[l>>>28&15]+p[l>>>24&15]+p[l>>>20&15]+p[l>>>16&15]+p[l>>>12&15]+p[l>>>8&15]+p[l>>>4&15]+p[l&15]),g};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=[t>>>24&255,t>>>16&255,t>>>8&255,t&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255];return this.is224||g.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),g};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),a=new DataView(t);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),t};const oe=(...t)=>new B(!1,!0).update(t.join("")).hex();var Ma={};U(Ma,{sha256:()=>oe});var xa={};U(xa,{BaseCache:()=>ue,InMemoryCache:()=>le,defaultHashKeyEncoder:()=>ce,deserializeStoredGeneration:()=>Ra,serializeGeneration:()=>La});const ce=(...t)=>oe(t.join("_"));function Ra(t){return t.message!==void 0?{text:t.text,message:Qe(t.message)}:{text:t.text}}function La(t){const a={text:t.text};return t.message!==void 0&&(a.message=t.message.toDict()),a}var ue=class{keyEncoder=ce;makeDefaultKeyEncoder(t){this.keyEncoder=t}};const Da=new Map;var le=class he extends ue{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new he(Da)}},Fa={};U(Fa,{encodingForModel:()=>At,getEncoding:()=>me});const st={},Ba=new Zt({});async function me(t){return t in st||(st[t]=Ba.fetch(`https://tiktoken.pages.dev/js/${t}.json`).then(a=>a.json()).then(a=>new Ia(a)).catch(a=>{throw delete st[t],a})),await st[t]}async function At(t){return me(Ca(t))}var Ua={};U(Ua,{BaseLangChain:()=>pe,BaseLanguageModel:()=>ge,calculateMaxTokens:()=>za,getEmbeddingContextSize:()=>ja,getModelContextSize:()=>fe,getModelNameForTiktoken:()=>ht,isOpenAITool:()=>Va});const ht=t=>t.startsWith("gpt-5")?"gpt-5":t.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":t.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":t.startsWith("gpt-4-32k")?"gpt-4-32k":t.startsWith("gpt-4-")?"gpt-4":t.startsWith("gpt-4o")?"gpt-4o":t,ja=t=>{switch(t){case"text-embedding-ada-002":return 8191;default:return 2046}},fe=t=>{switch(ht(t)){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 Va(t){return typeof t!="object"||!t?!1:!!("type"in t&&t.type==="function"&&"function"in t&&typeof t.function=="object"&&t.function&&"name"in t.function&&"parameters"in t.function)}const za=async({prompt:t,modelName:a})=>{let n;try{n=(await At(ht(a))).encode(t).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(t.length/4)}return fe(a)-n},Ga=()=>!1;var pe=class extends H{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(t){super(t),this.verbose=t.verbose??Ga(),this.callbacks=t.callbacks,this.tags=t.tags??[],this.metadata=t.metadata??{}}},ge=class extends pe{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:t,callbackManager:a,...n}){const{cache:r,...c}=n;super({callbacks:t??a,...c}),typeof r=="object"?this.cache=r:r?this.cache=le.global():this.cache=void 0,this.caller=new Zt(n??{})}_encoding;async getNumTokens(t){let a;typeof t=="string"?a=t:a=t.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(a.length/4);if(!this._encoding)try{this._encoding=await At("modelName"in this?ht(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(a).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(t){return typeof t=="string"?new re(t):Array.isArray(t)?new ie(t.map(nt)):t}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:t,...a}){const n={...this._identifyingParams(),...a,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([u,m])=>m!==void 0).map(([u,m])=>`${u}:${JSON.stringify(m)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(t){throw new Error("Use .toJSON() instead")}get profile(){return{}}},ct=class extends H{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(t){super(t),t&&(this.func=t.func)}async invoke(t,a){const n=it(a);return this.func&&await this.func(t,n),this._callWithConfig(r=>Promise.resolve(r),t,n)}async*transform(t,a){const n=it(a);let r,c=!0;for await(const u of this._transformStreamWithConfig(t,m=>m,n))if(yield u,c)if(r===void 0)r=u;else try{r=ot(r,u)}catch{r=void 0,c=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(t){return new $t(new Ht({steps:t}))}};const Za=t=>t();function _t(t){const a=t.constructor;return new a({...t,content:t.contentBlocks,response_metadata:{...t.response_metadata,output_version:"v1"}})}var $a={};U($a,{BaseChatModel:()=>de,SimpleChatModel:()=>Ha});function yt(t){const a=[];for(const n of t){let r=n;if(Array.isArray(n.content))for(let c=0;c<n.content.length;c++){const u=n.content[c];(na(u)||ra(u))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,c),ia(u),...n.content.slice(c+1)]}))}a.push(r)}return a}var de=class Z extends ge{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(a){super(a),this.outputVersion=Za(()=>{const n=a.outputVersion??ta("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(a){const[n,r]=super._separateRunnableConfigFromCallOptions(a);return r.signal=n.signal,[n,r]}async invoke(a,n){const r=Z._convertInputToPromptValue(a);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(a,n,r){throw new Error("Not implemented.")}async*_streamIterator(a,n){if(this._streamResponseChunks===Z.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(a,n);else{const c=Z._convertInputToPromptValue(a).toChatMessages(),[u,m]=this._separateRunnableConfigFromCallOptionsCompat(n),l={...u.metadata,...this.getLsParams(m)},g=await bt.configure(u.callbacks,this.callbacks,u.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:m,invocation_params:this?.invocationParams(m),batch_size:1},T=m.outputVersion??this.outputVersion,_=await g?.handleChatModelStart(this.toJSON(),[yt(c)],u.runId,void 0,f,void 0,void 0,u.runName);let v,d;try{for await(const y of this._streamResponseChunks(c,m,_?.[0])){if(y.message.id==null){const b=_?.at(0)?.runId;b!=null&&y.message._updateId(`run-${b}`)}y.message.response_metadata={...y.generationInfo,...y.message.response_metadata},T==="v1"?yield _t(y.message):yield y.message,v?v=v.concat(y):v=y,Ut(y.message)&&y.message.usage_metadata!==void 0&&(d={tokenUsage:{promptTokens:y.message.usage_metadata.input_tokens,completionTokens:y.message.usage_metadata.output_tokens,totalTokens:y.message.usage_metadata.total_tokens}})}}catch(y){throw await Promise.all((_??[]).map(b=>b?.handleLLMError(y))),y}await Promise.all((_??[]).map(y=>y?.handleLLMEnd({generations:[[v]],llmOutput:d})))}}getLsParams(a){const n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:a.stop,ls_provider:n}}async _generateUncached(a,n,r,c){const u=a.map(v=>v.map(nt));let m;if(c!==void 0&&c.length===u.length)m=c;else{const v={...r.metadata,...this.getLsParams(n)},d=await bt.configure(r.callbacks,this.callbacks,r.tags,this.tags,v,this.metadata,{verbose:this.verbose}),y={options:n,invocation_params:this?.invocationParams(n),batch_size:1};m=await d?.handleChatModelStart(this.toJSON(),u.map(yt),r.runId,void 0,y,void 0,void 0,r.runName)}const l=n.outputVersion??this.outputVersion,g=[],f=[];if(!!m?.[0].handlers.find(ea)&&!this.disableStreaming&&u.length===1&&this._streamResponseChunks!==Z.prototype._streamResponseChunks)try{const v=await this._streamResponseChunks(u[0],n,m?.[0]);let d,y;for await(const b of v){if(b.message.id==null){const E=m?.at(0)?.runId;E!=null&&b.message._updateId(`run-${E}`)}d===void 0?d=b:d=ot(d,b),Ut(b.message)&&b.message.usage_metadata!==void 0&&(y={tokenUsage:{promptTokens:b.message.usage_metadata.input_tokens,completionTokens:b.message.usage_metadata.output_tokens,totalTokens:b.message.usage_metadata.total_tokens}})}if(d===void 0)throw new Error("Received empty response from chat model call.");g.push([d]),await m?.[0].handleLLMEnd({generations:g,llmOutput:y})}catch(v){throw await m?.[0].handleLLMError(v),v}else{const v=await Promise.allSettled(u.map(async(d,y)=>{const b=await this._generate(d,{...n,promptIndex:y},m?.[y]);if(l==="v1")for(const E of b.generations)E.message=_t(E.message);return b}));await Promise.all(v.map(async(d,y)=>{if(d.status==="fulfilled"){const b=d.value;for(const E of b.generations){if(E.message.id==null){const w=m?.at(0)?.runId;w!=null&&E.message._updateId(`run-${w}`)}E.message.response_metadata={...E.generationInfo,...E.message.response_metadata}}return b.generations.length===1&&(b.generations[0].message.response_metadata={...b.llmOutput,...b.generations[0].message.response_metadata}),g[y]=b.generations,f[y]=b.llmOutput,m?.[y]?.handleLLMEnd({generations:[b.generations],llmOutput:b.llmOutput})}else return await m?.[y]?.handleLLMError(d.reason),Promise.reject(d.reason)}))}const _={generations:g,llmOutput:f.length?this._combineLLMOutput?.(...f):void 0};return Object.defineProperty(_,jt,{value:m?{runIds:m?.map(v=>v.runId)}:void 0,configurable:!0}),_}async _generateCached({messages:a,cache:n,llmStringKey:r,parsedOptions:c,handledOptions:u}){const m=a.map(w=>w.map(nt)),l={...u.metadata,...this.getLsParams(c)},g=await bt.configure(u.callbacks,this.callbacks,u.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:c,invocation_params:this?.invocationParams(c),batch_size:1},T=await g?.handleChatModelStart(this.toJSON(),m.map(yt),u.runId,void 0,f,void 0,void 0,u.runName),_=[],d=(await Promise.allSettled(m.map(async(w,M)=>{const S=Z._convertInputToPromptValue(w).toString(),R=await n.lookup(S,r);return R==null&&_.push(M),R}))).map((w,M)=>({result:w,runManager:T?.[M]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),y=c.outputVersion??this.outputVersion,b=[];await Promise.all(d.map(async({result:w,runManager:M},S)=>{if(w.status==="fulfilled"){const R=w.value;return b[S]=R.map(D=>("message"in D&&Y(D.message)&&aa(D.message)&&(D.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},y==="v1"&&(D.message=_t(D.message))),D.generationInfo={...D.generationInfo,tokenUsage:{}},D)),R.length&&await M?.handleLLMNewToken(R[0].text),M?.handleLLMEnd({generations:[R]},void 0,void 0,void 0,{cached:!0})}else return await M?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));const E={generations:b,missingPromptIndices:_,startedRunManagers:T};return Object.defineProperty(E,jt,{value:T?{runIds:T?.map(w=>w.runId)}:void 0,configurable:!0}),E}async generate(a,n,r){let c;Array.isArray(n)?c={stop:n}:c=n;const u=a.map(y=>y.map(nt)),[m,l]=this._separateRunnableConfigFromCallOptionsCompat(c);if(m.callbacks=m.callbacks??r,!this.cache)return this._generateUncached(u,l,m);const{cache:g}=this,f=this._getSerializedCacheKeyParametersForCall(l),{generations:T,missingPromptIndices:_,startedRunManagers:v}=await this._generateCached({messages:u,cache:g,llmStringKey:f,parsedOptions:l,handledOptions:m});let d={};if(_.length>0){const y=await this._generateUncached(_.map(b=>u[b]),l,m,v!==void 0?_.map(b=>v?.[b]):void 0);await Promise.all(y.generations.map(async(b,E)=>{const w=_[E];T[w]=b;const M=Z._convertInputToPromptValue(u[w]).toString();return g.update(M,f,b)})),d=y.llmOutput??{}}return{generations:T,llmOutput:d}}invocationParams(a){return{}}_modelType(){return"base_chat_model"}async generatePrompt(a,n,r){const c=a.map(u=>u.toChatMessages());return this.generate(c,n,r)}withStructuredOutput(a,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');const r=a,c=n?.name,u=Gt(r)??"A function available to call.",m=n?.method,l=n?.includeRaw;if(m==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let g=c??"extract",f;wt(r)?f=[{type:"function",function:{name:g,description:u,parameters:ut(r)}}]:("name"in r&&(g=r.name),f=[{type:"function",function:{name:g,description:u,parameters:r}}]);const T=this.bindTools(f),_=It.from(b=>{if(!sa.isInstance(b))throw new Error("Input is not an AIMessageChunk.");if(!b.tool_calls||b.tool_calls.length===0)throw new Error("No tool calls found in the response.");const E=b.tool_calls.find(w=>w.name===g);if(!E)throw new Error(`No tool call found with name ${g}.`);return E.args});if(!l)return T.pipe(_).withConfig({runName:"StructuredOutput"});const v=ct.assign({parsed:(b,E)=>_.invoke(b.raw,E)}),d=ct.assign({parsed:()=>null}),y=v.withFallbacks({fallbacks:[d]});return Wt.from([{raw:T},y]).withConfig({runName:"StructuredOutputRunnable"})}},Ha=class extends de{async _generate(t,a,n){const r=await this._call(t,a,n),c=new Xt(r);if(typeof c.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:c.content,message:c}]}}},Wa=class extends H{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(t){super(t),this.runnables=t.runnables}async invoke(t,a){const{key:n,input:r}=t,c=this.runnables[n];if(c===void 0)throw new Error(`No runnable associated with key "${n}".`);return c.invoke(r,it(a))}async batch(t,a,n){const r=t.map(_=>_.key),c=t.map(_=>_.input);if(r.find(_=>this.runnables[_]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");const m=r.map(_=>this.runnables[_]),l=this._getOptionsList(a??{},t.length),g=l[0]?.maxConcurrency??n?.maxConcurrency,f=g&&g>0?g:t.length,T=[];for(let _=0;_<c.length;_+=f){const v=c.slice(_,_+f).map((y,b)=>m[b].invoke(y,l[b])),d=await Promise.all(v);T.push(d)}return T.flat()}async stream(t,a){const{key:n,input:r}=t,c=this.runnables[n];if(c===void 0)throw new Error(`No runnable associated with key "${n}".`);return c.stream(r,a)}},Xa=class extends H{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(t){super(t),this.branches=t.branches,this.default=t.default}static from(t){if(t.length<1)throw new Error("RunnableBranch requires at least one branch");const n=t.slice(0,-1).map(([c,u])=>[rt(c),rt(u)]),r=rt(t[t.length-1]);return new this({branches:n,default:r})}async _invoke(t,a,n){let r;for(let c=0;c<this.branches.length;c+=1){const[u,m]=this.branches[c];if(await u.invoke(t,G(a,{callbacks:n?.getChild(`condition:${c+1}`)}))){r=await m.invoke(t,G(a,{callbacks:n?.getChild(`branch:${c+1}`)}));break}}return r||(r=await this.default.invoke(t,G(a,{callbacks:n?.getChild("branch:default")}))),r}async invoke(t,a={}){return this._callWithConfig(this._invoke,t,a)}async*_streamIterator(t,a){const r=await(await Yt(a))?.handleChainStart(this.toJSON(),oa(t,"input"),a?.runId,void 0,void 0,void 0,a?.runName);let c,u=!0,m;try{for(let l=0;l<this.branches.length;l+=1){const[g,f]=this.branches[l];if(await g.invoke(t,G(a,{callbacks:r?.getChild(`condition:${l+1}`)}))){m=await f.stream(t,G(a,{callbacks:r?.getChild(`branch:${l+1}`)}));for await(const _ of m)if(yield _,u)if(c===void 0)c=_;else try{c=ot(c,_)}catch{c=void 0,u=!1}break}}if(m===void 0){m=await this.default.stream(t,G(a,{callbacks:r?.getChild("branch:default")}));for await(const l of m)if(yield l,u)if(c===void 0)c=l;else try{c=ot(c,l)}catch{c=void 0,u=!1}}}catch(l){throw await r?.handleChainError(l),l}await r?.handleChainEnd(c??{})}},Ya=class extends Jt{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(t){let a=It.from((u,m)=>this._enterHistory(u,m??{})).withConfig({runName:"loadHistory"});const n=t.historyMessagesKey??t.inputMessagesKey;n&&(a=ct.assign({[n]:a}).withConfig({runName:"insertHistory"}));const r=a.pipe(t.runnable.withListeners({onEnd:(u,m)=>this._exitHistory(u,m??{})})).withConfig({runName:"RunnableWithMessageHistory"}),c=t.config??{};super({...t,config:c,bound:r}),this.runnable=t.runnable,this.getMessageHistory=t.getMessageHistory,this.inputMessagesKey=t.inputMessagesKey,this.outputMessagesKey=t.outputMessagesKey,this.historyMessagesKey=t.historyMessagesKey}_getInputMessages(t){let a;if(typeof t=="object"&&!Array.isArray(t)&&!Y(t)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(t).length===1?n=Object.keys(t)[0]:n="input",Array.isArray(t[n])&&Array.isArray(t[n][0])?a=t[n][0]:a=t[n]}else a=t;if(typeof a=="string")return[new Ct(a)];if(Array.isArray(a))return a;if(Y(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
1
|
+
import{c5 as Ft,c6 as Bt,c7 as X,c8 as et,i as wt,c9 as H,bH as ut,_ as U,ca as Ie,cb as Se,cc as Ae,cd as Ne,ce as Oe,cf as ke,cg as Pe,ch as Me,ci as xe,cj as Re,g as Le,ck as De,cl as Fe,cm as Be,c as Ue,cn as je,co as Ve,cp as ze,cq as Ge,cr as Ze,bS as $e,cs as He,b as zt,ct as We,cu as Gt,cv as Xe,cw as Ye,cx as Je,cy as Ct,cz as Ke,cA as qe,cB as Qe,w as Zt,cC as nt,e as it,cD as $t,cE as Ht,cF as ot,bT as ta,C as bt,cG as Ut,cH as ea,cI as jt,bI as Y,bO as aa,cJ as It,bL as sa,bU as Wt,cK as na,cL as ra,cM as ia,bJ as Xt,cN as rt,j as G,cO as Yt,cP as oa,cQ as Jt,cR as ca,k as ua,m as la,cS as ha,cT as ma,cU as fa,cV as pa,cW as ga,cX as da,cY as ba,cZ as _a,bK as Vt,c_ as ya,c$ as Ta,d0 as va,o as Kt,s as qt,d1 as Ea,d2 as Tt,d3 as wa}from"./index-BJaUn1y0.js";import{g as Ca,T as Ia}from"./chunk-VL2OQCWN-Bq-lrj3t.js";function Qt(t,a,n,r,c){if(a!==t){typeof a.toJSON=="function"&&(a=a.toJSON());for(var u=Ft(a),m=Ft(t),l=!1,g=m.length-1;g>=0;g--){var f=m[g],T=t[f];if(Bt(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var _=a[f];typeof T=="object"&&T!=null&&typeof _=="object"&&_!=null&&Array.isArray(T)===Array.isArray(_)?Qt(T,_,n,r+"/"+X(f),c):T!==_&&(c&&n.push({op:"test",path:r+"/"+X(f),value:et(T)}),n.push({op:"replace",path:r+"/"+X(f),value:et(_)}))}else Array.isArray(t)===Array.isArray(a)?(c&&n.push({op:"test",path:r+"/"+X(f),value:et(T)}),n.push({op:"remove",path:r+"/"+X(f)}),l=!0):(c&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&u.length==m.length))for(var g=0;g<u.length;g++){var f=u[g];!Bt(t,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+X(f),value:et(a[f])})}}}function St(t,a,n=!1){var r=[];return Qt(t,a,r,"",n),r}function te(t){return t!==void 0&&Array.isArray(t.lc_namespace)}function ee(t){return t!==void 0&&H.isRunnable(t)&&"lc_name"in t.constructor&&typeof t.constructor.lc_name=="function"&&t.constructor.lc_name()==="RunnableToolLike"}function ae(t){return!!t&&typeof t=="object"&&"name"in t&&"schema"in t&&(wt(t.schema)||t.schema!=null&&typeof t.schema=="object"&&"type"in t.schema&&typeof t.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(t.schema.type))}function se(t){return ae(t)||ee(t)||te(t)}var Sa={};U(Sa,{convertToOpenAIFunction:()=>ne,convertToOpenAITool:()=>Aa,isLangChainTool:()=>se,isRunnableToolLike:()=>ee,isStructuredTool:()=>te,isStructuredToolParams:()=>ae});function ne(t,a){const n=typeof a=="number"?void 0:a;return{name:t.name,description:t.description,parameters:ut(t.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function Aa(t,a){const n=typeof a=="number"?void 0:a;let r;return se(t)?r={type:"function",function:ne(t)}:r=t,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Na={};U(Na,{extendInteropZodObject:()=>Je,getInteropZodDefaultGetter:()=>Ye,getInteropZodObjectShape:()=>Xe,getSchemaDescription:()=>Gt,interopParse:()=>We,interopParseAsync:()=>zt,interopSafeParse:()=>He,interopSafeParseAsync:()=>$e,interopZodObjectMakeFieldsOptional:()=>Ze,interopZodObjectPartial:()=>Ge,interopZodObjectPassthrough:()=>ze,interopZodObjectStrict:()=>Ve,interopZodTransformInputSchema:()=>je,isInteropZodError:()=>Ue,isInteropZodLiteral:()=>Be,isInteropZodObject:()=>Fe,isInteropZodSchema:()=>wt,isShapelessZodSchema:()=>De,isSimpleStringZodSchema:()=>Le,isZodArrayV4:()=>Re,isZodLiteralV3:()=>xe,isZodLiteralV4:()=>Me,isZodNullableV4:()=>Pe,isZodObjectV3:()=>ke,isZodObjectV4:()=>Oe,isZodOptionalV4:()=>Ne,isZodSchema:()=>Ae,isZodSchemaV3:()=>Se,isZodSchemaV4:()=>Ie});var Oa={};U(Oa,{BasePromptValue:()=>lt,ChatPromptValue:()=>ie,ImagePromptValue:()=>ka,StringPromptValue:()=>re});var lt=class extends qe{},re=class extends lt{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(t){super({value:t}),this.value=t}toString(){return this.value}toChatMessages(){return[new Ct(this.value)]}},ie=class extends lt{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(t){Array.isArray(t)&&(t={messages:t}),super(t),this.messages=t.messages}toString(){return Ke(this.messages)}toChatMessages(){return this.messages}},ka=class extends lt{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(t){"imageUrl"in t||(t={imageUrl:t}),super(t),this.imageUrl=t.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Ct({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},p="0123456789abcdef".split(""),Pa=[-2147483648,8388608,32768,128],F=[24,16,8,0],at=[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],k=[];function B(t,a){a?(k[0]=k[16]=k[1]=k[2]=k[3]=k[4]=k[5]=k[6]=k[7]=k[8]=k[9]=k[10]=k[11]=k[12]=k[13]=k[14]=k[15]=0,this.blocks=k):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(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=t}B.prototype.update=function(t){if(!this.finalized){var a,n=typeof t;if(n!=="string"){if(n==="object"){if(t===null)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(t)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,c=0,u,m=t.length,l=this.blocks;c<m;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(u=this.start;c<m&&u<64;++c)l[u>>>2]|=t[c]<<F[u++&3];else for(u=this.start;c<m&&u<64;++c)r=t.charCodeAt(c),r<128?l[u>>>2]|=r<<F[u++&3]:r<2048?(l[u>>>2]|=(192|r>>>6)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]):r<55296||r>=57344?(l[u>>>2]|=(224|r>>>12)<<F[u++&3],l[u>>>2]|=(128|r>>>6&63)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]):(r=65536+((r&1023)<<10|t.charCodeAt(++c)&1023),l[u>>>2]|=(240|r>>>18)<<F[u++&3],l[u>>>2]|=(128|r>>>12&63)<<F[u++&3],l[u>>>2]|=(128|r>>>6&63)<<F[u++&3],l[u>>>2]|=(128|r&63)<<F[u++&3]);this.lastByteIndex=u,this.bytes+=u-this.start,u>=64?(this.block=l[16],this.start=u-64,this.hash(),this.hashed=!0):this.start=u}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,a=this.lastByteIndex;t[16]=this.block,t[a>>>2]|=Pa[a&3],this.block=t[16],a>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=this.blocks,f,T,_,v,d,y,b,E,w,M,S;for(f=16;f<64;++f)d=g[f-15],T=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,d=g[f-2],_=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,g[f]=g[f-16]+T+g[f-7]+_<<0;for(S=a&n,f=0;f<64;f+=4)this.first?(this.is224?(E=300032,d=g[0]-1413257819,l=d-150054599<<0,r=d+24177077<<0):(E=704751109,d=g[0]-210244248,l=d-1521486534<<0,r=d+143694565<<0),this.first=!1):(T=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),_=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),E=t&a,v=E^t&n^S,b=c&u^~c&m,d=l+_+b+at[f]+g[f],y=T+v,l=r+d<<0,r=d+y<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),_=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&t,v=w^r&a^E,b=m&l^~m&c,d=u+_+b+at[f+1]+g[f+1],y=T+v,m=n+d<<0,n=d+y<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),_=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),M=n&r,v=M^n&t^w,b=u&m^~u&l,d=c+_+b+at[f+2]+g[f+2],y=T+v,u=a+d<<0,a=d+y<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),_=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),S=a&n,v=S^a&r^M,b=u&m^~u&l,d=c+_+b+at[f+3]+g[f+3],y=T+v,c=t+d<<0,t=d+y<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+t<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+c<<0,this.h5=this.h5+u<<0,this.h6=this.h6+m<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=p[t>>>28&15]+p[t>>>24&15]+p[t>>>20&15]+p[t>>>16&15]+p[t>>>12&15]+p[t>>>8&15]+p[t>>>4&15]+p[t&15]+p[a>>>28&15]+p[a>>>24&15]+p[a>>>20&15]+p[a>>>16&15]+p[a>>>12&15]+p[a>>>8&15]+p[a>>>4&15]+p[a&15]+p[n>>>28&15]+p[n>>>24&15]+p[n>>>20&15]+p[n>>>16&15]+p[n>>>12&15]+p[n>>>8&15]+p[n>>>4&15]+p[n&15]+p[r>>>28&15]+p[r>>>24&15]+p[r>>>20&15]+p[r>>>16&15]+p[r>>>12&15]+p[r>>>8&15]+p[r>>>4&15]+p[r&15]+p[c>>>28&15]+p[c>>>24&15]+p[c>>>20&15]+p[c>>>16&15]+p[c>>>12&15]+p[c>>>8&15]+p[c>>>4&15]+p[c&15]+p[u>>>28&15]+p[u>>>24&15]+p[u>>>20&15]+p[u>>>16&15]+p[u>>>12&15]+p[u>>>8&15]+p[u>>>4&15]+p[u&15]+p[m>>>28&15]+p[m>>>24&15]+p[m>>>20&15]+p[m>>>16&15]+p[m>>>12&15]+p[m>>>8&15]+p[m>>>4&15]+p[m&15];return this.is224||(g+=p[l>>>28&15]+p[l>>>24&15]+p[l>>>20&15]+p[l>>>16&15]+p[l>>>12&15]+p[l>>>8&15]+p[l>>>4&15]+p[l&15]),g};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var t=this.h0,a=this.h1,n=this.h2,r=this.h3,c=this.h4,u=this.h5,m=this.h6,l=this.h7,g=[t>>>24&255,t>>>16&255,t>>>8&255,t&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255];return this.is224||g.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),g};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),a=new DataView(t);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),t};const oe=(...t)=>new B(!1,!0).update(t.join("")).hex();var Ma={};U(Ma,{sha256:()=>oe});var xa={};U(xa,{BaseCache:()=>ue,InMemoryCache:()=>le,defaultHashKeyEncoder:()=>ce,deserializeStoredGeneration:()=>Ra,serializeGeneration:()=>La});const ce=(...t)=>oe(t.join("_"));function Ra(t){return t.message!==void 0?{text:t.text,message:Qe(t.message)}:{text:t.text}}function La(t){const a={text:t.text};return t.message!==void 0&&(a.message=t.message.toDict()),a}var ue=class{keyEncoder=ce;makeDefaultKeyEncoder(t){this.keyEncoder=t}};const Da=new Map;var le=class he extends ue{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new he(Da)}},Fa={};U(Fa,{encodingForModel:()=>At,getEncoding:()=>me});const st={},Ba=new Zt({});async function me(t){return t in st||(st[t]=Ba.fetch(`https://tiktoken.pages.dev/js/${t}.json`).then(a=>a.json()).then(a=>new Ia(a)).catch(a=>{throw delete st[t],a})),await st[t]}async function At(t){return me(Ca(t))}var Ua={};U(Ua,{BaseLangChain:()=>pe,BaseLanguageModel:()=>ge,calculateMaxTokens:()=>za,getEmbeddingContextSize:()=>ja,getModelContextSize:()=>fe,getModelNameForTiktoken:()=>ht,isOpenAITool:()=>Va});const ht=t=>t.startsWith("gpt-5")?"gpt-5":t.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":t.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":t.startsWith("gpt-4-32k")?"gpt-4-32k":t.startsWith("gpt-4-")?"gpt-4":t.startsWith("gpt-4o")?"gpt-4o":t,ja=t=>{switch(t){case"text-embedding-ada-002":return 8191;default:return 2046}},fe=t=>{switch(ht(t)){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 Va(t){return typeof t!="object"||!t?!1:!!("type"in t&&t.type==="function"&&"function"in t&&typeof t.function=="object"&&t.function&&"name"in t.function&&"parameters"in t.function)}const za=async({prompt:t,modelName:a})=>{let n;try{n=(await At(ht(a))).encode(t).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(t.length/4)}return fe(a)-n},Ga=()=>!1;var pe=class extends H{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(t){super(t),this.verbose=t.verbose??Ga(),this.callbacks=t.callbacks,this.tags=t.tags??[],this.metadata=t.metadata??{}}},ge=class extends pe{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:t,callbackManager:a,...n}){const{cache:r,...c}=n;super({callbacks:t??a,...c}),typeof r=="object"?this.cache=r:r?this.cache=le.global():this.cache=void 0,this.caller=new Zt(n??{})}_encoding;async getNumTokens(t){let a;typeof t=="string"?a=t:a=t.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(a.length/4);if(!this._encoding)try{this._encoding=await At("modelName"in this?ht(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(a).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(t){return typeof t=="string"?new re(t):Array.isArray(t)?new ie(t.map(nt)):t}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:t,...a}){const n={...this._identifyingParams(),...a,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([u,m])=>m!==void 0).map(([u,m])=>`${u}:${JSON.stringify(m)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(t){throw new Error("Use .toJSON() instead")}get profile(){return{}}},ct=class extends H{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(t){super(t),t&&(this.func=t.func)}async invoke(t,a){const n=it(a);return this.func&&await this.func(t,n),this._callWithConfig(r=>Promise.resolve(r),t,n)}async*transform(t,a){const n=it(a);let r,c=!0;for await(const u of this._transformStreamWithConfig(t,m=>m,n))if(yield u,c)if(r===void 0)r=u;else try{r=ot(r,u)}catch{r=void 0,c=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(t){return new $t(new Ht({steps:t}))}};const Za=t=>t();function _t(t){const a=t.constructor;return new a({...t,content:t.contentBlocks,response_metadata:{...t.response_metadata,output_version:"v1"}})}var $a={};U($a,{BaseChatModel:()=>de,SimpleChatModel:()=>Ha});function yt(t){const a=[];for(const n of t){let r=n;if(Array.isArray(n.content))for(let c=0;c<n.content.length;c++){const u=n.content[c];(na(u)||ra(u))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,c),ia(u),...n.content.slice(c+1)]}))}a.push(r)}return a}var de=class Z extends ge{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(a){super(a),this.outputVersion=Za(()=>{const n=a.outputVersion??ta("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(a){const[n,r]=super._separateRunnableConfigFromCallOptions(a);return r.signal=n.signal,[n,r]}async invoke(a,n){const r=Z._convertInputToPromptValue(a);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(a,n,r){throw new Error("Not implemented.")}async*_streamIterator(a,n){if(this._streamResponseChunks===Z.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(a,n);else{const c=Z._convertInputToPromptValue(a).toChatMessages(),[u,m]=this._separateRunnableConfigFromCallOptionsCompat(n),l={...u.metadata,...this.getLsParams(m)},g=await bt.configure(u.callbacks,this.callbacks,u.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:m,invocation_params:this?.invocationParams(m),batch_size:1},T=m.outputVersion??this.outputVersion,_=await g?.handleChatModelStart(this.toJSON(),[yt(c)],u.runId,void 0,f,void 0,void 0,u.runName);let v,d;try{for await(const y of this._streamResponseChunks(c,m,_?.[0])){if(y.message.id==null){const b=_?.at(0)?.runId;b!=null&&y.message._updateId(`run-${b}`)}y.message.response_metadata={...y.generationInfo,...y.message.response_metadata},T==="v1"?yield _t(y.message):yield y.message,v?v=v.concat(y):v=y,Ut(y.message)&&y.message.usage_metadata!==void 0&&(d={tokenUsage:{promptTokens:y.message.usage_metadata.input_tokens,completionTokens:y.message.usage_metadata.output_tokens,totalTokens:y.message.usage_metadata.total_tokens}})}}catch(y){throw await Promise.all((_??[]).map(b=>b?.handleLLMError(y))),y}await Promise.all((_??[]).map(y=>y?.handleLLMEnd({generations:[[v]],llmOutput:d})))}}getLsParams(a){const n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:a.stop,ls_provider:n}}async _generateUncached(a,n,r,c){const u=a.map(v=>v.map(nt));let m;if(c!==void 0&&c.length===u.length)m=c;else{const v={...r.metadata,...this.getLsParams(n)},d=await bt.configure(r.callbacks,this.callbacks,r.tags,this.tags,v,this.metadata,{verbose:this.verbose}),y={options:n,invocation_params:this?.invocationParams(n),batch_size:1};m=await d?.handleChatModelStart(this.toJSON(),u.map(yt),r.runId,void 0,y,void 0,void 0,r.runName)}const l=n.outputVersion??this.outputVersion,g=[],f=[];if(!!m?.[0].handlers.find(ea)&&!this.disableStreaming&&u.length===1&&this._streamResponseChunks!==Z.prototype._streamResponseChunks)try{const v=await this._streamResponseChunks(u[0],n,m?.[0]);let d,y;for await(const b of v){if(b.message.id==null){const E=m?.at(0)?.runId;E!=null&&b.message._updateId(`run-${E}`)}d===void 0?d=b:d=ot(d,b),Ut(b.message)&&b.message.usage_metadata!==void 0&&(y={tokenUsage:{promptTokens:b.message.usage_metadata.input_tokens,completionTokens:b.message.usage_metadata.output_tokens,totalTokens:b.message.usage_metadata.total_tokens}})}if(d===void 0)throw new Error("Received empty response from chat model call.");g.push([d]),await m?.[0].handleLLMEnd({generations:g,llmOutput:y})}catch(v){throw await m?.[0].handleLLMError(v),v}else{const v=await Promise.allSettled(u.map(async(d,y)=>{const b=await this._generate(d,{...n,promptIndex:y},m?.[y]);if(l==="v1")for(const E of b.generations)E.message=_t(E.message);return b}));await Promise.all(v.map(async(d,y)=>{if(d.status==="fulfilled"){const b=d.value;for(const E of b.generations){if(E.message.id==null){const w=m?.at(0)?.runId;w!=null&&E.message._updateId(`run-${w}`)}E.message.response_metadata={...E.generationInfo,...E.message.response_metadata}}return b.generations.length===1&&(b.generations[0].message.response_metadata={...b.llmOutput,...b.generations[0].message.response_metadata}),g[y]=b.generations,f[y]=b.llmOutput,m?.[y]?.handleLLMEnd({generations:[b.generations],llmOutput:b.llmOutput})}else return await m?.[y]?.handleLLMError(d.reason),Promise.reject(d.reason)}))}const _={generations:g,llmOutput:f.length?this._combineLLMOutput?.(...f):void 0};return Object.defineProperty(_,jt,{value:m?{runIds:m?.map(v=>v.runId)}:void 0,configurable:!0}),_}async _generateCached({messages:a,cache:n,llmStringKey:r,parsedOptions:c,handledOptions:u}){const m=a.map(w=>w.map(nt)),l={...u.metadata,...this.getLsParams(c)},g=await bt.configure(u.callbacks,this.callbacks,u.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:c,invocation_params:this?.invocationParams(c),batch_size:1},T=await g?.handleChatModelStart(this.toJSON(),m.map(yt),u.runId,void 0,f,void 0,void 0,u.runName),_=[],d=(await Promise.allSettled(m.map(async(w,M)=>{const S=Z._convertInputToPromptValue(w).toString(),R=await n.lookup(S,r);return R==null&&_.push(M),R}))).map((w,M)=>({result:w,runManager:T?.[M]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),y=c.outputVersion??this.outputVersion,b=[];await Promise.all(d.map(async({result:w,runManager:M},S)=>{if(w.status==="fulfilled"){const R=w.value;return b[S]=R.map(D=>("message"in D&&Y(D.message)&&aa(D.message)&&(D.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},y==="v1"&&(D.message=_t(D.message))),D.generationInfo={...D.generationInfo,tokenUsage:{}},D)),R.length&&await M?.handleLLMNewToken(R[0].text),M?.handleLLMEnd({generations:[R]},void 0,void 0,void 0,{cached:!0})}else return await M?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));const E={generations:b,missingPromptIndices:_,startedRunManagers:T};return Object.defineProperty(E,jt,{value:T?{runIds:T?.map(w=>w.runId)}:void 0,configurable:!0}),E}async generate(a,n,r){let c;Array.isArray(n)?c={stop:n}:c=n;const u=a.map(y=>y.map(nt)),[m,l]=this._separateRunnableConfigFromCallOptionsCompat(c);if(m.callbacks=m.callbacks??r,!this.cache)return this._generateUncached(u,l,m);const{cache:g}=this,f=this._getSerializedCacheKeyParametersForCall(l),{generations:T,missingPromptIndices:_,startedRunManagers:v}=await this._generateCached({messages:u,cache:g,llmStringKey:f,parsedOptions:l,handledOptions:m});let d={};if(_.length>0){const y=await this._generateUncached(_.map(b=>u[b]),l,m,v!==void 0?_.map(b=>v?.[b]):void 0);await Promise.all(y.generations.map(async(b,E)=>{const w=_[E];T[w]=b;const M=Z._convertInputToPromptValue(u[w]).toString();return g.update(M,f,b)})),d=y.llmOutput??{}}return{generations:T,llmOutput:d}}invocationParams(a){return{}}_modelType(){return"base_chat_model"}async generatePrompt(a,n,r){const c=a.map(u=>u.toChatMessages());return this.generate(c,n,r)}withStructuredOutput(a,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');const r=a,c=n?.name,u=Gt(r)??"A function available to call.",m=n?.method,l=n?.includeRaw;if(m==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let g=c??"extract",f;wt(r)?f=[{type:"function",function:{name:g,description:u,parameters:ut(r)}}]:("name"in r&&(g=r.name),f=[{type:"function",function:{name:g,description:u,parameters:r}}]);const T=this.bindTools(f),_=It.from(b=>{if(!sa.isInstance(b))throw new Error("Input is not an AIMessageChunk.");if(!b.tool_calls||b.tool_calls.length===0)throw new Error("No tool calls found in the response.");const E=b.tool_calls.find(w=>w.name===g);if(!E)throw new Error(`No tool call found with name ${g}.`);return E.args});if(!l)return T.pipe(_).withConfig({runName:"StructuredOutput"});const v=ct.assign({parsed:(b,E)=>_.invoke(b.raw,E)}),d=ct.assign({parsed:()=>null}),y=v.withFallbacks({fallbacks:[d]});return Wt.from([{raw:T},y]).withConfig({runName:"StructuredOutputRunnable"})}},Ha=class extends de{async _generate(t,a,n){const r=await this._call(t,a,n),c=new Xt(r);if(typeof c.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:c.content,message:c}]}}},Wa=class extends H{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(t){super(t),this.runnables=t.runnables}async invoke(t,a){const{key:n,input:r}=t,c=this.runnables[n];if(c===void 0)throw new Error(`No runnable associated with key "${n}".`);return c.invoke(r,it(a))}async batch(t,a,n){const r=t.map(_=>_.key),c=t.map(_=>_.input);if(r.find(_=>this.runnables[_]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");const m=r.map(_=>this.runnables[_]),l=this._getOptionsList(a??{},t.length),g=l[0]?.maxConcurrency??n?.maxConcurrency,f=g&&g>0?g:t.length,T=[];for(let _=0;_<c.length;_+=f){const v=c.slice(_,_+f).map((y,b)=>m[b].invoke(y,l[b])),d=await Promise.all(v);T.push(d)}return T.flat()}async stream(t,a){const{key:n,input:r}=t,c=this.runnables[n];if(c===void 0)throw new Error(`No runnable associated with key "${n}".`);return c.stream(r,a)}},Xa=class extends H{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(t){super(t),this.branches=t.branches,this.default=t.default}static from(t){if(t.length<1)throw new Error("RunnableBranch requires at least one branch");const n=t.slice(0,-1).map(([c,u])=>[rt(c),rt(u)]),r=rt(t[t.length-1]);return new this({branches:n,default:r})}async _invoke(t,a,n){let r;for(let c=0;c<this.branches.length;c+=1){const[u,m]=this.branches[c];if(await u.invoke(t,G(a,{callbacks:n?.getChild(`condition:${c+1}`)}))){r=await m.invoke(t,G(a,{callbacks:n?.getChild(`branch:${c+1}`)}));break}}return r||(r=await this.default.invoke(t,G(a,{callbacks:n?.getChild("branch:default")}))),r}async invoke(t,a={}){return this._callWithConfig(this._invoke,t,a)}async*_streamIterator(t,a){const r=await(await Yt(a))?.handleChainStart(this.toJSON(),oa(t,"input"),a?.runId,void 0,void 0,void 0,a?.runName);let c,u=!0,m;try{for(let l=0;l<this.branches.length;l+=1){const[g,f]=this.branches[l];if(await g.invoke(t,G(a,{callbacks:r?.getChild(`condition:${l+1}`)}))){m=await f.stream(t,G(a,{callbacks:r?.getChild(`branch:${l+1}`)}));for await(const _ of m)if(yield _,u)if(c===void 0)c=_;else try{c=ot(c,_)}catch{c=void 0,u=!1}break}}if(m===void 0){m=await this.default.stream(t,G(a,{callbacks:r?.getChild("branch:default")}));for await(const l of m)if(yield l,u)if(c===void 0)c=l;else try{c=ot(c,l)}catch{c=void 0,u=!1}}}catch(l){throw await r?.handleChainError(l),l}await r?.handleChainEnd(c??{})}},Ya=class extends Jt{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(t){let a=It.from((u,m)=>this._enterHistory(u,m??{})).withConfig({runName:"loadHistory"});const n=t.historyMessagesKey??t.inputMessagesKey;n&&(a=ct.assign({[n]:a}).withConfig({runName:"insertHistory"}));const r=a.pipe(t.runnable.withListeners({onEnd:(u,m)=>this._exitHistory(u,m??{})})).withConfig({runName:"RunnableWithMessageHistory"}),c=t.config??{};super({...t,config:c,bound:r}),this.runnable=t.runnable,this.getMessageHistory=t.getMessageHistory,this.inputMessagesKey=t.inputMessagesKey,this.outputMessagesKey=t.outputMessagesKey,this.historyMessagesKey=t.historyMessagesKey}_getInputMessages(t){let a;if(typeof t=="object"&&!Array.isArray(t)&&!Y(t)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(t).length===1?n=Object.keys(t)[0]:n="input",Array.isArray(t[n])&&Array.isArray(t[n][0])?a=t[n][0]:a=t[n]}else a=t;if(typeof a=="string")return[new Ct(a)];if(Array.isArray(a))return a;if(Y(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
2
2
|
Got ${JSON.stringify(a,null,2)}`)}_getOutputMessages(t){let a;if(!Array.isArray(t)&&!Y(t)&&typeof t!="string"){let n;this.outputMessagesKey!==void 0?n=this.outputMessagesKey:Object.keys(t).length===1?n=Object.keys(t)[0]:n="output",t.generations!==void 0?a=t.generations[0][0].message:a=t[n]}else a=t;if(typeof a=="string")return[new Xt(a)];if(Array.isArray(a))return a;if(Y(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(a,null,2)}`)}async _enterHistory(t,a){const r=await(a?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(t)):r}async _exitHistory(t,a){const n=a.configurable?.messageHistory;let r;Array.isArray(t.inputs)&&Array.isArray(t.inputs[0])?r=t.inputs[0]:r=t.inputs;let c=this._getInputMessages(r);if(this.historyMessagesKey===void 0){const l=await n.getMessages();c=c.slice(l.length)}const u=t.outputs;if(!u)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(t,null,2)}`);const m=this._getOutputMessages(u);await n.addMessages([...c,...m])}async _mergeConfig(...t){const a=await super._mergeConfig(...t);if(!a.configurable||!a.configurable.sessionId){const r={[this.inputMessagesKey??"input"]:"foo"},c={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
3
3
|
eg. chain.invoke(${JSON.stringify(r)}, ${JSON.stringify(c)})`)}const{sessionId:n}=a.configurable;return a.configurable.messageHistory=await this.getMessageHistory(n),a}},Ja={};U(Ja,{RouterRunnable:()=>Wa,Runnable:()=>H,RunnableAssign:()=>$t,RunnableBinding:()=>Jt,RunnableBranch:()=>Xa,RunnableEach:()=>da,RunnableLambda:()=>It,RunnableMap:()=>Ht,RunnableParallel:()=>ga,RunnablePassthrough:()=>ct,RunnablePick:()=>pa,RunnableRetry:()=>fa,RunnableSequence:()=>Wt,RunnableToolLike:()=>ma,RunnableWithFallbacks:()=>ha,RunnableWithMessageHistory:()=>Ya,_coerceToRunnable:()=>rt,ensureConfig:()=>it,getCallbackManagerForConfig:()=>Yt,mergeConfigs:()=>la,patchConfig:()=>G,pickRunnableConfigKeys:()=>ua,raceWithSignal:()=>ca});var be=class extends H{parseResultWithPrompt(t,a,n){return this.parseResult(t,n)}_baseMessageToString(t){return typeof t.content=="string"?t.content:this._baseMessageContentToString(t.content)}_baseMessageContentToString(t){return JSON.stringify(t)}async invoke(t,a){return typeof t=="string"?this._callWithConfig(async(n,r)=>this.parseResult([{text:n}],r?.callbacks),t,{...a,runType:"parser"}):this._callWithConfig(async(n,r)=>this.parseResult([{message:n,text:this._baseMessageToString(n)}],r?.callbacks),t,{...a,runType:"parser"})}},mt=class extends be{parseResult(t,a){return this.parse(t[0].text,a)}async parseWithPrompt(t,a,n){return this.parse(t,n)}_type(){throw new Error("_type not implemented")}},$=class extends Error{llmOutput;observation;sendToLLM;constructor(t,a,n,r=!1){if(super(t),this.llmOutput=a,this.observation=n,this.sendToLLM=r,r&&(n===void 0||a===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");ba(this,"OUTPUT_PARSING_FAILURE")}},q=class extends mt{async*_transform(t){for await(const a of t)typeof a=="string"?yield this.parseResult([{text:a}]):yield this.parseResult([{message:a,text:this._baseMessageToString(a)}])}async*transform(t,a){yield*this._transformStreamWithConfig(t,this._transform.bind(this),{...a,runType:"parser"})}},Nt=class extends q{diff=!1;constructor(t){super(t),this.diff=t?.diff??this.diff}async*_transform(t){let a,n;for await(const r of t){if(typeof r!="string"&&typeof r.content!="string")throw new Error("Cannot handle non-string output.");let c;if(_a(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");c=new Vt({message:r,text:r.content})}else if(Y(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");c=new Vt({message:ya(r),text:r.content})}else c=new Ta({text:r});n===void 0?n=c:n=n.concat(c);const u=await this.parsePartialResult([n]);u!=null&&!va(u,a)&&(this.diff?yield this._diff(a,u):yield u,a=u)}}getFormatInstructions(){return""}},Ka=class extends q{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(t){return Promise.resolve(this.textEncoder.encode(t))}getFormatInstructions(){return""}},Q=class extends q{re;async*_transform(t){let a="";for await(const n of t)if(typeof n=="string"?a+=n:a+=n.content,this.re){const r=[...a.matchAll(this.re)];if(r.length>1){let c=0;for(const u of r.slice(0,-1))yield[u[1]],c+=(u.index??0)+u[0].length;a=a.slice(c)}}else{const r=await this.parse(a);if(r.length>1){for(const c of r.slice(0,-1))yield[c];a=r[r.length-1]}}for(const n of await this.parse(a))yield[n]}},qa=class extends Q{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(t){try{return t.trim().split(",").map(a=>a.trim())}catch{throw new $(`Could not parse output: ${t}`,t)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},Qa=class extends Q{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:t,separator:a}){super(...arguments),this.length=t,this.separator=a||","}async parse(t){try{const a=t.trim().split(this.separator).map(n=>n.trim());if(this.length!==void 0&&a.length!==this.length)throw new $(`Incorrect number of items. Expected ${this.length}, got ${a.length}.`);return a}catch(a){throw Object.getPrototypeOf(a)===$.prototype?a:new $(`Could not parse output: ${t}`)}}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\`)`}},ts=class extends Q{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:
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as at,d as rt,e as mt,O as Ct,f as Ot,J as yt,R as G}from"./index-drkUjmF5.js";import{i as ut,bH as It,bI as vt,bJ as _t,bK as Et,bL as Tt,bM as wt,bN as St,bO as lt,bP as Rt,bQ as At,bR as x,bS as xt,bT as kt,bU as Nt}from"./index-Dva6g5Hr.js";import"./embeddings-DYojZti_.js";import"./chunk-VL2OQCWN-Ci7Z2Gkc.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){return wt.isInstance(t)?t.role:t.type}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,r]=s.replace(/^data:/,"").split(";");if(r!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(f=>L(f,e)).filter(f=>f!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const r=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const f=r?.[u.id];if(f)return f}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,r)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&r!==0)throw new Error("System message should be the first one");const c=Ft(u),f=i.content[i.content.length];if(!i.mergeWithPreviousContent&&f&&f.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const g=Yt(o,e,t.slice(0,r),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...g),{mergeWithPreviousContent:!1,content:i.content}}let a=c;(a==="function"||a==="system"&&!n)&&(a="user");const l={role:a,parts:g};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,l]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((a,l)=>("functionCall"in l&&l.functionCall&&a.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),a),[]);let r;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?r=u[0].text:Array.isArray(u)&&u.length>0?r=u.map(a=>a.thought&&"text"in a&&a.text?{type:"thinking",thinking:a.text,...a.thoughtSignature?{signature:a.thoughtSignature}:{}}:"text"in a?{type:"text",text:a.text}:"inlineData"in a?{type:"inlineData",inlineData:a.inlineData}:"functionCall"in a?{type:"functionCall",functionCall:a.functionCall}:"functionResponse"in a?{type:"functionResponse",functionResponse:a.functionResponse}:"fileData"in a?{type:"fileData",fileData:a.fileData}:"executableCode"in a?{type:"executableCode",executableCode:a.executableCode}:"codeExecutionResult"in a?{type:"codeExecutionResult",codeExecutionResult:a.codeExecutionResult}:a):r=[];const c=o?.reduce((a,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(a[l.id]=l.thoughtSignature),a),{});let f="";return typeof r=="string"?f=r:Array.isArray(r)&&r.length>0&&(f=r.find(l=>"text"in l)?.text??f),{generations:[{text:f,message:new _t({content:r??"",tool_calls:o?.map(a=>({type:"tool_call",id:a.id,name:a.functionCall.name,args:a.functionCall.args})),additional_kwargs:{...i,[b]:c},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((a,l)=>("functionCall"in l&&l.functionCall&&a.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),a),[]);let r;const u=s?.parts;Array.isArray(u)&&u.every(a=>"text"in a&&!a.thought)?r=u.map(a=>a.text).join(""):Array.isArray(u)?r=u.map(a=>a.thought&&"text"in a&&a.text?{type:"thinking",thinking:a.text,...a.thoughtSignature?{signature:a.thoughtSignature}:{}}:"text"in a?{type:"text",text:a.text}:"inlineData"in a?{type:"inlineData",inlineData:a.inlineData}:"functionCall"in a?{type:"functionCall",functionCall:a.functionCall}:"functionResponse"in a?{type:"functionResponse",functionResponse:a.functionResponse}:"fileData"in a?{type:"fileData",fileData:a.fileData}:"executableCode"in a?{type:"executableCode",executableCode:a.executableCode}:"codeExecutionResult"in a?{type:"codeExecutionResult",codeExecutionResult:a.codeExecutionResult}:a):r=[];let c="";r&&typeof r=="string"?c=r:Array.isArray(r)&&(c=r.find(l=>"text"in l)?.text??"");const f=[];o&&f.push(...o.map(a=>({type:"tool_call_chunk",id:a.id,name:a.functionCall.name,args:JSON.stringify(a.functionCall.args)})));const g=o?.reduce((a,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(a[l.id]=l.thoughtSignature),a),{});return new Et({text:c,message:new Tt({content:r||"",name:s?s.role:void 0,tool_call_chunks:f,additional_kwargs:{[b]:g},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const r=new Qt(t,e,n,s,o);return{url:r.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(r),body:i})}}async function R(t,e,n,s,i,o={},r=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,r)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const r of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)r.text&&o.push(r.text),r.executableCode&&o.push("\n```"+r.executableCode.language+`
|
|
1
|
+
import{c as at,d as rt,e as mt,O as Ct,f as Ot,J as yt,R as G}from"./index-BYv53yca.js";import{i as ut,bH as It,bI as vt,bJ as _t,bK as Et,bL as Tt,bM as wt,bN as St,bO as lt,bP as Rt,bQ as At,bR as x,bS as xt,bT as kt,bU as Nt}from"./index-BJaUn1y0.js";import"./embeddings-C-ohjac4.js";import"./chunk-VL2OQCWN-Bq-lrj3t.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){return wt.isInstance(t)?t.role:t.type}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,r]=s.replace(/^data:/,"").split(";");if(r!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(f=>L(f,e)).filter(f=>f!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const r=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const f=r?.[u.id];if(f)return f}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,r)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&r!==0)throw new Error("System message should be the first one");const c=Ft(u),f=i.content[i.content.length];if(!i.mergeWithPreviousContent&&f&&f.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const g=Yt(o,e,t.slice(0,r),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...g),{mergeWithPreviousContent:!1,content:i.content}}let a=c;(a==="function"||a==="system"&&!n)&&(a="user");const l={role:a,parts:g};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,l]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((a,l)=>("functionCall"in l&&l.functionCall&&a.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),a),[]);let r;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?r=u[0].text:Array.isArray(u)&&u.length>0?r=u.map(a=>a.thought&&"text"in a&&a.text?{type:"thinking",thinking:a.text,...a.thoughtSignature?{signature:a.thoughtSignature}:{}}:"text"in a?{type:"text",text:a.text}:"inlineData"in a?{type:"inlineData",inlineData:a.inlineData}:"functionCall"in a?{type:"functionCall",functionCall:a.functionCall}:"functionResponse"in a?{type:"functionResponse",functionResponse:a.functionResponse}:"fileData"in a?{type:"fileData",fileData:a.fileData}:"executableCode"in a?{type:"executableCode",executableCode:a.executableCode}:"codeExecutionResult"in a?{type:"codeExecutionResult",codeExecutionResult:a.codeExecutionResult}:a):r=[];const c=o?.reduce((a,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(a[l.id]=l.thoughtSignature),a),{});let f="";return typeof r=="string"?f=r:Array.isArray(r)&&r.length>0&&(f=r.find(l=>"text"in l)?.text??f),{generations:[{text:f,message:new _t({content:r??"",tool_calls:o?.map(a=>({type:"tool_call",id:a.id,name:a.functionCall.name,args:a.functionCall.args})),additional_kwargs:{...i,[b]:c},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((a,l)=>("functionCall"in l&&l.functionCall&&a.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),a),[]);let r;const u=s?.parts;Array.isArray(u)&&u.every(a=>"text"in a&&!a.thought)?r=u.map(a=>a.text).join(""):Array.isArray(u)?r=u.map(a=>a.thought&&"text"in a&&a.text?{type:"thinking",thinking:a.text,...a.thoughtSignature?{signature:a.thoughtSignature}:{}}:"text"in a?{type:"text",text:a.text}:"inlineData"in a?{type:"inlineData",inlineData:a.inlineData}:"functionCall"in a?{type:"functionCall",functionCall:a.functionCall}:"functionResponse"in a?{type:"functionResponse",functionResponse:a.functionResponse}:"fileData"in a?{type:"fileData",fileData:a.fileData}:"executableCode"in a?{type:"executableCode",executableCode:a.executableCode}:"codeExecutionResult"in a?{type:"codeExecutionResult",codeExecutionResult:a.codeExecutionResult}:a):r=[];let c="";r&&typeof r=="string"?c=r:Array.isArray(r)&&(c=r.find(l=>"text"in l)?.text??"");const f=[];o&&f.push(...o.map(a=>({type:"tool_call_chunk",id:a.id,name:a.functionCall.name,args:JSON.stringify(a.functionCall.args)})));const g=o?.reduce((a,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(a[l.id]=l.thoughtSignature),a),{});return new Et({text:c,message:new Tt({content:r||"",name:s?s.role:void 0,tool_call_chunks:f,additional_kwargs:{[b]:g},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const r=new Qt(t,e,n,s,o);return{url:r.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(r),body:i})}}async function R(t,e,n,s,i,o={},r=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,r)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const r of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)r.text&&o.push(r.text),r.executableCode&&o.push("\n```"+r.executableCode.language+`
|
|
2
2
|
`+r.executableCode.code+"\n```\n"),r.codeExecutionResult&&o.push("\n```\n"+r.codeExecutionResult.output+"\n```\n");return o.length>0?o.join(""):""}function Z(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const r of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)r.functionCall&&o.push(r.functionCall);if(o.length>0)return o}const re=[T.RECITATION,T.SAFETY,T.LANGUAGE];function A(t){return!!t.finishReason&&re.includes(t.finishReason)}function O(t){var e,n,s;let i="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)i+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(i+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(i+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const o=t.candidates[0];A(o)&&(i+=`Candidate was blocked due to ${o.finishReason}`,o.finishMessage&&(i+=`: ${o.finishMessage}`))}return i}function w(t){return this instanceof w?(this.v=t,this):new w(t)}function ue(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),i,o=[];return i={},r("next"),r("throw"),r("return"),i[Symbol.asyncIterator]=function(){return this},i;function r(l){s[l]&&(i[l]=function(d){return new Promise(function(p,C){o.push([l,d,p,C])>1||u(l,d)})})}function u(l,d){try{c(s[l](d))}catch(p){a(o[0][3],p)}}function c(l){l.value instanceof w?Promise.resolve(l.value.v).then(f,g):a(o[0][2],l)}function f(l){u("next",l)}function g(l){u("throw",l)}function a(l,d){l(d),o.shift(),o.length&&u(o[0][0],o[0][1])}}const Q=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function le(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=fe(e),[s,i]=n.tee();return{stream:de(s),response:ce(i)}}async function ce(t){const e=[],n=t.getReader();for(;;){const{done:s,value:i}=await n.read();if(s)return M(pe(e));e.push(i)}}function de(t){return ue(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:i}=yield w(n.read());if(i)break;yield yield w(M(s))}})}function fe(t){const e=t.getReader();return new ReadableStream({start(s){let i="";return o();function o(){return e.read().then(({value:r,done:u})=>{if(u){if(i.trim()){s.error(new m("Failed to parse stream"));return}s.close();return}i+=r;let c=i.match(Q),f;for(;c;){try{f=JSON.parse(c[1])}catch{s.error(new m(`Error parsing JSON response: "${c[1]}"`));return}s.enqueue(f),i=i.substring(c[0].length),c=i.match(Q)}return o()}).catch(r=>{let u=r;throw u.stack=r.stack,u.name==="AbortError"?u=new ft("Request aborted when reading from the stream"):u=new m("Error reading from the stream"),u})}}})}function pe(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let i=0;for(const o of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[i]||(n.candidates[i]={index:i}),n.candidates[i].citationMetadata=o.citationMetadata,n.candidates[i].groundingMetadata=o.groundingMetadata,n.candidates[i].finishReason=o.finishReason,n.candidates[i].finishMessage=o.finishMessage,n.candidates[i].safetyRatings=o.safetyRatings,o.content&&o.content.parts){n.candidates[i].content||(n.candidates[i].content={role:o.content.role||"user",parts:[]});const r={};for(const u of o.content.parts)u.text&&(r.text=u.text),u.functionCall&&(r.functionCall=u.functionCall),u.executableCode&&(r.executableCode=u.executableCode),u.codeExecutionResult&&(r.codeExecutionResult=u.codeExecutionResult),Object.keys(r).length===0&&(r.text=""),n.candidates[i].content.parts.push(r)}i++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function pt(t,e,n,s){const i=await R(e,v.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return le(i)}async function gt(t,e,n,s){const o=await(await R(e,v.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:M(o)}}function ht(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function S(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return ge(e)}function ge(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,i=!1;for(const o of t)"functionResponse"in o?(n.parts.push(o),i=!0):(e.parts.push(o),s=!0);if(s&&i)throw new m("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!i)throw new m("No content is provided for sending chat message.");return s?e:n}function he(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const i=t.generateContentRequest!=null;if(t.contents){if(i)throw new y("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(i)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const o=S(t);s.contents=[o]}return{generateContentRequest:s}}function X(t){let e;return t.contents?e=t:e={contents:[S(t)]},t.systemInstruction&&(e.systemInstruction=ht(t.systemInstruction)),e}function me(t){return typeof t=="string"||Array.isArray(t)?{content:S(t)}:t}const tt=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],Ce={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Oe(t){let e=!1;for(const n of t){const{role:s,parts:i}=n;if(!e&&s!=="user")throw new m(`First content should be with role 'user', got ${s}`);if(!Y.includes(s))throw new m(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(Y)}`);if(!Array.isArray(i))throw new m("Content should have 'parts' property with an array of Parts");if(i.length===0)throw new m("Each Content should have at least one part");const o={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const u of i)for(const c of tt)c in u&&(o[c]+=1);const r=Ce[s];for(const u of tt)if(!r.includes(u)&&o[u]>0)throw new m(`Content with role '${s}' can't contain '${u}' part`);e=!0}}function et(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const nt="SILENT_ERROR";class ye{constructor(e,n,s,i={}){this.model=n,this.params=s,this._requestOptions=i,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(Oe(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,i,o,r,u,c;await this._sendPromise;const f=S(e),g={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(r=this.params)===null||r===void 0?void 0:r.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,f]},a=Object.assign(Object.assign({},this._requestOptions),n);let l;return this._sendPromise=this._sendPromise.then(()=>gt(this._apiKey,this.model,g,a)).then(d=>{var p;if(et(d.response)){this._history.push(f);const C=Object.assign({parts:[],role:"model"},(p=d.response.candidates)===null||p===void 0?void 0:p[0].content);this._history.push(C)}else{const C=O(d.response);C&&console.warn(`sendMessage() was unsuccessful. ${C}. Inspect response object for details.`)}l=d}).catch(d=>{throw this._sendPromise=Promise.resolve(),d}),await this._sendPromise,l}async sendMessageStream(e,n={}){var s,i,o,r,u,c;await this._sendPromise;const f=S(e),g={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(r=this.params)===null||r===void 0?void 0:r.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,f]},a=Object.assign(Object.assign({},this._requestOptions),n),l=pt(this._apiKey,this.model,g,a);return this._sendPromise=this._sendPromise.then(()=>l).catch(d=>{throw new Error(nt)}).then(d=>d.response).then(d=>{if(et(d)){this._history.push(f);const p=Object.assign({},d.candidates[0].content);p.role||(p.role="model"),this._history.push(p)}else{const p=O(d);p&&console.warn(`sendMessageStream() was unsuccessful. ${p}. Inspect response object for details.`)}}).catch(d=>{d.message!==nt&&console.error(d)}),l}}async function Ie(t,e,n,s){return(await R(e,v.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function ve(t,e,n,s){return(await R(e,v.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function _e(t,e,n,s){const i=n.requests.map(r=>Object.assign(Object.assign({},r),{model:e}));return(await R(e,v.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:i}),s)).json()}class st{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=ht(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return gt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}async generateContentStream(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return pt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}startChat(e){var n;return new ye(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=he(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),i=Object.assign(Object.assign({},this._requestOptions),n);return Ie(this.apiKey,this.model,s,i)}async embedContent(e,n={}){const s=me(e),i=Object.assign(Object.assign({},this._requestOptions),n);return ve(this.apiKey,this.model,s,i)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return _e(this.apiKey,this.model,e,s)}}class it{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new m("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new st(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new y("Cached content must contain a `name` field.");if(!e.model)throw new y("Cached content must contain a `model` field.");const i=["model","systemInstruction"];for(const r of i)if(n?.[r]&&e[r]&&n?.[r]!==e[r]){if(r==="model"){const u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,c=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(u===c)continue}throw new y(`Different value for "${r}" specified in modelParams (${n[r]}) and cachedContent (${e[r]})`)}const o=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new st(this.apiKey,o,s)}}function ot(t,e){const n=Ee(t),s=we(n,e);return{tools:n,toolConfig:s}}function Ee(t){let e=[];const n=[];return t.forEach(i=>{if(at(i)){const[o]=Wt([i]);o.functionDeclarations&&e.push(...o.functionDeclarations)}else if(rt(i)){const{functionDeclarations:o}=Te(i);if(o)e.push(...o);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else n.push(i)}),n.find(i=>"functionDeclarations"in i)?n.map(i=>{if(e?.length>0&&"functionDeclarations"in i){const o={functionDeclarations:[...i.functionDeclarations||[],...e]};return e=[],o}return i}):[...n,...e.length>0?[{functionDeclarations:e}]:[]]}function Te(t){return{functionDeclarations:[{name:t.function.name,description:t.function.description,parameters:I(t.function.parameters)}]}}function we(t,e){if(!t.length||!e)return;const{toolChoice:n,allowedFunctionNames:s}=e,i={any:E.ANY,auto:E.AUTO,none:E.NONE};if(n&&["any","auto","none"].includes(n))return{functionCallingConfig:{mode:i[n]??"MODE_UNSPECIFIED",allowedFunctionNames:s}};if(typeof n=="string"||s)return{functionCallingConfig:{mode:E.ANY,allowedFunctionNames:[...s??[],...n&&typeof n=="string"?[n]:[]]}}}const Se={"gemini-embedding-001":{maxInputTokens:2048,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-image":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-05-20":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-lite-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-05-06":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.0-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash-preview-native-audio":{maxInputTokens:131072,imageInputs:!1,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.0-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-06-05":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-06-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-image-preview":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-04-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-pro-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-pro":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-flash":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-1.5-flash-8b":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-pro":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1}};var Re=Se,be=class extends Ot{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;thinkingConfig;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")||this.model.startsWith("gemini-3")}constructor(t){if(super(t),this.model=t.model.replace(/^models\//,""),this.maxOutputTokens=t.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=t.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=t.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=t.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=t.stopSequences??this.stopSequences,this.apiKey=t.apiKey??kt("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=t.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(n=>n.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=t.streaming??this.streaming,this.json=t.json,this.thinkingConfig=t.thinkingConfig??this.thinkingConfig,this.client=new it(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{},...this.thinkingConfig?{thinkingConfig:this.thinkingConfig}:{}}},{apiVersion:t.apiVersion,baseUrl:t.baseUrl,customHeaders:t.customHeaders}),this.streamUsage=t.streamUsage??this.streamUsage}useCachedContent(t,e,n){this.apiKey&&(this.client=new it(this.apiKey).getGenerativeModelFromCachedContent(t,e,n))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(t){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:t.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(t,e){return this.withConfig({tools:ot(t)?.tools,...e})}invocationParams(t){const e=t?.tools?.length?ot(t.tools,{toolChoice:t.tool_choice,allowedFunctionNames:t.allowedFunctionNames}):void 0;return t?.responseSchema?(this.client.generationConfig.responseSchema=t.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...e?.tools?{tools:e.tools}:{},...e?.toolConfig?{toolConfig:e.toolConfig}:{}}}async _generate(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[f]=s;this.client.systemInstruction=f,i=s.slice(1)}const o=this.invocationParams(e);if(this.streaming){const f={},g=this._streamResponseChunks(t,e,n),a={};for await(const d of g){const p=d.generationInfo?.completion??0;a[p]===void 0?a[p]=d:a[p]=a[p].concat(d)}return{generations:Object.entries(a).sort(([d],[p])=>parseInt(d,10)-parseInt(p,10)).map(([d,p])=>p),llmOutput:{estimatedTokenUsage:f}}}const r=await this.completionWithRetry({...o,contents:i});let u;"usageMetadata"in r.response&&(u=j(r.response.usageMetadata,this.model));const c=Bt(r.response,{usageMetadata:u});return c.generations?.length>0&&await n?.handleLLMNewToken(c.generations[0]?.text??""),c}async*_streamResponseChunks(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[l]=s;this.client.systemInstruction=l,i=s.slice(1)}const r={...this.invocationParams(e),contents:i},u=await this.caller.callWithOptions({signal:e?.signal},async()=>{const{stream:l}=await this.client.generateContentStream(r);return l});let c,f=0,g=0,a=0;for await(const l of u){if("usageMetadata"in l&&l.usageMetadata!==void 0&&this.streamUsage!==!1&&e.streamUsage!==!1){c=j(l.usageMetadata,this.model);const p=l.usageMetadata.promptTokenCount??0;c.input_tokens=Math.max(0,p-f),f=p;const C=l.usageMetadata.candidatesTokenCount??0;c.output_tokens=Math.max(0,C-g),g=C;const D=l.usageMetadata.totalTokenCount??0;c.total_tokens=Math.max(0,D-a),a=D}const d=qt(l,{usageMetadata:c});d&&(yield d,await n?.handleLLMNewToken(d.text??""))}}async completionWithRetry(t,e){return this.caller.callWithOptions({signal:e?.signal},async()=>{try{return await this.client.generateContent(t)}catch(n){throw n.message?.includes("400 Bad Request")&&(n.status=400),n}})}get profile(){return Re[this.model]??{}}withStructuredOutput(t,e){const n=t,s=e?.name,i=e?.method,o=e?.includeRaw;if(i==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let r,u;if(i==="functionCalling"){let a=s??"extract",l;if(ut(n)){const d=N(n);l=[{functionDeclarations:[{name:a,description:d.description??"A function available to call.",parameters:d}]}],u=new F({returnSingle:!0,keyName:a,zodSchema:n})}else{let d;typeof n.name=="string"&&typeof n.parameters=="object"&&n.parameters!=null?(d=n,d.parameters=I(n.parameters),a=n.name):d={name:a,description:n.description??"",parameters:I(n)},l=[{functionDeclarations:[d]}],u=new F({returnSingle:!0,keyName:a})}r=this.bindTools(l).withConfig({allowedFunctionNames:[a]})}else{const a=N(n);r=this.withConfig({responseSchema:a}),u=new yt}if(!o)return r.pipe(u).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const c=G.assign({parsed:(a,l)=>u.invoke(a.raw,l)}),f=G.assign({parsed:()=>null}),g=c.withFallbacks({fallbacks:[f]});return Nt.from([{raw:r},g]).withConfig({runName:"StructuredOutputRunnable"})}};export{be as ChatGoogleGenerativeAI};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as je,y as ee,z as Ee,B as k,F as te,R as ze,S as be,D as qe,E as Ve,G as A,H as L,I as Ce,J as G,K as We,L as Xe,M as Je,N as Ge,O as xe,P as se,Q as oe,U as K,V as P,W as _e,X as Ke,Y as Qe,Z as Ye,$ as Ze,a0 as et,a1 as tt,a2 as rt,a3 as at,a4 as I,a5 as nt,a6 as st,a7 as ot,a8 as $,a9 as it,aa as ie,ab as lt,ac as re,ad as U,ae as ut,af as dt,ag as ct}from"./index-Dva6g5Hr.js";import{ah as wr,ai as gr,aj as Rr,ak as Sr,al as vr,am as Er,an as br,ao as Cr,ap as xr,aq as _r,ar as kr,as as Ar,at as Dr,au as Hr,av as Tr,aw as Fr,ax as Pr,ay as Nr,az as Ur,aA as Or,aB as Lr,aC as Ir,aD as Br,aE as Mr,aF as $r,aG as jr,aH as zr,aI as qr,aJ as Vr,aK as Wr,aL as Xr,aM as Jr,aN as Gr,aO as Kr,aP as Qr,aQ as Yr,aR as Zr,aS as ea,aT as ta,aU as ra,aV as aa,aW as na,aX as sa,aY as oa,aZ as ia,a_ as la,a$ as ua,b0 as da,b1 as ca,b2 as fa,b3 as ha,b4 as pa,b5 as ma,b6 as ya,b7 as wa,b8 as ga,b9 as Ra,ba as Sa,bb as va,bc as Ea,bd as ba,be as Ca,bf as xa,bg as _a,bh as ka,bi as Aa,bj as Da,bk as Ha,bl as Ta,bm as Fa,bn as Pa,bo as Na,bp as Ua,bq as Oa,br as La,bs as Ia,bt as Ba,bu as Ma,bv as $a,bw as ja,bx as za,by as qa,bz as Va,bA as Wa,bB as Xa,bC as Ja,bD as Ga,bE as Ka,bF as Qa,bG as Ya}from"./index-Dva6g5Hr.js";var T={},le;function ft(){if(le)return T;le=1,Object.defineProperty(T,"__esModule",{value:!0}),T.parseCookie=u,T.parse=u,T.stringifyCookie=s,T.stringifySetCookie=i,T.serialize=i,T.parseSetCookie=l,T.stringifySetCookie=i,T.serialize=i;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/,n=/^-?\d+$/,o=Object.prototype.toString,d=(()=>{const f=function(){};return f.prototype=Object.create(null),f})();function u(f,v){const m=new d,c=f.length;if(c<2)return m;const R=v?.decode||y;let S=0;do{const C=p(f,S,c);if(C===-1)break;const E=h(f,S,c);if(C>E){S=f.lastIndexOf(";",C-1)+1;continue}const _=w(f,S,C);m[_]===void 0&&(m[_]=R(w(f,C+1,E))),S=E+1}while(S<c);return m}function s(f,v){const m=v?.encode||encodeURIComponent,c=[];for(const R of Object.keys(f)){const S=f[R];if(S===void 0)continue;if(!e.test(R))throw new TypeError(`cookie name is invalid: ${R}`);const C=m(S);if(!t.test(C))throw new TypeError(`cookie val is invalid: ${S}`);c.push(`${R}=${C}`)}return c.join("; ")}function i(f,v,m){const c=typeof f=="object"?f:{...m,name:f,value:String(v)},S=(typeof v=="object"?v:m)?.encode||encodeURIComponent;if(!e.test(c.name))throw new TypeError(`argument name is invalid: ${c.name}`);const C=c.value?S(c.value):"";if(!t.test(C))throw new TypeError(`argument val is invalid: ${c.value}`);let E=c.name+"="+C;if(c.maxAge!==void 0){if(!Number.isInteger(c.maxAge))throw new TypeError(`option maxAge is invalid: ${c.maxAge}`);E+="; Max-Age="+c.maxAge}if(c.domain){if(!r.test(c.domain))throw new TypeError(`option domain is invalid: ${c.domain}`);E+="; Domain="+c.domain}if(c.path){if(!a.test(c.path))throw new TypeError(`option path is invalid: ${c.path}`);E+="; Path="+c.path}if(c.expires){if(!g(c.expires)||!Number.isFinite(c.expires.valueOf()))throw new TypeError(`option expires is invalid: ${c.expires}`);E+="; Expires="+c.expires.toUTCString()}if(c.httpOnly&&(E+="; HttpOnly"),c.secure&&(E+="; Secure"),c.partitioned&&(E+="; Partitioned"),c.priority)switch(typeof c.priority=="string"?c.priority.toLowerCase():void 0){case"low":E+="; Priority=Low";break;case"medium":E+="; Priority=Medium";break;case"high":E+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${c.priority}`)}if(c.sameSite)switch(typeof c.sameSite=="string"?c.sameSite.toLowerCase():c.sameSite){case!0:case"strict":E+="; SameSite=Strict";break;case"lax":E+="; SameSite=Lax";break;case"none":E+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${c.sameSite}`)}return E}function l(f,v){const m=v?.decode||y,c=f.length,R=h(f,0,c),S=p(f,0,R),C=S===-1?{name:"",value:m(w(f,0,R))}:{name:w(f,0,S),value:m(w(f,S+1,R))};let E=R+1;for(;E<c;){const _=h(f,E,c),F=p(f,E,_),x=F===-1?w(f,E,_):w(f,E,F),b=F===-1?void 0:w(f,F+1,_);switch(x.toLowerCase()){case"httponly":C.httpOnly=!0;break;case"secure":C.secure=!0;break;case"partitioned":C.partitioned=!0;break;case"domain":C.domain=b;break;case"path":C.path=b;break;case"max-age":b&&n.test(b)&&(C.maxAge=Number(b));break;case"expires":if(!b)break;const D=new Date(b);Number.isFinite(D.valueOf())&&(C.expires=D);break;case"priority":if(!b)break;const H=b.toLowerCase();(H==="low"||H==="medium"||H==="high")&&(C.priority=H);break;case"samesite":if(!b)break;const M=b.toLowerCase();(M==="lax"||M==="strict"||M==="none")&&(C.sameSite=M);break}E=_+1}return C}function h(f,v,m){const c=f.indexOf(";",v);return c===-1?m:c}function p(f,v,m){const c=f.indexOf("=",v);return c<m?c:-1}function w(f,v,m){let c=v,R=m;do{const S=f.charCodeAt(c);if(S!==32&&S!==9)break}while(++c<R);for(;R>c;){const S=f.charCodeAt(R-1);if(S!==32&&S!==9)break;R--}return f.slice(c,R)}function y(f){if(f.indexOf("%")===-1)return f;try{return decodeURIComponent(f)}catch{return f}}function g(f){return o.call(f)==="[object Date]"}return T}var ue=ft(),O={exports:{}},de;function ht(){if(de)return O.exports;de=1;var e={decodeValues:!0,map:!1,silent:!1};function t(s){return typeof s!="string"||s in{}}function r(){return Object.create(null)}function a(s){return typeof s=="string"&&!!s.trim()}function n(s,i){var l=s.split(";").filter(a),h=l.shift(),p=o(h),w=p.name,y=p.value;if(i=i?Object.assign({},e,i):e,t(w))return null;try{y=i.decodeValues?decodeURIComponent(y):y}catch(f){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",f)}var g=r();return g.name=w,g.value=y,l.forEach(function(f){var v=f.split("="),m=v.shift().trimLeft().toLowerCase();if(!t(m)){var c=v.join("=");if(m==="expires")g.expires=new Date(c);else if(m==="max-age"){var R=parseInt(c,10);Number.isNaN(R)||(g.maxAge=R)}else m==="secure"?g.secure=!0:m==="httponly"?g.httpOnly=!0:m==="samesite"?g.sameSite=c:m==="partitioned"?g.partitioned=!0:m&&(g[m]=c)}}),g}function o(s){var i="",l="",h=s.split("=");return h.length>1?(i=h.shift(),l=h.join("=")):l=s,{name:i,value:l}}function d(s,i){if(i=i?Object.assign({},e,i):e,!s)return i.map?r():[];if(s.headers)if(typeof s.headers.getSetCookie=="function")s=s.headers.getSetCookie();else if(s.headers["set-cookie"])s=s.headers["set-cookie"];else{var l=s.headers[Object.keys(s.headers).find(function(p){return p.toLowerCase()==="set-cookie"})];!l&&s.headers.cookie&&!i.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),s=l}if(Array.isArray(s)||(s=[s]),i.map){var h=r();return s.filter(a).reduce(function(p,w){var y=n(w,i);return y&&!t(y.name)&&(p[y.name]=y),p},h)}else return s.filter(a).map(function(p){return n(p,i)}).filter(Boolean)}function u(s){if(Array.isArray(s))return s;if(typeof s!="string")return[];var i=[],l=0,h,p,w,y,g;function f(){for(;l<s.length&&/\s/.test(s.charAt(l));)l+=1;return l<s.length}function v(){return p=s.charAt(l),p!=="="&&p!==";"&&p!==","}for(;l<s.length;){for(h=l,g=!1;f();)if(p=s.charAt(l),p===","){for(w=l,l+=1,f(),y=l;l<s.length&&v();)l+=1;l<s.length&&s.charAt(l)==="="?(g=!0,l=y,i.push(s.substring(h,w)),h=l):l=w+1}else l+=1;(!g||l>=s.length)&&i.push(s.substring(h,s.length))}return i}return O.exports=d,O.exports.parse=d,O.exports.parseString=n,O.exports.splitCookiesString=u,O.exports}var pt=ht(),mt={};function rr({context:e,url:t,nonce:r}){typeof t=="string"&&(t=new URL(t));let{manifest:a,routeModules:n,criticalCss:o,serverHandoffString:d}=e,u=je(a.routes,n,e.future,e.isSpaMode);e.staticHandlerContext.loaderData={...e.staticHandlerContext.loaderData};for(let i of e.staticHandlerContext.matches){let l=i.route.id,h=n[l],p=e.manifest.routes[l];h&&p&&ee(l,h.clientLoader,p.hasLoader,e.isSpaMode)&&(h.HydrateFallback||!p.hasLoader)&&delete e.staticHandlerContext.loaderData[l]}let s=Ee(u,e.staticHandlerContext);return k.createElement(k.Fragment,null,k.createElement(te.Provider,{value:{manifest:a,routeModules:n,criticalCss:o,serverHandoffString:d,future:e.future,ssr:e.ssr,isSpaMode:e.isSpaMode,routeDiscovery:e.routeDiscovery,serializeError:e.serializeError,renderMeta:e.renderMeta}},k.createElement(ze,{location:s.state.location},k.createElement(be,{router:s,context:e.staticHandlerContext,hydrate:!1}))),e.serverHandoffStream?k.createElement(k.Suspense,null,k.createElement(qe,{context:e,identifier:0,reader:e.serverHandoffStream.getReader(),textDecoder:new TextDecoder,nonce:r})):null)}function ar(e,t){return function({initialEntries:a,initialIndex:n,hydrationData:o,future:d}){let u=k.useRef(),s=k.useRef();if(u.current==null){s.current={future:{unstable_subResourceIntegrity:d?.unstable_subResourceIntegrity===!0,v8_middleware:d?.v8_middleware===!0,unstable_trailingSlashAwareDataRequests:d?.unstable_trailingSlashAwareDataRequests===!0},manifest:{routes:{},entry:{imports:[],module:""},url:"",version:""},routeModules:{},ssr:!1,isSpaMode:!1,routeDiscovery:{mode:"lazy",manifestPath:"/__manifest"}};let i=ke(We(e,l=>l),t!==void 0?t:d?.v8_middleware?new G:{},s.current.manifest,s.current.routeModules);u.current=Xe(i,{initialEntries:a,initialIndex:n,hydrationData:o})}return k.createElement(te.Provider,{value:s.current},k.createElement(Je,{router:u.current}))}}function ke(e,t,r,a,n){return e.map(o=>{if(!o.id)throw new Error("Expected a route.id in react-router processRoutes() function");let d={id:o.id,path:o.path,index:o.index,Component:o.Component?et(o.Component):void 0,HydrateFallback:o.HydrateFallback?Ze(o.HydrateFallback):void 0,ErrorBoundary:o.ErrorBoundary?Ye(o.ErrorBoundary):void 0,action:o.action?s=>o.action({...s,context:t}):void 0,loader:o.loader?s=>o.loader({...s,context:t}):void 0,middleware:o.middleware?o.middleware.map(s=>(...i)=>s({...i[0],context:t},i[1])):void 0,handle:o.handle,shouldRevalidate:o.shouldRevalidate},u={id:o.id,path:o.path,index:o.index,parentId:n,hasAction:o.action!=null,hasLoader:o.loader!=null,hasClientAction:!1,hasClientLoader:!1,hasClientMiddleware:!1,hasErrorBoundary:o.ErrorBoundary!=null,module:"build/stub-path-to-module.js",clientActionModule:void 0,clientLoaderModule:void 0,clientMiddlewareModule:void 0,hydrateFallbackModule:void 0};return r.routes[d.id]=u,a[o.id]={default:d.Component||tt,ErrorBoundary:d.ErrorBoundary||void 0,handle:o.handle,links:o.links,meta:o.meta,shouldRevalidate:o.shouldRevalidate},o.children&&(d.children=ke(o.children,t,r,a,d.id)),d})}var ae=new TextEncoder,yt=async(e,t)=>{let r=ae.encode(e),a=await Ae(t,["sign"]),n=await crypto.subtle.sign("HMAC",a,r),o=btoa(String.fromCharCode(...new Uint8Array(n))).replace(/=+$/,"");return e+"."+o},wt=async(e,t)=>{let r=e.lastIndexOf("."),a=e.slice(0,r),n=e.slice(r+1),o=ae.encode(a),d=await Ae(t,["verify"]);try{let u=gt(atob(n));return await crypto.subtle.verify("HMAC",d,u,o)?a:!1}catch{return!1}},Ae=async(e,t)=>crypto.subtle.importKey("raw",ae.encode(e),{name:"HMAC",hash:"SHA-256"},!1,t);function gt(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var De=(e,t={})=>{let{secrets:r=[],...a}={path:"/",sameSite:"lax",...t};return Ct(e,a.expires),{get name(){return e},get isSigned(){return r.length>0},get expires(){return typeof a.maxAge<"u"?new Date(Date.now()+a.maxAge*1e3):a.expires},async parse(n,o){if(!n)return null;let d=ue.parse(n,{...a,...o});if(e in d){let u=d[e];return typeof u=="string"&&u!==""?await St(u,r):""}else return null},async serialize(n,o){return ue.serialize(e,n===""?"":await Rt(n,r),{...a,...o})}}},He=e=>e!=null&&typeof e.name=="string"&&typeof e.isSigned=="boolean"&&typeof e.parse=="function"&&typeof e.serialize=="function";async function Rt(e,t){let r=vt(e);return t.length>0&&(r=await yt(r,t[0])),r}async function St(e,t){if(t.length>0){for(let r of t){let a=await wt(e,r);if(a!==!1)return ce(a)}return null}return ce(e)}function vt(e){return btoa(bt(encodeURIComponent(JSON.stringify(e))))}function ce(e){try{return JSON.parse(decodeURIComponent(Et(atob(e))))}catch{return{}}}function Et(e){let t=e.toString(),r="",a=0,n,o;for(;a<t.length;)n=t.charAt(a++),/[\w*+\-./@]/.exec(n)?r+=n:(o=n.charCodeAt(0),o<256?r+="%"+fe(o,2):r+="%u"+fe(o,4).toUpperCase());return r}function fe(e,t){let r=e.toString(16);for(;r.length<t;)r="0"+r;return r}function bt(e){let t=e.toString(),r="",a=0,n,o;for(;a<t.length;){if(n=t.charAt(a++),n==="%"){if(t.charAt(a)==="u"){if(o=t.slice(a+1,a+5),/^[\da-f]{4}$/i.exec(o)){r+=String.fromCharCode(parseInt(o,16)),a+=5;continue}}else if(o=t.slice(a,a+2),/^[\da-f]{2}$/i.exec(o)){r+=String.fromCharCode(parseInt(o,16)),a+=2;continue}}r+=n}return r}function Ct(e,t){_e(!t,`The "${e}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`)}function xt(e){return Object.keys(e).reduce((t,r)=>{let a=e[r];return a&&(t[r]=a.module),t},{})}var _t=(e=>(e.Development="development",e.Production="production",e.Test="test",e))(_t||{});function kt(e){return e==="development"||e==="production"||e==="test"}function V(e,t){if(e instanceof Error&&t!=="development"){let r=new Error("Unexpected Server Error");return r.stack=void 0,r}return e}function z(e,t){return Object.entries(e).reduce((r,[a,n])=>Object.assign(r,{[a]:V(n,t)}),{})}function Te(e,t){let r=V(e,t);return{message:r.message,stack:r.stack}}function he(e,t){if(!e)return null;let r=Object.entries(e),a={};for(let[n,o]of r)if(P(o))a[n]={...o,__type:"RouteErrorResponse"};else if(o instanceof Error){let d=V(o,t);a[n]={message:d.message,stack:d.stack,__type:"Error",...d.name!=="Error"?{__subType:d.name}:{}}}else a[n]=o;return a}function Q(e,t,r){let a=Ce(e,t,r);return a?a.map(n=>({params:n.params,pathname:n.pathname,route:n.route})):null}async function pe(e,t){let r=await e({request:Dt(At(t.request)),params:t.params,context:t.context,unstable_pattern:t.unstable_pattern});if(lt(r)&&r.init&&r.init.status&&re(r.init.status))throw new Response(null,r.init);return r}function At(e){let t=new URL(e.url),r=t.searchParams.getAll("index");t.searchParams.delete("index");let a=[];for(let o of r)o&&a.push(o);for(let o of a)t.searchParams.append("index",o);let n={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return n.body&&(n.duplex="half"),new Request(t.href,n)}function Dt(e){let t=new URL(e.url);t.searchParams.delete("_routes");let r={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return r.body&&(r.duplex="half"),new Request(t.href,r)}function j(e,t){if(e===!1||e===null||typeof e>"u")throw console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"),new Error(t)}var Fe="__reactRouterDevServerHooks";function nr(e){globalThis[Fe]=e}function W(){return globalThis[Fe]}function Pe(e,t){if(typeof process<"u")try{if(mt?.IS_RR_BUILD_REQUEST==="yes")return e.headers.get(t)}catch{}return null}function Ne(e){let t={};return Object.values(e).forEach(r=>{if(r){let a=r.parentId||"";t[a]||(t[a]=[]),t[a].push(r)}}),t}function Ue(e,t="",r=Ne(e)){return(r[t]||[]).map(a=>({...a,children:Ue(e,a.id,r)}))}function Oe(e,t,r="",a=Ne(e)){return(a[r]||[]).map(n=>{let o={hasErrorBoundary:n.id==="root"||n.module.ErrorBoundary!=null,id:n.id,path:n.path,middleware:n.module.middleware,loader:n.module.loader?async d=>{let u=Pe(d.request,"X-React-Router-Prerender-Data");if(u!=null){let i=u&&decodeURI(u);j(i,"Missing prerendered data for route");let l=new TextEncoder().encode(i),h=new ReadableStream({start(y){y.enqueue(l),y.close()}}),w=(await at(h,globalThis)).value;if(w&&I in w){let y=w[I],g={status:y.status};throw y.reload?nt(y.redirect,g):y.replace?st(y.redirect,g):ot(y.redirect,g)}else{j(w&&n.id in w,"Unable to decode prerendered data");let y=w[n.id];return j("data"in y,"Unable to process prerendered data"),y.data}}return await pe(n.module.loader,d)}:void 0,action:n.module.action?d=>pe(n.module.action,d):void 0,handle:n.module.handle};return n.index?{index:!0,...o}:{caseSensitive:n.caseSensitive,children:Oe(e,t,n.id,a),...o}})}function me(e){return K(JSON.stringify(e))}function ne(e,t){return Ht(e,r=>{let a=t.routes[r.route.id];return j(a,`Route with id "${r.route.id}" not found in build`),a.module.headers})}function Ht(e,t,r){let a=e.errors?e.matches.findIndex(u=>e.errors[u.route.id]):-1,n=a>=0?e.matches.slice(0,a+1):e.matches,o;if(a>=0){let{actionHeaders:u,actionData:s,loaderHeaders:i,loaderData:l}=e;e.matches.slice(a).some(h=>{let p=h.route.id;return u[p]&&(!s||!s.hasOwnProperty(p))?o=u[p]:i[p]&&!l.hasOwnProperty(p)&&(o=i[p]),o!=null})}const d=new Headers(r);return n.reduce((u,s,i)=>{let{id:l}=s.route,h=e.loaderHeaders[l]||new Headers,p=e.actionHeaders[l]||new Headers,w=o!=null&&i===n.length-1,y=w&&o!==h&&o!==p,g=t(s);if(g==null){let v=new Headers(u);return y&&N(o,v),N(p,v),N(h,v),v}let f=new Headers(typeof g=="function"?g({loaderHeaders:h,parentHeaders:u,actionHeaders:p,errorHeaders:w?o:void 0}):g);return y&&N(o,f),N(p,f),N(h,f),N(u,f),f},new Headers(d))}function N(e,t){let r=e.get("Set-Cookie");if(r){let a=pt.splitCookiesString(r),n=new Set(t.getSetCookie());a.forEach(o=>{n.has(o)||t.append("Set-Cookie",o)})}}function Le(e,t){let r=e.get("origin"),a=typeof r=="string"&&r!=="null"?new URL(r).host:r,n=Pt(e);if(a&&(!n||a!==n.value)&&!Ft(a,t))throw n?new Error(`${n.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`):new Error("`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action.")}function Tt(e,t){const r=e.split("."),a=t.split(".");if(a.length<1||r.length<a.length||a.length===1&&(a[0]==="*"||a[0]==="**"))return!1;for(;a.length;){const n=a.pop(),o=r.pop();switch(n){case"":return!1;case"*":{if(o)continue;return!1}case"**":return a.length>0?!1:o!==void 0;case void 0:default:if(o!==n)return!1}}return r.length===0}function Ft(e,t=[]){return t.some(r=>r&&(r===e||Tt(e,r)))}function Pt(e){let r=e.get("x-forwarded-host")?.split(",")[0]?.trim(),a=e.get("host");return r?{type:"x-forwarded-host",value:r}:a?{type:"host",value:a}:void 0}var Ie=new Set([...dt,304]);async function Nt(e,t,r,a,n,o,d){try{Le(a.headers,Array.isArray(e.allowedActionOrigins)?e.allowedActionOrigins:[]);let l=new Request(n,{method:a.method,body:a.body,headers:a.headers,signal:a.signal,...a.body?{duplex:"half"}:void 0}),h=await r.query(l,{requestContext:o,skipLoaderErrorBubbling:!0,skipRevalidation:!0,generateMiddlewareResponse:e.future.v8_middleware?async p=>{try{let w=await p(l);return u(w)}catch(w){return s(w)}}:void 0});return u(h)}catch(l){return s(l)}function u(l){return U(l)?l:i(l)}function s(l){return d(l),B(a,e,t,{result:{error:l},headers:new Headers,status:500})}function i(l){let h=ne(l,e);if(re(l.statusCode)&&h.has("Location"))return new Response(null,{status:l.statusCode,headers:h});l.errors&&(Object.values(l.errors).forEach(w=>{(!P(w)||w.error)&&d(w)}),l.errors=z(l.errors,t));let p;return l.errors?p={error:Object.values(l.errors)[0]}:p={data:Object.values(l.actionData||{})[0]},B(a,e,t,{result:p,headers:h,status:l.statusCode})}}async function Ut(e,t,r,a,n,o,d){let u=new URL(a.url).searchParams.get("_routes"),s=u?new Set(u.split(",")):null;try{let p=new Request(n,{headers:a.headers,signal:a.signal}),w=await r.query(p,{requestContext:o,filterMatchesToLoad:y=>!s||s.has(y.route.id),skipLoaderErrorBubbling:!0,generateMiddlewareResponse:e.future.v8_middleware?async y=>{try{let g=await y(p);return i(g)}catch(g){return l(g)}}:void 0});return i(w)}catch(p){return l(p)}function i(p){return U(p)?p:h(p)}function l(p){return d(p),B(a,e,t,{result:{error:p},headers:new Headers,status:500})}function h(p){let w=ne(p,e);if(re(p.statusCode)&&w.has("Location"))return new Response(null,{status:p.statusCode,headers:w});p.errors&&(Object.values(p.errors).forEach(f=>{(!P(f)||f.error)&&d(f)}),p.errors=z(p.errors,t));let y={},g=new Set(p.matches.filter(f=>s?s.has(f.route.id):f.route.loader!=null).map(f=>f.route.id));if(p.errors)for(let[f,v]of Object.entries(p.errors))y[f]={error:v};for(let[f,v]of Object.entries(p.loaderData))!(f in y)&&g.has(f)&&(y[f]={data:v});return B(a,e,t,{result:y,headers:w,status:p.statusCode})}}function B(e,t,r,{result:a,headers:n,status:o}){let d=new Headers(n);return d.set("X-Remix-Response","yes"),Ie.has(o)?new Response(null,{status:o,headers:d}):(d.set("Content-Type","text/x-script"),d.delete("Content-Length"),new Response(Y(a,e.signal,t.entry.module.streamTimeout,r),{status:o||200,headers:d}))}function ye(e,t,r,a){let n=Ot(e.status,e.headers,r.basename),o=new Headers(e.headers);return o.delete("Location"),o.set("Content-Type","text/x-script"),B(t,r,a,{result:t.method==="GET"?{[I]:n}:n,headers:o,status:xe})}function Ot(e,t,r){let a=t.get("Location");return r&&(a=$(a,r)||a),{redirect:a,status:e,revalidate:t.has("X-Remix-Revalidate")||t.has("Set-Cookie"),reload:t.has("X-Remix-Reload-Document"),replace:t.has("X-Remix-Replace")}}function Y(e,t,r,a){let n=new AbortController,o=setTimeout(()=>n.abort(new Error("Server Timeout")),typeof r=="number"?r:4950);return t.addEventListener("abort",()=>clearTimeout(o)),ct(e,{signal:n.signal,plugins:[d=>{if(d instanceof Error){let{name:u,message:s,stack:i}=a==="production"?V(d,a):d;return["SanitizedError",u,s,i]}if(d instanceof L){let{data:u,status:s,statusText:i}=d;return["ErrorResponse",u,s,i]}if(d&&typeof d=="object"&&I in d)return["SingleFetchRedirect",d[I]]}],postPlugins:[d=>{if(d&&typeof d=="object")return["SingleFetchClassInstance",Object.fromEntries(Object.entries(d))]},()=>["SingleFetchFallback"]]})}function we(e,t){let r=Ue(e.routes),a=Oe(e.routes,e.future),n=kt(t)?t:"production",o=Ke(a,{basename:e.basename,unstable_instrumentations:e.entry.module.unstable_instrumentations}),d=e.entry.module.handleError||((s,{request:i})=>{n!=="test"&&!i.signal.aborted&&console.error(P(s)&&s.error?s.error:s)}),u=async(s,i)=>{let l={},h,p=R=>{t==="development"&&W()?.processRequestError?.(R),d(R,{context:h,params:l,request:s})};if(e.future.v8_middleware){if(i&&!(i instanceof G)){let R=new Error("Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function.");return p(R),q(R,n)}h=i||new G}else h=i||{};let w=new URL(s.url),y=e.basename||"/",g=w.pathname;e.future.unstable_trailingSlashAwareDataRequests?g.endsWith("/_.data")?g=g.replace(/_.data$/,""):g=g.replace(/\.data$/,""):($(g,y)==="/_root.data"?g=y:g.endsWith(".data")&&(g=g.replace(/\.data$/,"")),$(g,y)!=="/"&&g.endsWith("/")&&(g=g.slice(0,-1)));let f=Pe(s,"X-React-Router-SPA-Mode")==="yes";if(!e.ssr){let R=decodeURI(g);if(y!=="/"){let S=$(R,y);if(S==null)return d(new L(404,"Not Found",`Refusing to prerender the \`${R}\` path because it does not start with the basename \`${y}\``),{context:h,params:l,request:s}),new Response("Not Found",{status:404,statusText:"Not Found"});R=S}if(e.prerender.length===0)f=!0;else if(!e.prerender.includes(R)&&!e.prerender.includes(R+"/")){if(w.pathname.endsWith(".data"))return d(new L(404,"Not Found",`Refusing to SSR the path \`${R}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`),{context:h,params:l,request:s}),new Response("Not Found",{status:404,statusText:"Not Found"});f=!0}}let v=it(e.routeDiscovery.manifestPath,y);if(w.pathname===v)try{return await Lt(e,r,w)}catch(R){return p(R),new Response("Unknown Server Error",{status:500})}let m=Q(r,g,e.basename);m&&m.length>0&&Object.assign(l,m[0].params);let c;if(w.pathname.endsWith(".data")){let R=new URL(s.url);R.pathname=g;let S=Q(r,R.pathname,e.basename);c=await It(n,e,o,s,R,h,p),ie(c)&&(c=ye(c,s,e,n)),e.entry.module.handleDataRequest&&(c=await e.entry.module.handleDataRequest(c,{context:h,params:S?S[0].params:{},request:s}),ie(c)&&(c=ye(c,s,e,n)))}else if(!f&&m&&m[m.length-1].route.module.default==null&&m[m.length-1].route.module.ErrorBoundary==null)c=await Mt(n,e,o,m.slice(-1)[0].route.id,s,h,p);else{let{pathname:R}=w,S;e.unstable_getCriticalCss?S=await e.unstable_getCriticalCss({pathname:R}):t==="development"&&W()?.getCriticalCss&&(S=await W()?.getCriticalCss?.(R)),c=await Bt(n,e,o,s,h,p,f,S)}return s.method==="HEAD"?new Response(null,{headers:c.headers,status:c.status,statusText:c.statusText}):c};return e.entry.module.unstable_instrumentations&&(u=Qe(u,e.entry.module.unstable_instrumentations.map(s=>s.handler).filter(Boolean))),{routes:r,dataRoutes:a,serverMode:n,staticHandler:o,errorHandler:d,requestHandler:u}}var sr=(e,t)=>{let r,a,n,o,d,u;return async function(i,l){if(r=typeof e=="function"?await e():e,typeof e=="function"){let h=we(r,t);a=h.routes,n=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}else if(!a||!n||!o||!d||!u){let h=we(r,t);a=h.routes,n=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}return u(i,l)}};async function Lt(e,t,r){if(e.assets.version!==r.searchParams.get("version"))return new Response(null,{status:204,headers:{"X-Remix-Reload-Document":"true"}});let a={};if(r.searchParams.has("paths")){let n=new Set;(r.searchParams.get("paths")||"").split(",").filter(Boolean).forEach(u=>{u.startsWith("/")||(u=`/${u}`);let s=u.split("/").slice(1);s.forEach((i,l)=>{let h=s.slice(0,l+1).join("/");n.add(`/${h}`)})});for(let u of n){let s=Q(t,u,e.basename);if(s)for(let i of s){let l=i.route.id,h=e.assets.routes[l];h&&(a[l]=h)}}return Response.json(a,{headers:{"Cache-Control":"public, max-age=31536000, immutable"}})}return new Response("Invalid Request",{status:400})}async function It(e,t,r,a,n,o,d){return a.method!=="GET"?await Nt(t,e,r,a,n,o,d):await Ut(t,e,r,a,n,o,d)}async function Bt(e,t,r,a,n,o,d,u){try{a.method==="POST"&&Le(a.headers,Array.isArray(t.allowedActionOrigins)?t.allowedActionOrigins:[]);let i=await r.query(a,{requestContext:n,generateMiddlewareResponse:t.future.v8_middleware?async l=>{try{let h=await l(a);return U(h)||(h=await s(h,d)),h}catch(h){return o(h),new Response(null,{status:500})}}:void 0});return U(i)||(i=await s(i,d)),i}catch(i){return o(i),new Response(null,{status:500})}async function s(i,l){let h=ne(i,t);if(Ie.has(i.statusCode))return new Response(null,{status:i.statusCode,headers:h});i.errors&&(Object.values(i.errors).forEach(f=>{(!P(f)||f.error)&&o(f)}),i.errors=z(i.errors,e));let p={loaderData:i.loaderData,actionData:i.actionData,errors:he(i.errors,e)},w={basename:t.basename,future:t.future,routeDiscovery:t.routeDiscovery,ssr:t.ssr,isSpaMode:l},y={manifest:t.assets,routeModules:xt(t.routes),staticHandlerContext:i,criticalCss:u,serverHandoffString:me({...w,criticalCss:u}),serverHandoffStream:Y(p,a.signal,t.entry.module.streamTimeout,e),renderMeta:{},future:t.future,ssr:t.ssr,routeDiscovery:t.routeDiscovery,isSpaMode:l,serializeError:f=>Te(f,e)},g=t.entry.module.default;try{return await g(a,i.statusCode,h,y,n)}catch(f){o(f);let v=f;if(U(f))try{let c=await jt(f);v=new L(f.status,f.statusText,c)}catch{}i=ut(r.dataRoutes,i,v),i.errors&&(i.errors=z(i.errors,e));let m={loaderData:i.loaderData,actionData:i.actionData,errors:he(i.errors,e)};y={...y,staticHandlerContext:i,serverHandoffString:me(w),serverHandoffStream:Y(m,a.signal,t.entry.module.streamTimeout,e),renderMeta:{}};try{return await g(a,i.statusCode,h,y,n)}catch(c){return o(c),q(c,e)}}}}async function Mt(e,t,r,a,n,o,d){try{let i=await r.queryRoute(n,{routeId:a,requestContext:o,generateMiddlewareResponse:t.future.v8_middleware?async l=>{try{let h=await l(n);return u(h)}catch(h){return s(h)}}:void 0});return u(i)}catch(i){return s(i)}function u(i){return U(i)?i:typeof i=="string"?new Response(i):Response.json(i)}function s(i){if(U(i))return i;if(P(i))return d(i),$t(i,e);if(i instanceof Error&&i.message==="Expected a response from queryRoute"){let l=new Error("Expected a Response to be returned from resource route handler");return d(l),q(l,e)}return d(i),q(i,e)}}function $t(e,t){return Response.json(Te(e.error||new Error("Unexpected Server Error"),t),{status:e.status,statusText:e.statusText})}function q(e,t){let r="Unexpected Server Error";return t!=="production"&&(r+=`
|
|
1
|
+
import{x as je,y as ee,z as Ee,B as k,F as te,R as ze,S as be,D as qe,E as Ve,G as A,H as L,I as Ce,J as G,K as We,L as Xe,M as Je,N as Ge,O as xe,P as se,Q as oe,U as K,V as P,W as _e,X as Ke,Y as Qe,Z as Ye,$ as Ze,a0 as et,a1 as tt,a2 as rt,a3 as at,a4 as I,a5 as nt,a6 as st,a7 as ot,a8 as $,a9 as it,aa as ie,ab as lt,ac as re,ad as U,ae as ut,af as dt,ag as ct}from"./index-BJaUn1y0.js";import{ah as wr,ai as gr,aj as Rr,ak as Sr,al as vr,am as Er,an as br,ao as Cr,ap as xr,aq as _r,ar as kr,as as Ar,at as Dr,au as Hr,av as Tr,aw as Fr,ax as Pr,ay as Nr,az as Ur,aA as Or,aB as Lr,aC as Ir,aD as Br,aE as Mr,aF as $r,aG as jr,aH as zr,aI as qr,aJ as Vr,aK as Wr,aL as Xr,aM as Jr,aN as Gr,aO as Kr,aP as Qr,aQ as Yr,aR as Zr,aS as ea,aT as ta,aU as ra,aV as aa,aW as na,aX as sa,aY as oa,aZ as ia,a_ as la,a$ as ua,b0 as da,b1 as ca,b2 as fa,b3 as ha,b4 as pa,b5 as ma,b6 as ya,b7 as wa,b8 as ga,b9 as Ra,ba as Sa,bb as va,bc as Ea,bd as ba,be as Ca,bf as xa,bg as _a,bh as ka,bi as Aa,bj as Da,bk as Ha,bl as Ta,bm as Fa,bn as Pa,bo as Na,bp as Ua,bq as Oa,br as La,bs as Ia,bt as Ba,bu as Ma,bv as $a,bw as ja,bx as za,by as qa,bz as Va,bA as Wa,bB as Xa,bC as Ja,bD as Ga,bE as Ka,bF as Qa,bG as Ya}from"./index-BJaUn1y0.js";var T={},le;function ft(){if(le)return T;le=1,Object.defineProperty(T,"__esModule",{value:!0}),T.parseCookie=u,T.parse=u,T.stringifyCookie=s,T.stringifySetCookie=i,T.serialize=i,T.parseSetCookie=l,T.stringifySetCookie=i,T.serialize=i;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/,n=/^-?\d+$/,o=Object.prototype.toString,d=(()=>{const f=function(){};return f.prototype=Object.create(null),f})();function u(f,v){const m=new d,c=f.length;if(c<2)return m;const R=v?.decode||y;let S=0;do{const C=p(f,S,c);if(C===-1)break;const E=h(f,S,c);if(C>E){S=f.lastIndexOf(";",C-1)+1;continue}const _=w(f,S,C);m[_]===void 0&&(m[_]=R(w(f,C+1,E))),S=E+1}while(S<c);return m}function s(f,v){const m=v?.encode||encodeURIComponent,c=[];for(const R of Object.keys(f)){const S=f[R];if(S===void 0)continue;if(!e.test(R))throw new TypeError(`cookie name is invalid: ${R}`);const C=m(S);if(!t.test(C))throw new TypeError(`cookie val is invalid: ${S}`);c.push(`${R}=${C}`)}return c.join("; ")}function i(f,v,m){const c=typeof f=="object"?f:{...m,name:f,value:String(v)},S=(typeof v=="object"?v:m)?.encode||encodeURIComponent;if(!e.test(c.name))throw new TypeError(`argument name is invalid: ${c.name}`);const C=c.value?S(c.value):"";if(!t.test(C))throw new TypeError(`argument val is invalid: ${c.value}`);let E=c.name+"="+C;if(c.maxAge!==void 0){if(!Number.isInteger(c.maxAge))throw new TypeError(`option maxAge is invalid: ${c.maxAge}`);E+="; Max-Age="+c.maxAge}if(c.domain){if(!r.test(c.domain))throw new TypeError(`option domain is invalid: ${c.domain}`);E+="; Domain="+c.domain}if(c.path){if(!a.test(c.path))throw new TypeError(`option path is invalid: ${c.path}`);E+="; Path="+c.path}if(c.expires){if(!g(c.expires)||!Number.isFinite(c.expires.valueOf()))throw new TypeError(`option expires is invalid: ${c.expires}`);E+="; Expires="+c.expires.toUTCString()}if(c.httpOnly&&(E+="; HttpOnly"),c.secure&&(E+="; Secure"),c.partitioned&&(E+="; Partitioned"),c.priority)switch(typeof c.priority=="string"?c.priority.toLowerCase():void 0){case"low":E+="; Priority=Low";break;case"medium":E+="; Priority=Medium";break;case"high":E+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${c.priority}`)}if(c.sameSite)switch(typeof c.sameSite=="string"?c.sameSite.toLowerCase():c.sameSite){case!0:case"strict":E+="; SameSite=Strict";break;case"lax":E+="; SameSite=Lax";break;case"none":E+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${c.sameSite}`)}return E}function l(f,v){const m=v?.decode||y,c=f.length,R=h(f,0,c),S=p(f,0,R),C=S===-1?{name:"",value:m(w(f,0,R))}:{name:w(f,0,S),value:m(w(f,S+1,R))};let E=R+1;for(;E<c;){const _=h(f,E,c),F=p(f,E,_),x=F===-1?w(f,E,_):w(f,E,F),b=F===-1?void 0:w(f,F+1,_);switch(x.toLowerCase()){case"httponly":C.httpOnly=!0;break;case"secure":C.secure=!0;break;case"partitioned":C.partitioned=!0;break;case"domain":C.domain=b;break;case"path":C.path=b;break;case"max-age":b&&n.test(b)&&(C.maxAge=Number(b));break;case"expires":if(!b)break;const D=new Date(b);Number.isFinite(D.valueOf())&&(C.expires=D);break;case"priority":if(!b)break;const H=b.toLowerCase();(H==="low"||H==="medium"||H==="high")&&(C.priority=H);break;case"samesite":if(!b)break;const M=b.toLowerCase();(M==="lax"||M==="strict"||M==="none")&&(C.sameSite=M);break}E=_+1}return C}function h(f,v,m){const c=f.indexOf(";",v);return c===-1?m:c}function p(f,v,m){const c=f.indexOf("=",v);return c<m?c:-1}function w(f,v,m){let c=v,R=m;do{const S=f.charCodeAt(c);if(S!==32&&S!==9)break}while(++c<R);for(;R>c;){const S=f.charCodeAt(R-1);if(S!==32&&S!==9)break;R--}return f.slice(c,R)}function y(f){if(f.indexOf("%")===-1)return f;try{return decodeURIComponent(f)}catch{return f}}function g(f){return o.call(f)==="[object Date]"}return T}var ue=ft(),O={exports:{}},de;function ht(){if(de)return O.exports;de=1;var e={decodeValues:!0,map:!1,silent:!1};function t(s){return typeof s!="string"||s in{}}function r(){return Object.create(null)}function a(s){return typeof s=="string"&&!!s.trim()}function n(s,i){var l=s.split(";").filter(a),h=l.shift(),p=o(h),w=p.name,y=p.value;if(i=i?Object.assign({},e,i):e,t(w))return null;try{y=i.decodeValues?decodeURIComponent(y):y}catch(f){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",f)}var g=r();return g.name=w,g.value=y,l.forEach(function(f){var v=f.split("="),m=v.shift().trimLeft().toLowerCase();if(!t(m)){var c=v.join("=");if(m==="expires")g.expires=new Date(c);else if(m==="max-age"){var R=parseInt(c,10);Number.isNaN(R)||(g.maxAge=R)}else m==="secure"?g.secure=!0:m==="httponly"?g.httpOnly=!0:m==="samesite"?g.sameSite=c:m==="partitioned"?g.partitioned=!0:m&&(g[m]=c)}}),g}function o(s){var i="",l="",h=s.split("=");return h.length>1?(i=h.shift(),l=h.join("=")):l=s,{name:i,value:l}}function d(s,i){if(i=i?Object.assign({},e,i):e,!s)return i.map?r():[];if(s.headers)if(typeof s.headers.getSetCookie=="function")s=s.headers.getSetCookie();else if(s.headers["set-cookie"])s=s.headers["set-cookie"];else{var l=s.headers[Object.keys(s.headers).find(function(p){return p.toLowerCase()==="set-cookie"})];!l&&s.headers.cookie&&!i.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),s=l}if(Array.isArray(s)||(s=[s]),i.map){var h=r();return s.filter(a).reduce(function(p,w){var y=n(w,i);return y&&!t(y.name)&&(p[y.name]=y),p},h)}else return s.filter(a).map(function(p){return n(p,i)}).filter(Boolean)}function u(s){if(Array.isArray(s))return s;if(typeof s!="string")return[];var i=[],l=0,h,p,w,y,g;function f(){for(;l<s.length&&/\s/.test(s.charAt(l));)l+=1;return l<s.length}function v(){return p=s.charAt(l),p!=="="&&p!==";"&&p!==","}for(;l<s.length;){for(h=l,g=!1;f();)if(p=s.charAt(l),p===","){for(w=l,l+=1,f(),y=l;l<s.length&&v();)l+=1;l<s.length&&s.charAt(l)==="="?(g=!0,l=y,i.push(s.substring(h,w)),h=l):l=w+1}else l+=1;(!g||l>=s.length)&&i.push(s.substring(h,s.length))}return i}return O.exports=d,O.exports.parse=d,O.exports.parseString=n,O.exports.splitCookiesString=u,O.exports}var pt=ht(),mt={};function rr({context:e,url:t,nonce:r}){typeof t=="string"&&(t=new URL(t));let{manifest:a,routeModules:n,criticalCss:o,serverHandoffString:d}=e,u=je(a.routes,n,e.future,e.isSpaMode);e.staticHandlerContext.loaderData={...e.staticHandlerContext.loaderData};for(let i of e.staticHandlerContext.matches){let l=i.route.id,h=n[l],p=e.manifest.routes[l];h&&p&&ee(l,h.clientLoader,p.hasLoader,e.isSpaMode)&&(h.HydrateFallback||!p.hasLoader)&&delete e.staticHandlerContext.loaderData[l]}let s=Ee(u,e.staticHandlerContext);return k.createElement(k.Fragment,null,k.createElement(te.Provider,{value:{manifest:a,routeModules:n,criticalCss:o,serverHandoffString:d,future:e.future,ssr:e.ssr,isSpaMode:e.isSpaMode,routeDiscovery:e.routeDiscovery,serializeError:e.serializeError,renderMeta:e.renderMeta}},k.createElement(ze,{location:s.state.location},k.createElement(be,{router:s,context:e.staticHandlerContext,hydrate:!1}))),e.serverHandoffStream?k.createElement(k.Suspense,null,k.createElement(qe,{context:e,identifier:0,reader:e.serverHandoffStream.getReader(),textDecoder:new TextDecoder,nonce:r})):null)}function ar(e,t){return function({initialEntries:a,initialIndex:n,hydrationData:o,future:d}){let u=k.useRef(),s=k.useRef();if(u.current==null){s.current={future:{unstable_subResourceIntegrity:d?.unstable_subResourceIntegrity===!0,v8_middleware:d?.v8_middleware===!0,unstable_trailingSlashAwareDataRequests:d?.unstable_trailingSlashAwareDataRequests===!0},manifest:{routes:{},entry:{imports:[],module:""},url:"",version:""},routeModules:{},ssr:!1,isSpaMode:!1,routeDiscovery:{mode:"lazy",manifestPath:"/__manifest"}};let i=ke(We(e,l=>l),t!==void 0?t:d?.v8_middleware?new G:{},s.current.manifest,s.current.routeModules);u.current=Xe(i,{initialEntries:a,initialIndex:n,hydrationData:o})}return k.createElement(te.Provider,{value:s.current},k.createElement(Je,{router:u.current}))}}function ke(e,t,r,a,n){return e.map(o=>{if(!o.id)throw new Error("Expected a route.id in react-router processRoutes() function");let d={id:o.id,path:o.path,index:o.index,Component:o.Component?et(o.Component):void 0,HydrateFallback:o.HydrateFallback?Ze(o.HydrateFallback):void 0,ErrorBoundary:o.ErrorBoundary?Ye(o.ErrorBoundary):void 0,action:o.action?s=>o.action({...s,context:t}):void 0,loader:o.loader?s=>o.loader({...s,context:t}):void 0,middleware:o.middleware?o.middleware.map(s=>(...i)=>s({...i[0],context:t},i[1])):void 0,handle:o.handle,shouldRevalidate:o.shouldRevalidate},u={id:o.id,path:o.path,index:o.index,parentId:n,hasAction:o.action!=null,hasLoader:o.loader!=null,hasClientAction:!1,hasClientLoader:!1,hasClientMiddleware:!1,hasErrorBoundary:o.ErrorBoundary!=null,module:"build/stub-path-to-module.js",clientActionModule:void 0,clientLoaderModule:void 0,clientMiddlewareModule:void 0,hydrateFallbackModule:void 0};return r.routes[d.id]=u,a[o.id]={default:d.Component||tt,ErrorBoundary:d.ErrorBoundary||void 0,handle:o.handle,links:o.links,meta:o.meta,shouldRevalidate:o.shouldRevalidate},o.children&&(d.children=ke(o.children,t,r,a,d.id)),d})}var ae=new TextEncoder,yt=async(e,t)=>{let r=ae.encode(e),a=await Ae(t,["sign"]),n=await crypto.subtle.sign("HMAC",a,r),o=btoa(String.fromCharCode(...new Uint8Array(n))).replace(/=+$/,"");return e+"."+o},wt=async(e,t)=>{let r=e.lastIndexOf("."),a=e.slice(0,r),n=e.slice(r+1),o=ae.encode(a),d=await Ae(t,["verify"]);try{let u=gt(atob(n));return await crypto.subtle.verify("HMAC",d,u,o)?a:!1}catch{return!1}},Ae=async(e,t)=>crypto.subtle.importKey("raw",ae.encode(e),{name:"HMAC",hash:"SHA-256"},!1,t);function gt(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var De=(e,t={})=>{let{secrets:r=[],...a}={path:"/",sameSite:"lax",...t};return Ct(e,a.expires),{get name(){return e},get isSigned(){return r.length>0},get expires(){return typeof a.maxAge<"u"?new Date(Date.now()+a.maxAge*1e3):a.expires},async parse(n,o){if(!n)return null;let d=ue.parse(n,{...a,...o});if(e in d){let u=d[e];return typeof u=="string"&&u!==""?await St(u,r):""}else return null},async serialize(n,o){return ue.serialize(e,n===""?"":await Rt(n,r),{...a,...o})}}},He=e=>e!=null&&typeof e.name=="string"&&typeof e.isSigned=="boolean"&&typeof e.parse=="function"&&typeof e.serialize=="function";async function Rt(e,t){let r=vt(e);return t.length>0&&(r=await yt(r,t[0])),r}async function St(e,t){if(t.length>0){for(let r of t){let a=await wt(e,r);if(a!==!1)return ce(a)}return null}return ce(e)}function vt(e){return btoa(bt(encodeURIComponent(JSON.stringify(e))))}function ce(e){try{return JSON.parse(decodeURIComponent(Et(atob(e))))}catch{return{}}}function Et(e){let t=e.toString(),r="",a=0,n,o;for(;a<t.length;)n=t.charAt(a++),/[\w*+\-./@]/.exec(n)?r+=n:(o=n.charCodeAt(0),o<256?r+="%"+fe(o,2):r+="%u"+fe(o,4).toUpperCase());return r}function fe(e,t){let r=e.toString(16);for(;r.length<t;)r="0"+r;return r}function bt(e){let t=e.toString(),r="",a=0,n,o;for(;a<t.length;){if(n=t.charAt(a++),n==="%"){if(t.charAt(a)==="u"){if(o=t.slice(a+1,a+5),/^[\da-f]{4}$/i.exec(o)){r+=String.fromCharCode(parseInt(o,16)),a+=5;continue}}else if(o=t.slice(a,a+2),/^[\da-f]{2}$/i.exec(o)){r+=String.fromCharCode(parseInt(o,16)),a+=2;continue}}r+=n}return r}function Ct(e,t){_e(!t,`The "${e}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`)}function xt(e){return Object.keys(e).reduce((t,r)=>{let a=e[r];return a&&(t[r]=a.module),t},{})}var _t=(e=>(e.Development="development",e.Production="production",e.Test="test",e))(_t||{});function kt(e){return e==="development"||e==="production"||e==="test"}function V(e,t){if(e instanceof Error&&t!=="development"){let r=new Error("Unexpected Server Error");return r.stack=void 0,r}return e}function z(e,t){return Object.entries(e).reduce((r,[a,n])=>Object.assign(r,{[a]:V(n,t)}),{})}function Te(e,t){let r=V(e,t);return{message:r.message,stack:r.stack}}function he(e,t){if(!e)return null;let r=Object.entries(e),a={};for(let[n,o]of r)if(P(o))a[n]={...o,__type:"RouteErrorResponse"};else if(o instanceof Error){let d=V(o,t);a[n]={message:d.message,stack:d.stack,__type:"Error",...d.name!=="Error"?{__subType:d.name}:{}}}else a[n]=o;return a}function Q(e,t,r){let a=Ce(e,t,r);return a?a.map(n=>({params:n.params,pathname:n.pathname,route:n.route})):null}async function pe(e,t){let r=await e({request:Dt(At(t.request)),params:t.params,context:t.context,unstable_pattern:t.unstable_pattern});if(lt(r)&&r.init&&r.init.status&&re(r.init.status))throw new Response(null,r.init);return r}function At(e){let t=new URL(e.url),r=t.searchParams.getAll("index");t.searchParams.delete("index");let a=[];for(let o of r)o&&a.push(o);for(let o of a)t.searchParams.append("index",o);let n={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return n.body&&(n.duplex="half"),new Request(t.href,n)}function Dt(e){let t=new URL(e.url);t.searchParams.delete("_routes");let r={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return r.body&&(r.duplex="half"),new Request(t.href,r)}function j(e,t){if(e===!1||e===null||typeof e>"u")throw console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"),new Error(t)}var Fe="__reactRouterDevServerHooks";function nr(e){globalThis[Fe]=e}function W(){return globalThis[Fe]}function Pe(e,t){if(typeof process<"u")try{if(mt?.IS_RR_BUILD_REQUEST==="yes")return e.headers.get(t)}catch{}return null}function Ne(e){let t={};return Object.values(e).forEach(r=>{if(r){let a=r.parentId||"";t[a]||(t[a]=[]),t[a].push(r)}}),t}function Ue(e,t="",r=Ne(e)){return(r[t]||[]).map(a=>({...a,children:Ue(e,a.id,r)}))}function Oe(e,t,r="",a=Ne(e)){return(a[r]||[]).map(n=>{let o={hasErrorBoundary:n.id==="root"||n.module.ErrorBoundary!=null,id:n.id,path:n.path,middleware:n.module.middleware,loader:n.module.loader?async d=>{let u=Pe(d.request,"X-React-Router-Prerender-Data");if(u!=null){let i=u&&decodeURI(u);j(i,"Missing prerendered data for route");let l=new TextEncoder().encode(i),h=new ReadableStream({start(y){y.enqueue(l),y.close()}}),w=(await at(h,globalThis)).value;if(w&&I in w){let y=w[I],g={status:y.status};throw y.reload?nt(y.redirect,g):y.replace?st(y.redirect,g):ot(y.redirect,g)}else{j(w&&n.id in w,"Unable to decode prerendered data");let y=w[n.id];return j("data"in y,"Unable to process prerendered data"),y.data}}return await pe(n.module.loader,d)}:void 0,action:n.module.action?d=>pe(n.module.action,d):void 0,handle:n.module.handle};return n.index?{index:!0,...o}:{caseSensitive:n.caseSensitive,children:Oe(e,t,n.id,a),...o}})}function me(e){return K(JSON.stringify(e))}function ne(e,t){return Ht(e,r=>{let a=t.routes[r.route.id];return j(a,`Route with id "${r.route.id}" not found in build`),a.module.headers})}function Ht(e,t,r){let a=e.errors?e.matches.findIndex(u=>e.errors[u.route.id]):-1,n=a>=0?e.matches.slice(0,a+1):e.matches,o;if(a>=0){let{actionHeaders:u,actionData:s,loaderHeaders:i,loaderData:l}=e;e.matches.slice(a).some(h=>{let p=h.route.id;return u[p]&&(!s||!s.hasOwnProperty(p))?o=u[p]:i[p]&&!l.hasOwnProperty(p)&&(o=i[p]),o!=null})}const d=new Headers(r);return n.reduce((u,s,i)=>{let{id:l}=s.route,h=e.loaderHeaders[l]||new Headers,p=e.actionHeaders[l]||new Headers,w=o!=null&&i===n.length-1,y=w&&o!==h&&o!==p,g=t(s);if(g==null){let v=new Headers(u);return y&&N(o,v),N(p,v),N(h,v),v}let f=new Headers(typeof g=="function"?g({loaderHeaders:h,parentHeaders:u,actionHeaders:p,errorHeaders:w?o:void 0}):g);return y&&N(o,f),N(p,f),N(h,f),N(u,f),f},new Headers(d))}function N(e,t){let r=e.get("Set-Cookie");if(r){let a=pt.splitCookiesString(r),n=new Set(t.getSetCookie());a.forEach(o=>{n.has(o)||t.append("Set-Cookie",o)})}}function Le(e,t){let r=e.get("origin"),a=typeof r=="string"&&r!=="null"?new URL(r).host:r,n=Pt(e);if(a&&(!n||a!==n.value)&&!Ft(a,t))throw n?new Error(`${n.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`):new Error("`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action.")}function Tt(e,t){const r=e.split("."),a=t.split(".");if(a.length<1||r.length<a.length||a.length===1&&(a[0]==="*"||a[0]==="**"))return!1;for(;a.length;){const n=a.pop(),o=r.pop();switch(n){case"":return!1;case"*":{if(o)continue;return!1}case"**":return a.length>0?!1:o!==void 0;case void 0:default:if(o!==n)return!1}}return r.length===0}function Ft(e,t=[]){return t.some(r=>r&&(r===e||Tt(e,r)))}function Pt(e){let r=e.get("x-forwarded-host")?.split(",")[0]?.trim(),a=e.get("host");return r?{type:"x-forwarded-host",value:r}:a?{type:"host",value:a}:void 0}var Ie=new Set([...dt,304]);async function Nt(e,t,r,a,n,o,d){try{Le(a.headers,Array.isArray(e.allowedActionOrigins)?e.allowedActionOrigins:[]);let l=new Request(n,{method:a.method,body:a.body,headers:a.headers,signal:a.signal,...a.body?{duplex:"half"}:void 0}),h=await r.query(l,{requestContext:o,skipLoaderErrorBubbling:!0,skipRevalidation:!0,generateMiddlewareResponse:e.future.v8_middleware?async p=>{try{let w=await p(l);return u(w)}catch(w){return s(w)}}:void 0});return u(h)}catch(l){return s(l)}function u(l){return U(l)?l:i(l)}function s(l){return d(l),B(a,e,t,{result:{error:l},headers:new Headers,status:500})}function i(l){let h=ne(l,e);if(re(l.statusCode)&&h.has("Location"))return new Response(null,{status:l.statusCode,headers:h});l.errors&&(Object.values(l.errors).forEach(w=>{(!P(w)||w.error)&&d(w)}),l.errors=z(l.errors,t));let p;return l.errors?p={error:Object.values(l.errors)[0]}:p={data:Object.values(l.actionData||{})[0]},B(a,e,t,{result:p,headers:h,status:l.statusCode})}}async function Ut(e,t,r,a,n,o,d){let u=new URL(a.url).searchParams.get("_routes"),s=u?new Set(u.split(",")):null;try{let p=new Request(n,{headers:a.headers,signal:a.signal}),w=await r.query(p,{requestContext:o,filterMatchesToLoad:y=>!s||s.has(y.route.id),skipLoaderErrorBubbling:!0,generateMiddlewareResponse:e.future.v8_middleware?async y=>{try{let g=await y(p);return i(g)}catch(g){return l(g)}}:void 0});return i(w)}catch(p){return l(p)}function i(p){return U(p)?p:h(p)}function l(p){return d(p),B(a,e,t,{result:{error:p},headers:new Headers,status:500})}function h(p){let w=ne(p,e);if(re(p.statusCode)&&w.has("Location"))return new Response(null,{status:p.statusCode,headers:w});p.errors&&(Object.values(p.errors).forEach(f=>{(!P(f)||f.error)&&d(f)}),p.errors=z(p.errors,t));let y={},g=new Set(p.matches.filter(f=>s?s.has(f.route.id):f.route.loader!=null).map(f=>f.route.id));if(p.errors)for(let[f,v]of Object.entries(p.errors))y[f]={error:v};for(let[f,v]of Object.entries(p.loaderData))!(f in y)&&g.has(f)&&(y[f]={data:v});return B(a,e,t,{result:y,headers:w,status:p.statusCode})}}function B(e,t,r,{result:a,headers:n,status:o}){let d=new Headers(n);return d.set("X-Remix-Response","yes"),Ie.has(o)?new Response(null,{status:o,headers:d}):(d.set("Content-Type","text/x-script"),d.delete("Content-Length"),new Response(Y(a,e.signal,t.entry.module.streamTimeout,r),{status:o||200,headers:d}))}function ye(e,t,r,a){let n=Ot(e.status,e.headers,r.basename),o=new Headers(e.headers);return o.delete("Location"),o.set("Content-Type","text/x-script"),B(t,r,a,{result:t.method==="GET"?{[I]:n}:n,headers:o,status:xe})}function Ot(e,t,r){let a=t.get("Location");return r&&(a=$(a,r)||a),{redirect:a,status:e,revalidate:t.has("X-Remix-Revalidate")||t.has("Set-Cookie"),reload:t.has("X-Remix-Reload-Document"),replace:t.has("X-Remix-Replace")}}function Y(e,t,r,a){let n=new AbortController,o=setTimeout(()=>n.abort(new Error("Server Timeout")),typeof r=="number"?r:4950);return t.addEventListener("abort",()=>clearTimeout(o)),ct(e,{signal:n.signal,plugins:[d=>{if(d instanceof Error){let{name:u,message:s,stack:i}=a==="production"?V(d,a):d;return["SanitizedError",u,s,i]}if(d instanceof L){let{data:u,status:s,statusText:i}=d;return["ErrorResponse",u,s,i]}if(d&&typeof d=="object"&&I in d)return["SingleFetchRedirect",d[I]]}],postPlugins:[d=>{if(d&&typeof d=="object")return["SingleFetchClassInstance",Object.fromEntries(Object.entries(d))]},()=>["SingleFetchFallback"]]})}function we(e,t){let r=Ue(e.routes),a=Oe(e.routes,e.future),n=kt(t)?t:"production",o=Ke(a,{basename:e.basename,unstable_instrumentations:e.entry.module.unstable_instrumentations}),d=e.entry.module.handleError||((s,{request:i})=>{n!=="test"&&!i.signal.aborted&&console.error(P(s)&&s.error?s.error:s)}),u=async(s,i)=>{let l={},h,p=R=>{t==="development"&&W()?.processRequestError?.(R),d(R,{context:h,params:l,request:s})};if(e.future.v8_middleware){if(i&&!(i instanceof G)){let R=new Error("Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function.");return p(R),q(R,n)}h=i||new G}else h=i||{};let w=new URL(s.url),y=e.basename||"/",g=w.pathname;e.future.unstable_trailingSlashAwareDataRequests?g.endsWith("/_.data")?g=g.replace(/_.data$/,""):g=g.replace(/\.data$/,""):($(g,y)==="/_root.data"?g=y:g.endsWith(".data")&&(g=g.replace(/\.data$/,"")),$(g,y)!=="/"&&g.endsWith("/")&&(g=g.slice(0,-1)));let f=Pe(s,"X-React-Router-SPA-Mode")==="yes";if(!e.ssr){let R=decodeURI(g);if(y!=="/"){let S=$(R,y);if(S==null)return d(new L(404,"Not Found",`Refusing to prerender the \`${R}\` path because it does not start with the basename \`${y}\``),{context:h,params:l,request:s}),new Response("Not Found",{status:404,statusText:"Not Found"});R=S}if(e.prerender.length===0)f=!0;else if(!e.prerender.includes(R)&&!e.prerender.includes(R+"/")){if(w.pathname.endsWith(".data"))return d(new L(404,"Not Found",`Refusing to SSR the path \`${R}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`),{context:h,params:l,request:s}),new Response("Not Found",{status:404,statusText:"Not Found"});f=!0}}let v=it(e.routeDiscovery.manifestPath,y);if(w.pathname===v)try{return await Lt(e,r,w)}catch(R){return p(R),new Response("Unknown Server Error",{status:500})}let m=Q(r,g,e.basename);m&&m.length>0&&Object.assign(l,m[0].params);let c;if(w.pathname.endsWith(".data")){let R=new URL(s.url);R.pathname=g;let S=Q(r,R.pathname,e.basename);c=await It(n,e,o,s,R,h,p),ie(c)&&(c=ye(c,s,e,n)),e.entry.module.handleDataRequest&&(c=await e.entry.module.handleDataRequest(c,{context:h,params:S?S[0].params:{},request:s}),ie(c)&&(c=ye(c,s,e,n)))}else if(!f&&m&&m[m.length-1].route.module.default==null&&m[m.length-1].route.module.ErrorBoundary==null)c=await Mt(n,e,o,m.slice(-1)[0].route.id,s,h,p);else{let{pathname:R}=w,S;e.unstable_getCriticalCss?S=await e.unstable_getCriticalCss({pathname:R}):t==="development"&&W()?.getCriticalCss&&(S=await W()?.getCriticalCss?.(R)),c=await Bt(n,e,o,s,h,p,f,S)}return s.method==="HEAD"?new Response(null,{headers:c.headers,status:c.status,statusText:c.statusText}):c};return e.entry.module.unstable_instrumentations&&(u=Qe(u,e.entry.module.unstable_instrumentations.map(s=>s.handler).filter(Boolean))),{routes:r,dataRoutes:a,serverMode:n,staticHandler:o,errorHandler:d,requestHandler:u}}var sr=(e,t)=>{let r,a,n,o,d,u;return async function(i,l){if(r=typeof e=="function"?await e():e,typeof e=="function"){let h=we(r,t);a=h.routes,n=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}else if(!a||!n||!o||!d||!u){let h=we(r,t);a=h.routes,n=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}return u(i,l)}};async function Lt(e,t,r){if(e.assets.version!==r.searchParams.get("version"))return new Response(null,{status:204,headers:{"X-Remix-Reload-Document":"true"}});let a={};if(r.searchParams.has("paths")){let n=new Set;(r.searchParams.get("paths")||"").split(",").filter(Boolean).forEach(u=>{u.startsWith("/")||(u=`/${u}`);let s=u.split("/").slice(1);s.forEach((i,l)=>{let h=s.slice(0,l+1).join("/");n.add(`/${h}`)})});for(let u of n){let s=Q(t,u,e.basename);if(s)for(let i of s){let l=i.route.id,h=e.assets.routes[l];h&&(a[l]=h)}}return Response.json(a,{headers:{"Cache-Control":"public, max-age=31536000, immutable"}})}return new Response("Invalid Request",{status:400})}async function It(e,t,r,a,n,o,d){return a.method!=="GET"?await Nt(t,e,r,a,n,o,d):await Ut(t,e,r,a,n,o,d)}async function Bt(e,t,r,a,n,o,d,u){try{a.method==="POST"&&Le(a.headers,Array.isArray(t.allowedActionOrigins)?t.allowedActionOrigins:[]);let i=await r.query(a,{requestContext:n,generateMiddlewareResponse:t.future.v8_middleware?async l=>{try{let h=await l(a);return U(h)||(h=await s(h,d)),h}catch(h){return o(h),new Response(null,{status:500})}}:void 0});return U(i)||(i=await s(i,d)),i}catch(i){return o(i),new Response(null,{status:500})}async function s(i,l){let h=ne(i,t);if(Ie.has(i.statusCode))return new Response(null,{status:i.statusCode,headers:h});i.errors&&(Object.values(i.errors).forEach(f=>{(!P(f)||f.error)&&o(f)}),i.errors=z(i.errors,e));let p={loaderData:i.loaderData,actionData:i.actionData,errors:he(i.errors,e)},w={basename:t.basename,future:t.future,routeDiscovery:t.routeDiscovery,ssr:t.ssr,isSpaMode:l},y={manifest:t.assets,routeModules:xt(t.routes),staticHandlerContext:i,criticalCss:u,serverHandoffString:me({...w,criticalCss:u}),serverHandoffStream:Y(p,a.signal,t.entry.module.streamTimeout,e),renderMeta:{},future:t.future,ssr:t.ssr,routeDiscovery:t.routeDiscovery,isSpaMode:l,serializeError:f=>Te(f,e)},g=t.entry.module.default;try{return await g(a,i.statusCode,h,y,n)}catch(f){o(f);let v=f;if(U(f))try{let c=await jt(f);v=new L(f.status,f.statusText,c)}catch{}i=ut(r.dataRoutes,i,v),i.errors&&(i.errors=z(i.errors,e));let m={loaderData:i.loaderData,actionData:i.actionData,errors:he(i.errors,e)};y={...y,staticHandlerContext:i,serverHandoffString:me(w),serverHandoffStream:Y(m,a.signal,t.entry.module.streamTimeout,e),renderMeta:{}};try{return await g(a,i.statusCode,h,y,n)}catch(c){return o(c),q(c,e)}}}}async function Mt(e,t,r,a,n,o,d){try{let i=await r.queryRoute(n,{routeId:a,requestContext:o,generateMiddlewareResponse:t.future.v8_middleware?async l=>{try{let h=await l(n);return u(h)}catch(h){return s(h)}}:void 0});return u(i)}catch(i){return s(i)}function u(i){return U(i)?i:typeof i=="string"?new Response(i):Response.json(i)}function s(i){if(U(i))return i;if(P(i))return d(i),$t(i,e);if(i instanceof Error&&i.message==="Expected a response from queryRoute"){let l=new Error("Expected a Response to be returned from resource route handler");return d(l),q(l,e)}return d(i),q(i,e)}}function $t(e,t){return Response.json(Te(e.error||new Error("Unexpected Server Error"),t),{status:e.status,statusText:e.statusText})}function q(e,t){let r="Unexpected Server Error";return t!=="production"&&(r+=`
|
|
2
2
|
|
|
3
3
|
${String(e)}`),new Response(r,{status:500,headers:{"Content-Type":"text/plain"}})}function jt(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}function X(e){return`__flash_${e}__`}var Be=(e={},t="")=>{let r=new Map(Object.entries(e));return{get id(){return t},get data(){return Object.fromEntries(r)},has(a){return r.has(a)||r.has(X(a))},get(a){if(r.has(a))return r.get(a);let n=X(a);if(r.has(n)){let o=r.get(n);return r.delete(n),o}},set(a,n){r.set(a,n)},flash(a,n){r.set(X(a),n)},unset(a){r.delete(a)}}},or=e=>e!=null&&typeof e.id=="string"&&typeof e.data<"u"&&typeof e.has=="function"&&typeof e.get=="function"&&typeof e.set=="function"&&typeof e.flash=="function"&&typeof e.unset=="function";function zt({cookie:e,createData:t,readData:r,updateData:a,deleteData:n}){let o=He(e)?e:De(e?.name||"__session",e);return Me(o),{async getSession(d,u){let s=d&&await o.parse(d,u),i=s&&await r(s);return Be(i||{},s||"")},async commitSession(d,u){let{id:s,data:i}=d,l=u?.maxAge!=null?new Date(Date.now()+u.maxAge*1e3):u?.expires!=null?u.expires:o.expires;return s?await a(s,i,l):s=await t(i,l),o.serialize(s,u)},async destroySession(d,u){return await n(d.id),o.serialize("",{...u,maxAge:void 0,expires:new Date(0)})}}}function Me(e){_e(e.isSigned,`The "${e.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`)}function ir({cookie:e}={}){let t=He(e)?e:De(e?.name||"__session",e);return Me(t),{async getSession(r,a){return Be(r&&await t.parse(r,a)||{})},async commitSession(r,a){let n=await t.serialize(r.data,a);if(n.length>4096)throw new Error("Cookie length will exceed browser maximum. Length: "+n.length);return n},async destroySession(r,a){return t.serialize("",{...a,maxAge:void 0,expires:new Date(0)})}}}function lr({cookie:e}={}){let t=new Map;return zt({cookie:e,async createData(r,a){let n=Math.random().toString(36).substring(2,10);return t.set(n,{data:r,expires:a}),n},async readData(r){if(t.has(r)){let{data:a,expires:n}=t.get(r);if(!n||n>new Date)return a;n&&t.delete(r)}return null},async updateData(r,a,n){t.set(r,{data:a,expires:n})},async deleteData(r){t.delete(r)}})}function ur(e,...t){let r=t[0],a=qt(e).replace(/\/:([\w-]+)(\?)?/g,(n,o,d)=>{const u=d===void 0,s=r?.[o];if(u&&s===void 0)throw new Error(`Path '${e}' requires param '${o}' but it was not provided`);return s===void 0?"":"/"+s});if(e.endsWith("*")){const n=r?.["*"];n!==void 0&&(a+="/"+n)}return a||"/"}function qt(e){let t=e.length-1,r=e[t];if(r!=="*"&&r!=="/")return e;for(t--;t>=0&&e[t]==="/";t--);return e.slice(0,t+1)}var Z=new TextEncoder,ge="</body></html>";function Re(e){let t=new TextDecoder,r,a=new Promise(s=>r=s),n=!1,o=[],d=null;function u(s){for(let i of o){let l=t.decode(i,{stream:!0});l.endsWith(ge)&&(l=l.slice(0,-ge.length)),s.enqueue(Z.encode(l))}o.length=0,d=null}return new TransformStream({transform(s,i){o.push(s),!d&&(d=setTimeout(async()=>{u(i),n||(n=!0,Vt(e,i).catch(l=>i.error(l)).then(r))},0))},async flush(s){await a,d&&(clearTimeout(d),u(s)),s.enqueue(Z.encode("</body></html>"))}})}async function Vt(e,t){let r=new TextDecoder("utf-8",{fatal:!0});const a=e.getReader();try{let o;for(;(o=await a.read())&&!o.done;){const d=o.value;try{J(JSON.stringify(r.decode(d,{stream:!0})),t)}catch{let s=JSON.stringify(btoa(String.fromCodePoint(...d)));J(`Uint8Array.from(atob(${s}), m => m.codePointAt(0))`,t)}}}finally{a.releaseLock()}let n=r.decode();n.length&&J(JSON.stringify(n),t)}function J(e,t){t.enqueue(Z.encode(`<script>${Wt(`(self.__FLIGHT_DATA||=[]).push(${e})`)}<\/script>`))}function Wt(e){return e.replace(/<!--/g,"<\\!--").replace(/<\/(script)/gi,"</\\$1")}var Xt=class extends A.Component{constructor(e){super(e),this.state={error:null,location:e.location}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location?{error:null,location:e.location}:{error:t.error,location:t.location}}render(){return this.state.error?A.createElement($e,{error:this.state.error,renderAppShell:!0}):this.props.children}};function Se({renderAppShell:e,title:t,children:r}){return e?A.createElement("html",{lang:"en"},A.createElement("head",null,A.createElement("meta",{charSet:"utf-8"}),A.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),A.createElement("title",null,t)),A.createElement("body",null,A.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},r))):r}function $e({error:e,renderAppShell:t}){console.error(e);let r=A.createElement("script",{dangerouslySetInnerHTML:{__html:`
|
|
4
4
|
console.log(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as wn,O as Ut,f as bn,c as $t,d as xn,S as Sn,J as kn,R as Bt}from"./index-drkUjmF5.js";import{bS as Tn,d4 as y,d5 as Lt,d6 as Mn,d7 as On,d8 as jt,bR as xs,bO as qt,cy as Wt,bP as vn,bQ as In,bL as N,bJ as Dt,bT as Rn,bH as ie,i as at,bK as An,bU as Cn,d9 as b,da as w,db as E,dc as Ze,dd as Mt,de as Pn,df as En}from"./index-Dva6g5Hr.js";import"./index-B7a6zmqU.js";import"./chunk-VL2OQCWN-Ci7Z2Gkc.js";var Ft=class extends wn{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(n){throw new Ut(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const s=await Tn(this.zodSchema,e);if(s.success)return s.data;throw new Ut(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(s.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(r=>{const{message:a}=r;return Array.isArray(a.content)?Ss(a.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[s]=e;return await this._validateResult(s.args)}};function Ss(t){const e=[];for(const s of t)s.type==="tool_use"&&e.push({name:s.name,args:s.input,id:s.id,type:"tool_call"});return e}function Nn(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}const Un=y({cache_control:On().optional().nullable(),defer_loading:Mn().optional(),input_examples:Lt(jt()).optional(),allowed_callers:Lt(jt()).optional()}),Ht={tool_search_tool_regex_20251119:"advanced-tool-use-2025-11-20",tool_search_tool_bm25_20251119:"advanced-tool-use-2025-11-20",memory_20250818:"context-management-2025-06-27",web_fetch_20250910:"web-fetch-2025-09-10",code_execution_20250825:"code-execution-2025-08-25",computer_20251124:"computer-use-2025-11-24",computer_20250124:"computer-use-2025-01-24",mcp_toolset:"mcp-client-2025-11-20"};function $n(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function Bn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function Ln(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function jn(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const qn={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=xs({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Wn=t=>t();function Dn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Fn(t){function*e(){for(const s of t)Dn(s)&&(s.source==="char"?yield{type:"char_location",file_id:s.url??"",start_char_index:s.startIndex??0,end_char_index:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="page"?yield{type:"page_location",file_id:s.url??"",start_page_number:s.startIndex??0,end_page_number:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="block"?yield{type:"content_block_location",file_id:s.url??"",start_block_index:s.startIndex??0,end_block_index:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="url"?yield{type:"web_search_result_location",url:s.url??"",title:s.title??null,encrypted_index:String(s.startIndex??0),cited_text:s.citedText??""}:s.source==="search"&&(yield{type:"search_result_location",title:s.title??null,start_block_index:s.startIndex??0,end_block_index:s.endIndex??0,search_result_index:0,source:s.source??"",cited_text:s.citedText??""}))}return Array.from(e())}function oe(t){return typeof t=="string"?t:Hn(t)}function Hn(t){const e=[];for(let s=0,{length:n}=t;s<n;s++)e.push(String.fromCharCode(t[s]));return btoa(e.join(""))}function it(t){return(t??"").split(";")[0].toLowerCase()}function ke(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function Z(t,e){const s=ke(e,"cache_control");s!==void 0&&(t.cache_control=s);const n=ke(e,"citations");n!==void 0&&(t.citations=n);const r=ke(e,"context");r!==void 0&&(t.context=r);const a=ke(e,"title");return a!==void 0&&(t.title=a),t}function ot(t,e){const s=ke(e,"cache_control");return s!==void 0&&(t.cache_control=s),t}function Jt(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function Jn(t){const e=[],s=t.response_metadata,n="model_provider"in s&&s?.model_provider==="anthropic";for(const r of t.contentBlocks)if(r.type==="text")r.annotations?e.push({type:"text",text:r.text,citations:Fn(r.annotations)}):e.push({type:"text",text:r.text});else if(r.type==="tool_call")e.push({type:"tool_use",id:r.id??"",name:r.name,input:r.args});else if(r.type==="tool_call_chunk"){const a=Wn(()=>{if(typeof r.args!="string")return r.args;try{return JSON.parse(r.args)}catch{return{}}});e.push({type:"tool_use",id:r.id??"",name:r.name??"",input:a})}else if(r.type==="reasoning"&&n)e.push({type:"thinking",thinking:r.reasoning,signature:String(r.signature)});else if(r.type==="server_tool_call"&&n)r.name==="web_search"?e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args}):r.name==="code_execution"&&e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args});else if(r.type==="server_tool_call_result"&&n)if(r.name==="web_search"&&Array.isArray(r.output.urls)){const a=r.output.urls.map(i=>({type:"web_search_result",title:"",encrypted_content:"",url:i}));e.push({type:"web_search_tool_result",tool_use_id:r.toolCallId??"",content:a})}else r.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:r.toolCallId??"",content:r.output}):r.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:r.toolCallId??"",content:r.output});else{if(r.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(r.type==="file"){const a=r.metadata;if(r.fileId){e.push(Z({type:"document",source:{type:"file",file_id:r.fileId}},a));continue}if(r.url){const i=it(r.mimeType);if(i==="application/pdf"||i===""){e.push(Z({type:"document",source:{type:"url",url:r.url}},a));continue}}if(r.data){const i=it(r.mimeType);if(i===""||i==="application/pdf")e.push(Z({type:"document",source:{type:"base64",data:oe(r.data),media_type:"application/pdf"}},a));else if(i==="text/plain")e.push(Z({type:"document",source:{type:"text",data:oe(r.data),media_type:"text/plain"}},a));else if(Jt(i))e.push(Z({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:oe(r.data),media_type:i}}]}},a));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${i}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(r.type==="image"){const a=r.metadata;if(r.fileId){e.push(ot({type:"image",source:{type:"file",file_id:r.fileId}},a));continue}if(r.url){e.push(ot({type:"image",source:{type:"url",url:r.url}},a));continue}if(r.data){const i=it(r.mimeType)||"image/png";Jt(i)&&e.push(ot({type:"image",source:{type:"base64",data:oe(r.data),media_type:i}},a));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else r.type==="video"||(r.type==="text-plain"?r.data&&e.push(Z({type:"document",source:{type:"text",data:oe(r.data),media_type:"text/plain"}},r.metadata)):r.type==="non_standard"&&n&&e.push(r.value))}return e}function Kt(t){const e=xs({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let s;try{s=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
1
|
+
import{e as wn,O as Ut,f as bn,c as $t,d as xn,S as Sn,J as kn,R as Bt}from"./index-BYv53yca.js";import{bS as Tn,d4 as y,d5 as Lt,d6 as Mn,d7 as On,d8 as jt,bR as xs,bO as qt,cy as Wt,bP as vn,bQ as In,bL as N,bJ as Dt,bT as Rn,bH as ie,i as at,bK as An,bU as Cn,d9 as b,da as w,db as E,dc as Ze,dd as Mt,de as Pn,df as En}from"./index-BJaUn1y0.js";import"./index-yQ7MwS3o.js";import"./chunk-VL2OQCWN-Bq-lrj3t.js";var Ft=class extends wn{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(n){throw new Ut(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const s=await Tn(this.zodSchema,e);if(s.success)return s.data;throw new Ut(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(s.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(r=>{const{message:a}=r;return Array.isArray(a.content)?Ss(a.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[s]=e;return await this._validateResult(s.args)}};function Ss(t){const e=[];for(const s of t)s.type==="tool_use"&&e.push({name:s.name,args:s.input,id:s.id,type:"tool_call"});return e}function Nn(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}const Un=y({cache_control:On().optional().nullable(),defer_loading:Mn().optional(),input_examples:Lt(jt()).optional(),allowed_callers:Lt(jt()).optional()}),Ht={tool_search_tool_regex_20251119:"advanced-tool-use-2025-11-20",tool_search_tool_bm25_20251119:"advanced-tool-use-2025-11-20",memory_20250818:"context-management-2025-06-27",web_fetch_20250910:"web-fetch-2025-09-10",code_execution_20250825:"code-execution-2025-08-25",computer_20251124:"computer-use-2025-11-24",computer_20250124:"computer-use-2025-01-24",mcp_toolset:"mcp-client-2025-11-20"};function $n(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function Bn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function Ln(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function jn(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const qn={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=xs({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Wn=t=>t();function Dn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Fn(t){function*e(){for(const s of t)Dn(s)&&(s.source==="char"?yield{type:"char_location",file_id:s.url??"",start_char_index:s.startIndex??0,end_char_index:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="page"?yield{type:"page_location",file_id:s.url??"",start_page_number:s.startIndex??0,end_page_number:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="block"?yield{type:"content_block_location",file_id:s.url??"",start_block_index:s.startIndex??0,end_block_index:s.endIndex??0,document_title:s.title??null,document_index:0,cited_text:s.citedText??""}:s.source==="url"?yield{type:"web_search_result_location",url:s.url??"",title:s.title??null,encrypted_index:String(s.startIndex??0),cited_text:s.citedText??""}:s.source==="search"&&(yield{type:"search_result_location",title:s.title??null,start_block_index:s.startIndex??0,end_block_index:s.endIndex??0,search_result_index:0,source:s.source??"",cited_text:s.citedText??""}))}return Array.from(e())}function oe(t){return typeof t=="string"?t:Hn(t)}function Hn(t){const e=[];for(let s=0,{length:n}=t;s<n;s++)e.push(String.fromCharCode(t[s]));return btoa(e.join(""))}function it(t){return(t??"").split(";")[0].toLowerCase()}function ke(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function Z(t,e){const s=ke(e,"cache_control");s!==void 0&&(t.cache_control=s);const n=ke(e,"citations");n!==void 0&&(t.citations=n);const r=ke(e,"context");r!==void 0&&(t.context=r);const a=ke(e,"title");return a!==void 0&&(t.title=a),t}function ot(t,e){const s=ke(e,"cache_control");return s!==void 0&&(t.cache_control=s),t}function Jt(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function Jn(t){const e=[],s=t.response_metadata,n="model_provider"in s&&s?.model_provider==="anthropic";for(const r of t.contentBlocks)if(r.type==="text")r.annotations?e.push({type:"text",text:r.text,citations:Fn(r.annotations)}):e.push({type:"text",text:r.text});else if(r.type==="tool_call")e.push({type:"tool_use",id:r.id??"",name:r.name,input:r.args});else if(r.type==="tool_call_chunk"){const a=Wn(()=>{if(typeof r.args!="string")return r.args;try{return JSON.parse(r.args)}catch{return{}}});e.push({type:"tool_use",id:r.id??"",name:r.name??"",input:a})}else if(r.type==="reasoning"&&n)e.push({type:"thinking",thinking:r.reasoning,signature:String(r.signature)});else if(r.type==="server_tool_call"&&n)r.name==="web_search"?e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args}):r.name==="code_execution"&&e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args});else if(r.type==="server_tool_call_result"&&n)if(r.name==="web_search"&&Array.isArray(r.output.urls)){const a=r.output.urls.map(i=>({type:"web_search_result",title:"",encrypted_content:"",url:i}));e.push({type:"web_search_tool_result",tool_use_id:r.toolCallId??"",content:a})}else r.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:r.toolCallId??"",content:r.output}):r.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:r.toolCallId??"",content:r.output});else{if(r.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(r.type==="file"){const a=r.metadata;if(r.fileId){e.push(Z({type:"document",source:{type:"file",file_id:r.fileId}},a));continue}if(r.url){const i=it(r.mimeType);if(i==="application/pdf"||i===""){e.push(Z({type:"document",source:{type:"url",url:r.url}},a));continue}}if(r.data){const i=it(r.mimeType);if(i===""||i==="application/pdf")e.push(Z({type:"document",source:{type:"base64",data:oe(r.data),media_type:"application/pdf"}},a));else if(i==="text/plain")e.push(Z({type:"document",source:{type:"text",data:oe(r.data),media_type:"text/plain"}},a));else if(Jt(i))e.push(Z({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:oe(r.data),media_type:i}}]}},a));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${i}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(r.type==="image"){const a=r.metadata;if(r.fileId){e.push(ot({type:"image",source:{type:"file",file_id:r.fileId}},a));continue}if(r.url){e.push(ot({type:"image",source:{type:"url",url:r.url}},a));continue}if(r.data){const i=it(r.mimeType)||"image/png";Jt(i)&&e.push(ot({type:"image",source:{type:"base64",data:oe(r.data),media_type:i}},a));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else r.type==="video"||(r.type==="text-plain"?r.data&&e.push(Z({type:"document",source:{type:"text",data:oe(r.data),media_type:"text/plain"}},r.metadata)):r.type==="non_standard"&&n&&e.push(r.value))}return e}function Kt(t){const e=xs({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let s;try{s=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
2
2
|
|
|
3
3
|
`))}if(s.protocol==="http:"||s.protocol==="https:")return{type:"url",url:t};throw new Error([`Invalid image URL protocol: ${JSON.stringify(s.protocol)}. Anthropic only supports images as http, https, or base64-encoded data URLs on 'image_url' content blocks.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
4
4
|
|