@esri/solutions-components 5.1.0-next.124 → 5.1.0-next.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{EWUZF57U.js → 232XXYVJ.js} +1 -1
- package/dist/cdn/{Y6ZWXE53.js → 23LRX7AS.js} +1 -1
- package/dist/cdn/{Z25OUDBP.js → 23SGJQLW.js} +1 -1
- package/dist/cdn/2KSXH2TC.js +2 -0
- package/dist/cdn/3JZVI5AM.js +7 -0
- package/dist/cdn/{C7SMCM7E.js → 3UJAJDSF.js} +1 -1
- package/dist/cdn/{A4RZESK7.js → 3UKDJZ2D.js} +2 -2
- package/dist/cdn/{JR5GBFT2.js → 4V4CR63B.js} +1 -1
- package/dist/cdn/{ZV6TCDGB.js → 4Z6UJJJR.js} +1 -1
- package/dist/cdn/4ZUE6R22.js +2 -0
- package/dist/cdn/5AAG5ERI.js +2 -0
- package/dist/cdn/{6GSCRFFW.js → 5GHZQ66V.js} +1 -1
- package/dist/cdn/5U2GHXOV.js +2 -0
- package/dist/cdn/5UIJ4Z3C.js +2 -0
- package/dist/cdn/{6RTR35JT.js → 5XDPNTYE.js} +1 -1
- package/dist/cdn/6ID6N5BF.js +2 -0
- package/dist/cdn/6IMLSV3Z.js +2 -0
- package/dist/cdn/{K5MMGZY2.js → 6Q52JBZW.js} +1 -1
- package/dist/cdn/{4MAZNAHZ.js → 6SSQ6MIC.js} +1 -1
- package/dist/cdn/{KZBWKZOC.js → 74XF7DBP.js} +1 -1
- package/dist/cdn/75WQ7UGJ.js +2 -0
- package/dist/cdn/7CGCLEYB.js +2 -0
- package/dist/cdn/{SH72A5PB.js → 7V57GR4X.js} +1 -1
- package/dist/cdn/{D66IBZZA.js → 7ZKKR7QO.js} +1 -1
- package/dist/cdn/AL7O7ZB2.js +3 -0
- package/dist/cdn/{MYPJ63EE.js → ANVT6ANQ.js} +1 -1
- package/dist/cdn/{GWSB6X4X.js → AOJP5RQ6.js} +1 -1
- package/dist/cdn/{XQQ52NKX.js → AYSQIO6L.js} +1 -1
- package/dist/cdn/{WGEHABGS.js → B33EUN4X.js} +1 -1
- package/dist/cdn/BLCW2CZO.js +2 -0
- package/dist/cdn/{3WKKIXVT.js → BOSEAFVW.js} +1 -1
- package/dist/cdn/{CGFMGQ3A.js → BROZWKD5.js} +1 -1
- package/dist/cdn/CB7QDBRG.js +2 -0
- package/dist/cdn/CEWRVOKP.js +2 -0
- package/dist/cdn/{MOK7GNOH.js → CWXZSWUA.js} +1 -1
- package/dist/cdn/D4FRUAT3.js +2 -0
- package/dist/cdn/DQ7NBBUU.js +2 -0
- package/dist/cdn/{D5Y4JMF7.js → E4ZB3BPD.js} +1 -1
- package/dist/cdn/E5X2RW5Y.js +109 -0
- package/dist/cdn/{KGECA3WE.js → EDZIFJZR.js} +1 -1
- package/dist/cdn/{NYWKJJKK.js → EIF4KZBD.js} +1 -1
- package/dist/cdn/{B6Y3RA4F.js → ENG5BCAV.js} +1 -1
- package/dist/cdn/EOSKMSMP.js +2 -0
- package/dist/cdn/{RH47YGDG.js → EVZXWT6K.js} +1 -1
- package/dist/cdn/EXC566PM.js +2 -0
- package/dist/cdn/FOTFZKKU.js +2 -0
- package/dist/cdn/FTY7YPLA.js +88 -0
- package/dist/cdn/FW2HWQC7.js +2 -0
- package/dist/cdn/{MGAKD4WY.js → GDDMG3Q4.js} +1 -1
- package/dist/cdn/{BRBOVJ3Q.js → GPL6FNKN.js} +1 -1
- package/dist/cdn/{DUDZ4BGI.js → GSD6O5J7.js} +1 -1
- package/dist/cdn/{SSF6ST7U.js → H4YPSJ5G.js} +1 -1
- package/dist/cdn/{TTOCCH2K.js → H7J2FXMS.js} +1 -1
- package/dist/cdn/{C5QZMZX7.js → HEI6GMZN.js} +1 -1
- package/dist/cdn/{AZ4JB3M3.js → HJW2JW4G.js} +1 -1
- package/dist/cdn/HO4GBQJG.js +2 -0
- package/dist/cdn/HT2HC33W.js +2 -0
- package/dist/cdn/{IHKF4AMV.js → HYLQNC4V.js} +3 -3
- package/dist/cdn/HZOBBQYW.js +431 -0
- package/dist/cdn/ICSHJV2N.js +2 -0
- package/dist/cdn/IFI66PVI.js +2 -0
- package/dist/cdn/{YFXSWGXE.js → IHG7KTNC.js} +1 -1
- package/dist/cdn/IP3VJ34C.js +4 -0
- package/dist/cdn/IV7RVOFY.js +56 -0
- package/dist/cdn/{3UIIZPJJ.js → IYQGIBWM.js} +1 -1
- package/dist/cdn/{JFJRHOAG.js → KCTWFRCW.js} +1 -1
- package/dist/cdn/{F64NVBUS.js → KEOBSFBN.js} +1 -1
- package/dist/cdn/{N2KSPEVT.js → LP2JYX4X.js} +1 -1
- package/dist/cdn/{C4IFGE7P.js → MDNGEZ2V.js} +1 -1
- package/dist/cdn/{XVMCFCUH.js → MEDCFXMB.js} +1 -1
- package/dist/cdn/{X6JL6SAH.js → MOH6GREK.js} +1 -1
- package/dist/cdn/MURYADCX.js +2 -0
- package/dist/cdn/{JBNWEBAG.js → N22MFQSQ.js} +1 -1
- package/dist/cdn/N5D5ABJ6.js +2 -0
- package/dist/cdn/{5HZMUGQD.js → N7BXCDA3.js} +1 -1
- package/dist/cdn/{SGJY2CP3.js → ODB4CELR.js} +1 -1
- package/dist/cdn/PZW6JMSM.js +2 -0
- package/dist/cdn/{5MVIKBSS.js → QF2IXVAT.js} +1 -1
- package/dist/cdn/{CQRK2NYK.js → QJICQ4W3.js} +1 -1
- package/dist/cdn/QNRKGTZT.js +121 -0
- package/dist/cdn/{GIANH6D4.js → R3C2X4CM.js} +1 -1
- package/dist/cdn/{DKB6JTUF.js → RKZXRHZK.js} +1 -1
- package/dist/cdn/RPEQD2MH.js +2 -0
- package/dist/cdn/{SMNWKCWR.js → RXM4BHPK.js} +1 -1
- package/dist/cdn/S5F6KJQM.js +18 -0
- package/dist/cdn/SFFLZSAY.js +2 -0
- package/dist/cdn/SSH4MSHE.js +2 -0
- package/dist/cdn/{BQVD2BBH.js → SSZBIVTK.js} +1 -1
- package/dist/cdn/{EZ4DX2MW.js → TFTW5B3R.js} +1 -1
- package/dist/cdn/{I74AIIHN.js → TIF36KTA.js} +1 -1
- package/dist/cdn/TV3ZHJ7B.js +2 -0
- package/dist/cdn/{U6JZYJ4D.js → UM3P3Q52.js} +1 -1
- package/dist/cdn/{WH2NFOMH.js → UUHDVB24.js} +5 -5
- package/dist/cdn/UY5JVVRO.js +2 -0
- package/dist/cdn/VEDAG7UO.js +2 -0
- package/dist/cdn/VFBFI3KQ.js +2 -0
- package/dist/cdn/{BXOH6SN4.js → VTI5LEQY.js} +1 -1
- package/dist/cdn/W5FWW67G.js +2 -0
- package/dist/cdn/{RB3YU5TX.js → WA3BLQHA.js} +1 -1
- package/dist/cdn/{JEEUSHAF.js → X73XP424.js} +1 -1
- package/dist/cdn/XC3IZAIH.js +2 -0
- package/dist/cdn/{3FOUGCWY.js → XDZPQACK.js} +1 -1
- package/dist/cdn/XGODSNWZ.js +2 -0
- package/dist/cdn/{UNKHKP5I.js → YJCH2NIS.js} +1 -1
- package/dist/cdn/{A4NILC27.js → YKM2YRZP.js} +1 -1
- package/dist/cdn/{FBRYBN7J.js → YMLQXXAS.js} +1 -1
- package/dist/cdn/{JUUVYK2H.js → YQHYMLC7.js} +1 -1
- package/dist/cdn/{Y3CYPNEY.js → YWXDNRE2.js} +1 -1
- package/dist/cdn/{E4GB5Z4R.js → ZNWZWFMH.js} +1 -1
- package/dist/cdn/{DGUS2OKW.js → ZS3UOY5Q.js} +1 -1
- package/dist/cdn/{5VDDAINK.js → ZX3UHK6P.js} +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/Auth.js +163 -71
- package/dist/chunks/CardsFetcher.js +3 -2
- package/dist/chunks/getRelatedInfos.js +1 -1
- package/dist/chunks/helpers.js +24 -20
- package/dist/chunks/interfaces.js +152 -141
- package/dist/chunks/solution-deploy-dialog.js +24 -18
- package/dist/chunks/solutions-deploy-app-nav.js +4 -5
- package/dist/components/arcgis-solutions-assistant/customElement.js +681 -57987
- package/dist/components/consent-manager/customElement.js +23 -3598
- package/dist/components/solution-builder-assistant/customElement.d.ts +8 -2
- package/dist/components/solution-builder-assistant/customElement.js +30 -23
- package/dist/components/solution-builder-assistant/index.js +1 -1
- package/dist/components/solution-configure-titles/customElement.js +63 -61
- package/dist/components/solution-delete-dialog/customElement.js +17 -14
- package/dist/components/solution-deployed-card/customElement.js +2 -3
- package/dist/components/solution-deployed-card-panel/customElement.d.ts +7 -0
- package/dist/components/solution-deployed-card-panel/customElement.js +34 -32
- package/dist/components/solution-deployed-card-panel/index.js +1 -0
- package/dist/components/solution-details-panel/customElement.d.ts +7 -4
- package/dist/components/solution-details-panel/customElement.js +115 -180
- package/dist/components/solution-snapshot-gallery/customElement.js +2 -1
- package/dist/components/solution-social-share/customElement.js +2 -2
- package/dist/components/solution-user-avatar/customElement.js +1 -1
- package/dist/components/solutions-deploy-app/customElement.d.ts +4 -0
- package/dist/components/solutions-deploy-app/customElement.js +14 -11
- package/dist/components/solutions-deploy-app-nav/customElement.js +2 -3
- package/dist/components/solutions-deployed-list/customElement.js +7 -6
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +3 -3
- package/dist/solutions-components_commit.txt +5 -8
- package/dist/types/lumina.d.ts +3 -3
- package/dist/types/preact.d.ts +3 -3
- package/dist/types/react.d.ts +3 -3
- package/dist/types/stencil.d.ts +3 -3
- package/dist/utils/Auth.d.ts +11 -0
- package/package.json +11 -6
- package/dist/cdn/2V4C3U3A.js +0 -2
- package/dist/cdn/3RUVSQ7E.js +0 -2
- package/dist/cdn/4FZ44STD.js +0 -2
- package/dist/cdn/52KL2BJB.js +0 -2
- package/dist/cdn/5DS6TJ6G.js +0 -2
- package/dist/cdn/5ZIXJCIR.js +0 -18
- package/dist/cdn/62PVXXRD.js +0 -2
- package/dist/cdn/7JUP4GFU.js +0 -2
- package/dist/cdn/7UERL2R2.js +0 -2
- package/dist/cdn/7WKV6M26.js +0 -2
- package/dist/cdn/BKZZ625R.js +0 -2
- package/dist/cdn/BWYFMFIB.js +0 -423
- package/dist/cdn/CQKON2YR.js +0 -2
- package/dist/cdn/F2J3FYTD.js +0 -2
- package/dist/cdn/GVEIFIEZ.js +0 -2
- package/dist/cdn/H5WTVMPJ.js +0 -2
- package/dist/cdn/HNZAE56I.js +0 -2
- package/dist/cdn/HQJ25PBT.js +0 -2
- package/dist/cdn/IF52R2FM.js +0 -2
- package/dist/cdn/IOKTYFKK.js +0 -7
- package/dist/cdn/IRRMUFW7.js +0 -2
- package/dist/cdn/JFKCARWJ.js +0 -2
- package/dist/cdn/K7QUGRWR.js +0 -4
- package/dist/cdn/MN3KMBU6.js +0 -2
- package/dist/cdn/MNZJP3PW.js +0 -2
- package/dist/cdn/MPZE3IV4.js +0 -2
- package/dist/cdn/QKKYYRVF.js +0 -2
- package/dist/cdn/QTV6GN3W.js +0 -2
- package/dist/cdn/QVJAIVT4.js +0 -2
- package/dist/cdn/RPEBBYE4.js +0 -2
- package/dist/cdn/RXFNNWEJ.js +0 -2
- package/dist/cdn/SBLN3F4Y.js +0 -2
- package/dist/cdn/STWIOVJR.js +0 -2
- package/dist/cdn/TUQVCY7T.js +0 -2
- package/dist/cdn/UM4ITZ4R.js +0 -2
- package/dist/cdn/VFEROJ77.js +0 -2
- package/dist/cdn/VL4OP3CF.js +0 -2
- package/dist/cdn/YNOD3Q5G.js +0 -2
- package/dist/cdn/ZPT5ISDK.js +0 -2
- package/dist/chunks/common.js +0 -26
- package/dist/chunks/get.js +0 -387
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{b as va,c as $n,d as $l}from"./QPIMTXPL.js";var bI=va((YH,kg)=>{"use strict";var C4=Object.prototype.hasOwnProperty,Jt="~";function Lc(){}Object.create&&(Lc.prototype=Object.create(null),new Lc().__proto__||(Jt=!1));function O4(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function vI(e,t,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new O4(r,i||e,n),o=Jt?Jt+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],a]:e._events[o].push(a):(e._events[o]=a,e._eventsCount++),e}function kd(e,t){--e._eventsCount===0?e._events=new Lc:delete e._events[t]}function Nt(){this._events=new Lc,this._eventsCount=0}Nt.prototype.eventNames=function(){var t=[],r,i;if(this._eventsCount===0)return t;for(i in r=this._events)C4.call(r,i)&&t.push(Jt?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Nt.prototype.listeners=function(t){var r=Jt?Jt+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,o=new Array(a);n<a;n++)o[n]=i[n].fn;return o};Nt.prototype.listenerCount=function(t){var r=Jt?Jt+t:t,i=this._events[r];return i?i.fn?1:i.length:0};Nt.prototype.emit=function(t,r,i,n,a,o){var s=Jt?Jt+t:t;if(!this._events[s])return!1;var c=this._events[s],u=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,i),!0;case 4:return c.fn.call(c.context,r,i,n),!0;case 5:return c.fn.call(c.context,r,i,n,a),!0;case 6:return c.fn.call(c.context,r,i,n,a,o),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,i);break;case 4:c[d].fn.call(c[d].context,r,i,n);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[d].fn.apply(c[d].context,l)}}return!0};Nt.prototype.on=function(t,r,i){return vI(this,t,r,i,!1)};Nt.prototype.once=function(t,r,i){return vI(this,t,r,i,!0)};Nt.prototype.removeListener=function(t,r,i,n){var a=Jt?Jt+t:t;if(!this._events[a])return this;if(!r)return kd(this,a),this;var o=this._events[a];if(o.fn)o.fn===r&&(!n||o.once)&&(!i||o.context===i)&&kd(this,a);else{for(var s=0,c=[],u=o.length;s<u;s++)(o[s].fn!==r||n&&!o[s].once||i&&o[s].context!==i)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:kd(this,a)}return this};Nt.prototype.removeAllListeners=function(t){var r;return t?(r=Jt?Jt+t:t,this._events[r]&&kd(this,r)):(this._events=new Lc,this._eventsCount=0),this};Nt.prototype.off=Nt.prototype.removeListener;Nt.prototype.addListener=Nt.prototype.on;Nt.prefixed=Jt;Nt.EventEmitter=Nt;typeof kg<"u"&&(kg.exports=Nt)});var xI=va((QH,wI)=>{"use strict";wI.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(i=>{i(t())}).then(()=>r),r=>new Promise(i=>{i(t())}).then(()=>{throw r})))});var kI=va((eG,Id)=>{"use strict";var P4=xI(),$d=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},SI=(e,t,r)=>new Promise((i,n)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){i(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{i(r())}catch(c){n(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new $d(o);typeof e.cancel=="function"&&e.cancel(),n(s)},t);P4(e.then(i,n),()=>{clearTimeout(a)})});Id.exports=SI;Id.exports.default=SI;Id.exports.TimeoutError=$d});var $I=va($g=>{"use strict";Object.defineProperty($g,"__esModule",{value:!0});function N4(e,t,r){let i=0,n=e.length;for(;n>0;){let a=n/2|0,o=i+a;r(e[o],t)<=0?(i=++o,n-=a+1):n=a}return i}$g.default=N4});var II=va(Eg=>{"use strict";Object.defineProperty(Eg,"__esModule",{value:!0});var R4=$I(),Ig=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let i={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(i);return}let n=R4.default(this._queue,i,(a,o)=>o.priority-a.priority);this._queue.splice(n,0,i)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};Eg.default=Ig});var Td=va(Ag=>{"use strict";Object.defineProperty(Ag,"__esModule",{value:!0});var M4=bI(),EI=kI(),j4=II(),Ed=()=>{},z4=new EI.TimeoutError,Tg=class extends M4{constructor(t){var r,i,n,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Ed,this._resolveIdle=Ed,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:j4.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(n=t.interval)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Ed,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Ed,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((i,n)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?t():EI.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(z4)});i(await o)}catch(o){n(o)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async i=>this.add(i,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};Ag.default=Tg});var gO=va(Ap=>{"use strict";Ap.byteLength=P6;Ap.toByteArray=R6;Ap.fromByteArray=z6;var Hn=[],Gr=[],O6=typeof Uint8Array<"u"?Uint8Array:Array,Sw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(xo=0,mO=Sw.length;xo<mO;++xo)Hn[xo]=Sw[xo],Gr[Sw.charCodeAt(xo)]=xo;var xo,mO;Gr[45]=62;Gr[95]=63;function hO(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function P6(e){var t=hO(e),r=t[0],i=t[1];return(r+i)*3/4-i}function N6(e,t,r){return(t+r)*3/4-r}function R6(e){var t,r=hO(e),i=r[0],n=r[1],a=new O6(N6(e,i,n)),o=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)t=Gr[e.charCodeAt(c)]<<18|Gr[e.charCodeAt(c+1)]<<12|Gr[e.charCodeAt(c+2)]<<6|Gr[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return n===2&&(t=Gr[e.charCodeAt(c)]<<2|Gr[e.charCodeAt(c+1)]>>4,a[o++]=t&255),n===1&&(t=Gr[e.charCodeAt(c)]<<10|Gr[e.charCodeAt(c+1)]<<4|Gr[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function M6(e){return Hn[e>>18&63]+Hn[e>>12&63]+Hn[e>>6&63]+Hn[e&63]}function j6(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),n.push(M6(i));return n.join("")}function z6(e){for(var t,r=e.length,i=r%3,n=[],a=16383,o=0,s=r-i;o<s;o+=a)n.push(j6(e,o,o+a>s?s:o+a));return i===1?(t=e[r-1],n.push(Hn[t>>2]+Hn[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(Hn[t>>10]+Hn[t>>4&63]+Hn[t<<2&63]+"=")),n.join("")}});var Ze="__start__",Ye="__end__",In="__input__";var Mo="__error__",Il="__pregel_ns_writes",Rr="__pregel_send",jo="__pregel_call",Yr="__pregel_read",Qr="__pregel_checkpointer",zo="__pregel_resuming",wc="__pregel_task_id",xc="__pregel_stream",pM="__pregel_resume_value",Do="__pregel_resume_map",ir="__pregel_scratchpad",wa="__pregel_previous",mM="__pregel_durability",El="checkpoint_id",Mr="checkpoint_ns",bS="__pregel_node_finished",jr="checkpoint_map",wS="__pregel_abort_signals",Ue="__interrupt__",gr="__resume__",Sc="__no_writes__",Ci="__return__",xa="__previous__",lt="langsmith:hidden";var mh="__self__",En="__pregel_tasks",zr="__pregel_push",Tl="__pregel_pull",_r="00000000-0000-0000-0000-000000000000",xS=[lt,In,Ue,gr,Mo,Sc,Rr,Yr,Qr,mM,xc,zo,wc,jo,pM,ir,wa,jr,Mr,El],ph=Symbol.for("langgraph.command"),SS=class{[ph];constructor(e){this[ph]=e}};function Al(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var ba=class{lg_name="Send";node;args;constructor(e,t){this.node=e,this.args=bc(t)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function dt(e){return e instanceof ba}var Ro="__overwrite__",hM=class{lg_name="Overwrite";[Ro];constructor(e){this[Ro]=e}get value(){return this[Ro]}toJSON(){return{[Ro]:this[Ro]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function Cl(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[Ro]]:[!1,void 0]}function kS(e){return Cl(e)[0]}function Sa(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[Ue])}var nr=class extends SS{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(e){super(e),this.resume=e.resume,this.graph=e.graph,this.update=e.update,e.goto&&(this.goto=Array.isArray(e.goto)?bc(e.goto):[bc(e.goto)])}_updateAsTuples(){return this.update&&typeof this.update=="object"&&!Array.isArray(this.update)?Object.entries(this.update):Array.isArray(this.update)&&this.update.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string")?this.update:[["__root__",this.update]]}toJSON(){let e;return typeof this.goto=="string"?e=this.goto:dt(this.goto)?e=this.goto.toJSON():e=this.goto?.map(t=>typeof t=="string"?t:t.toJSON()),{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:e}}};function ht(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function bc(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let r;if(Array.isArray(e))r=[],t.set(e,r),e.forEach((i,n)=>{r[n]=bc(i,t)});else if(ht(e)&&!(e instanceof nr))r=new nr(e),t.set(e,r);else if(Al(e)&&!(e instanceof ba))r=new ba(e.node,e.args),t.set(e,r);else if(ht(e)||dt(e))r=e,t.set(e,r);else if("lc_serializable"in e&&e.lc_serializable)r=e,t.set(e,r);else{r={},t.set(e,r);for(let[i,n]of Object.entries(e))r[i]=bc(n,t)}return r}return e}var en=class extends Error{lc_error_code;constructor(e,t){let r=e??"";t?.lc_error_code&&(r=`${r}
|
|
3
|
+
|
|
4
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
|
|
5
|
+
`),super(r),this.lc_error_code=t?.lc_error_code}},hh=class extends en{get is_bubble_up(){return!0}},gh=class extends en{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},ka=class extends en{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},ti=class extends hh{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},Ol=class extends ti{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},Pl=class extends hh{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function _h(e){return e!==void 0&&e.name===Pl.unminifiable_name}function $a(e){return e!==void 0&&e.is_bubble_up===!0}function ri(e){return e!==void 0&&[ti.unminifiable_name,Ol.unminifiable_name].includes(e.name)}var Nl=class extends en{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Ne=class extends en{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},be=class extends en{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},gM=class extends en{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},yh=class extends en{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},_M=class extends en{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},kc=class extends en{constructor(e,t){super(e,t),this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}},yM=()=>(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]===void 0&&(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]=new Set),globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]);var $S=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function vM(e){return typeof e=="string"&&$S.test(e)}var Uo=vM;function bM(e){if(!Uo(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var Rl=bM;var $t=[];for(Ml=0;Ml<256;++Ml)$t.push((Ml+256).toString(16).slice(1));var Ml;function Tn(e,t=0){return($t[e[t+0]]+$t[e[t+1]]+$t[e[t+2]]+$t[e[t+3]]+"-"+$t[e[t+4]]+$t[e[t+5]]+"-"+$t[e[t+6]]+$t[e[t+7]]+"-"+$t[e[t+8]]+$t[e[t+9]]+"-"+$t[e[t+10]]+$t[e[t+11]]+$t[e[t+12]]+$t[e[t+13]]+$t[e[t+14]]+$t[e[t+15]]).toLowerCase()}var jl,wM=new Uint8Array(16);function $c(){if(!jl&&(jl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!jl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jl(wM)}var vh,zl,bh=0,wh=0;function xM(e,t,r){var i=t&&r||0,n=t||new Array(16);e=e||{};var a=e.node,o=e.clockseq;if(e._v6||(a||(a=vh),o==null&&(o=zl)),a==null||o==null){var s=e.random||(e.rng||$c)();a==null&&(a=[s[0],s[1],s[2],s[3],s[4],s[5]],!vh&&!e._v6&&(a[0]|=1,vh=a)),o==null&&(o=(s[6]<<8|s[7])&16383,zl===void 0&&!e._v6&&(zl=o))}var c=e.msecs!==void 0?e.msecs:Date.now(),u=e.nsecs!==void 0?e.nsecs:wh+1,l=c-bh+(u-wh)/1e4;if(l<0&&e.clockseq===void 0&&(o=o+1&16383),(l<0||c>bh)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");bh=c,wh=u,zl=o,c+=122192928e5;var d=((c&268435455)*1e4+u)%4294967296;n[i++]=d>>>24&255,n[i++]=d>>>16&255,n[i++]=d>>>8&255,n[i++]=d&255;var f=c/4294967296*1e4&268435455;n[i++]=f>>>8&255,n[i++]=f&255,n[i++]=f>>>24&15|16,n[i++]=f>>>16&255,n[i++]=o>>>8|128,n[i++]=o&255;for(var p=0;p<6;++p)n[i+p]=a[p];return t||Tn(n)}var IS=xM;function xh(e){var t=typeof e=="string"?Rl(e):e,r=SM(t);return typeof e=="string"?Tn(r):r}function SM(e,t=!1){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function kM(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var $M="6ba7b810-9dad-11d1-80b4-00c04fd430c8",IM="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Sh(e,t,r){function i(n,a,o,s){var c;if(typeof n=="string"&&(n=kM(n)),typeof a=="string"&&(a=Rl(a)),((c=a)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+n.length);if(u.set(a),u.set(n,a.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){s=s||0;for(var l=0;l<16;++l)o[s+l]=u[l];return o}return Tn(u)}try{i.name=e}catch{}return i.DNS=$M,i.URL=IM,i}var EM=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kh={randomUUID:EM};function TM(e,t,r){if(kh.randomUUID&&!t&&!e)return kh.randomUUID();e=e||{};var i=e.random||(e.rng||$c)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(var n=0;n<16;++n)t[r+n]=i[n];return t}return Tn(i)}var Dl=TM;function AM(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function $h(e,t){return e<<t|e>>>32-t}function CM(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var i=unescape(encodeURIComponent(e));e=[];for(var n=0;n<i.length;++n)e.push(i.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=new Array(o),c=0;c<o;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[c*64+l*4]<<24|e[c*64+l*4+1]<<16|e[c*64+l*4+2]<<8|e[c*64+l*4+3];s[c]=u}s[o-1][14]=(e.length-1)*8/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=$h(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var g=r[0],y=r[1],b=r[2],w=r[3],x=r[4],k=0;k<80;++k){var E=Math.floor(k/20),V=$h(g,5)+AM(E,y,b,w)+x+t[E]+f[k]>>>0;x=w,w=b,b=$h(y,30)>>>0,y=g,g=V}r[0]=r[0]+g>>>0,r[1]=r[1]+y>>>0,r[2]=r[2]+b>>>0,r[3]=r[3]+w>>>0,r[4]=r[4]+x>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var ES=CM;var OM=Sh("v5",80,ES),Ih=OM;function TS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function AS(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?TS(Object(r),!0).forEach(function(i){PM(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):TS(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function PM(e,t,r){return(t=NM(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function NM(e){var t=RM(e,"string");return typeof t=="symbol"?t:t+""}function RM(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ul(e={},t,r=0){var i=IS(AS(AS({},e),{},{_v6:!0}),new Uint8Array(16));if(i=xh(i),t){for(var n=0;n<16;n++)t[r+n]=i[n];return t}return Tn(i)}function Ic(e){return Ul({clockseq:e})}function ni(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(i=>parseInt(i,16));return Ih(e,new Uint8Array(r))}var Ec="__pregel_tasks",Eh="__error__",Ia="__scheduled__",Th="__interrupt__",Ah="__resume__";var CS="[...]",MM="[Circular]",Ll=[],Lo=[];function jM(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function OS(e,t,r,i){typeof i>"u"&&(i=jM()),Oh(e,"",0,[],void 0,0,i);var n;try{Lo.length===0?n=JSON.stringify(e,t,r):n=JSON.stringify(e,zM(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ll.length!==0;){var a=Ll.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return n}function Ch(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),Ll.push([i,r,t,n])):Lo.push([t,r,e]):(i[r]=e,Ll.push([i,r,t]))}function Oh(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Ch(MM,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Ch(CS,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Ch(CS,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Oh(e[s],s,s,i,e,a,o);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];Oh(e[u],u,s,i,e,a,o)}}i.pop()}}function zM(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Lo.length>0)for(var i=0;i<Lo.length;i++){var n=Lo[i];if(n[1]===t&&n[0]===r){r=n[2],Lo.splice(i,1);break}}return e.call(this,t,r)}}var DM=/([A-Z]+)([A-Z][a-z0-9]+)/g,UM=/([a-z0-9])([A-Z])/g,PS=/[-_\s]+/g;function LM(e){return e.replace(DM,"$1_$2").replace(UM,"$1_$2").replace(PS,"_").toLowerCase()}function FM(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(PS,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,i)=>i.toUpperCase()):t}function NS(e,t){return t?.[e]||LM(e)}function RS(e,t){return t?.[e]||FM(e)}function Fl(e,t,r){let i={};for(let n in e)Object.hasOwn(e,n)&&(i[t(n,r)]=e[n]);return i}var MS="__lc_escaped__";function BM(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function VM(e){return{[MS]:e}}function Ph(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function ZM(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function HM(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function Bl(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return HM(e);if(ZM(e))return e;t.add(e);let r=e;if(BM(r))return t.delete(e),VM(r);let i={};for(let[n,a]of Object.entries(r))i[n]=Bl(a,t);return t.delete(e),i}return Array.isArray(e)?e.map(r=>Bl(r,t)):e}function Vl(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(Ph(t))return t[MS];let r={};for(let[i,n]of Object.entries(t))r[i]=Vl(n);return r}return Array.isArray(e)?e.map(t=>Vl(t)):e}var jS=Object.defineProperty,A=(e,t)=>{let r={};for(var i in e)jS(r,i,{get:e[i],enumerable:!0});return t||jS(r,Symbol.toStringTag,{value:"Module"}),r};var DS=A({Serializable:()=>ut,get_lc_unique_name:()=>Fo});function zS(e){return Array.isArray(e)?[...e]:{...e}}function GM(e,t){let r=zS(e);for(let[i,n]of Object.entries(t)){let[a,...o]=i.split(".").reverse(),s=r;for(let c of o.reverse()){if(s[c]===void 0)break;s[c]=zS(s[c]),s=s[c]}s[a]!==void 0&&(s[a]={lc:1,type:"secret",id:[n]})}return r}function Fo(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var ut=class US{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Fo(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([i])=>this.lc_serializable_keys?.includes(i))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof US||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},i=Object.keys(this.lc_kwargs).reduce((s,c)=>(s[c]=c in this?this[c]:this.lc_kwargs[c],s),{});for(let s=Object.getPrototypeOf(this);s;s=Object.getPrototypeOf(s))Object.assign(t,Reflect.get(s,"lc_aliases",this)),Object.assign(r,Reflect.get(s,"lc_secrets",this)),Object.assign(i,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,u=i,[l,...d]=s.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in u)||u[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?u[f]={}:Array.isArray(c[f])&&(u[f]=[])),c=c[f],u=u[f]}l in c&&c[l]!==void 0&&(u[l]=u[l]||c[l])});let n={},a=new WeakSet;a.add(this);for(let[s,c]of Object.entries(i))n[s]=Bl(c,a);let o=Fl(Object.keys(r).length?GM(n,r):n,NS,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var LS=A({getEnv:()=>HS,getEnvironmentVariable:()=>Ht,getRuntimeEnvironment:()=>Rh,isBrowser:()=>FS,isDeno:()=>Zl,isJsDom:()=>VS,isNode:()=>ZS,isWebWorker:()=>BS}),FS=()=>typeof window<"u"&&typeof window.document<"u",BS=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",VS=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),Zl=()=>typeof Deno<"u",ZS=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!Zl(),HS=()=>{let e;return FS()?e="browser":ZS()?e="node":BS()?e="webworker":VS()?e="jsdom":Zl()?e="deno":e="other",e},Nh;function Rh(){return Nh===void 0&&(Nh={library:"langchain-js",runtime:HS()}),Nh}function Ht(e){try{return typeof process<"u"?process.env?.[e]:Zl()?Deno?.env.get(e):void 0}catch{return}}var GS=[];var JS=A({});var KS=A({});var ee="0123456789abcdef".split(""),JM=[-2147483648,8388608,32768,128],tn=[24,16,8,0],Hl=[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],vt=[];function rn(e,t){t?(vt[0]=vt[16]=vt[1]=vt[2]=vt[3]=vt[4]=vt[5]=vt[6]=vt[7]=vt[8]=vt[9]=vt[10]=vt[11]=vt[12]=vt[13]=vt[14]=vt[15]=0,this.blocks=vt):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}rn.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var i,n=0,a,o=e.length,s=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,this.block=s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)for(a=this.start;n<o&&a<64;++n)s[a>>>2]|=e[n]<<tn[a++&3];else for(a=this.start;n<o&&a<64;++n)i=e.charCodeAt(n),i<128?s[a>>>2]|=i<<tn[a++&3]:i<2048?(s[a>>>2]|=(192|i>>>6)<<tn[a++&3],s[a>>>2]|=(128|i&63)<<tn[a++&3]):i<55296||i>=57344?(s[a>>>2]|=(224|i>>>12)<<tn[a++&3],s[a>>>2]|=(128|i>>>6&63)<<tn[a++&3],s[a>>>2]|=(128|i&63)<<tn[a++&3]):(i=65536+((i&1023)<<10|e.charCodeAt(++n)&1023),s[a>>>2]|=(240|i>>>18)<<tn[a++&3],s[a>>>2]|=(128|i>>>12&63)<<tn[a++&3],s[a>>>2]|=(128|i>>>6&63)<<tn[a++&3],s[a>>>2]|=(128|i&63)<<tn[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=s[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};rn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=JM[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};rn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,u,l,d,f,p,m,g,y,b,w,x;for(u=16;u<64;++u)p=c[u-15],l=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[u-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(x=t&r,u=0;u<64;u+=4)this.first?(this.is224?(y=300032,p=c[0]-1413257819,s=p-150054599<<0,i=p+24177077<<0):(y=704751109,p=c[0]-210244248,s=p-1521486534<<0,i=p+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),y=e&t,f=y^e&r^x,g=n&a^~n&o,p=s+d+g+Hl[u]+c[u],m=l+f,s=i+p<<0,i=p+m<<0),l=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=i&e,f=b^i&t^y,g=o&s^~o&n,p=a+d+g+Hl[u+1]+c[u+1],m=l+f,o=r+p<<0,r=p+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=r&i,f=w^r&e^b,g=a&o^~a&s,p=n+d+g+Hl[u+2]+c[u+2],m=l+f,a=t+p<<0,t=p+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),x=t&r,f=x^t&i^w,g=a&o^~a&s,p=n+d+g+Hl[u+3]+c[u+3],m=l+f,n=e+p<<0,e=p+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+i<<0,this.h4=this.h4+n<<0,this.h5=this.h5+a<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};rn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=ee[e>>>28&15]+ee[e>>>24&15]+ee[e>>>20&15]+ee[e>>>16&15]+ee[e>>>12&15]+ee[e>>>8&15]+ee[e>>>4&15]+ee[e&15]+ee[t>>>28&15]+ee[t>>>24&15]+ee[t>>>20&15]+ee[t>>>16&15]+ee[t>>>12&15]+ee[t>>>8&15]+ee[t>>>4&15]+ee[t&15]+ee[r>>>28&15]+ee[r>>>24&15]+ee[r>>>20&15]+ee[r>>>16&15]+ee[r>>>12&15]+ee[r>>>8&15]+ee[r>>>4&15]+ee[r&15]+ee[i>>>28&15]+ee[i>>>24&15]+ee[i>>>20&15]+ee[i>>>16&15]+ee[i>>>12&15]+ee[i>>>8&15]+ee[i>>>4&15]+ee[i&15]+ee[n>>>28&15]+ee[n>>>24&15]+ee[n>>>20&15]+ee[n>>>16&15]+ee[n>>>12&15]+ee[n>>>8&15]+ee[n>>>4&15]+ee[n&15]+ee[a>>>28&15]+ee[a>>>24&15]+ee[a>>>20&15]+ee[a>>>16&15]+ee[a>>>12&15]+ee[a>>>8&15]+ee[a>>>4&15]+ee[a&15]+ee[o>>>28&15]+ee[o>>>24&15]+ee[o>>>20&15]+ee[o>>>16&15]+ee[o>>>12&15]+ee[o>>>8&15]+ee[o>>>4&15]+ee[o&15];return this.is224||(c+=ee[s>>>28&15]+ee[s>>>24&15]+ee[s>>>20&15]+ee[s>>>16&15]+ee[s>>>12&15]+ee[s>>>8&15]+ee[s>>>4&15]+ee[s&15]),c};rn.prototype.toString=rn.prototype.hex;rn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};rn.prototype.array=rn.prototype.digest;rn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};var Bo=(...e)=>new rn(!1,!0).update(e.join("")).hex();var WS=A({sha256:()=>Bo});function qS(e){let t=Symbol.for(e);return{brand(r,i){let n=i?Symbol.for(`${e}.${i}`):t;class a extends r{[n]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&n in s&&s[n]===!0}}return Object.defineProperty(a,"name",{value:r.name}),a},sub(r){return qS(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var XS=qS("langchain");var YS=A({ContextOverflowError:()=>KM,LangChainError:()=>Mh,ModelAbortError:()=>Jl,addLangChainErrorFields:()=>ii,ns:()=>Gl});function ii(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
6
|
+
|
|
7
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
8
|
+
`,e}var Gl=XS.sub("error"),Mh=class extends Gl.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Jl=class extends Gl.brand(Mh,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},KM=class QS extends Gl.brand(Mh,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new QS(t.message);return r.cause=t,r}};function An(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function Vo(e){return An(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Zo(e){return An(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function ek(e){return An(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function Kl(e){return An(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function Wl(e){if(An(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function tk(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),i=t[1].trim();if(r===""||i==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let n={};for(let a of e.split(";").slice(1)){let o=a.split("=");if(o.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=o[0].trim(),c=o[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);n[s]=c}return{type:r,subtype:i,parameters:n}}function Tc({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),i;if(r){i=r[1].toLowerCase();let n=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:i,data:n}}}function rk(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function K(e,t){return te(e)&&e.type===t}function te(e){return typeof e=="object"&&e!==null}function gt(e){return Array.isArray(e)}function P(e){return typeof e=="string"}function yr(e){return typeof e=="number"}function ql(e){return e instanceof Uint8Array}function jh(e){try{return JSON.parse(e)}catch{return}}var vr=e=>e();function WM(e){if(e.type==="char_location"&&P(e.document_title)&&yr(e.start_char_index)&&yr(e.end_char_index)&&P(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="page_location"&&P(e.document_title)&&yr(e.start_page_number)&&yr(e.end_page_number)&&P(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="content_block_location"&&P(e.document_title)&&yr(e.start_block_index)&&yr(e.end_block_index)&&P(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="web_search_result_location"&&P(e.url)&&P(e.title)&&P(e.encrypted_index)&&P(e.cited_text)){let{url:t,title:r,encrypted_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(i),endIndex:Number(i),citedText:n}}if(e.type==="search_result_location"&&P(e.source)&&P(e.title)&&yr(e.start_block_index)&&yr(e.end_block_index)&&P(e.cited_text)){let{source:t,title:r,start_block_index:i,end_block_index:n,cited_text:a,...o}=e;return{...o,type:"citation",source:"search",url:t,title:r??void 0,startIndex:i,endIndex:n,citedText:a}}}function ik(e){if(K(e,"document")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&P(e.source.media_type)&&P(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&P(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&P(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&P(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(K(e,"image")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&P(e.source.media_type)&&P(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&P(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&P(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function ak(e){function*t(){for(let r of e){let i=ik(r);i?yield i:yield r}}return Array.from(t())}function nk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"text")&&P(i.text)){let{text:n,citations:a,...o}=i;if(gt(a)&&a.length){let s=a.reduce((c,u)=>{let l=WM(u);return l?[...c,l]:c},[]);yield{...o,type:"text",text:n,annotations:s};continue}else{yield{...o,type:"text",text:n};continue}}else if(K(i,"thinking")&&P(i.thinking)){let{thinking:n,signature:a,...o}=i;yield{...o,type:"reasoning",reasoning:n,signature:a};continue}else if(K(i,"redacted_thinking")){yield{type:"non_standard",value:i};continue}else if(K(i,"tool_use")&&P(i.name)&&P(i.id)){yield{type:"tool_call",id:i.id,name:i.name,args:i.input};continue}else if(K(i,"input_json_delta")){if(qM(e)&&e.tool_call_chunks?.length){let n=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:n.id,name:n.name,args:n.args,index:n.index};continue}}else if(K(i,"server_tool_use")&&P(i.name)&&P(i.id)){let{name:n,id:a}=i;if(n==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:vr(()=>{if(typeof i.input=="string")return i.input;if(te(i.input)&&P(i.input.query))return i.input.query;if(P(i.partial_json)){let o=jh(i.partial_json);if(o?.query)return o.query}return""})}};continue}else if(i.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:vr(()=>{if(typeof i.input=="string")return i.input;if(te(i.input)&&P(i.input.code))return i.input.code;if(P(i.partial_json)){let o=jh(i.partial_json);if(o?.code)return o.code}return""})}};continue}}else if(K(i,"web_search_tool_result")&&P(i.tool_use_id)&>(i.content)){let{content:n,tool_use_id:a}=i;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:n.reduce((o,s)=>K(s,"web_search_result")?[...o,s.url]:o,[])}};continue}else if(K(i,"code_execution_tool_result")&&P(i.tool_use_id)&&te(i.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(K(i,"mcp_tool_use")){yield{id:i.id,type:"server_tool_call",name:"mcp_tool_use",args:i.input};continue}else if(K(i,"mcp_tool_result")&&P(i.tool_use_id)&&te(i.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(K(i,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:i.input};continue}else if(K(i,"search_result")){yield{id:i.id,type:"non_standard",value:i};continue}else if(K(i,"tool_result")){yield{id:i.id,type:"non_standard",value:i};continue}else{let n=ik(i);if(n){yield n;continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var ok={translateContent:nk,translateContentChunk:nk};function qM(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function XM(e){return Vo(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Zo(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:Kl(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function sk(e){return e.map(XM)}function ck(e){return!!(K(e,"image_url")&&te(e.image_url)||K(e,"input_audio")&&te(e.input_audio)||K(e,"file")&&te(e.file))}function uk(e){if(K(e,"image_url")&&te(e.image_url)&&P(e.image_url.url)){let t=Tc({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(K(e,"input_audio")&&te(e.input_audio)&&P(e.input_audio.data)&&P(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(K(e,"file")&&te(e.file)&&P(e.file.data)){let t=Tc({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(P(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function YM(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Xl(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function QM(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Xl(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Xl(e){let t=[];for(let r of e)ck(r)?t.push(uk(r)):t.push(r);return t}function ej(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:i,end_index:n}=e;return{type:"citation",url:t,title:r,startIndex:i,endIndex:n}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:i}=e;return{type:"citation",title:r,startIndex:i,endIndex:i,fileId:t}}return e}function lk(e){function*t(){te(e.additional_kwargs?.reasoning)&>(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((i,n)=>te(n)&&P(n.text)?`${i}${n.text}`:i,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r)if(K(i,"text")){let{text:n,annotations:a,phase:o,extras:s,...c}=i,u=te(s)?{...s}:{};P(o)&&(u.phase=o);let l=Object.keys(u).length>0?{extras:u}:{};Array.isArray(a)?yield{...c,...l,type:"text",text:String(n),annotations:a.map(ej)}:yield{...c,...l,type:"text",text:String(n)}}for(let i of e.tool_calls??[])yield{type:"tool_call",id:i.id,name:i.name,args:i.args};if(te(e.additional_kwargs)&>(e.additional_kwargs.tool_outputs))for(let i of e.additional_kwargs.tool_outputs){if(K(i,"web_search_call")){let n={};if(te(i.action)&&P(i.action.query)&&(n.query=i.action.query),yield{id:i.id,type:"server_tool_call",name:"web_search",args:n},i.status==="completed"||i.status==="failed"){let a={};te(i.action)&&(a.action=i.action),yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:a}}continue}else if(K(i,"file_search_call")){yield{id:i.id,type:"server_tool_call",name:"file_search",args:{queries:gt(i.queries)?i.queries:[]}},(i.status==="completed"||i.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:gt(i.results)?{results:i.results}:{}});continue}else if(K(i,"computer_call")){yield{type:"non_standard",value:i};continue}else if(K(i,"code_interpreter_call")){if(P(i.code)&&(yield{id:i.id,type:"server_tool_call",name:"code_interpreter",args:{code:i.code}}),gt(i.outputs)){let n=vr(()=>{if(i.status!=="in_progress"){if(i.status==="completed")return 0;if(i.status==="incomplete")return 127;if(i.status!=="interpreting"&&i.status==="failed")return 1}});for(let a of i.outputs)if(K(a,"logs")){yield{type:"server_tool_call_result",toolCallId:i.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:n??0,stderr:[0,void 0].includes(n)?void 0:String(a.logs),stdout:[0,void 0].includes(n)?String(a.logs):void 0}};continue}}continue}else if(K(i,"mcp_call")){yield{id:i.id,type:"server_tool_call",name:"mcp_call",args:i.input};continue}else if(K(i,"mcp_list_tools")){yield{id:i.id,type:"server_tool_call",name:"mcp_list_tools",args:i.input};continue}else if(K(i,"mcp_approval_request")){yield{type:"non_standard",value:i};continue}else if(K(i,"tool_search_call")){let n={};te(i.arguments)&&Object.assign(n,i.arguments);let a={};P(i.execution)&&(a.execution=i.execution),P(i.status)&&(a.status=i.status),P(i.call_id)&&(a.call_id=i.call_id),yield{id:P(i.id)?i.id:"",type:"server_tool_call",name:"tool_search",args:n,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(K(i,"tool_search_output")){let n={name:"tool_search"};P(i.execution)&&(n.execution=i.execution),yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":i.status==="failed"?"error":"success",output:{tools:gt(i.tools)?i.tools:[]},extras:n};continue}else if(K(i,"image_generation_call")){P(i.result)&&(yield{type:"image",mimeType:"image/png",data:i.result,id:P(i.id)?i.id:void 0,metadata:{status:P(i.status)?i.status:void 0}}),yield{type:"non_standard",value:i};continue}te(i)&&(yield{type:"non_standard",value:i})}}return Array.from(t())}function tj(e){function*t(){yield*lk(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var dk={translateContent:e=>typeof e.content=="string"?YM(e):lk(e),translateContentChunk:e=>typeof e.content=="string"?QM(e):tj(e)};function Yl(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function fk(e,t="pretty"){return t==="pretty"?rj(e):JSON.stringify(e)}function rj(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,i=Math.floor((80-r.length)/2),n="=".repeat(i),a=r.length%2===0?n:`${n}=`;if(t.push(`${n}${r}${a}`),e.type==="ai"){let o=e;if(o.tool_calls&&o.tool_calls.length>0){t.push("Tool Calls:");for(let s of o.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,u]of Object.entries(s.args))t.push(` ${c}: ${typeof u=="object"?JSON.stringify(u):u}`)}}}if(e.type==="tool"){let o=e;o.name&&t.push(`Name: ${o.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
|
|
9
|
+
`)}var zh=Symbol.for("langchain.message");function pk(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Pt(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>An(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=pk(e);return Oi(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>An(r))?[...e,{type:"file",source_type:"text",text:t}]:[...pk(e),{type:"text",text:t}]}function Ql(e,t){return e==="error"||t==="error"?"error":"success"}function nj(e,t){function r(i,n){if(typeof i!="object"||i===null||i===void 0)return i;if(n>=t)return Array.isArray(i)?"[Array]":"[Object]";if(Array.isArray(i))return i.map(o=>r(o,n+1));let a={};for(let o of Object.keys(i))a[o]=r(i[o],n+1);return a}return JSON.stringify(r(e,0),null,2)}var Ce=class extends ut{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[zh]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(e){let t=typeof e=="string"||Array.isArray(e)?{content:e}:e;t.additional_kwargs||(t.additional_kwargs={}),t.response_metadata||(t.response_metadata={}),super(t),this.name=t.name,t.content===void 0&&t.contentBlocks!==void 0?(this.content=t.contentBlocks,this.response_metadata={output_version:"v1",...t.response_metadata}):t.content!==void 0?(this.content=t.content??[],this.response_metadata=t.response_metadata):(this.content=[],this.response_metadata=t.response_metadata),this.additional_kwargs=t.additional_kwargs,this.id=t.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[sk,Xl,ak].reduce((t,r)=>r(t),e)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(e){return typeof e=="object"&&e!==null&&zh in e&&e[zh]===!0&&Yl(e)}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=nj(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return fk(this,e)}};function _k(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var Dh=["index","created","timestamp"];function Ke(e,t,r){let i=r?.ignoreKeys??Dh;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let n={...e};for(let[a,o]of Object.entries(t))if(n[a]==null)n[a]=o;else{if(o==null)continue;if(typeof n[a]!=typeof o||Array.isArray(n[a])!==Array.isArray(o))throw new Error(`field[${a}] already exists in the message chunk, but with a different type.`);if(typeof n[a]=="string"){if(a==="type")continue;if(["id","name","output_version","model_provider"].includes(a))o&&(n[a]=o);else{if(i.includes(a))continue;n[a]+=o}}else if(typeof n[a]=="number"){if(i.includes(a))continue;n[a]=n[a]+o}else if(typeof n[a]=="object"&&!Array.isArray(n[a]))n[a]=Ke(n[a],o,r);else if(Array.isArray(n[a]))n[a]=Oi(n[a],o,r);else{if(n[a]===o)continue;console.warn(`field[${a}] already exists in this message chunk and value has unsupported type.`)}}return n}function ij(e){return typeof e=="number"||typeof e=="string"}function mk(e){return typeof e!="object"||e===null||!("index"in e)?!1:ij(e.index)}function hk(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function gk(e){return e.endsWith("_delta")?e.slice(0,-6):e}function aj(e,t){return typeof e!="object"||e===null||typeof t!="object"||t===null||!("type"in e)||!("type"in t)?!1:typeof e.type=="string"&&typeof t.type=="string"&&gk(e.type)!==gk(t.type)}function oj(e,t){let r=mk(t),i=hk(t);return!r&&!i?-1:e.findIndex(n=>{let a=mk(n),o=hk(n);return r&&a?n.index!==t.index||aj(n,t)?!1:o&&i?n.id===t.id:!0:!r&&!a&&i&&o?n.id===t.id:!1})}function Oi(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let i=[...e];for(let n of t){let a=oj(i,n);if(a!==-1)i[a]=Ke(i[a],n,r);else{if(typeof n=="object"&&n!==null&&"text"in n&&n.text==="")continue;i.push(n)}}return i}}}function ed(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e??t;if(typeof e!=typeof t)throw new Error(`Cannot merge objects of different types.
|
|
10
|
+
Left ${typeof e}
|
|
11
|
+
Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return Oi(e,t,r);if(typeof e=="object"&&typeof t=="object")return Ke(e,t,r);if(e===t)return e;throw new Error(`Can not merge objects of different types.
|
|
12
|
+
Left ${e}
|
|
13
|
+
Right ${t}`)}}var bt=class yk extends Ce{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===yk.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function td(e){return typeof e.role=="string"}function We(e){return typeof e?._getType=="function"}function ai(e){return bt.isInstance(e)}var vk=A({ToolMessage:()=>_t,ToolMessageChunk:()=>Ho,defaultToolCallParser:()=>Cc,isDirectToolOutput:()=>Ac,isToolMessage:()=>Oc,isToolMessageChunk:()=>Uh});function Ac(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var _t=class extends Ce{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}lc_direct_tool_output=!0;type="tool";status;tool_call_id;metadata;artifact;constructor(e,t,r){let i=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(i),this.tool_call_id=i.tool_call_id,this.artifact=i.artifact,this.status=i.status,this.metadata=i.metadata}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},Ho=class extends bt{type="tool";tool_call_id;status;artifact;constructor(e){super(e),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status}static lc_name(){return"ToolMessageChunk"}concat(e){let t=this.constructor;return new t({content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),artifact:ed(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:Ql(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Cc(e){let t=[],r=[];for(let i of e)if(i.function){let n=i.function.name;try{let a=JSON.parse(i.function.arguments);t.push({name:n||"",args:a||{},id:i.id})}catch{r.push({name:n,args:i.function.arguments,id:i.id,error:"Malformed args."})}}else continue;return[t,r]}function Oc(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function Uh(e){return e._getType()==="tool"}function Pi(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function bk(e){return!!(e&&typeof e=="object"&&"toolCall"in e&&e.toolCall!=null&&typeof e.toolCall=="object"&&"id"in e.toolCall&&typeof e.toolCall.id=="string")}var Go=class extends Error{output;constructor(e,t){super(e),this.output=t}};function Ea(e,t=Cn){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let i=e.substring(r+3);i.startsWith(`json
|
|
14
|
+
`)?i=i.substring(5):i.startsWith("json")?i=i.substring(4):i.startsWith(`
|
|
15
|
+
`)&&(i=i.substring(1));let n=i.indexOf("```"),a=i;return n!==-1&&(a=i.substring(0,n)),t(a.trim())}function sj(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw new Error("Unexpected end of JSON input");let r=0;function i(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function n(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let l="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")l+=`
|
|
16
|
+
`;else if(f==="t")l+=" ";else if(f==="r")l+="\r";else if(f==="\\")l+="\\";else if(f==='"')l+='"';else if(f==="b")l+="\b";else if(f==="f")l+="\f";else if(f==="/")l+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?l+=String.fromCharCode(Number.parseInt(p,16)):l+=`u${p}`,r+=p.length;else throw new Error(`Invalid unicode escape sequence '\\u${p}' at position ${r}`)}else throw new Error(`Invalid escape sequence '\\${f}' at position ${r}`);d=!1}else if(f==="\\")d=!0;else{if(f==='"')return r+=1,l;l+=f}r+=1}return d&&(l+="\\"),l}function a(){let l=r,d="";if(t[r]==="-"&&(d+="-",r+=1),r<t.length&&t[r]==="0"&&(d+="0",r+=1,t[r]>="0"&&t[r]<="9"))throw new Error(`Invalid number at position ${l}`);if(r<t.length&&t[r]>="1"&&t[r]<="9")for(;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&t[r]===".")for(d+=".",r+=1;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&(t[r]==="e"||t[r]==="E"))for(d+=t[r],r+=1,r<t.length&&(t[r]==="+"||t[r]==="-")&&(d+=t[r],r+=1);r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(d==="-")return-0;let f=Number.parseFloat(d);if(Number.isNaN(f))throw r=l,new Error(`Invalid number '${d}' at position ${l}`);return f}function o(){if(i(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let l=t[r];if(l==="{")return c();if(l==="[")return s();if(l==='"')return n();if("null".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),null;if("true".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),!0;if("false".startsWith(t.substring(r,r+5)))return r+=Math.min(5,t.length-r),!1;if(l==="-"||l>="0"&&l<="9")return a();throw new Error(`Unexpected character '${l}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let l=[];if(r+=1,i(),r>=t.length)return l;if(t[r]==="]")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length||(l.push(o()),i(),r>=t.length))return l;if(t[r]==="]")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return l}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let l={};if(r+=1,i(),r>=t.length)return l;if(t[r]==="}")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length)return l;let d=n();if(i(),r>=t.length)return l;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,i(),r>=t.length||(l[d]=o(),i(),r>=t.length))return l;if(t[r]==="}")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return l}let u=o();if(i(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return u}function Cn(e){try{return typeof e>"u"?null:sj(e)}catch{return null}}function Lh(e){switch(e){case"csv":return"text/csv";case"doc":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"html":return"text/html";case"md":return"text/markdown";case"pdf":return"application/pdf";case"txt":return"text/plain";case"xls":return"application/vnd.ms-excel";case"xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"gif":return"image/gif";case"jpeg":return"image/jpeg";case"jpg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"flv":return"video/flv";case"mkv":return"video/mkv";case"mov":return"video/mov";case"mp4":return"video/mp4";case"mpeg":return"video/mpeg";case"mpg":return"video/mpg";case"three_gp":return"video/three_gp";case"webm":return"video/webm";case"wmv":return"video/wmv";default:return"application/octet-stream"}}function cj(e){if(te(e.document)&&te(e.document.source)){let t=Lh(te(e.document)&&P(e.document.format)?e.document.format:"");if(te(e.document.source)){if(te(e.document.source.s3Location)&&P(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(ql(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(P(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(gt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,i)=>te(i)&&P(i.text)?r+i.text:r,"")}}}return{type:"non_standard",value:e}}function uj(e){if(K(e,"image")&&te(e.image)){let t=Lh(te(e.image)&&P(e.image.format)?e.image.format:"");if(te(e.image.source)){if(te(e.image.source.s3Location)&&P(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(ql(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function lj(e){if(K(e,"video")&&te(e.video)){let t=Lh(te(e.video)&&P(e.video.format)?e.video.format:"");if(te(e.video.source)){if(te(e.video.source.s3Location)&&P(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(ql(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function wk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"cache_point")){yield{type:"non_standard",value:i};continue}else if(K(i,"citations_content")&&te(i.citationsContent)){yield{type:"text",text:gt(i.citationsContent.content)?i.citationsContent.content.reduce((n,a)=>te(a)&&P(a.text)?n+a.text:n,""):"",annotations:gt(i.citationsContent.citations)?i.citationsContent.citations.reduce((n,a)=>{if(te(a)){let o=gt(a.sourceContent)?a.sourceContent.reduce((c,u)=>te(u)&&P(u.text)?c+u.text:c,""):"",s=vr(()=>{if(te(a.location)){let c=a.location.documentChar||a.location.documentPage||a.location.documentChunk;if(te(c))return{source:yr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:yr(c.start)?c.start:void 0,endIndex:yr(c.end)?c.end:void 0}}return{}});n.push({type:"citation",citedText:o,...s})}return n},[]):[]};continue}else if(K(i,"document")&&te(i.document)){yield cj(i);continue}else if(K(i,"guard_content")){yield{type:"non_standard",value:i};continue}else if(K(i,"image")&&te(i.image)){yield uj(i);continue}else if(K(i,"reasoning_content")&&P(i.reasoningText)){yield{type:"reasoning",reasoning:i.reasoningText};continue}else if(K(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"tool_result")){yield{type:"non_standard",value:i};continue}else{if(K(i,"tool_call"))continue;if(K(i,"video")&&te(i.video)){yield lj(i);continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var xk={translateContent:wk,translateContentChunk:wk};function Sk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var kk={translateContent:Sk,translateContentChunk:Sk};function $k(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"thinking")&&P(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(K(i,"inlineData")&&te(i.inlineData)&&P(i.inlineData.mimeType)&&P(i.inlineData.data)){yield{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data};continue}else if(K(i,"functionCall")&&te(i.functionCall)&&P(i.functionCall.name)&&te(i.functionCall.args)){yield{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args};continue}else if(K(i,"functionResponse")){yield{type:"non_standard",value:i};continue}else if(K(i,"fileData")&&te(i.fileData)&&P(i.fileData.mimeType)&&P(i.fileData.fileUri)){yield{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri};continue}else if(K(i,"executableCode")){yield{type:"non_standard",value:i};continue}else if(K(i,"codeExecutionResult")){yield{type:"non_standard",value:i};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Ik={translateContent:$k,translateContentChunk:$k};function Ek(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"reasoning")&&P(i.reasoning)){let n=vr(()=>{let a=r.indexOf(i);if(gt(e.additional_kwargs?.signatures)&&a>=0)return e.additional_kwargs.signatures.at(a)});P(n)?yield{type:"reasoning",reasoning:i.reasoning,signature:n}:yield{type:"reasoning",reasoning:i.reasoning};continue}else if(K(i,"thinking")&&P(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(K(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"image_url")){if(P(i.image_url))if(i.image_url.startsWith("data:")){let n=i.image_url.match(/^data:([^;]+);base64,(.+)$/);n?yield{type:"image",data:n[2],mimeType:n[1]}:yield{type:"image",url:i.image_url}}else yield{type:"image",url:i.image_url};continue}else if(K(i,"media")&&P(i.mimeType)&&P(i.data)){yield{type:"file",mimeType:i.mimeType,data:i.data};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Tk={translateContent:Ek,translateContentChunk:Ek};function Ak(e){let t=[],r=e.additional_kwargs?.reasoning;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let i=e.content,n=i.match(/<think>([\s\S]*?)<\/think>/);if(n){let a=n[1].trim();a.length>0&&t.push({type:"reasoning",reasoning:a}),i=i.replace(/<think>[\s\S]*?<\/think>/,"").trim()}i.length>0&&t.push({type:"text",text:i})}else for(let i of e.content)if(typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)){let n=i.text,a=n.match(/<think>([\s\S]*?)<\/think>/);if(a){let o=a[1].trim();o.length>0&&t.push({type:"reasoning",reasoning:o}),n=n.replace(/<think>[\s\S]*?<\/think>/,"").trim()}n.length>0&&t.push({type:"text",text:n})}for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Ck={translateContent:Ak,translateContentChunk:Ak};function Ok(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Pk={translateContent:Ok,translateContentChunk:Ok};function Nk(e){let t=[];if(te(e.additional_kwargs?.reasoning)){let i=e.additional_kwargs.reasoning;if(gt(i.summary)){let n=i.summary.reduce((a,o)=>te(o)&&P(o.text)?`${a}${o.text}`:a,"");n.length>0&&t.push({type:"reasoning",reasoning:n})}}let r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Rk={translateContent:Nk,translateContentChunk:Nk};function Mk(e){function*t(){let r=vr(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let i=e.additional_kwargs?.originalTextContentBlock;if(i?.thoughtSignature&&!e.content.some(n=>"thoughtSignature"in n)){let n=[...e.content];for(let a=n.length-1;a>=0;a--){let o=n[a];if(o.type==="text"&&!o.thought)return o.thoughtSignature=i.thoughtSignature,n}}return e.content}});for(let i of r){let n=vr(()=>K(i,"text")&&P(i.text)?{type:"text",text:i.text}:K(i,"inlineData")&&te(i.inlineData)&&P(i.inlineData.mimeType)&&P(i.inlineData.data)?{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data}:K(i,"functionCall")&&te(i.functionCall)&&P(i.functionCall.name)&&te(i.functionCall.args)?{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args}:K(i,"functionResponse")?{type:"non_standard",value:i}:K(i,"fileData")&&te(i.fileData)&&P(i.fileData.mimeType)&&P(i.fileData.fileUri)?{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri}:K(i,"executableCode")?{type:"non_standard",value:i}:K(i,"codeExecutionResult")?{type:"non_standard",value:i}:{type:"non_standard",value:i}),a=vr(()=>"thought"in i&&i.thought?{type:"reasoning",reasoning:n.type==="text"?n.text:"",reasoningContentBlock:n}:n),o={thought:i.thought,thoughtSignature:i.thoughtSignature,partMetadata:i.partMetadata,...a};for(let s in o)o[s]===void 0&&delete o[s];yield o}}return Array.from(t())}var jk={translateContent:Mk,translateContentChunk:Mk};globalThis.lc_block_translators_registry??=new Map([["anthropic",ok],["bedrock-converse",xk],["deepseek",kk],["google",jk],["google-genai",Ik],["google-vertexai",Tk],["groq",Ck],["ollama",Pk],["openai",dk],["xai",Rk]]);function Fh(e){return globalThis.lc_block_translators_registry.get(e)}function rd(e,t){return Ke(e,t)??{}}function zk(e,t){let r={};return(e?.audio!==void 0||t?.audio!==void 0)&&(r.audio=(e?.audio??0)+(t?.audio??0)),(e?.image!==void 0||t?.image!==void 0)&&(r.image=(e?.image??0)+(t?.image??0)),(e?.video!==void 0||t?.video!==void 0)&&(r.video=(e?.video??0)+(t?.video??0)),(e?.document!==void 0||t?.document!==void 0)&&(r.document=(e?.document??0)+(t?.document??0)),(e?.text!==void 0||t?.text!==void 0)&&(r.text=(e?.text??0)+(t?.text??0)),r}function dj(e,t){let r={...zk(e,t)};return(e?.cache_read!==void 0||t?.cache_read!==void 0)&&(r.cache_read=(e?.cache_read??0)+(t?.cache_read??0)),(e?.cache_creation!==void 0||t?.cache_creation!==void 0)&&(r.cache_creation=(e?.cache_creation??0)+(t?.cache_creation??0)),r}function fj(e,t){let r={...zk(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function Jo(e,t){return{input_tokens:(e?.input_tokens??0)+(t?.input_tokens??0),output_tokens:(e?.output_tokens??0)+(t?.output_tokens??0),total_tokens:(e?.total_tokens??0)+(t?.total_tokens??0),input_token_details:dj(e?.input_token_details,t?.input_token_details),output_token_details:fj(e?.output_token_details,t?.output_token_details)}}var Ee=class extends Ce{type="ai";tool_calls=[];invalid_tool_calls=[];usage_metadata;get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",usage_metadata:"usage_metadata"}}constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:{}};else{t=e;let r=t.additional_kwargs?.tool_calls,i=t.tool_calls;r!=null&&r.length>0&&(i===void 0||i.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
|
|
17
|
+
|
|
18
|
+
Please upgrade your packages to versions that set`,"message tool calls. e.g., `pnpm install @langchain/anthropic`,","pnpm install @langchain/openai`, etc."].join(" "));try{if(r!=null&&i===void 0){let[n,a]=Cc(r);t.tool_calls=n??[],t.invalid_tool_calls=a??[]}else t.tool_calls=t.tool_calls??[],t.invalid_tool_calls=t.invalid_tool_calls??[]}catch{t.tool_calls=[],t.invalid_tool_calls=[]}if(t.response_metadata!==void 0&&"output_version"in t.response_metadata&&t.response_metadata.output_version==="v1"&&(t.contentBlocks=t.content,t.content=void 0),t.contentBlocks!==void 0){if(t.tool_calls){let a=t.tool_calls.filter(o=>!t.contentBlocks?.some(s=>s.type==="tool_call"&&s.id===o.id&&s.name===o.name));t.contentBlocks.push(...a.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.args})))}let n=t.contentBlocks.filter(a=>a.type==="tool_call").filter(a=>!t.tool_calls?.some(o=>o.id===a.id&&o.name===a.name));n.length>0&&(t.tool_calls=[...t.tool_calls??[],...n.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args}))])}}super(t),typeof t!="string"&&(this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=t.usage_metadata}static lc_name(){return"AIMessage"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=Fh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls){let t=this.tool_calls.filter(r=>!e.some(i=>i.id===r.id&&i.name===r.name));e.push(...t.map(r=>({type:"tool_call",id:r.id,name:r.name,args:r.args})))}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};function Ko(e){return e._getType()==="ai"}function Pc(e){return e._getType()==="ai"}var Qe=class extends bt{type="ai";tool_calls=[];invalid_tool_calls=[];tool_call_chunks=[];usage_metadata;constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0||e.tool_call_chunks.length===0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{let r=nd(e.tool_call_chunks??[]);t={...e,tool_call_chunks:r.tool_call_chunks,tool_calls:r.tool_calls,invalid_tool_calls:r.invalid_tool_calls,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks",usage_metadata:"usage_metadata"}}static lc_name(){return"AIMessageChunk"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=Fh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls&&typeof this.content!="string"){let t=this.content.filter(r=>r.type==="tool_call").map(r=>r.id);for(let r of this.tool_calls)r.id&&!t.includes(r.id)&&e.push({...r,type:"tool_call",id:r.id,name:r.name,args:r.args})}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){let t={content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:rd(this.response_metadata,e.response_metadata),tool_call_chunks:[],tool_calls:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let i=Oi(this.tool_call_chunks,e.tool_call_chunks);i!==void 0&&i.length>0&&(t.tool_call_chunks=i)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let i=Oi(this.tool_calls,e.tool_calls);i!==void 0&&i.length>0&&(t.tool_calls=i)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=Jo(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};var nn=class Dk extends Ce{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return Dk}constructor(t,r){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:r}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},Ta=class extends bt{static lc_name(){return"ChatMessageChunk"}type="generic";role;constructor(e,t){(typeof e=="string"||Array.isArray(e))&&(e={content:e,role:t}),super(e),this.role=e.role}concat(e){let t=this.constructor;return new t({content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}};function Uk(e){return e._getType()==="generic"}function Lk(e){return e._getType()==="generic"}var Aa=class extends Ce{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Ca=class extends bt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function Fk(e){return e._getType()==="function"}function Bk(e){return e._getType()==="function"}var rt=class extends Ce{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},Oa=class extends bt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function Vk(e){return e.getType()==="human"}function Zk(e){return e.getType()==="human"}var an=class extends Ce{type="remove";id;constructor(e){super({...e,content:[]}),this.id=e.id}get _printableFields(){return{...super._printableFields,id:this.id}}static isInstance(e){return super.isInstance(e)&&e.type==="remove"}};var Gt=class id extends Ce{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new id({content:Pt(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(id.isInstance(t))return new id({content:Pt(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},oi=class extends bt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Pt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function Hk(e){return e._getType()==="system"}function Gk(e){return e._getType()==="system"}var Jk=e=>e();function pj(e){return Pi(e)?e:typeof e.id=="string"&&e.type==="function"&&typeof e.function=="object"&&e.function!==null&&"arguments"in e.function&&typeof e.function.arguments=="string"&&"name"in e.function&&typeof e.function.name=="string"?{id:e.id,args:JSON.parse(e.function.arguments),name:e.function.name,type:"tool_call"}:e}function mj(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function Bh(e){let t,r;if(mj(e)){let i=e.id.at(-1);i==="HumanMessage"||i==="HumanMessageChunk"?t="user":i==="AIMessage"||i==="AIMessageChunk"?t="assistant":i==="SystemMessage"||i==="SystemMessageChunk"?t="system":i==="FunctionMessage"||i==="FunctionMessageChunk"?t="function":i==="ToolMessage"||i==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:i,...n}=e;t=i,r=n}if(t==="human"||t==="user")return new rt(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Ee(r);let a=i.map(pj);return new Ee({...n,tool_calls:a})}else{if(t==="system")return new Gt(r);if(t==="developer")return new Gt({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new _t({...r,content:r.content,tool_call_id:r.tool_call_id,name:r.name});if(t==="remove"&&"id"in r&&typeof r.id=="string")return new an({...r,id:r.id});throw ii(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
|
|
19
|
+
|
|
20
|
+
Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function It(e){if(typeof e=="string")return new rt(e);if(We(e))return e;if(Array.isArray(e)){let[t,r]=e;return Bh({type:t,content:r})}else if(td(e)){let{role:t,...r}=e;return Bh({...r,type:t})}else return Bh(e)}function hj(e){if(typeof e=="string")return e;switch(e.type){case"text":return e.text??"";case"text-plain":return e.text??"[text-plain file]";case"image":case"image_url":return"[image]";case"audio":case"input_audio":return"[audio]";case"video":return"[video]";case"file":return"[file]";case"reasoning":case"tool_call":case"tool_call_chunk":case"invalid_tool_call":case"server_tool_call":case"server_tool_call_chunk":case"server_tool_call_result":case"non_standard":return"";default:return e.type?`[${e.type}]`:""}}function Wo(e,t="Human",r="AI"){let i=[];for(let n of e){let a;if(n.type==="human")a=t;else if(n.type==="ai")a=r;else if(n.type==="system")a="System";else if(n.type==="tool")a="Tool";else if(n.type==="generic")a=n.role;else throw new Error(`Got unsupported message type: ${n.type}`);let o=n.name?`${n.name}, `:"",s=typeof n.content=="string"?n.content:Array.isArray(n.content)?n.content.map(hj).filter(Boolean).join(""):"",c=`${a}: ${o}${s}`;if(n.type==="ai"){let u=n;u.tool_calls&&u.tool_calls.length>0?c+=JSON.stringify(u.tool_calls):u.additional_kwargs&&"function_call"in u.additional_kwargs&&(c+=JSON.stringify(u.additional_kwargs.function_call))}i.push(c)}return i.join(`
|
|
21
|
+
`)}function gj(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function Nc(e){let t=gj(e);switch(t.type){case"human":return new rt(t.data);case"ai":return new Ee(t.data);case"system":return new Gt(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new Aa(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new _t(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new nn(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function Kk(e){return e.map(Nc)}function Wk(e){return e.map(t=>t.toDict())}function Pa(e){let t=e._getType();if(t==="human")return new Oa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new Qe({...r})}else{if(t==="system")return new oi({...e});if(t==="function")return new Ca({...e});if(nn.isInstance(e))return new Ta({...e});throw new Error("Unknown message type.")}}function nd(e){let t=e.reduce((n,a)=>{let o=n.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?n[o].push(a):n.push([a]),n},[]),r=[],i=[];for(let n of t){let a=null,o=n[0]?.name??"",s=n.map(l=>l.args||"").join("").trim(),c=s.length?s:"{}",u=n[0]?.id;try{if(a=Cn(c),!u||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:o,args:a,id:u,type:"tool_call"})}catch{i.push({name:o,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var qk=A({BaseCache:()=>Yk,InMemoryCache:()=>Vh,defaultHashKeyEncoder:()=>Xk,deserializeStoredGeneration:()=>_j,serializeGeneration:()=>yj}),Xk=(...e)=>Bo(e.join("_"));function _j(e){return e.message!==void 0?{text:e.text,message:Nc(e.message)}:{text:e.text}}function yj(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var Yk=class{keyEncoder=Xk;makeDefaultKeyEncoder(e){this.keyEncoder=e}},vj=new Map,Vh=class Qk extends Yk{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new Qk(vj)}};var e$="ffffffff-ffff-ffff-ffff-ffffffffffff";var t$="00000000-0000-0000-0000-000000000000";var r$=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function br(e){return typeof e=="string"&&r$.test(e)}function Na(e){if(!br(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Et=[];for(let e=0;e<256;++e)Et.push((e+256).toString(16).slice(1));function wr(e,t=0){return(Et[e[t+0]]+Et[e[t+1]]+Et[e[t+2]]+Et[e[t+3]]+"-"+Et[e[t+4]]+Et[e[t+5]]+"-"+Et[e[t+6]]+Et[e[t+7]]+"-"+Et[e[t+8]]+Et[e[t+9]]+"-"+Et[e[t+10]]+Et[e[t+11]]+Et[e[t+12]]+Et[e[t+13]]+Et[e[t+14]]+Et[e[t+15]]).toLowerCase()}function n$(e,t=0){let r=wr(e,t);if(!br(r))throw TypeError("Stringified UUID is invalid");return r}var bj=new Uint8Array(16);function Ni(){return crypto.getRandomValues(bj)}var Rc={};function ad(e,t,r){let i,n=e?._v6??!1;if(e){let a=Object.keys(e);a.length===1&&a[0]==="_v6"&&(e=void 0)}if(e)i=i$(e.random??e.rng?.()??Ni(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{let a=Date.now(),o=Ni();wj(Rc,a,o),i=i$(o,Rc.msecs,Rc.nsecs,n?void 0:Rc.clockseq,n?void 0:Rc.node,t,r)}return t??wr(i)}function wj(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=(r[8]<<8|r[9])&16383),e.msecs=t,e}function i$(e,t,r,i,n,a,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!a)a=new Uint8Array(16),o=0;else if(o<0||o+16>a.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);t??=Date.now(),r??=0,i??=(e[8]<<8|e[9])&16383,n??=e.slice(10,16),t+=122192928e5;let s=((t&268435455)*1e4+r)%4294967296;a[o++]=s>>>24&255,a[o++]=s>>>16&255,a[o++]=s>>>8&255,a[o++]=s&255;let c=t/4294967296*1e4&268435455;a[o++]=c>>>8&255,a[o++]=c&255,a[o++]=c>>>24&15|16,a[o++]=c>>>16&255,a[o++]=i>>>8|128,a[o++]=i&255;for(let u=0;u<6;++u)a[o++]=n[u];return a}function od(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():xj(e,t,r)}function xj(e,t,r){e=e||{};let i=e.random??e.rng?.()??Ni();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return wr(i)}function Sj(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Zh(e,t){return e<<t|e>>>32-t}function a$(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Zh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),y=Zh(u,5)+Sj(g,l,d,f)+p+t[g]+c[m]>>>0;p=f,f=d,d=Zh(l,30)>>>0,l=u,u=y}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function kj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var o$="6ba7b810-9dad-11d1-80b4-00c04fd430c8",s$="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function c$(e,t,r,i,n,a){let o=typeof r=="string"?kj(r):r,s=typeof i=="string"?Na(i):i;if(typeof i=="string"&&(i=Na(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return wr(c)}function Ra(e,t,r,i){return c$(80,a$,e,t,r,i)}Ra.DNS=o$;Ra.URL=s$;function u$(e){let t=$j(typeof e=="string"?Na(e):e);return typeof e=="string"?wr(t):t}function $j(e){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function l$(e,t,r){e??={},r??=0;let i=ad({...e,_v6:!0},new Uint8Array(16));if(i=u$(i),t){if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;n++)t[r+n]=i[n];return t}return wr(i)}var Hh={};function xr(e,t,r){let i;if(e)i=d$(e.random??e.rng?.()??Ni(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Ni();Ij(Hh,n,a),i=d$(a,Hh.msecs,Hh.seq,t,r)}return t??wr(i)}function Ij(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function d$(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}function f$(e){if(!br(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var p$=A({MAX:()=>e$,NIL:()=>t$,parse:()=>Na,stringify:()=>n$,v1:()=>ad,v4:()=>od,v5:()=>Ra,v6:()=>l$,v7:()=>xr,validate:()=>br,version:()=>f$});var m$=A({BaseCallbackHandler:()=>Sr,callbackHandlerPrefersChatModelStreamEvents:()=>Gh,callbackHandlerPrefersStreaming:()=>Mc,isBaseCallbackHandler:()=>Jh}),Ej=class{};function Mc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function Gh(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var Sr=class extends Ej{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Fo(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Ht("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return ut.prototype.toJSON.call(this)}toJSONNotImplemented(){return ut.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Sr{name=xr();constructor(){super(),Object.assign(this,e)}}return new t}},Jh=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var h$=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Tj(e){return typeof e=="string"&&h$.test(e)}var jc=Tj;function Aj(e){if(!jc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var sd=Aj;var Tt=[];for(let e=0;e<256;++e)Tt.push((e+256).toString(16).slice(1));function qo(e,t=0){return(Tt[e[t+0]]+Tt[e[t+1]]+Tt[e[t+2]]+Tt[e[t+3]]+"-"+Tt[e[t+4]]+Tt[e[t+5]]+"-"+Tt[e[t+6]]+Tt[e[t+7]]+"-"+Tt[e[t+8]]+Tt[e[t+9]]+"-"+Tt[e[t+10]]+Tt[e[t+11]]+Tt[e[t+12]]+Tt[e[t+13]]+Tt[e[t+14]]+Tt[e[t+15]]).toLowerCase()}var Cj=new Uint8Array(16);function Xo(){return crypto.getRandomValues(Cj)}function Oj(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Pj(e,t,r)}function Pj(e,t,r){e=e||{};let i=e.random??e.rng?.()??Xo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return qo(i)}var Ma=Oj;function Nj(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Kh(e,t){return e<<t|e>>>32-t}function Rj(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Kh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),y=Kh(u,5)+Nj(g,l,d,f)+p+t[g]+c[m]>>>0;p=f,f=d,d=Kh(l,30)>>>0,l=u,u=y}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var g$=Rj;function Mj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Wh="6ba7b810-9dad-11d1-80b4-00c04fd430c8",qh="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Xh(e,t,r,i,n,a){let o=typeof r=="string"?Mj(r):r,s=typeof i=="string"?sd(i):i;if(typeof i=="string"&&(i=sd(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return qo(c)}function Yh(e,t,r,i){return Xh(80,g$,e,t,r,i)}Yh.DNS=Wh;Yh.URL=qh;var Qh=Yh;var eg={};function jj(e,t,r){let i;if(e)i=_$(e.random??e.rng?.()??Xo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Xo();zj(eg,n,a),i=_$(a,eg.msecs,eg.seq,t,r)}return t??qo(i)}function zj(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function _$(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Yo=jj;var y$="gen_ai.operation.name",v$="gen_ai.system",tg="gen_ai.request.model",b$="gen_ai.response.model",rg="gen_ai.usage.input_tokens",ng="gen_ai.usage.output_tokens",ig="gen_ai.usage.total_tokens",w$="gen_ai.request.max_tokens",x$="gen_ai.request.temperature",S$="gen_ai.request.top_p",k$="gen_ai.request.frequency_penalty",$$="gen_ai.request.presence_penalty",I$="gen_ai.response.finish_reasons",E$="gen_ai.prompt",T$="gen_ai.completion",A$="gen_ai.request.extra_query",C$="gen_ai.request.extra_body",O$="gen_ai.serialized.name",P$="gen_ai.serialized.signature",N$="gen_ai.serialized.doc",R$="gen_ai.response.id",M$="gen_ai.response.service_tier",j$="gen_ai.response.system_fingerprint",z$="gen_ai.usage.input_token_details",D$="gen_ai.usage.output_token_details",U$="langsmith.trace.session_id",L$="langsmith.trace.session_name",F$="langsmith.span.kind",B$="langsmith.trace.name",V$="langsmith.metadata",ag="langsmith.span.tags";var Z$="langsmith.request.streaming",H$="langsmith.request.headers";var og="langsmith.usage_metadata";var Lj=(...e)=>fetch(...e),Fj,G$=Symbol.for("ls:fetch_implementation");var J$=()=>globalThis[G$]===void 0?!0:Fj??!1,K$=e=>async(...t)=>{if(e||He("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[G$]??Lj)(...t);return(e||He("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var zc=()=>He("PROJECT")??wt("LANGCHAIN_SESSION")??"default";var W$={};function ja(e){W$[e]||(console.warn(e),W$[e]=!0)}var N=e=>BigInt(e),Q$=N("0x9E3779B1"),eI=N("0x85EBCA77"),Bj=N("0xC2B2AE3D"),Ri=N("0x9E3779B185EBCA87"),za=N("0xC2B2AE3D27D4EB4F"),tI=N("0x165667B19E3779F9"),lg=N("0x85EBCA77C2B2AE63"),Vj=N("0x27D4EB2F165667C5"),Zj=N("0x165667919E3779F9"),Hj=N("0x9FB21C651E98DF25");function Gj(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var On=Gj("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),es=(N(1)<<N(128))-N(1),_e=(N(1)<<N(64))-N(1),dd=(N(1)<<N(32))-N(1),si=64,rI=si/8,Jj=8,cd=4;function Fe(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Ge(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Qo(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function sg(e,t=0){return e[t]}var Kj=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),Wj=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),qj=(e,t)=>(e&dd)*(t&dd)&_e,ts=e=>{if(!e)throw new Error("Assert failed")};function Xj(e,t){return(e<<t|e>>N(32)-t)&dd}function nI(e,t,r){for(let i=0;i<rI;i++){let n=Ge(t,i*8),a=n^Ge(r,i*8);e[i^1]+=n,e[i]+=qj(a,a>>N(32))}return e}function q$(e,t,r,i){for(let n=0;n<i;n++)nI(e,Fe(t,n*si),Fe(r,n*8));return e}function Yj(e,t){for(let r=0;r<rI;r++){let i=Ge(t,r*8),n=e[r];n=cg(n,N(47)),n^=i,n*=Q$,e[r]=n&_e}return e}function ud(e,t){return iI(e[0]^Ge(t,0),e[1]^Ge(t,Jj))}function X$(e,t,r){let i=r;return i+=ud(e.slice(0),Fe(t,0*cd)),i+=ud(e.slice(2),Fe(t,4*cd)),i+=ud(e.slice(4),Fe(t,8*cd)),i+=ud(e.slice(6),Fe(t,12*cd)),Pn(i&_e)}function Qj(e,t,r,i,n){let a=Math.floor((r.byteLength-si)/8),o=si*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=q$(e,Fe(t,c*o),r,a),e=n(e,Fe(r,r.byteLength-si));{let c=Math.floor((t.byteLength-1-o*s)/si);e=q$(e,Fe(t,s*o),r,c),e=i(e,Fe(t,t.byteLength-si),Fe(r,r.byteLength-si-7))}return e}function e4(e,t,r){let i=new BigUint64Array([Bj,Ri,za,tI,lg,eI,Vj,Q$]);ts(e.length>128),i=Qj(i,e,t,nI,Yj),ts(i.length*8==64);{let n=X$(i,Fe(t,11),N(e.byteLength)*Ri&_e);return X$(i,Fe(t,t.byteLength-si-11),~(N(e.byteLength)*za)&_e)<<N(64)|n}}function iI(e,t){let r=e*t&es;return r&_e^r>>N(64)}function Y$(e,t,r){return iI((Ge(e,0)^Ge(t,0)+r)&_e,(Ge(e,8)^Ge(t,8)-r)&_e)}function ld(e,t,r,i,n){let a=e&_e,o=e>>N(64)&_e;return a+=Y$(t,i,n),a^=Ge(r,0)+Ge(r,8),a&=_e,o+=Y$(r,Fe(i,16),n),o^=Ge(t,0)+Ge(t,8),o&=_e,o<<N(64)|a}function Pn(e){return e^=e>>N(37),e*=Zj,e&=_e,e^=e>>N(32),e}function fd(e){return e^=e>>N(33),e*=za,e&=_e,e^=e>>N(29),e*=tI,e&=_e,e^=e>>N(32),e}function t4(e,t,r){let i=e.byteLength;ts(i>0&&i<=3);let n=N(sg(e,i-1))|N(i<<8)|N(sg(e,0)<<16)|N(sg(e,i>>1)<<24),a=(N(Qo(t,0))^N(Qo(t,4)))+r,o=(n^a)&_e,s=(N(Qo(t,8))^N(Qo(t,12)))-r,c=(Xj(Wj(n),N(13))^s)&_e;return(fd(c)&_e)<<N(64)|fd(o)}function cg(e,t){return e^e>>t}function r4(e,t,r){let i=e.byteLength;ts(i>=4&&i<=8);{let n=Qo(e,0),a=Qo(e,i-4),o=N(n)|N(a)<<N(32),s=(Ge(t,16)^Ge(t,24))+r&_e,u=(o^s)*(Ri+(N(i)<<N(2)))&es;return u+=(u&_e)<<N(65),u&=es,u^=u>>N(67),cg(cg(u&_e,N(35))*Hj&_e,N(28))|Pn(u>>N(64))<<N(64)}}function n4(e,t,r){let i=e.byteLength;ts(i>=9&&i<=16);{let n=(Ge(t,32)^Ge(t,40))+r&_e,a=(Ge(t,48)^Ge(t,56))-r&_e,o=Ge(e),s=Ge(e,i-8),c=(o^s^n)*Ri,u=(c&_e)+(N(i-1)<<N(54));c=c&(es^_e)|u,s^=a,c+=s+(s&dd)*(eI-N(1))<<N(64),c&=es,c^=Kj(c>>N(64));let l=(c&_e)*za;return l+=(c>>N(64))*za<<N(64),l&=es,Pn(l&_e)|Pn(l>>N(64))<<N(64)}}function i4(e,t){let r=e.byteLength;return ts(r<=16),r>8?n4(e,On,t):r>=4?r4(e,On,t):r>0?t4(e,On,t):fd(t^Ge(On,64)^Ge(On,72))|fd(t^Ge(On,80)^Ge(On,88))<<N(64)}function ug(e){return~e+N(1)&_e}function a4(e,t,r){let i=N(e.byteLength)*Ri&_e,n=N(e.byteLength-1)/N(32);for(;n>=0;){let s=Number(n);i=ld(i,Fe(e,16*s),Fe(e,e.byteLength-16*(s+1)),Fe(t,32*s),r),n--}let a=i+(i>>N(64))&_e;a=Pn(a);let o=(i&_e)*Ri+(i>>N(64))*lg+(N(e.byteLength)-r&_e)*za;return o&=_e,o=ug(Pn(o)),a|o<<N(64)}function o4(e,t,r){let i=N(e.byteLength)*Ri&_e;for(let o=32;o<160;o+=32)i=ld(i,Fe(e,o-32),Fe(e,o-16),Fe(t,o-32),r);i=Pn(i&_e)|Pn(i>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)i=ld(i,Fe(e,o-32),Fe(e,o-16),Fe(t,3+o-160),r);i=ld(i,Fe(e,e.byteLength-16),Fe(e,e.byteLength-32),Fe(t,103),ug(r));let n=i+(i>>N(64))&_e;n=Pn(n);let a=(i&_e)*Ri+(i>>N(64))*lg+(N(e.byteLength)-r&_e)*za;return a&=_e,a=ug(Pn(a)),n|a<<N(64)}function aI(e,t=N(0)){let r=e.byteLength;return r<=16?i4(e,t):r<=128?a4(e,On,t):r<=240?o4(e,On,t):e4(e,On,t)}function oI(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&_e,n=e>>N(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var sI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pe(e,t){if(!sI.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function pd(e){let t=typeof e=="string"?Date.parse(e):e;return Yo({msecs:t,seq:0})}function s4(e){if(!sI.test(e))return null;let t=e[14];return parseInt(t,16)}function c4(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function u4(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var l4=new TextEncoder;function d4(e){let t=l4.encode(e),r=aI(t);return oI(r)}function Dc(e,t){let r=`${e}:${t}`,i=d4(r),n=new Uint8Array(16);if(s4(e)===7){let o=c4(e);n.set(o.slice(0,6),0)}else{let o=Date.now();n[0]=o/1099511627776&255,n[1]=o/4294967296&255,n[2]=o/16777216&255,n[3]=o/65536&255,n[4]=o/256&255,n[5]=o&255}return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),u4(n)}var Da={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function cI(e){}async function md(e,t){}async function uI(e){return[]}async function lI(e){return{size:0}}function rs(e){return!1}function hd(e){return""}function f4(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var gd=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let i=Da.dirname(t);rs(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw rs(n)&&void 0,a}}load(t){if(!rs(t))return 0;let r;try{let a=hd(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:n};this.cache.set(a,s),i+=1}return i}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,i]of this.cache.entries())f4(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},_d=new gd;var yd="0.7.1";var Rn,p4=()=>typeof window<"u"&&typeof window.document<"u",m4=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",h4=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),mI=()=>typeof Deno<"u",g4=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!mI(),Uc=()=>Rn||(typeof Bun<"u"?Rn="bun":p4()?Rn="browser":g4()?Rn="node":m4()?Rn="webworker":h4()?Rn="jsdom":mI()?Rn="deno":Rn="other",Rn),dg;function vd(){if(dg===void 0){let e=Uc(),t=y4();dg={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:yd,...t}}return dg}function pg(){let e=_4(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_CONFIG_FILE","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!i.toLowerCase().includes("key")&&!i.toLowerCase().includes("secret")&&!i.toLowerCase().includes("token")&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function _4(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function wt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function He(e){return wt(`LANGSMITH_${e}`)||wt(`LANGCHAIN_${e}`)}var fg;function y4(){if(fg!==void 0)return fg;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let i=wt(r);i!==void 0&&(t[r]=i)}return fg=t,t}function fI(){return wt("OTEL_ENABLED")==="true"||He("OTEL_ENABLED")==="true"}var pI=new Set(["langsmith","otel"]);function bd(e){if(e!==void 0)return e;let t=He("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!pI.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...pI].sort().join(", ")}`);return fI()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return fI()?"otel":"langsmith"}var gg=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&bd()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},_g=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new gg})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},yg=class{active(){return{}}with(t,r){return r()}},mg=Symbol.for("ls:otel_trace"),hg=Symbol.for("ls:otel_context"),hI=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),v4=new _g,b4=new yg,vg=class{getTraceInstance(){return globalThis[mg]??v4}getContextInstance(){return globalThis[hg]??b4}initializeGlobalInstances(t){globalThis[mg]===void 0&&(globalThis[mg]=t.trace),globalThis[hg]===void 0&&(globalThis[hg]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[hI]=t}getDefaultOTLPTracerComponents(){return globalThis[hI]??void 0}},bg=new vg;function wd(){return bg.getTraceInstance()}function gI(){return bg.getContextInstance()}function _I(){return bg.getDefaultOTLPTracerComponents()}var w4={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function x4(e){return w4[e]||e}function S4(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var xd=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&wd().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(F$,r.run_type);let s=x4(r.run_type||"chain");t.setAttribute(y$,s)}"name"in r&&r.name&&t.setAttribute(B$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(U$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(L$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(tg,n),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(og,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(rg,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(ng,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(ig,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${V$}.${s}`,S4(c)?String(c):JSON.stringify(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(ag,o.join(", ")):o&&t.setAttribute(ag,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(O$,String(s.name)),s.signature&&t.setAttribute(P$,String(s.signature)),s.doc&&t.setAttribute(N$,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let a=n.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?i="anthropic":a.includes("bedrock")?i="aws.bedrock":a.includes("azure")&&a.includes("openai")?i="az.ai.openai":a.includes("azure")&&a.includes("inference")?i="az.ai.inference":a.includes("cohere")?i="cohere":a.includes("deepseek")?i="deepseek":a.includes("gemini")?i="gemini":a.includes("groq")?i="groq":a.includes("watson")||a.includes("ibm")?i="ibm.watsonx.ai":a.includes("mistral")?i="mistral_ai":a.includes("gpt")||a.includes("openai")?i="openai":a.includes("perplexity")||a.includes("sonar")?i="perplexity":a.includes("vertex")?i="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(i="xai")}t.setAttribute(v$,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(w$,i.max_tokens),i.temperature!==void 0&&t.setAttribute(x$,i.temperature),i.top_p!==void 0&&t.setAttribute(S$,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(k$,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute($$,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(tg,i.model),i.stream!==void 0&&t.setAttribute(Z$,i.stream),i.extra_headers&&t.setAttribute(H$,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(A$,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(C$,JSON.stringify(i.extra_body))),t.setAttribute(E$,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(rg,n[0]),t.setAttribute(ng,n[1]),t.setAttribute(ig,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(b$,String(i.model)),i.id&&t.setAttribute(R$,i.id),i.choices&&Array.isArray(i.choices)){let a=i.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(I$,a.join(", "))}if(i.service_tier&&t.setAttribute(M$,i.service_tier),i.system_fingerprint&&t.setAttribute(j$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;t.setAttribute(og,JSON.stringify(a)),a.input_token_details&&t.setAttribute(z$,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(D$,JSON.stringify(a.output_token_details))}}t.setAttribute(T$,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let o of i){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let n=t.generations||[];if(!Array.isArray(n))return null;let a=Array.isArray(n[0])?n.flat():n;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var k4=Object.prototype.toString,$4=e=>k4.call(e)==="[object Error]",I4=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function wg(e){if(!(e&&$4(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:I4.has(r)}function E4(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Sd(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var xg=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function T4(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function yI(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function A4({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof xg)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),yI(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=yI(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!wg(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=T4(r,n),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let g=()=>{clearTimeout(y),n.signal?.removeEventListener("abort",g),m(n.signal.reason)},y=setTimeout(()=>{n.signal?.removeEventListener("abort",g),p()},f);n.unref&&y.unref?.(),n.signal?.addEventListener("abort",g,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Sg(e,t={}){if(t={...t},E4(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Sd("factor",t.factor,{min:0,allowInfinity:!1}),Sd("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Sd("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Sd("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await A4({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Ad=$l(Td(),1),TI="default"in Ad.default?Ad.default.default:Ad.default;var D4=[408,425,429,500,502,503,504],Fc=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new TI({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let a=this.onFailedResponseHook,o=this.queue.add(()=>Sg(()=>r(...i).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let u="response"in s?s.response:void 0;if(a&&await a(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!D4.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function Cg(e){return typeof e?._getType=="function"}function Og(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function Od(e){return`Invalid prompt identifier format: "${e}". Expected one of:
|
|
22
|
+
- "prompt-name" (for private prompts)
|
|
23
|
+
- "owner/prompt-name" (for prompts with explicit owner)
|
|
24
|
+
- "prompt-name:commit-hash" (with commit reference)
|
|
25
|
+
- "owner/prompt-name:commit-hash" (with owner and commit)`}var Pg=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}},Ng=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithNotFoundError",this.status=404}};function Pd(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function AI(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function Y(e,t,r){let i;if(e.ok){r&&(i=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(i="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{let s=new Error(`${e.status} ${e.statusText}`);throw s.status=e?.status,s}if(i===void 0)try{i=await e.text()}catch{i=""}let n=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${i}`;if(e.status===404)throw new Ng(n);if(e.status===409)throw new Pg(n);let a=new Error(n);throw a.status=e.status,a}var CI="ERR_CONFLICTING_ENDPOINTS",Cd=class extends Error{constructor(){super("You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT and LANGSMITH_RUNS_ENDPOINTS."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:CI}),this.name="ConflictingEndpointsError"}};function OI(e){return typeof e=="object"&&e!==null&&e.code===CI}function Rt(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(Od(e));let[t,r]=e.split(":"),i=r||"latest";if(t.includes("/")){let[n,a]=t.split("/",2);if(!n||!a)throw new Error(Od(e));return[n,a,i]}else{if(!t)throw new Error(Od(e));return["-",t,i]}}var Nd="https://api.smith.langchain.com",U4="langsmith-cli",L4=6e4,F4=1e4;function B4(){let e=Uc();return e==="browser"||e==="webworker"}function V4(){let e=wt("LANGSMITH_CONFIG_FILE");if(e)return e;let t=wt("HOME")??wt("USERPROFILE");if(t)return Da.join(t,".langsmith","config.json")}function Z4(e){let t=wt("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function H4(){if(B4())return;let e=V4();if(!(!e||!rs(e)))try{let t=JSON.parse(hd(e)),r=Z4(t),i=r?t.profiles?.[r]:void 0;return!r||!i?void 0:{configPath:e,config:t,profileName:r,profile:i}}catch{return}}function Dr(e){return e!=null&&e.trim()!==""}function Mi(e){return e?.trim().replace(/^["']|["']$/g,"")}function G4(e){let t=e.oauth;if(!t?.refresh_token)return!1;if(!t.access_token)return!0;if(!t.expires_at)return!1;let r=Date.parse(t.expires_at);return Number.isNaN(r)?!1:r<=Date.now()+L4}function J4(e){let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);let r="/api/v1";return t.endsWith(r)?t.slice(0,-r.length):t}function K4(e,t){e.oauth??={},t.access_token&&(e.oauth.access_token=t.access_token),t.refresh_token&&(e.oauth.refresh_token=t.refresh_token),typeof t.expires_in=="number"&&t.expires_in>0&&(e.oauth.expires_at=new Date(Date.now()+t.expires_in*1e3).toISOString())}function PI(e){return e.reason??new Error("The operation was aborted.")}async function W4(e,t){if(!t)return e;if(t.aborted)throw PI(t);let r,i=new Promise((n,a)=>{let o=()=>{a(PI(t))};t.addEventListener("abort",o,{once:!0}),r=()=>{t.removeEventListener("abort",o)}});try{return await Promise.race([e,i])}finally{r?.()}}function NI(){let e=H4(),t=e?.profile;if(!e||!t)return{};let r=Mi(t.api_key),i=Mi(t.oauth?.access_token),n=Mi(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:i,oauthRefreshToken:n,profileAuth:r||i||n?new Rg(e):void 0}}var Rg=class{constructor(t){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"refreshPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedAuthorizationValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.rememberProfileAuthHeader(this.currentAuthHeader())}currentAuthHeader(){let t=q4(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){G4(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await W4(this.refreshPromise,r));let i=RI(this.state.profile);return this.rememberProfileAuthHeader(i),i}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}async refreshOAuthToken(t){let r=this.state.profile.oauth?.refresh_token;if(!r)return;let i=Mi(this.state.profile.api_url)??Nd;try{let n=new URLSearchParams({grant_type:"refresh_token",client_id:U4,refresh_token:r}),a=await t(`${J4(i)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString(),signal:AbortSignal.timeout(F4)});if(!a.ok)return;let o=await a.json();if(!o.access_token)return;K4(this.state.profile,o),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await md(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
|
|
26
|
+
`)}catch{return}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function q4(e){let t=Mi(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!Mi(e.oauth?.refresh_token))return RI(e)}function RI(e){let t=Mi(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=Mi(e.api_key);if(r)return{name:"x-api-key",value:r}}var MI="[...]",X4={result:"[Circular]"},Md=[],ns=[],Y4=new TextEncoder;function Q4(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Rd(e){return Y4.encode(e)}function jI(e){if(e&&typeof e=="object"&&e!==null){if(e instanceof Map)return Object.fromEntries(e);if(e instanceof Set)return Array.from(e);if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(e instanceof Error)return{name:e.name,message:e.message}}else if(typeof e=="bigint")return e.toString();return e}function ez(e){return function(t,r){if(e){let i=e.call(this,t,r);if(i!==void 0)return i}return jI(r)}}function zI(e){try{let n=function(l){let d=i(l);return d>r&&(r=d),d+2},a=function(l){return l===0?2:2+l*4},o=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"},s=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"?4:c(l)},c=function(l){if(l===null)return 4;if(l===void 0)return 0;let d=typeof l;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(l)?l.toString().length:4;if(d==="bigint")return l.toString().length+2;if(d==="string")return n(l);if(d==="function"||d==="symbol")return 0;let f=l;if(f instanceof Date)return 26;if(f instanceof RegExp)return i(f.toString())+2;if(f instanceof Error){let m=f.name??"",g=f.message??"";return 22+i(m)+i(g)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+a(f.byteLength);if(ArrayBuffer.isView(f)){if(f instanceof DataView)return 2;let m=f.length??0,y=f instanceof Float32Array||f instanceof Float64Array?30:12;return 2+m*y}if(f instanceof ArrayBuffer)return 2;if(t.has(f))return 24;if(typeof f.toJSON=="function"){let m;try{m=f.toJSON("")}catch{return 16}t.add(f);let g=c(m);return t.delete(f),g}t.add(f);let p;if(Array.isArray(f)){p=2;let m=f.length;for(let g=0;g<m;g++)p+=s(f[g]),g<m-1&&(p+=1)}else if(f instanceof Map){p=2;let m=0;for(let[g,y]of f){if(o(y))continue;m>0&&(p+=1);let b=typeof g=="string"?g:String(g);p+=i(b)+3,p+=c(y),m++}}else if(f instanceof Set){p=2;let m=0;for(let g of f)m>0&&(p+=1),p+=s(g),m++}else{p=2;let m=0,g=Object.keys(f);for(let y=0;y<g.length;y++){let b=g[y],w=f[b];o(w)||(m>0&&(p+=1),p+=i(b)+3,p+=c(w),m++)}}return t.delete(f),p},t=new Set,r=0,i=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?l=>Buffer.byteLength(l,"utf8"):l=>l.length;return{size:c(e),maxStringLen:r}}catch{return{size:Mt(e).length,maxStringLen:0}}}function Mt(e,t,r,i,n){try{let a=JSON.stringify(e,ez(r),i);return Rd(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
|
|
27
|
+
Context: ${t}`:""}`),Rd("[Unserializable]");He("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
|
|
28
|
+
Context: ${t}`:""}`),typeof n>"u"&&(n=Q4()),jg(e,"",0,[],void 0,0,n);let o;try{ns.length===0?o=JSON.stringify(e,r,i):o=JSON.stringify(e,tz(r),i)}catch{return Rd("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Md.length!==0;){let s=Md.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return Rd(o)}}function Mg(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),Md.push([i,r,t,n])):ns.push([t,r,e]):(i[r]=e,Md.push([i,r,t]))}function jg(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Mg(X4,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Mg(MI,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Mg(MI,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)jg(e[s],s,s,i,e,a,o);else{e=jI(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];jg(e[u],u,s,i,e,a,o)}}i.pop()}}function tz(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(ns.length>0)for(var i=0;i<ns.length;i++){var n=ns[i];if(n[1]===t&&n[0]===r){r=n[2],ns.splice(i,1);break}}return e.call(this,t,r)}}var nz=`
|
|
29
|
+
const { parentPort } = require("worker_threads");
|
|
30
|
+
|
|
31
|
+
const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
|
|
32
|
+
|
|
33
|
+
function serializeWellKnownTypes(val) {
|
|
34
|
+
if (val && typeof val === "object") {
|
|
35
|
+
if (val instanceof Map) return Object.fromEntries(val);
|
|
36
|
+
if (val instanceof Set) return Array.from(val);
|
|
37
|
+
if (val instanceof Date) return val.toISOString();
|
|
38
|
+
if (val instanceof RegExp) return val.toString();
|
|
39
|
+
if (val instanceof Error) return { name: val.name, message: val.message };
|
|
40
|
+
} else if (typeof val === "bigint") {
|
|
41
|
+
return val.toString();
|
|
42
|
+
}
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function defaultReplacer(_key, val) {
|
|
47
|
+
return serializeWellKnownTypes(val);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Decirculate in-place: replace circular refs with { result: "[Circular]" }
|
|
51
|
+
// then restore after stringify. Mirrors fast-safe-stringify's decirc().
|
|
52
|
+
const restoreStack = [];
|
|
53
|
+
function decirc(val, k, stack, parent) {
|
|
54
|
+
if (typeof val === "object" && val !== null) {
|
|
55
|
+
for (let i = 0; i < stack.length; i++) {
|
|
56
|
+
if (stack[i] === val) {
|
|
57
|
+
const orig = parent[k];
|
|
58
|
+
parent[k] = CIRCULAR_REPLACE_NODE;
|
|
59
|
+
restoreStack.push([parent, k, orig]);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
stack.push(val);
|
|
64
|
+
if (Array.isArray(val)) {
|
|
65
|
+
for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
|
|
66
|
+
} else {
|
|
67
|
+
const normalized = serializeWellKnownTypes(val);
|
|
68
|
+
// Only recurse into normalized if it's still an object (arrays/objects),
|
|
69
|
+
// else it was replaced with a primitive (e.g. Date -> string).
|
|
70
|
+
if (normalized === val) {
|
|
71
|
+
const keys = Object.keys(val);
|
|
72
|
+
for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
stack.pop();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function serialize(obj) {
|
|
80
|
+
try {
|
|
81
|
+
return JSON.stringify(obj, defaultReplacer);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (!String(e && e.message).includes("Converting circular structure to JSON")) {
|
|
84
|
+
return "[Unserializable]";
|
|
85
|
+
}
|
|
86
|
+
decirc(obj, "", [], { "": obj });
|
|
87
|
+
try {
|
|
88
|
+
return JSON.stringify(obj, defaultReplacer);
|
|
89
|
+
} catch (_) {
|
|
90
|
+
return "[unable to serialize, circular reference is too complex to analyze]";
|
|
91
|
+
} finally {
|
|
92
|
+
while (restoreStack.length) {
|
|
93
|
+
const [p, k, v] = restoreStack.pop();
|
|
94
|
+
p[k] = v;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
parentPort.on("message", (msg) => {
|
|
101
|
+
const { id, op, payload } = msg;
|
|
102
|
+
try {
|
|
103
|
+
if (op === "serialize") {
|
|
104
|
+
const str = serialize(payload);
|
|
105
|
+
const buf = Buffer.from(str, "utf8");
|
|
106
|
+
// Slice into its own ArrayBuffer so we can transfer without dragging
|
|
107
|
+
// unrelated bytes from any shared pool buffer.
|
|
108
|
+
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
109
|
+
parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
|
|
110
|
+
} else if (op === "ping") {
|
|
111
|
+
parentPort.postMessage({ id });
|
|
112
|
+
} else {
|
|
113
|
+
parentPort.postMessage({ id, error: "unknown op: " + op });
|
|
114
|
+
}
|
|
115
|
+
} catch (e) {
|
|
116
|
+
parentPort.postMessage({ id, error: String((e && e.message) || e) });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
`,Dg=class{constructor(){Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startPromise",{enumerable:!0,configurable:!0,writable:!0,value:null})}async ensureStarted(){if(this.disabled)return!1;if(this.worker!==null)return!0;if(this.startPromise!==null)return this.startPromise;this.startPromise=this._start();try{return await this.startPromise}finally{this.startPromise=null}}async _start(){if(!!1||null===null)return this.disabled=!0,!1;try{let t=new null(nz,{eval:!0});return t.on("message",r=>{let i=this.pending.get(r.id);i&&(this.pending.delete(r.id),r.error?i.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?i.resolve(new Uint8Array(r.bytes,0,r.length)):i.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,i]of this.pending)i.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,i]of this.pending)i.reject(new Error(`worker exited with code ${r}`));this.pending.clear(),this.worker=null}),t.unref(),this.worker=t,!0}catch{return this.disabled=!0,!1}}async serialize(t){if(!await this.ensureStarted())return null;let i=this.nextId++;return new Promise((n,a)=>{this.pending.set(i,{resolve:n,reject:a});try{this.worker.postMessage({id:i,op:"serialize",payload:t})}catch(o){this.pending.delete(i),a(o)}})}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null);for(let[,t]of this.pending)t.reject(new Error("worker terminated"));this.pending.clear()}},zg=null;function UI(){return zg===null&&(zg=new Dg),zg}var iz=64*1024,az=2048;function LI(e,t=iz,r=az){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let i=[e],n=new Set,a=0;for(;i.length>0;){if(a++>=r)return!1;let o=i.pop();if(o==null)continue;let s=typeof o;if(s==="string"){if(o.length>=t)return!0;continue}if(s!=="object")continue;let c=o;if(n.has(c)||(n.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let l=c.length-1;l>=0;l--)i.push(c[l]);continue}if(c instanceof Map){for(let[,l]of c)i.push(l);continue}if(c instanceof Set){for(let l of c)i.push(l);continue}let u=Object.keys(c);for(let l=u.length-1;l>=0;l--)i.push(c[u[l]])}return!1}function oz(e,t){let[r]=Rt(e);if(r!=="-"&&!t)throw new Error("Pulling a public prompt by owner/name is disabled by default because prompts may contain untrusted serialized LangChain objects. If you trust this prompt, set `dangerouslyPullPublicPrompt: true` to acknowledge the risk.")}function FI(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function Bc(e){return{...e,start_time:FI(e.start_time),end_time:FI(e.end_time)}}function BI(e,t,r){if(r)return e;let i=vd(),n=t??pg(),a=e.extra??{},o=a.metadata;return e.extra={...a,runtime:{...i,...a?.runtime},metadata:{...n,...n.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??n.revision_id}:{},...o}},e}var sz=e=>{let t=e?.toString()??He("TRACING_SAMPLING_RATE");if(t===void 0)return;let r=parseFloat(t);if(r<0||r>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${r}`);return r},cz=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function uz(e){let t=[];for await(let r of e)t.push(r);return t}function jd(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var lz=async e=>{if(e?.status===429){let t=parseInt(e.headers.get("retry-after")??"10",10)*1e3;if(t>0)return await new Promise(r=>setTimeout(r,t)),!0}return!1};function VI(e){return typeof e=="number"?Number(e.toFixed(4)):e}var dz=24*1024*1024,HI=1024*1024*1024,fz=1e4,pz=100,Ug=class{constructor(t){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"maxSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSizeBytes=t??HI}peek(){return this.items[0]}push(t){let r,i=new Promise(a=>{r=a}),n=zI(t.item).size;return this.sizeBytes+n>this.maxSizeBytes&&this.items.length>0?(console.warn(`AutoBatchQueue size limit (${this.maxSizeBytes} bytes) exceeded. Dropping run with id: ${t.item.id}. Current queue size: ${this.sizeBytes} bytes, attempted addition: ${n} bytes.`),r(),i):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:r,itemPromise:i,size:n}),this.sizeBytes+=n,i)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let i=[],n=0;for(;n+(this.peek()?.size??0)<t&&this.items.length>0&&i.length<r;){let a=this.items.shift();a&&(i.push(a),n+=a.size,this.sizeBytes-=a.size)}if(i.length===0&&this.items.length>0){let a=this.items.shift();i.push(a),n+=a.size,this.sizeBytes-=a.size}return[i.map(a=>({action:a.action,item:a.payload,otelContext:a.otelContext,apiKey:a.apiKey,apiUrl:a.apiUrl,size:a.size})),()=>i.forEach(a=>a.itemPromiseResolve())]}},Nn=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||K$(this.debug);return(async(r,i)=>{let n,a=this.getProfileManagedAuthorizationHeader(i);return this.apiKey!==void 0?n={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(i,a)||(n=await this.profileAuth?.getAuthHeader(t,i?.signal)),t(r,this.applyCurrentAuthHeaders(i,n,a))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(Dr(r))return this.profileAuth.isProfileAuthorizationHeader(r??"")?r??void 0:void 0}isProfileManagedAuthorizationHeader(t,r){return t===r||this.profileAuth?.isProfileAuthorizationHeader(t)===!0}hasExplicitAuthHeader(t,r){if(!t?.headers)return!1;let i=new Headers(t.headers);if(Dr(i.get("x-api-key")))return!0;let n=i.get("Authorization");return Dr(n)?!this.isProfileManagedAuthorizationHeader(n??"",r):!1}applyCurrentAuthHeaders(t,r,i){if(!r)return t;let n=d=>{if(this.apiKey!==void 0&&r.name==="x-api-key")return d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value),d;if(r.name==="Authorization"){if(Dr(d.get("x-api-key")))return d;let p=d.get("Authorization");return Dr(p)&&!this.isProfileManagedAuthorizationHeader(p??"",i)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return Dr(f)&&!this.isProfileManagedAuthorizationHeader(f??"",i)||(Dr(f)&&d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value)),d};if(!t)return{headers:{[r.name]:r.value}};if(t.headers instanceof Headers)return{...t,headers:n(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:n(new Headers(t.headers))};let a={...t.headers??{}},o=d=>Object.keys(a).find(f=>f.toLowerCase()===d),s=d=>{let f=o(d);return f?a[f]:void 0},c=Dr(s("x-api-key")),u=s("authorization"),l=Dr(u)&&!this.isProfileManagedAuthorizationHeader(u??"",i);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=o("authorization");return d&&delete a[d],c||(a["x-api-key"]=r.value),{...t,headers:a}}if(r.name==="Authorization"){if(!c&&!l){let d=o("authorization");d&&d!=="Authorization"&&delete a[d],a.Authorization=r.value}return{...t,headers:a}}if(!l){let d=o("authorization");d&&delete a[d],c||(a["x-api-key"]=r.value)}return{...t,headers:a}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return Mt(t,r);if(!LI(t))return Mt(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=UI()),this._serializeWorker===null)return Mt(t,r);try{let i=await this._serializeWorker.serialize(t);return i===null?(this._serializeWorker=null,Mt(t,r)):i}catch{return Mt(t,r)}}constructor(t={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitTracedRuntimeInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:wt("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_serializeWorker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingDrains",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tracingMode",{enumerable:!0,configurable:!0,writable:!0,value:"langsmith"}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_promptCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"profileAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value:He("DISABLE_RUN_COMPRESSION")==="true"}),Object.defineProperty(this,"failedTracesDir",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"failedTracesMaxBytes",{enumerable:!0,configurable:!0,writable:!0,value:100*1024*1024}),Object.defineProperty(this,"_customHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:wt("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=sz(t.tracingSamplingRate),this.apiUrl=jd(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let i=jd(t.apiKey??r.apiKey);if(this.apiKey=Dr(i)?i:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=jd(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=jd(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new Fc({...t.callerOptions??{},maxRetries:4,debug:t.debug??this.debug}),this.traceBatchConcurrency=t.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=t.debug??this.debug,this.fetchImplementation=t.fetchImplementation,this.failedTracesDir=He("FAILED_TRACES_DIR")||void 0;let n=He("FAILED_TRACES_MAX_MB");if(n){let o=parseInt(n,10);Number.isFinite(o)&&o>0&&(this.failedTracesMaxBytes=o*1024*1024)}let a=t.maxIngestMemoryBytes??HI;this.batchIngestCaller=new Fc({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:a,...t.callerOptions??{},onFailedResponseHook:lz,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.hideMetadata=t.hideMetadata??r.hideMetadata,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new Ug(a),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=bd(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new xd),this.cachedLSEnvVarsForMetadata=pg(),t.cache!==void 0&&t.disablePromptCache&&ja("Both 'cache' and 'disablePromptCache' were provided. The 'cache' parameter is deprecated and will be removed in a future version. Using 'cache' parameter value."),t.cache!==void 0?(ja("The 'cache' parameter is deprecated and will be removed in a future version. Use 'configureGlobalPromptCache()' to configure the global cache, or 'disablePromptCache: true' to disable caching for this client."),t.cache===!1?this._promptCache=void 0:t.cache===!0?this._promptCache=_d:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=_d),this._customHeaders=t.headers??{}}static getDefaultClientConfig(){let t=NI(),r=He("API_KEY"),i=He("ENDPOINT"),n=He("WORKSPACE_ID"),a=Dr(r),o=i??t.apiUrl??Nd,s=n??t.workspaceId,c=He("HIDE_INPUTS")==="true",u=He("HIDE_OUTPUTS")==="true",l=He("HIDE_METADATA")==="true";return{apiUrl:o,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:u,hideMetadata:l,workspaceId:s,oauthAccessToken:a?void 0:t.oauthAccessToken,oauthRefreshToken:a?void 0:t.oauthRefreshToken,profileAuth:a?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:cz(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("aws")?(this.webUrl="https://aws.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("apac")?(this.webUrl="https://apac.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${yd}`,...this._customHeaders};if(this.apiKey!==void 0)t["x-api-key"]=`${this.apiKey}`;else{let r=this.profileAuth?.currentAuthHeader();r&&(t[r.name]=r.value)}return this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),t}get headers(){return this._customHeaders}set headers(t){this._customHeaders=t??{}}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}async processInputs(t){return this.hideInputs===!1?t:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(t):t}async processOutputs(t){return this.hideOutputs===!1?t:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(t):t}async processMetadata(t){return this.hideMetadata===!1?t:this.hideMetadata===!0?{}:typeof this.hideMetadata=="function"?this.hideMetadata(t):t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:i,...n}=r;return n}return r})}async prepareRunCreateOrUpdateInputs(t){let r={...t};return r.inputs!==void 0&&(r.inputs=await this.processInputs(r.inputs)),r.outputs!==void 0&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events!==void 0&&(r.events=this._filterNewTokenEvents(r.events)),r}async _getResponse(t,r){let i=r?.toString()??"",n=`${this.apiUrl}${t}?${i}`;return await this.caller.call(async()=>{let o=await this._fetch(n,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(o,`fetch ${t}`),o})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,i){let n=Number(r.get("offset"))||0,a=Number(r.get("limit"))||100;for(;;){r.set("offset",String(n)),r.set("limit",String(a));let o=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let u=await this._fetch(o,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(u,`fetch ${t}`),u}),c=i?i(await s.json()):await s.json();if(c.length===0||(yield c,c.length<a))break;n+=c.length}}async*_getCursorPaginatedList(t,r=null,i="POST",n="runs"){let a=r?{...r}:{};for(;;){let o=JSON.stringify(a),c=await(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}${t}`,{method:i,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(l,`fetch ${t}`),l})).json();if(!c||!c[n])break;yield c[n];let u=c.cursors;if(!u||!u.next)break;a.cursor=u.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(t,r=!1){if(this.tracingSampleRate===void 0)return t;if(r){let i=[];for(let n of t)this.filteredPostUuids.has(n.trace_id)?n.id===n.trace_id&&this.filteredPostUuids.delete(n.trace_id):i.push(n);return i}else{let i=[];for(let n of t){let a=n.trace_id??n.id;this.filteredPostUuids.has(a)||(n.id===a?this._shouldSample()?i.push(n):this.filteredPostUuids.add(a):i.push(n))}return i}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??dz}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??pz}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let i=[];for(;this.autoBatchQueue.items.length>0;){let[n,a]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!n.length){a();break}let o=n.reduce((u,l)=>{let d=l.apiUrl??this.apiUrl,f=l.apiKey??this.apiKey,m=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl?"default":`${d}|${f}`;return u[m]||(u[m]=[]),u[m].push(l),u},{}),s=[];for(let[u,l]of Object.entries(o)){let d=this._processBatch(l,{apiUrl:u==="default"?void 0:u.split("|")[0],apiKey:u==="default"?void 0:u.split("|")[1]});s.push(d)}let c=Promise.all(s).finally(a);i.push(c)}return Promise.all(i)}static async _writeTraceToFallbackDir(t,r,i,n,a){try{let o=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:n,headers:i,body_base64:o.toString("base64")}),c=`trace_${Date.now()}_${Ma().slice(0,8)}.json`,u=Da.join(t,c);if(e._fallbackDirsCreated.has(t)||(await cI(t),e._fallbackDirsCreated.add(t)),a!==void 0&&a>0)try{let d=(await uI(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await lI(Da.join(t,p));f+=m}if(f>=a){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${a} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await md(u,s),console.warn(`LangSmith trace upload failed; data saved to ${u} for later replay.`)}catch(o){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,o)}}async _processBatch(t,r){if(!t.length)return;let i=t.reduce((n,a)=>n+(a.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let n={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},a=await this._ensureServerInfo();if(!this._multipartDisabled&&(a?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&a?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(n,{...r,useGzip:s,sizeBytes:i})}catch(c){if(Pd(c))this._multipartDisabled=!0,await this.batchIngestRuns(n,{...r,sizeBytes:i});else throw c}}else await this.batchIngestRuns(n,{...r,sizeBytes:i})}}catch(n){console.error("Error exporting batch:",n)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,i=[];for(let n of t)n.item.id&&n.otelContext&&(r.set(n.item.id,n.otelContext),n.action==="create"?i.push({operation:"post",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}):i.push({operation:"patch",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}));this.langSmithToOTELTranslator.exportBatch(i,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=BI(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let i=await this._getBatchSizeLimitBytes(),n=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>i||this.autoBatchQueue.items.length>n)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(fz),...this.fetchOptions});return await Y(i,"get server info"),i})).json();return this.debug&&console.log(`
|
|
120
|
+
=== LangSmith Server Configuration ===
|
|
121
|
+
`+JSON.stringify(r,null,2)+`
|
|
122
|
+
`),r}async _ensureServerInfo(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=(async()=>{if(this._serverInfo===void 0)try{this._serverInfo=await this._getServerInfo()}catch(t){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${t.status??"Unspecified status code"} ${t.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(t=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),t))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){let t=await this._getBatchSizeLimitBytes(),r=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r})}_cloneCurrentOTELContext(){let t=wd(),r=gI();if(this.langSmithToOTELTranslator!==void 0){let i=t.getActiveSpan();if(i)return t.setSpan(r.active(),i)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let i={...this._mergedHeaders,"Content-Type":"application/json"},n=t.project_name;delete t.project_name;let a=await this.prepareRunCreateOrUpdateInputs({session_name:n,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&a.trace_id!==void 0&&a.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:a,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let o=BI(a,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(i["x-tenant-id"]=r.workspaceId);let s=Mt(o,`Creating run with id: ${o.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Y(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),a=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(n.length>0&&a.length>0){let c=n.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of a)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);n=Object.values(c),a=u}let o={post:n,patch:a};if(!o.post.length&&!o.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=o[u].reverse(),d=l.pop();for(;d!==void 0;)s[u].push(d),d=l.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(u=>u.id).concat(s.patch.map(u=>u.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),i)}}async _postBatchIngestRuns(t,r){let i={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let n=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await Y(n,"batch create run",!0),n})}async multipartIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n={},a=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(n[f.id]=f.attachments),delete f.attachments,a.push(f)}let o=[];for(let d of r??[])o.push(await this.prepareRunCreateOrUpdateInputs(d));if(a.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(o.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(a.length>0&&o.length>0){let d=a.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of o)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);a=Object.values(d),o=f}if(a.length===0&&o.length===0)return;let u=[],l=[];for(let[d,f]of[["post",a],["patch",o]])for(let p of f){let{inputs:m,outputs:g,events:y,extra:b,error:w,serialized:x,attachments:k,...E}=p,V={inputs:m,outputs:g,events:y,extra:b,error:w,serialized:x},C=await this._serializeBody(E,`Serializing for multipart ingestion of run with id: ${E.id}`);l.push({name:`${d}.${E.id}`,payload:new Blob([C],{type:`application/json; length=${C.length}`})});for(let[v,W]of Object.entries(V)){if(W===void 0)continue;let F=await this._serializeBody(W,`Serializing ${v} for multipart ingestion of run with id: ${E.id}`);l.push({name:`${d}.${E.id}.${v}`,payload:new Blob([F],{type:`application/json; length=${F.length}`})})}if(E.id!==void 0){let v=n[E.id];if(v){delete n[E.id];for(let[W,F]of Object.entries(v)){let T,B;if(Array.isArray(F)?[T,B]=F:(T=F.mimeType,B=F.data),W.includes(".")){console.warn(`Skipping attachment '${W}' for run ${E.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${E.id}.${W}`,payload:new Blob([B],{type:`${T}; length=${B.byteLength}`})})}}}u.push(`trace=${E.trace_id},id=${E.id}`)}await this._sendMultipartRequest(l,u.join("; "),i)}async _createNodeFetchBody(t,r){let i=[];for(let o of t)i.push(new Blob([`--${r}\r
|
|
123
|
+
`])),i.push(new Blob([`Content-Disposition: form-data; name="${o.name}"\r
|
|
124
|
+
`,`Content-Type: ${o.payload.type}\r
|
|
125
|
+
\r
|
|
126
|
+
`])),i.push(o.payload),i.push(new Blob([`\r
|
|
127
|
+
`]));return i.push(new Blob([`--${r}--\r
|
|
128
|
+
`])),await new Blob(i).arrayBuffer()}async _createMultipartStream(t,r){let i=new TextEncoder;return new ReadableStream({async start(a){let o=async s=>{typeof s=="string"?a.enqueue(i.encode(s)):a.enqueue(s)};for(let s of t){await o(`--${r}\r
|
|
129
|
+
`),await o(`Content-Disposition: form-data; name="${s.name}"\r
|
|
130
|
+
`),await o(`Content-Type: ${s.payload.type}\r
|
|
131
|
+
\r
|
|
132
|
+
`);let u=s.payload.stream().getReader();try{let l;for(;!(l=await u.read()).done;)a.enqueue(l.value)}finally{u.releaseLock()}await o(`\r
|
|
133
|
+
`)}await o(`--${r}--\r
|
|
134
|
+
`),a.close()}})}async _sendMultipartRequest(t,r,i){let n="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),a=()=>this._createNodeFetchBody(t,n),o=()=>this._createMultipartStream(t,n),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:i?.sizeBytes},async()=>{let u=await c(),l={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${n}`};i?.apiKey!==void 0&&(l["x-api-key"]=i.apiKey);let d=u;i?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let f=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(f,"Failed to send multipart request",!0),f});try{let c,u=!1;J$()&&!this.multipartStreamingDisabled&&Uc()!=="bun"?(u=!0,c=await s(o)):c=await s(a),(!this.multipartStreamingDisabled||u)&&c.status===422&&(i?.apiUrl??this.apiUrl)!==Nd&&(console.warn(`Streaming multipart upload to ${i?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${r}".`),this.multipartStreamingDisabled=!0,c=await s(a))}catch(c){if(Pd(c))throw c;if(console.warn(`${c.message.trim()}
|
|
135
|
+
|
|
136
|
+
Context: ${r}`),this.failedTracesDir){let u=await this._createNodeFetchBody(t,n).catch(()=>null);u&&await e._writeTraceToFallbackDir(this.failedTracesDir,u,{"Content-Type":`multipart/form-data; boundary=${n}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,i){pe(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events&&(r.events=this._filterNewTokenEvents(r.events));let n={...r,id:t};if(!this._filterForSampling([n],!0).length)return;if(this.autoBatchTracing&&n.trace_id!==void 0&&n.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&n.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}let a={...this._mergedHeaders,"Content-Type":"application/json"};i?.apiKey!==void 0&&(a["x-api-key"]=i.apiKey),i?.workspaceId!==void 0&&(a["x-tenant-id"]=i.workspaceId);let o=Mt(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:a,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){pe(t);let i=Bc(await this._get(`/runs/${t}`));return r&&(i=await this._loadChildRuns(i)),i}async getRunUrl({runId:t,run:r,projectOpts:i}){if(r!==void 0){let n;r.session_id?n=r.session_id:i?.projectName?n=(await this.readProject({projectName:i?.projectName})).id:i?.projectId?n=i?.projectId:n=(await this.readProject({projectName:He("PROJECT")||"default"})).id;let a=await this._getTenantId();return`${this.getHostUrl()}/o/${a}/projects/p/${n}/r/${r.id}?poll=true`}else if(t!==void 0){let n=await this.readRun(t);if(!n.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${n.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await uz(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),i={},n={};r.sort((a,o)=>(a?.dotted_order??"").localeCompare(o?.dotted_order??""));for(let a of r){if(a.parent_run_id===null||a.parent_run_id===void 0)throw new Error(`Child run ${a.id} has no parent`);a.dotted_order?.startsWith(t.dotted_order??"")&&a.id!==t.id&&(a.parent_run_id in i||(i[a.parent_run_id]=[]),i[a.parent_run_id].push(a),n[a.id]=a)}t.child_runs=i[t.id]||[];for(let a in i)a!==t.id&&(n[a].child_runs=i[a]);return t}async*listRuns(t){let{projectId:r,projectName:i,parentRunId:n,traceId:a,referenceExampleId:o,startTime:s,executionOrder:c,isRoot:u,runType:l,error:d,id:f,query:p,filter:m,traceFilter:g,treeFilter:y,limit:b,select:w,order:x}=t,k=[];if(r&&(k=Array.isArray(r)?r:[r]),i){let v=Array.isArray(i)?i:[i],W=await Promise.all(v.map(F=>this.readProject({projectName:F}).then(T=>T.id)));k.push(...W)}let E=["app_path","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],V={session:k.length?k:null,run_type:l,reference_example:o,query:p,filter:m,trace_filter:g,tree_filter:y,execution_order:c,parent_run:n,start_time:s?s.toISOString():null,error:d,id:f,limit:b,trace:a,select:w||E,is_root:u,order:x};V.select.includes("child_run_ids")&&ja("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let C=0;for await(let v of this._getCursorPaginatedList("/runs/query",V)){let W=v.map(Bc);if(b){if(C>=b)break;if(W.length+C>b){yield*W.slice(0,b-C);break}C+=W.length,yield*W}else yield*W}}async*listGroupRuns(t){let{projectId:r,projectName:i,groupBy:n,filter:a,startTime:o,endTime:s,limit:c,offset:u}=t,d={session_id:r||(await this.readProject({projectName:i})).id,group_by:n,filter:a,start_time:o?o.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(u)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let g={...d,offset:f},y=Object.fromEntries(Object.entries(g).filter(([V,C])=>C!==void 0)),b=JSON.stringify(y),x=await(await this.caller.call(async()=>{let V=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:b});return await Y(V,`Failed to fetch ${p}`),V})).json(),{groups:k,total:E}=x;if(k.length===0)break;for(let V of k)yield V;if(f+=k.length,f>=E)break}}async*readThread(t){let{threadId:r,projectId:i,projectName:n,isRoot:a=!0,limit:o,filter:s,order:c="asc"}=t;if(!i&&!n)throw new Error("threadId requires projectId or projectName");let u=`eq(thread_id, ${JSON.stringify(r)})`,l=s?`and(${u}, ${s})`:u;yield*this.listRuns({projectId:i??void 0,projectName:n??void 0,isRoot:a,limit:o,filter:l,order:c})}async listThreads(t){let{projectId:r,projectName:i,limit:n,offset:a=0,filter:o,startTime:s,isRoot:c=!0}=t;if(!r&&!i)throw new Error("Either projectId or projectName must be provided");if(r&&i)throw new Error("Provide exactly one of projectId or projectName");let u=r??(await this.readProject({projectName:i})).id,l=s??new Date(Date.now()-1440*60*1e3),f={session:[u],is_root:c,limit:100,order:"desc",select:["id","name","status","start_time","end_time","thread_id","trace_id","run_type","error","tags","session_id","parent_run_id","total_tokens","total_cost","dotted_order","reference_example_id","feedback_stats","app_path","completion_cost","completion_tokens","prompt_cost","prompt_tokens","first_token_time"],start_time:l.toISOString()};o!=null&&(f.filter=o);let p=new Map;for await(let b of this._getCursorPaginatedList("/runs/query",f))for(let w of b){let x=Bc(w),k=x.thread_id;if(k){let E=p.get(k)??[];E.push(x),p.set(k,E)}}let m=[];for(let[b,w]of p.entries()){w.sort((C,v)=>{let W=C,F=v,T=W.start_time??"",B=F.start_time??"";if(T!==B)return T.localeCompare(B);let Z=W.dotted_order??"",ne=F.dotted_order??"";return Z.localeCompare(ne)});let k=[...w.map(C=>C.start_time).filter(Boolean)].sort(),E=k.length?k[0]:"",V=k.length?k[k.length-1]:"";m.push({thread_id:b,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:E,max_start_time:V,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((b,w)=>{let x=b.max_start_time??"";return(w.max_start_time??"").localeCompare(x)});let g=a>0?m.slice(a):m;return n!==void 0?g.slice(0,n):g}async getRunStats({id:t,trace:r,parentRun:i,runType:n,projectNames:a,projectIds:o,referenceExampleIds:s,startTime:c,endTime:u,error:l,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:g,dataSourceType:y}){let b=o||[];a&&(b=[...o||[],...await Promise.all(a.map(C=>this.readProject({projectName:C}).then(v=>v.id)))]);let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:i,run_type:n,session:b,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:g,data_source_type:y}).filter(([C,v])=>v!==void 0)),k=JSON.stringify(x);return await(await this.caller.call(async()=>{let C=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:k});return await Y(C,"get run stats"),C})).json()}async shareRun(t,{shareId:r}={}){let i={run_id:t,share_token:r||Ma()};pe(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await Y(s,"share run"),s})).json();if(o===null||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`}async unshareRun(t){pe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(r,"unshare run",!0),r})}async readRunSharedLink(t){pe(t);let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"read run shared link"),n})).json();if(!(i===null||!("share_token"in i)))return`${this.getHostUrl()}/public/${i.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){let i=new URLSearchParams({share_token:t});if(r!==void 0)for(let o of r)i.append("id",o);return pe(t),(await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/runs${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(o,"list shared runs"),o})).json()).map(Bc)}async readDatasetSharedSchema(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id),pe(t);let n=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(a,"read dataset shared schema"),a})).json();return n.url=`${this.getHostUrl()}/public/${n.share_token}/d`,n}async shareDataset(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id);let i={dataset_id:t};pe(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await Y(s,"share dataset"),s})).json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(t){pe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(r,"unshare dataset",!0),r})}async readSharedDataset(t){return pe(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"read shared dataset"),n})).json()}async listSharedExamples(t,r){let i={};r?.exampleIds&&(i.id=r.exampleIds);let n=new URLSearchParams;Object.entries(i).forEach(([s,c])=>{Array.isArray(c)?c.forEach(u=>n.append(s,u)):n.append(s,c)});let a=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${n.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(s,"list shared examples"),s}),o=await a.json();if(!a.ok)throw"detail"in o?new Error(`Failed to list shared examples.
|
|
137
|
+
Status: ${a.status}
|
|
138
|
+
Message: ${Array.isArray(o.detail)?o.detail.join(`
|
|
139
|
+
`):"Unspecified error"}`):new Error(`Failed to list shared examples: ${a.status} ${a.statusText}`);return o.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:i=null,upsert:n=!1,projectExtra:a=null,referenceDatasetId:o=null}){let s=n?"?upsert=true":"",c=`${this.apiUrl}/sessions${s}`,u=a||{};i&&(u.metadata=i);let l={name:t,extra:u,description:r};o!==null&&(l.reference_dataset_id=o);let d=JSON.stringify(l);return await(await this.caller.call(async()=>{let m=await this._fetch(c,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await Y(m,"create project"),m})).json()}async updateProject(t,{name:r=null,description:i=null,metadata:n=null,projectExtra:a=null,endTime:o=null}){let s=`${this.apiUrl}/sessions/${t}`,c=a;n&&(c={...c||{},metadata:n});let u=JSON.stringify({name:r,extra:c,description:i,end_time:o?new Date(o).toISOString():null});return await(await this.caller.call(async()=>{let f=await this._fetch(s,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await Y(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let i="/sessions",n=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),i+=`/${t}`;else if(r!==void 0)n.append("name",r);else throw new Error("Must provide projectName or projectId");let a=await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}?${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(o,"has project"),o});try{let o=await a.json();return a.ok?Array.isArray(o)?o.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:i}){let n="/sessions",a=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),n+=`/${t}`;else if(r!==void 0)a.append("name",r);else throw new Error("Must provide projectName or projectId");i!==void 0&&a.append("include_stats",i.toString());let o=await this._get(n,a),s;if(Array.isArray(o)){if(o.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=o[0]}else s=o;return s}async getProjectUrl({projectId:t,projectName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either projectName or projectId");let i=await this.readProject({projectId:t,projectName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${i.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let i=await this.readDataset({datasetId:t,datasetName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/datasets/${i.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;let t=new URLSearchParams({limit:"1"});for await(let r of this._getPaginated("/sessions",t))return this._tenantId=r[0].tenant_id,r[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:t,name:r,nameContains:i,referenceDatasetId:n,referenceDatasetName:a,includeStats:o,datasetVersion:s,referenceFree:c,metadata:u}={}){let l=new URLSearchParams;if(t!==void 0)for(let d of t)l.append("id",d);if(r!==void 0&&l.append("name",r),i!==void 0&&l.append("name_contains",i),n!==void 0)l.append("reference_dataset",n);else if(a!==void 0){let d=await this.readDataset({datasetName:a});l.append("reference_dataset",d.id)}o!==void 0&&l.append("include_stats",o.toString()),s!==void 0&&l.append("dataset_version",s),c!==void 0&&l.append("reference_free",c.toString()),u!==void 0&&l.append("metadata",JSON.stringify(u));for await(let d of this._getPaginated("/sessions",l))yield*d}async deleteProject({projectId:t,projectName:r}){let i;if(t===void 0&&r===void 0)throw new Error("Must provide projectName or projectId");if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");t===void 0?i=(await this.readProject({projectName:r})).id:i=t,pe(i),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/sessions/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,`delete session ${i} (${r})`,!0),n})}async uploadCsv({csvFile:t,fileName:r,inputKeys:i,outputKeys:n,description:a,dataType:o,name:s}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,r),i.forEach(p=>{u.append("input_keys",p)}),n.forEach(p=>{u.append("output_keys",p)}),a&&u.append("description",a),o&&u.append("data_type",o),s&&u.append("name",s),await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await Y(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:i,inputsSchema:n,outputsSchema:a,metadata:o}={}){let s={name:t,description:r,extra:{source:"sdk",...o?{metadata:o}:{}}};i&&(s.data_type=i),n&&(s.inputs_schema_definition=n),a&&(s.outputs_schema_definition=a);let c=JSON.stringify(s);return await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Y(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let i="/datasets",n=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)pe(t),i+=`/${t}`;else if(r)n.append("name",r);else throw new Error("Must provide datasetName or datasetId");let a=await this._get(i,n),o;if(Array.isArray(a)){if(a.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);o=a[0]}else o=a;return o}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(i){if(i instanceof Error&&i.message.toLocaleLowerCase().includes("not found"))return!1;throw i}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:i,toVersion:n}){let a=t;if(a===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(a!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");a===void 0&&(a=(await this.readDataset({datasetName:r})).id);let o=new URLSearchParams({from_version:typeof i=="string"?i:i.toISOString(),to_version:typeof n=="string"?n:n.toISOString()});return await this._get(`/datasets/${a}/versions/diff`,o)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let i="/datasets";if(t===void 0)if(r!==void 0)t=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${i}/${t}/openai_ft`)).text()).trim().split(`
|
|
140
|
+
`).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:i,datasetName:n,datasetNameContains:a,metadata:o}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(i!==void 0)for(let u of i)c.append("id",u);n!==void 0&&c.append("name",n),a!==void 0&&c.append("name_contains",a),o!==void 0&&c.append("metadata",JSON.stringify(o));for await(let u of this._getPaginated(s,c))yield*u}async updateDataset(t){let{datasetId:r,datasetName:i,...n}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:i})).id;pe(a);let o=JSON.stringify(n);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:i,asOf:n,tag:a}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:i})).id;pe(o);let s=JSON.stringify({as_of:typeof n=="string"?n:n.toISOString(),tag:a});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Y(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let i="/datasets",n=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(n=(await this.readDataset({datasetName:r})).id),n!==void 0)pe(n),i+=`/${n}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let a=await this._fetch(this.apiUrl+i,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(a,`delete ${i}`,!0),a})}async createExample(t,r,i){if(ZI(t)&&(r!==void 0||i!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let n=r?i?.datasetId:t.dataset_id,a=r?i?.datasetName:t.dataset_name;if(n===void 0&&a===void 0)throw new Error("Must provide either datasetName or datasetId");if(n!==void 0&&a!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");n===void 0&&(n=(await this.readDataset({datasetName:a})).id);let o=(r?i?.createdAt:t.created_at)||new Date,s;ZI(t)?s=t:s={inputs:t,outputs:r,created_at:o?.toISOString(),id:i?.exampleId,metadata:i?.metadata,split:i?.split,source_run_id:i?.sourceRunId,use_source_run_io:i?.useSourceRunIO,use_source_run_attachments:i?.useSourceRunAttachments,attachments:i?.attachments};let c=await this._uploadExamplesMultipart(n,[s]);return await this.readExample(c.example_ids?.[0]??Ma())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,x=w[0].dataset_id,k=w[0].dataset_name;if(x===void 0&&k===void 0)throw new Error("Must provide either datasetName or datasetId");if(x!==void 0&&k!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");x===void 0&&(x=(await this.readDataset({datasetName:k})).id);let E=await this._uploadExamplesMultipart(x,w);return await Promise.all(E.example_ids.map(C=>this.readExample(C)))}let{inputs:r,outputs:i,metadata:n,splits:a,sourceRunIds:o,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:u,exampleIds:l,datasetId:d,datasetName:f}=t;if(r===void 0)throw new Error("Must provide inputs when using legacy parameters");let p=d,m=f;if(p===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(p!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");p===void 0&&(p=(await this.readDataset({datasetName:m})).id);let g=r.map((w,x)=>({dataset_id:p,inputs:w,outputs:i?.[x],metadata:n?.[x],split:a?.[x],id:l?.[x],attachments:u?.[x],source_run_id:o?.[x],use_source_run_io:s?.[x],use_source_run_attachments:c?.[x]})),y=await this._uploadExamplesMultipart(p,g);return await Promise.all(y.example_ids.map(w=>this.readExample(w)))}async createLLMExample(t,r,i){return this.createExample({input:t},{output:r},i)}async createChatExample(t,r,i){let n=t.map(o=>Cg(o)?Og(o):o),a=Cg(r)?Og(r):r;return this.createExample({input:n},{output:a},i)}async readExample(t){pe(t);let r=`/examples/${t}`,i=await this._get(r),{attachment_urls:n,...a}=i,o=a;return n&&(o.attachments=Object.entries(n).reduce((s,[c,u])=>(s[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},s),{})),o}async*listExamples({datasetId:t,datasetName:r,exampleIds:i,asOf:n,splits:a,inlineS3Urls:o,metadata:s,limit:c,offset:u,filter:l,includeAttachments:d}={}){let f;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)f=t;else if(r!==void 0)f=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide a datasetName or datasetId");let p=new URLSearchParams({dataset:f}),m=n?typeof n=="string"?n:n?.toISOString():void 0;m&&p.append("as_of",m);let g=o??!0;if(p.append("inline_s3_urls",g.toString()),i!==void 0)for(let b of i)p.append("id",b);if(a!==void 0)for(let b of a)p.append("splits",b);if(s!==void 0){let b=JSON.stringify(s);p.append("metadata",b)}c!==void 0&&p.append("limit",c.toString()),u!==void 0&&p.append("offset",u.toString()),l!==void 0&&p.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(b=>p.append("select",b));let y=0;for await(let b of this._getPaginated("/examples",p)){for(let w of b){let{attachment_urls:x,...k}=w,E=k;x&&(E.attachments=Object.entries(x).reduce((V,[C,v])=>(V[C.slice(11)]={presigned_url:v.presigned_url,mime_type:v.mime_type||void 0},V),{})),yield E,y++}if(c!==void 0&&y>=c)break}}async deleteExample(t){pe(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,`delete ${r}`,!0),i})}async deleteExamples(t,r){if(t.forEach(i=>pe(i)),r?.hardDelete){let i=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"hard delete examples",!0),n})}else{let i=new URLSearchParams;t.forEach(n=>i.append("example_ids",n)),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/examples?${i.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"delete examples",!0),n})}}async updateExample(t,r){let i;r?i=t:i=t.id,pe(i);let n;r?n={id:i,...r}:n=t;let a;return n.dataset_id!==void 0?a=n.dataset_id:a=(await this.readExample(i)).dataset_id,this._updateExamplesMultipart(a,[n])}async updateExamples(t){let r;return t[0].dataset_id===void 0?r=(await this.readExample(t[0].id)).dataset_id:r=t[0].dataset_id,this._updateExamplesMultipart(r,t)}async readDatasetVersion({datasetId:t,datasetName:r,asOf:i,tag:n}){let a;if(t?a=t:a=(await this.readDataset({datasetName:r})).id,pe(a),i&&n||!i&&!n)throw new Error("Exactly one of asOf and tag must be specified.");let o=new URLSearchParams;return i!==void 0&&o.append("as_of",typeof i=="string"?i:i.toISOString()),n!==void 0&&o.append("tag",n),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/version?${o.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:i}){let n;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?n=(await this.readDataset({datasetName:r})).id:n=t,pe(n);let a=new URLSearchParams,o=i?typeof i=="string"?i:i?.toISOString():void 0;return o&&a.append("as_of",o),await this._get(`/datasets/${n}/splits`,a)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:i,exampleIds:n,remove:a=!1}){let o;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?o=(await this.readDataset({datasetName:r})).id:o=t,pe(o);let s={split_name:i,examples:n.map(u=>(pe(u),u)),remove:a},c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${o}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Y(u,"update dataset splits",!0),u})}async createFeedback(t,r,{score:i,value:n,correction:a,comment:o,sourceInfo:s,feedbackSourceType:c="api",sourceRunId:u,feedbackId:l,feedbackConfig:d,projectId:f,comparativeExperimentId:p,sessionId:m,startTime:g}){if(!t&&!f)throw new Error("One of runId or projectId must be provided");if(t&&f)throw new Error("Only one of runId or projectId can be provided");let y={type:c??"api",metadata:s??{}};u!==void 0&&y?.metadata!==void 0&&!y.metadata.__run&&(y.metadata.__run={run_id:u}),y?.metadata!==void 0&&y.metadata.__run?.run_id!==void 0&&pe(y.metadata.__run.run_id);let b={id:l??Yo(),run_id:t,key:r,score:VI(i),value:n,correction:a,comment:o,feedback_source:y,comparative_experiment_id:p,feedbackConfig:d,session_id:m??f,start_time:g},w=JSON.stringify(b),x=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let k=await this._fetch(x,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await Y(k,"create feedback",!0),k}),b}async updateFeedback(t,{score:r,value:i,correction:n,comment:a}){let o={};r!=null&&(o.score=VI(r)),i!=null&&(o.value=i),n!=null&&(o.correction=n),a!=null&&(o.comment=a),pe(t);let s=JSON.stringify(o);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Y(c,"update feedback",!0),c})}async readFeedback(t){pe(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){pe(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,`delete ${r}`,!0),i})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:i}={}){let n=new URLSearchParams;if(t)for(let a of t)pe(a),n.append("run",a);if(r)for(let a of r)n.append("key",a);if(i)for(let a of i)n.append("source",a);for await(let a of this._getPaginated("/feedback",n))yield*a}async createPresignedFeedbackToken(t,r,{expiration:i,feedbackConfig:n}={}){let a={run_id:t,feedback_key:r,feedback_config:n};i?typeof i=="string"?a.expires_at=i:(i?.hours||i?.minutes||i?.days)&&(a.expires_in=i):a.expires_in={hours:3};let o=JSON.stringify(a);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:i,createdAt:n,description:a,metadata:o,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(i||(i=(await this.readProject({projectId:r[0]})).reference_dataset_id),!i==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:i,description:a,created_at:(n??new Date)?.toISOString(),extra:{}};o&&(c.extra.metadata=o);let u=JSON.stringify(c);return(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await Y(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){pe(t);let r=new URLSearchParams({run_id:t});for await(let i of this._getPaginated("/feedback/tokens",r))yield*i}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,i){let n=this._selectEvalResults(t),a=[];for(let o of n){let s=i||{};o.evaluatorInfo&&(s={...o.evaluatorInfo,...s});let c=null;o.targetRunId?c=o.targetRunId:r&&(c=r.id),a.push(await this.createFeedback(c,o.key,{score:o.score,value:o.value,comment:o.comment,correction:o.correction,sourceInfo:s,sourceRunId:o.sourceRunId,feedbackConfig:o.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id,startTime:r?.start_time}))}return[n,a]}async logEvaluationFeedback(t,r,i){let[n]=await this._logEvaluationFeedback(t,r,i);return n}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:i,isLowerScoreBetter:n=!1}=t,a={feedback_key:r,feedback_config:i,is_lower_score_better:n};return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await Y(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:i,limit:n}=t,a=new URLSearchParams;r&&r.forEach(s=>{a.append("key",s)}),i&&a.append("name_contains",i),a.append("limit",(n!==void 0?Math.min(n,100):100).toString());let o=0;for await(let s of this._getPaginated("/feedback-configs",a))if(yield*s,o+=s.length,n!==void 0&&o>=n)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:i,isLowerScoreBetter:n}=r,a={feedback_key:t};return i!==void 0&&(a.feedback_config=i),n!==void 0&&(a.is_lower_score_better=n),(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await Y(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,"delete feedback config",!0),i})}async*listAnnotationQueues(t={}){let{queueIds:r,name:i,nameContains:n,limit:a}=t,o=new URLSearchParams;r&&r.forEach((c,u)=>{pe(c,`queueIds[${u}]`),o.append("ids",c)}),i&&o.append("name",i),n&&o.append("name_contains",n),o.append("limit",(a!==void 0?Math.min(a,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",o))if(yield*c,s++,a!==void 0&&s>=a)break}async createAnnotationQueue(t){let{name:r,description:i,queueId:n,rubricInstructions:a,rubricItems:o}=t,s={name:r,description:i,id:n||Ma(),rubric_instructions:a,rubric_items:o},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([l,d])=>d!==void 0)));return(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Y(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,"read annotation queue"),i})).json()}async updateAnnotationQueue(t,r){let{name:i,description:n,rubricInstructions:a,rubricItems:o}=r,s={};i!==void 0&&(s.name=i),n!==void 0&&(s.description=n),a!==void 0&&(s.rubric_instructions=a),o!==void 0&&(s.rubric_items=o);let c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Y(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let i=JSON.stringify(r.map((n,a)=>pe(n,`runIds[${a}]`).toString()));await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Y(n,"add runs to annotation queue",!0),n})}async getRunFromAnnotationQueue(t,r){let i=`/annotation-queues/${pe(t,"queueId")}/run`,a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(o,"get run from annotation queue"),o})).json();return Bc(a)}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs/${pe(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,"delete run from annotation queue",!0),i})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,"get size from annotation queue"),i})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let i=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
|
|
141
|
+
|
|
142
|
+
Current tenant: ${i.tenant_handle}
|
|
143
|
+
|
|
144
|
+
Requested tenant: ${r}`)}async _getLatestCommitHash(t){let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"get latest commit hash"),n})).json();if(i.commits.length!==0)return i.commits[0].commit_hash}async _likeOrUnlikePrompt(t,r){let[i,n,a]=Rt(t),o=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${i}/${n}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,i,n]=Rt(t);if(await this._currentTenantIsOwner(r)){let a=await this._getSettings();return n!=="latest"?`${this.getHostUrl()}/prompts/${i}/${n.substring(0,8)}?organizationId=${a.id}`:`${this.getHostUrl()}/prompts/${i}?organizationId=${a.id}`}else return n!=="latest"?`${this.getHostUrl()}/hub/${r}/${i}/${n.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${i}`}async promptExists(t){return!!await this.getPrompt(t)}async likePrompt(t){return this._likeOrUnlikePrompt(t,!0)}async unlikePrompt(t){return this._likeOrUnlikePrompt(t,!1)}async*listCommits(t){let[r,i,n]=Rt(t);for await(let a of this._getPaginated(`/commits/${r}/${i}/`,new URLSearchParams,o=>o.commits))yield*a}async*listPrompts(t){let r=new URLSearchParams;r.append("sort_field",t?.sortField??"updated_at"),r.append("sort_direction","desc"),r.append("is_archived",(!!t?.isArchived).toString()),t?.isPublic!==void 0&&r.append("is_public",t.isPublic.toString()),t?.query&&r.append("query",t.query);for await(let i of this._getPaginated("/repos",r,n=>n.repos))yield*i}async getPrompt(t){let[r,i,n]=Rt(t),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await Y(s,"get prompt"),s)}))?.json();return o?.repo?o.repo:null}async createPrompt(t,r){let i=await this._getSettings();if(r?.isPublic&&!i.tenant_handle)throw new Error(`Cannot create a public prompt without first
|
|
145
|
+
|
|
146
|
+
creating a LangChain Hub handle.
|
|
147
|
+
You can add a handle by creating a public prompt at:
|
|
148
|
+
|
|
149
|
+
https://smith.langchain.com/prompts`);let[n,a,o]=Rt(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("create a prompt",n);let s={repo_handle:a,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),u=await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Y(d,"create prompt"),d}),{repo:l}=await u.json();return l}async createCommit(t,r,i){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,a,o]=Rt(t),s=i?.parentCommitHash==="latest"||!i?.parentCommitHash?await this._getLatestCommitHash(`${n}/${a}`):i?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...i?.description!==void 0&&{description:i.description}},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}/commits/${n}/${a}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await Y(f,"create commit"),f})).json();return this._getPromptUrl(`${n}/${a}${d.commit_hash?`:${d.commit_hash}`:""}`)}async updateExamplesMultipart(t,r=[]){return this._updateExamplesMultipart(t,r)}async _updateExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let o of r){let s=o.id,c={...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split}},u=Mt(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(i.append(s,l),o.inputs){let d=Mt(o.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.inputs`,f)}if(o.outputs){let d=Mt(o.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.outputs`,f)}if(o.attachments)for(let[d,f]of Object.entries(o.attachments)){let p,m;Array.isArray(f)?[p,m]=f:(p=f.mimeType,m=f.data);let g=new Blob([m],{type:`${p}; length=${m.byteLength}`});i.append(`${s}.attachment.${d}`,g)}if(o.attachments_operations){let d=Mt(o.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.attachments_operations`,f)}}let n=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${n}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Y(o,"update examples"),o})).json()}async uploadExamplesMultipart(t,r=[]){return this._uploadExamplesMultipart(t,r)}async _uploadExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let a of r){let o=(a.id??Ma()).toString(),s={created_at:a.created_at,...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split},...a.source_run_id&&{source_run_id:a.source_run_id},...a.use_source_run_io&&{use_source_run_io:a.use_source_run_io},...a.use_source_run_attachments&&{use_source_run_attachments:a.use_source_run_attachments}},c=Mt(s,`Serializing body for uploaded example with id: ${o}`),u=new Blob([c],{type:"application/json"});if(i.append(o,u),a.inputs){let l=Mt(a.inputs,`Serializing inputs for uploaded example with id: ${o}`),d=new Blob([l],{type:"application/json"});i.append(`${o}.inputs`,d)}if(a.outputs){let l=Mt(a.outputs,`Serializing outputs for uploaded example with id: ${o}`),d=new Blob([l],{type:"application/json"});i.append(`${o}.outputs`,d)}if(a.attachments)for(let[l,d]of Object.entries(a.attachments)){let f,p;Array.isArray(d)?[f,p]=d:(f=d.mimeType,p=d.data);let m=new Blob([p],{type:`${f}; length=${p.byteLength}`});i.append(`${o}.attachment.${l}`,m)}}return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Y(a,"upload examples"),a})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,n]=Rt(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("update a prompt",i);let a={};if(r?.description!==void 0&&(a.description=r.description),r?.readme!==void 0&&(a.readme=r.readme),r?.tags!==void 0&&(a.tags=r.tags),r?.isPublic!==void 0&&(a.is_public=r.isPublic),r?.isArchived!==void 0&&(a.is_archived=r.isArchived),Object.keys(a).length===0)throw new Error("No valid update options provided");let o=JSON.stringify(a);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${i}/${n}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Y(c,"update prompt"),c})).json()}async deletePrompt(t){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[r,i,n]=Rt(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(o,"delete prompt"),o})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[i,n,a]=Rt(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${i}/${n}/${a}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(c,"pull prompt commit"),c})).json();return{owner:i,repo:n,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples,hub_model_config:s.model_config,hub_model_provider:s.model_provider}}async pullPromptCommit(t,r){oz(t,r?.dangerouslyPullPublicPrompt);let i=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let n=this._getPromptCacheKey(t,r?.includeModel),a=this._promptCache.get(n,i);if(a)return a;let o=await i();return this._promptCache.set(n,o,i),o}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let i=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(i.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&Object.keys(r).some(n=>n!=="object")&&await this.updatePrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}):await this.createPrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}),r?.object?await this.createCommit(t,r?.object,{parentCommitHash:r?.parentCommitHash,description:r?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[r,i]=Rt(t);return this._repoExists(r,i)}async skillExists(t){let[r,i]=Rt(t);return this._repoExists(r,i)}async pullAgent(t,r){return await this._pullDirectory(t,"agent",r?.version)}async pullSkill(t,r){return await this._pullDirectory(t,"skill",r?.version)}async pushAgent(t,r){return this._pushDirectory(t,"agent",r)}async pushSkill(t,r){return this._pushDirectory(t,"skill",r)}async deleteAgent(t){return this._deleteDirectory(t)}async deleteSkill(t){return this._deleteDirectory(t)}async*listAgents(t){yield*this._listReposByType("agent",t)}async*listSkills(t){yield*this._listReposByType("skill",t)}async*_listReposByType(t,r){let i=new URLSearchParams;i.append("repo_type",t),i.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&i.append("is_public",r.isPublic.toString()),r?.query&&i.append("query",r.query);for await(let n of this._getPaginated("/repos",i,a=>a.repos))yield*n}async _pullDirectory(t,r,i){let[n,a,o]=Rt(t),s=i??(o!=="latest"?o:void 0),c=new URL(`${this.apiUrl}/v1/platform/hub/repos/${n}/${a}/directories`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let l=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(l,"pull directory"),l})).json()}async _pushDirectory(t,r,i){if(i.parentCommit!==void 0&&(i.parentCommit.length<8||i.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[n,a]=Rt(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError(`push ${r}`,n);if(await this._repoExists(n,a))(i.description!==void 0||i.readme!==void 0||i.tags!==void 0||i.isPublic!==void 0)&&await this._updateRepoMetadata(n,a,i);else{let d=/^[a-z][a-z0-9-_]*$/;if(!d.test(a))throw new Error(`Invalid repo_handle ${JSON.stringify(a)}: must match ${d}`);await this._createRepo(a,r,i)}let o={files:i.files};i.parentCommit&&(o.parent_commit=i.parentCommit);let u=(await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${n}/${a}/directories/commits`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await Y(d,`push ${r}`),d})).json()).commit.commit_hash,l=n;return n==="-"&&(l=(await this._getSettings()).tenant_handle||n),`${this.getHostUrl()}/hub/${l}/${a}:${u.slice(0,8)}`}async _deleteDirectory(t){let[r,i]=Rt(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${r}/${i}/directories`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(n,"delete directory"),n})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Y(i,"check repo exists"),i}),!0}catch(i){if(Pd(i))return!1;throw i}}async _createRepo(t,r,i){let n={repo_handle:t,repo_type:r,is_public:!!i.isPublic};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags);try{await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await Y(a,`create ${r}`),a})}catch(a){if(AI(a))return;throw a}}async _updateRepoMetadata(t,r,i){let n={};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags),i.isPublic!==void 0&&(n.is_public=i.isPublic),Object.keys(n).length!==0&&await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await Y(a,"update repo metadata"),a})}async clonePublicDataset(t,r={}){let{sourceApiUrl:i=this.apiUrl,datasetName:n}=r,[a,o]=this.parseTokenOrUrl(t,i),s=new e({apiUrl:a,apiKey:"placeholder"}),c=await s.readSharedDataset(o),u=n||c.name;try{if(await this.hasDataset({datasetId:u})){console.log(`Dataset ${u} already exists in your tenant. Skipping.`);return}}catch{}let l=await s.listSharedExamples(o),d=await this.createDataset(u,{description:c.description,dataType:c.data_type||"kv",inputsSchema:c.inputs_schema_definition??void 0,outputsSchema:c.outputs_schema_definition??void 0});try{await this.createExamples({inputs:l.map(f=>f.inputs),outputs:l.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,i=2,n="dataset"){try{return pe(t),[r,t]}catch{}try{let o=new URL(t).pathname.split("/").filter(s=>s!=="");if(o.length>=i){let s=o[o.length-i];return[r,s]}else throw new Error(`Invalid public ${n} URL: ${t}`)}catch{throw new Error(`Invalid public ${n} URL or token: ${t}`)}}cleanup(){this._promptCache&&this._promptCache.stop()}async awaitPendingTraceBatches(){if(this.manualFlushMode)return console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches."),Promise.resolve();for(await new Promise(t=>setTimeout(t,1));this._pendingDrains.size>0;)await Promise.all([...this._pendingDrains]);await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await _I()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}toString(){let t=[`apiUrl=${JSON.stringify(this.apiUrl)}`];return this.webUrl!==void 0&&t.push(`webUrl=${JSON.stringify(this.webUrl)}`),this.workspaceId!==void 0&&t.push(`workspaceId=${JSON.stringify(this.workspaceId)}`),`[LangSmithClient ${t.join(" ")}]`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};Object.defineProperty(Nn,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function ZI(e){return"dataset_id"in e||"dataset_name"in e}var GI=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>He(r)==="true");var Mn=Symbol.for("lc:context_variables");var zd=Symbol.for("langsmith:replica_trace_roots");function Lg(e,t){if(Mn in e)return e[Mn][t]}function JI(e,t,r){let i=Mn in e?e[Mn]:{};i[t]=r,e[Mn]=i}var Vc=36,mz="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function KI(e){let r=Object.keys(e).sort().map(i=>`${i}:${e[i]??""}`).join("|");return Qh(r,mz)}function hz(e){return e.replace(/[-:.]/g,"")}function qI(e,t=1){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${r}Z`}function Fg(e,t,r=1){let i=qI(e,r);return{dottedOrder:hz(i)+t,microsecondPrecisionDatestring:i}}var gz=new Set(["projectName","updates","reroot"]);function _z(e){let t={};for(let r of Object.keys(e))gz.has(r)&&(t[r]=e[r]);return t}var Dd=class e{constructor(t,r,i,n){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=t,this.tags=r,this.project_name=i,this.replicas=n}static fromHeader(t){let r=t.split(","),i={},n=[],a,o;for(let s of r){let[c,u]=s.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?i=JSON.parse(l):c==="langsmith-tags"?n=l.split(","):c==="langsmith-project"?a=l:c==="langsmith-replicas"&&(o=JSON.parse(l).map(f=>Array.isArray(f)?f:_z(f)))}return new e(i,n,a,o)}toHeader(){let t=[];return this.metadata&&Object.keys(this.metadata).length>0&&t.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&t.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&t.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),t.join(",")}},on=class e{constructor(t){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"attachments",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"distributedParentId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_serialized_start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_awaitInputsOnPost",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),XI(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:i,...n}=t,a=n.client??e.getSharedClient(),o={...i,...n?.extra?.metadata};if(n.extra={...n.extra,metadata:o},"id"in n&&n.id==null&&delete n.id,Object.assign(this,{...r,...n,client:a}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=qI(this.start_time,this.execution_order)),this.id||(this.id=pd(this._serialized_start_time??this.start_time)),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.replicas=wz(this.replicas),!this.dotted_order){let{dottedOrder:s}=Fg(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+s:this.dotted_order=s}}set metadata(t){this.extra={...this.extra,metadata:{...this.extra?.metadata,...t}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){let t=Date.now();return{run_type:"chain",project_name:zc(),child_runs:[],api_url:wt("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:wt("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new Nn),e.sharedClient}createChild(t){let r=this.child_execution_order+1,i=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),n=t.replicas??i,a=new e({...t,parent_run:this,project_name:this.project_name,replicas:n,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),o=this.extra?.metadata??{},s=a.extra?.metadata??{};Object.keys(o).length>0&&(a.extra={...a.extra,metadata:{...o,...s}}),Mn in this&&(a[Mn]=this[Mn]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(vz(u)){let f={...u},p=yz(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:a.id}),p.handlers?.find(YI)?.updateFromRunTree?.(a),f.callbacks=p),a.extra[c]=f}let l=new Set,d=this;for(;d!=null&&!l.has(d.id);)l.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(a),a}async end(t,r,i=Date.now(),n){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??i,n&&Object.keys(n).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...n}}:{metadata:n})}_convertToCreate(t,r,i=!0){let n=t.extra??{};if(n?.runtime?.library===void 0&&(n.runtime||(n.runtime={}),r))for(let[s,c]of Object.entries(r))n.runtime[s]||(n.runtime[s]=c);let a=t.parent_run?.id??t.parent_run_id,o;return i?o=[]:o=t.child_runs.map(s=>this._convertToCreate(s,r,i)),{id:t.id,name:t.name,start_time:t._serialized_start_time??t.start_time,end_time:t.end_time,run_type:t.run_type,reference_example_id:t.reference_example_id,extra:n,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:o,parent_run_id:a,trace_id:t.trace_id,dotted_order:t.dotted_order,tags:t.tags,attachments:t.attachments,events:t.events}}_sliceParentId(t,r){if(r.dotted_order){let i=r.dotted_order.split("."),n=null;for(let a=0;a<i.length;a++)if(i[a].slice(-Vc)===t){n=a;break}if(n!==null){let a=i.slice(n+1);r.dotted_order=a.join("."),a.length>0?r.trace_id=a[0].slice(-Vc):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let i=Lg(this,zd)??{};i[t]=r,JI(this,zd,i);for(let n of this.child_runs)n._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,runtimeEnv:i,excludeChildRuns:n=!0,reroot:a=!1,distributedParentId:o,apiUrl:s,apiKey:c,workspaceId:u}=t,l=this._convertToCreate(this,i,n);if(r===this.project_name)return{...l,session_name:r};if(a){if(o)this._sliceParentId(o,l);else if(l.parent_run_id=void 0,l.dotted_order){let w=l.dotted_order.split(".");w.length>0&&(l.dotted_order=w[w.length-1],l.trace_id=l.id)}let b=KI({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});this._setReplicaTraceRoot(b,l.id)}let d;if(!a){let b=Lg(this,zd)??{},w=KI({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});if(d=b[w],d&&(l.trace_id=d,l.dotted_order)){let x=l.dotted_order.split("."),k=null;for(let E=0;E<x.length;E++)if(x[E].slice(-Vc)===d){k=E;break}if(k!==null){let E=x.slice(k);l.dotted_order=E.join(".")}}}let f=l.id,p=Dc(f,r),m;l.trace_id?m=Dc(l.trace_id,r):m=p;let g;l.parent_run_id&&(g=Dc(l.parent_run_id,r));let y;return l.dotted_order&&(y=l.dotted_order.split(".").map(x=>{let k=x.slice(-Vc),E=Dc(k,r);return x.slice(0,-Vc)+E}).join(".")),{...l,id:p,trace_id:m,parent_run_id:g,dotted_order:y,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=vd();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,apiKey:n,apiUrl:a,workspaceId:o,reroot:s,client:c}of this.replicas){let u=this._remapForProject({projectName:i??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:n,workspaceId:o});await(c??this.client).createRun(u,{apiKey:n,apiUrl:a,workspaceId:o})}else{let i=this._convertToCreate(this,r,t);await this.client.createRun(i)}if(!t){ja("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let i of this.child_runs)await i.postRun(!1)}this.child_runs=[]}catch(r){console.error(`Error in postRun for run ${this.id}:`,r)}}async patchRun(t){if(this.replicas&&this.replicas.length>0)for(let{projectName:r,apiKey:i,apiUrl:n,workspaceId:a,updates:o,reroot:s,client:c}of this.replicas){let u=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:i,workspaceId:a}),l={id:u.id,name:u.name,run_type:u.run_type,start_time:u.start_time,outputs:u.outputs,error:u.error,parent_run_id:u.parent_run_id,session_name:u.session_name,reference_example_id:u.reference_example_id,end_time:u.end_time,dotted_order:u.dotted_order,trace_id:u.trace_id,events:u.events,tags:u.tags,extra:u.extra,attachments:this.attachments,...o};t?.excludeInputs||(l.inputs=u.inputs),await(c??this.client).updateRun(u.id,l,{apiKey:i,apiUrl:n,workspaceId:a})}else try{let r={name:this.name,run_type:this.run_type,start_time:this._serialized_start_time??this.start_time,end_time:this.end_time,error:this.error,outputs:this.outputs,parent_run_id:this.parent_run?.id??this.parent_run_id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags,attachments:this.attachments,session_name:this.project_name};t?.excludeInputs||(r.inputs=this.inputs),await this.client.updateRun(this.id,r)}catch(r){console.error(`Error in patchRun for run ${this.id}`,r)}this.child_runs=[]}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(t){this.events||(this.events=[]),typeof t=="string"?this.events.push({name:"event",time:new Date().toISOString(),message:t}):this.events.push({...t,time:t.time??new Date().toISOString()})}static fromRunnableConfig(t,r){let i=t?.callbacks,n,a,o,s=GI();if(i){let u=i?.getParentRunId?.()??"",l=i?.handlers?.find(d=>d?.name=="langchain_tracer");n=l?.getRun?.(u),a=l?.projectName,o=l?.client,s=s||!!l}return n?new e({name:n.name,id:n.id,trace_id:n.trace_id,dotted_order:n.dotted_order,client:o,tracingEnabled:s,project_name:a,tags:[...new Set((n?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...n?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:o,tracingEnabled:s,project_name:a})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let i="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,n=i["langsmith-trace"];if(!n||typeof n!="string")return;let a=n.trim(),o=a.split(".").map(l=>{let[d,f]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=o[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:s,dotted_order:a};if(i.baggage&&typeof i.baggage=="string"){let l=Dd.fromHeader(i.baggage);c.metadata=l.metadata,c.tags=l.tags,c.project_name=l.project_name,c.replicas=l.replicas}let u=new e(c);return u.distributedParentId=u.id,u}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new Dd(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[i,n]of Object.entries(r))t.set(i,n);return r}};Object.defineProperty(on,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function XI(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function YI(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function WI(e){return Array.isArray(e)&&e.some(t=>YI(t))}function yz(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function vz(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(WI(t?.handlers)||WI(t))}function bz(){let e=wt("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let i of t){if(typeof i!="object"||i===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof i}`);continue}if(typeof i.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_url}`);continue}if(typeof i.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_key}`);continue}r.push({apiUrl:i.api_url.replace(/\/$/,""),apiKey:i.api_key})}return r}else if(typeof t=="object"&&t!==null){xz(t);let r=[];for(let[i,n]of Object.entries(t)){let a=i.replace(/\/$/,"");if(typeof n=="string")r.push({apiUrl:a,apiKey:n});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${i}: expected string, got ${typeof n}`);continue}}return r}else return console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof t}`),[]}catch(t){if(OI(t))throw t;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}}function wz(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):bz()}function xz(e){if(Object.keys(e).length>0&&He("ENDPOINT"))throw new Cd}var QI=A({BaseTracer:()=>At,isBaseTracer:()=>Ua}),Sz=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function Vg(e,t){if(e)return new on({...e,start_time:e._serialized_start_time??e.start_time,parent_run:Vg(t),child_runs:e.child_runs.map(r=>Vg(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:Rh()},tracingEnabled:!1})}function Bg(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Ua(e){return typeof e._addRunToRunMap=="function"}var At=class extends Sr{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?Sz(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
|
|
150
|
+
|
|
151
|
+
${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=Fg(new Date(e.start_time).getTime(),e.id,e.execution_order),i={...e},n=this.getRunById(i.parent_run_id);if(i.parent_run_id!==void 0?n?(this._addChildRun(n,i),n.child_execution_order=Math.max(n.child_execution_order,i.child_execution_order),i.trace_id=n.trace_id,n.dotted_order!==void 0&&(i.dotted_order=[n.dotted_order,t].join("."),i._serialized_start_time=r)):i.parent_run_id=void 0:(i.trace_id=i.id,i.dotted_order=t,i._serialized_start_time=r),this.usesRunTreeMap){let a=Vg(i,n);a!==void 0&&this.runTreeMap.set(i.id,a)}else this.runMap.set(i.id,i);return i}async _endTrace(e){let t=e.parent_run_id!==void 0&&this.getRunById(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):await this.persistRun(e),await this.onRunUpdate?.(e),this.usesRunTreeMap?this.runTreeMap.delete(e.id):this.runMap.delete(e.id)}_getExecutionOrder(e){let t=e!==void 0&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),u=Date.now(),l=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:a||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),u=Date.now(),l=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:a||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.outputs=e,a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMEnd?.(a),await this._endTrace(a),a}async handleLLMError(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMError?.(a),await this._endTrace(a),a}_createRunForChainStart(e,t,r,i,n,a,o,s,c){let u=this._getExecutionOrder(i),l=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:t,execution_order:u,child_execution_order:u,run_type:o??"chain",child_runs:[],extra:a?{...c,metadata:a}:{...c},tags:n||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.outputs=Bg(e,"output"),a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Bg(n.inputs,"input")),await this.onChainEnd?.(a),await this._endTrace(a),a}async handleChainError(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Bg(n.inputs,"input")),await this.onChainError?.(a),await this._endTrace(a),a}_createRunForToolStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{input:t},execution_order:s,child_execution_order:s,run_type:"tool",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onToolStart?.(s),s}async handleToolEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onToolEnd?.(r),await this._endTrace(r),r}async handleToolError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onToolError?.(r),await this._endTrace(r),r}async handleAgentAction(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="chain")return;let i=r;i.actions=i.actions||[],i.actions.push(e),i.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(r)}async handleAgentEnd(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(r))}_createRunForRetrieverStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{query:t},execution_order:s,child_execution_order:s,run_type:"retriever",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onRetrieverStart?.(s),s}async handleRetrieverEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onRetrieverEnd?.(r),await this._endTrace(r),r}async handleRetrieverError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onRetrieverError?.(r),await this._endTrace(r),r}async handleText(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(r))}async handleLLMNewToken(e,t,r,i,n,a){let o=this.getRunById(r);if(!o||o?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return o.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:a?.chunk}}),await this.onLLMNewToken?.(o,e,{chunk:a?.chunk}),o}};var tE=A({ConsoleCallbackHandler:()=>Ud}),rE={bold:{open:"\x1B[1m",close:"\x1B[22m"},color:{grey:{open:"\x1B[90m",close:"\x1B[39m"},green:{open:"\x1B[32m",close:"\x1B[39m"},cyan:{open:"\x1B[36m",close:"\x1B[39m"},red:{open:"\x1B[31m",close:"\x1B[39m"},blue:{open:"\x1B[34m",close:"\x1B[39m"}}};function Kt(e,t){return`${e.open}${t}${e.close}`}function Ur(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function eE(e){return typeof e=="string"?e.trim():e==null?e:Ur(e,e.toString())}function ji(e){if(!e.end_time)return"";let t=e.end_time-e.start_time;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}var{color:ar}=rE,Ud=class extends At{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,i,n)=>{let a=`${r.execution_order}:${r.run_type}:${r.name}`;return i===n.length-1?Kt(rE.bold,a):a}).join(" > ");return Kt(ar.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Ur(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.cyan,"[chain/end]")} [${t}] [${ji(e)}] Exiting Chain run with output: ${Ur(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.red,"[chain/error]")} [${t}] [${ji(e)}] Chain run errored with error: ${Ur(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${Kt(ar.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Ur(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.cyan,"[llm/end]")} [${t}] [${ji(e)}] Exiting LLM run with output: ${Ur(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.red,"[llm/error]")} [${t}] [${ji(e)}] LLM run errored with error: ${Ur(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.green,"[tool/start]")} [${t}] Entering Tool run with input: "${eE(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.cyan,"[tool/end]")} [${t}] [${ji(e)}] Exiting Tool run with output: "${eE(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.red,"[tool/error]")} [${t}] [${ji(e)}] Tool run errored with error: ${Ur(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Ur(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.cyan,"[retriever/end]")} [${t}] [${ji(e)}] Exiting Retriever run with output: ${Ur(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${Kt(ar.red,"[retriever/error]")} [${t}] [${ji(e)}] Retriever run errored with error: ${Ur(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${Kt(ar.blue,"[agent/action]")} [${r}] Agent selected action: ${Ur(t.actions[t.actions.length-1],"[action]")}`)}};var Zg,Ld=()=>(Zg===void 0&&(Zg=new Nn(Ht("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),Zg);var Gg=class{getStore(){}run(t,r){return r()}},Hg=Symbol.for("ls:tracing_async_local_storage"),kz=new Gg,Jg=class{getInstance(){return globalThis[Hg]??kz}initializeGlobalInstance(t){globalThis[Hg]===void 0&&(globalThis[Hg]=t)}},$z=new Jg;function nE(e=!1){let t=$z.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
|
|
152
|
+
|
|
153
|
+
Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Fd(e){return typeof e=="function"&&"langsmith:traceable"in e}var aE=A({LangChainTracer:()=>is,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>Wg}),Wg=new Set(["ls_agent_type"]);function Iz(e){let t;for(let r of e)for(let i of r)Ee.isInstance(i.message)&&i.message.usage_metadata!==void 0&&(t=Jo(t,i.message.usage_metadata));return t}var is=class Kg extends At{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:r,projectName:i,client:n,replicas:a,metadata:o,tags:s}=t;this.projectName=i??zc(),this.replicas=a,this.exampleId=r,this.client=n??Ld(),this.tracingMetadata=o?{...o}:void 0,this.tracingTags=s??[];let c=Kg.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){iE(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){iE(this,t);let r=this.getRunTreeWithTracingConfig(t.id);t.extra?.lc_defers_inputs?await r?.postRun():await r?.patchRun()}onLLMEnd(t){let r=t.outputs;if(r?.generations){let i=Iz(r.generations);if(i!==void 0){t.extra=t.extra??{};let n=t.extra.metadata??{};n.usage_metadata=i,t.extra.metadata=n}}}copyWithTracingConfig({metadata:t,tags:r}){let i;if(t===void 0)i=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)i={...t};else{i={...this.tracingMetadata};for(let[o,s]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(i,o)||Wg.has(o))&&(i[o]=s)}let n=r?Array.from(new Set([...this.tracingTags,...r])):[...this.tracingTags],a=new Kg({...this.fields,metadata:i,tags:n});return a.runMap=this.runMap,a.runTreeMap=this.runTreeMap,a}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,i=new Set;for(;r.parent_run&&!(i.has(r.id)||(i.add(r.id),!r.parent_run));)r=r.parent_run;i.clear();let n=[r];for(;n.length>0;){let a=n.shift();!a||i.has(a.id)||(i.add(a.id),this.runTreeMap.set(a.id,a),a.child_runs&&n.push(...a.child_runs))}this.client=t.client??this.client,this.replicas=t.replicas??this.replicas,this.projectName=t.project_name??this.projectName,this.exampleId=t.reference_example_id??this.exampleId,this.fields={...this.fields,client:this.client,replicas:this.replicas,projectName:this.projectName,exampleId:this.exampleId}}getRunTreeWithTracingConfig(t){let r=this.runTreeMap.get(t);if(r)return new on({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return nE(!0)}catch{return}}static[Symbol.hasInstance](t){if(typeof t!="object"||t===null)return!1;let r=t;return"name"in r&&r.name==="langchain_tracer"&&"copyWithTracingConfig"in r&&typeof r.copyWithTracingConfig=="function"&&"getRunTreeWithTracingConfig"in r&&typeof r.getRunTreeWithTracingConfig=="function"}};function iE(e,t){if(e.tracingMetadata){t.extra??={};let r=t.extra.metadata??{},i=!1;for(let[n,a]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(r,n)||Wg.has(n))&&r[n]!==a&&(r[n]=a,i=!0);i&&(t.extra.metadata=r)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var oE=Symbol.for("ls:tracing_async_local_storage"),zi=Symbol.for("lc:context_variables"),sE=e=>{globalThis[oE]=e},Di=()=>globalThis[oE];var Bd=$l(Td(),1),La;function Ez(){return new("default"in Bd.default?Bd.default.default:Bd.default)({autoStart:!0,concurrency:1})}function Tz(){return typeof La>"u"&&(La=Ez()),La}async function qe(e,t){if(t===!0){let r=Di();r!==void 0?await r.run(void 0,async()=>e()):await e()}else La=Tz(),La.add(async()=>{let r=Di();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function cE(){let e=Ld();await Promise.allSettled([typeof La<"u"?La.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var uE=A({awaitAllCallbacks:()=>cE,consumeCallback:()=>qe});var lE=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Ht(t)==="true");function qg(e){let t=Di();if(t!==void 0)return t.getStore()?.[zi]?.[e]}var Az=Symbol("lc:configure_hooks"),dE=()=>qg(Az)||[];var fE=A({BaseCallbackManager:()=>pE,BaseRunManager:()=>Hc,CallbackManager:()=>et,CallbackManagerForChainRun:()=>hE,CallbackManagerForLLMRun:()=>Xg,CallbackManagerForRetrieverRun:()=>mE,CallbackManagerForToolRun:()=>gE,ensureHandler:()=>as,parseCallbackConfigArg:()=>Fa});function Fa(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var pE=class{setHandler(e){return this.setHandlers([e])}},Hc=class{constructor(e,t,r,i,n,a,o,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=i,this.inheritableTags=n,this.metadata=a,this.inheritableMetadata=o,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>qe(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{try{await a.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},mE=class extends Hc{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleRetrieverEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}},t.awaitHandlers)))}},Xg=class extends Hc{async handleLLMNewToken(e,t,r,i,n,a){await Promise.all(this.handlers.map(o=>qe(async()=>{if(!o.ignoreLLM)try{await o.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,a)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMNewToken: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreLLM)try{await t.handleChatModelStreamEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChatModelStreamEvent: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleLLMError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleLLMEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},hE=class extends Hc{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleChainError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreChain)try{await a.handleChainError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleChainEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreChain)try{await a.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},gE=class extends Hc{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleToolError(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEvent(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if(t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},et=class Zc extends pE{handlers=[];inheritableHandlers=[];tags=[];inheritableTags=[];metadata={};inheritableMetadata={};name="callback_manager";_parentRunId;constructor(t,r){super(),this.handlers=r?.handlers??this.handlers,this.inheritableHandlers=r?.inheritableHandlers??this.inheritableHandlers,this.tags=r?.tags??this.tags,this.inheritableTags=r?.inheritableTags??this.inheritableTags,this.metadata=r?.metadata??this.metadata,this.inheritableMetadata=r?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=t}getParentRunId(){return this._parentRunId}async handleLLMStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:xr();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ua(f)&&f._createRunForLLMStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),qe(async()=>{try{await f.handleLLMStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c)}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new Xg(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:xr();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ua(f)&&f._createRunForChatModelStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),qe(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=Wo(u);await f.handleLLMStart?.(t,[p],d,this._parentRunId,a,this.tags,this.metadata,c)}}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new Xg(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,i=xr(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return Ua(l)&&l._createRunForChainStart(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u),qe(async()=>{try{await l.handleChainStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u)}catch(d){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleChainStart: ${d}`),l.raiseError)throw d}},l.awaitHandlers)})),new hE(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,i=xr(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Ua(u)&&u._createRunForToolStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),qe(async()=>{try{await u.handleToolStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s,c)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new gE(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,i=xr(),n=void 0,a=void 0,o=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return Ua(c)&&c._createRunForRetrieverStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),qe(async()=>{try{await c.handleRetrieverStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s)}catch(u){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${u}`),c.raiseError)throw u}},c.awaitHandlers)})),new mE(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,i,n,a){await Promise.all(this.handlers.map(o=>qe(async()=>{if(!o.ignoreCustomEvent)try{await o.handleCustomEvent?.(t,r,i,this.tags,this.metadata)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}addHandler(t,r=!0){this.handlers.push(t),r&&this.inheritableHandlers.push(t)}removeHandler(t){this.handlers=this.handlers.filter(r=>r!==t),this.inheritableHandlers=this.inheritableHandlers.filter(r=>r!==t)}setHandlers(t,r=!0){this.handlers=[],this.inheritableHandlers=[];for(let i of t)this.addHandler(i,r)}addTags(t,r=!0){this.removeTags(t),this.tags.push(...t),r&&this.inheritableTags.push(...t)}removeTags(t){this.tags=this.tags.filter(r=>!t.includes(r)),this.inheritableTags=this.inheritableTags.filter(r=>!t.includes(r))}addMetadata(t,r=!0){this.metadata={...this.metadata,...t},r&&(this.inheritableMetadata={...this.inheritableMetadata,...t})}removeMetadata(t){for(let r of Object.keys(t))delete this.metadata[r],delete this.inheritableMetadata[r]}copy(t=[],r=!0){let i=new Zc(this._parentRunId);for(let n of this.handlers){let a=this.inheritableHandlers.includes(n);i.addHandler(n,a)}for(let n of this.tags){let a=this.inheritableTags.includes(n);i.addTags([n],a)}for(let n of Object.keys(this.metadata)){let a=Object.keys(this.inheritableMetadata).includes(n);i.addMetadata({[n]:this.metadata[n]},a)}for(let n of t)i.handlers.filter(a=>a.name==="console_callback_handler").some(a=>a.name===n.name)||i.addHandler(n,r);return i}static fromHandlers(t){class r extends Sr{name=xr();constructor(){super(),Object.assign(this,t)}}let i=new this;return i.addHandler(new r),i}static configure(t,r,i,n,a,o,s){return this._configureSync(t,r,i,n,a,o,s)}static _configureSync(t,r,i,n,a,o,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new Zc,c.setHandlers(t?.map(as)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(as):r?.handlers,!1));let u=Ht("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=is.getTraceableRunTree(),d=l?.tracingEnabled??lE();if(l?.tracingEnabled===!1&&c){let g=c.handlers.filter(y=>y.name==="langchain_tracer");for(let y of g)c.removeHandler(y)}let f=d||(Ht("LANGCHAIN_TRACING")??!1);if(u||f){if(c||(c=new Zc),u&&!c.handlers.some(g=>g.name===Ud.prototype.name)){let g=new Ud;c.addHandler(g,!0)}if(f&&!c.handlers.some(g=>g.name==="langchain_tracer")&&d){let g=new is;c.addHandler(g,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(g=>g.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:g,inheritable:y=!0,handlerClass:b,envVar:w}of dE()){let x=w&&Ht(w)==="true"&&b,k,E=g!==void 0?qg(g):void 0;E&&Jh(E)?k=E:x&&(k=new b({})),k!==void 0&&(c||(c=new Zc),c.handlers.some(V=>V.name===k.name)||c.addHandler(k,y))}(i||n)&&c&&(c.addTags(i??[]),c.addTags(n??[],!1)),(a||o)&&c&&(c.addMetadata(a??{}),c.addMetadata(o??{},!1));let p=s?.tracerInheritableMetadata,m=s?.tracerInheritableTags;return c&&(p||m)&&(c.handlers=c.handlers.map(g=>g instanceof is?g.copyWithTracingConfig({metadata:p,tags:m}):g),c.inheritableHandlers=c.inheritableHandlers.map(g=>g instanceof is?g.copyWithTracingConfig({metadata:p,tags:m}):g)),c}};function as(e){return"name"in e?e:Sr.fromMethods(e)}var Yg=class{getStore(){}run(e,t){return t()}enterWith(e){}},Cz=new Yg,_E=Symbol.for("lc:child_config"),Oz=class{getInstance(){return Di()??Cz}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[_E]}runWithConfig(e,t,r){let i=et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),n=this.getInstance(),a=n.getStore(),o=i?.getParentRunId(),s=i?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return s&&o?c=s.getRunTreeWithTracingConfig(o):r||(c=new on({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[_E]:e}),a!==void 0&&a[zi]!==void 0&&(c===void 0&&(c={}),c[zi]=a[zi]),n.run(c,t)}initializeGlobalInstance(e){Di()===void 0&&sE(e)}},Te=new Oz;var yE=A({AsyncLocalStorageProviderSingleton:()=>Te,MockAsyncLocalStorage:()=>Yg,_CONTEXT_VARIABLES_KEY:()=>zi});var Pz=new Set(["api_key"]),Nz=new Set(["string","number","boolean"]);function Rz(e){let t=e.configurable??{},r=e.metadata??{},i={};for(let[n,a]of Object.entries(t))!n.startsWith("__")&&!Object.prototype.hasOwnProperty.call(r,n)&&!Pz.has(n)&&Nz.has(typeof a)&&(i[n]=a);return Object.keys(i).length>0?i:void 0}async function jt(e){return et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?Rz(e):void 0})}function xt(...e){let t={};for(let r of e.filter(i=>!!i))for(let i of Object.keys(r))if(i==="metadata")t[i]={...t[i],...r[i]};else if(i==="tags"){let n=t[i]??[];t[i]=[...new Set(n.concat(r[i]??[]))]}else if(i==="configurable")t[i]={...t[i],...r[i]};else if(i==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(i==="signal")t.signal===void 0?t.signal=r.signal:r.signal!==void 0&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,r.signal]):t.signal=r.signal);else if(i==="callbacks"){let n=t.callbacks,a=r.callbacks;if(Array.isArray(a))if(!n)t.callbacks=a;else if(Array.isArray(n))t.callbacks=n.concat(a);else{let o=n.copy();for(let s of a)o.addHandler(as(s),!0);t.callbacks=o}else if(a)if(!n)t.callbacks=a;else if(Array.isArray(n)){let o=a.copy();for(let s of n)o.addHandler(as(s),!0);t.callbacks=o}else t.callbacks=new et(a._parentRunId,{handlers:n.handlers.concat(a.handlers),inheritableHandlers:n.inheritableHandlers.concat(a.inheritableHandlers),tags:Array.from(new Set(n.tags.concat(a.tags))),inheritableTags:Array.from(new Set(n.inheritableTags.concat(a.inheritableTags))),metadata:{...n.metadata,...a.metadata}})}else{let n=i;t[n]=r[n]??t[n]}return t}function we(e){let t=Te.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:i,runName:n,...a}=t;r=Object.entries(a).reduce((o,[s,c])=>(c!==void 0&&(o[s]=c),o),r)}if(e&&(r=Object.entries(e).reduce((i,[n,a])=>(a!==void 0&&(i[n]=a),i),r)),r?.configurable&&typeof r.configurable.model=="string"&&r.metadata?.model===void 0&&(r.metadata||(r.metadata={}),r.metadata.model=r.configurable.model),r.timeout!==void 0){if(r.timeout<=0)throw new Error("Timeout must be a positive number");let i=r.timeout,n=AbortSignal.timeout(i);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=i),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,n])):r.signal=n,delete r.timeout}return r}function $e(e={},{callbacks:t,maxConcurrency:r,recursionLimit:i,runName:n,configurable:a,runId:o}={}){let s=we(e);return t!==void 0&&(delete s.runName,s.callbacks=t),i!==void 0&&(s.recursionLimit=i),r!==void 0&&(s.maxConcurrency=r),n!==void 0&&(s.runName=n),a!==void 0&&(s.configurable={...s.configurable,...a}),o!==void 0&&delete s.runId,s}function or(e){if(e)return{configurable:e.configurable,recursionLimit:e.recursionLimit,callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,maxConcurrency:e.maxConcurrency,timeout:e.timeout,signal:e.signal,store:e.store}}async function kr(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(i=>{if(!t?.aborted)throw i}),new Promise((i,n)=>{r=()=>{n(Ui(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&n(Ui(t))})]).finally(()=>t.removeEventListener("abort",r))}function Ui(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var vE=A({AsyncGeneratorWithSetup:()=>Li,IterableReadableStream:()=>ft,atee:()=>Vd,concat:()=>$r,pipeGeneratorWithSetup:()=>e_}),ft=class Qg extends ReadableStream{reader;ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{let t=await this.reader.read();return t.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:t.value}}catch(t){throw this.reader.releaseLock(),t}}async return(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),await t}return{done:!0,value:void 0}}async throw(t){if(this.ensureReader(),this.locked){let r=this.reader.cancel();this.reader.releaseLock(),await r}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let r=t.getReader();return new Qg({start(i){return n();function n(){return r.read().then(({done:a,value:o})=>{if(a){i.close();return}return i.enqueue(o),n()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Qg({async pull(r){let{value:i,done:n}=await t.next();n&&r.close(),r.enqueue(i)},async cancel(r){await t.return(r)}})}};function Vd(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(n){for(;;)if(n.length===0){let a=await e.next();for(let o of r)o.push(a)}else{if(n[0].done)return;yield n.shift().value}})}function $r(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string")return e+t;if(typeof e=="number"&&typeof t=="number")return e+t;if("concat"in e&&typeof e.concat=="function")return e.concat(t);if(typeof e=="object"&&typeof t=="object"){let r={...e};for(let[i,n]of Object.entries(t))i in r&&!Array.isArray(r[i])?r[i]=$r(r[i],n):r[i]=n;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Li=class{generator;setup;config;signal;firstResult;firstResultUsed=!1;constructor(e){this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{Te.runWithConfig(or(e.config),async()=>{this.firstResult=this.signal?kr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Te.runWithConfig(or(this.config),this.signal?async()=>kr(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}};async function e_(e,t,r,i,...n){let a=new Li({generator:t,startSetup:r,signal:i}),o=await a.setup;return{output:e(a,o,...n),setup:o}}var Mz=Object.prototype.hasOwnProperty;function Hd(e,t){return Mz.call(e,t)}function Gd(e){if(Array.isArray(e)){let r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=""+i;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)Hd(e,r)&&t.push(r);return t}function Ir(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Jd(e){let t=0,r=e.length,i;for(;t<r;){if(i=e.charCodeAt(t),i>=48&&i<=57){t++;continue}return!1}return!0}function Ba(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function wE(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Zd(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,i=e.length;r<i;r++)if(Zd(e[r]))return!0}else if(typeof e=="object"){let r=Gd(e),i=r.length;for(var t=0;t<i;t++)if(Zd(e[r[t]]))return!0}}return!1}function bE(e,t){let r=[e];for(let i in t){let n=typeof t[i]=="object"?JSON.stringify(t[i],null,2):t[i];typeof n<"u"&&r.push(`${i}: ${n}`)}return r.join(`
|
|
154
|
+
`)}var xE=class extends Error{constructor(e,t,r,i,n){super(bE(e,{name:t,index:r,operation:i,tree:n})),this.name=t,this.index=r,this.operation=i,this.tree=n,Object.setPrototypeOf(this,new.target.prototype),this.message=bE(e,{name:t,index:r,operation:i,tree:n})}};var SE=A({JsonPatchError:()=>nt,_areEquals:()=>Gc,applyOperation:()=>Va,applyPatch:()=>Fi,applyReducer:()=>Dz,deepClone:()=>jz,getValueByPointer:()=>Kd,validate:()=>kE,validator:()=>Wd}),nt=xE,jz=Ir,os={add:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return delete e[t],{newDocument:r,removed:i}},replace:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:function(e,t,r){let i=Kd(r,this.path);i&&(i=Ir(i));let n=Va(r,{op:"remove",path:this.from}).removed;return Va(r,{op:"add",path:this.path,value:n}),{newDocument:r,removed:i}},copy:function(e,t,r){let i=Kd(r,this.from);return Va(r,{op:"add",path:this.path,value:Ir(i)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Gc(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},zz={add:function(e,t,r){return Jd(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:os.move,copy:os.copy,test:os.test,_get:os._get};function Kd(e,t){if(t=="")return e;var r={op:"_get",path:t};return Va(e,r),r.value}function Va(e,t,r=!1,i=!0,n=!0,a=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):Wd(t,0)),t.path===""){let o={newDocument:e};if(t.op==="add")return o.newDocument=t.value,o;if(t.op==="replace")return o.newDocument=t.value,o.removed=e,o;if(t.op==="move"||t.op==="copy")return o.newDocument=Kd(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=Gc(e,t.value),o.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o.newDocument=e,o}else{if(t.op==="remove")return o.removed=e,o.newDocument=null,o;if(t.op==="_get")return t.value=e,o;if(r)throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else{i||(e=Ir(e));let o=(t.path||"").split("/"),s=e,c=1,u=o.length,l,d,f;for(typeof r=="function"?f=r:f=Wd;;){if(d=o[c],d&&d.indexOf("~")!=-1&&(d=wE(d)),n&&(d=="__proto__"||d=="prototype"&&c>0&&o[c-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&l===void 0&&(s[d]===void 0?l=o.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&f(t,0,e,l)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!Jd(d))throw new nt("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,t,e);Jd(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new nt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);let p=zz[t.op].call(t,s,d,e);if(p.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}}else if(c>=u){let p=os[t.op].call(t,s,d,e);if(p.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new nt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function Fi(e,t,r,i=!0,n=!0){if(r&&!Array.isArray(t))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");i||(e=Ir(e));let a=new Array(t.length);for(let o=0,s=t.length;o<s;o++)a[o]=Va(e,t[o],r,!0,n,o),e=a[o].newDocument;return a.newDocument=e,a}function Dz(e,t,r){let i=Va(e,t);if(i.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return i.newDocument}function Wd(e,t,r,i){if(typeof e!="object"||e===null||Array.isArray(e))throw new nt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(os[e.op]){if(typeof e.path!="string")throw new nt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new nt('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new nt("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Zd(e.value))throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var n=e.path.split("/").length,a=i.split("/").length;if(n!==a+1&&n!==a)throw new nt("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==i)throw new nt("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var o=kE([{op:"_get",path:e.from,value:void 0}],r);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new nt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function kE(e,t,r){try{if(!Array.isArray(e))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Fi(Ir(t),Ir(e),r||!0);else{r=r||Wd;for(var i=0;i<e.length;i++)r(e[i],i,t,void 0)}}catch(n){if(n instanceof nt)return n;throw n}}function Gc(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),i=Array.isArray(t),n,a,o;if(r&&i){if(a=e.length,a!=t.length)return!1;for(n=a;n--!==0;)if(!Gc(e[n],t[n]))return!1;return!0}if(r!=i)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(n=a;n--!==0;)if(!t.hasOwnProperty(s[n]))return!1;for(n=a;n--!==0;)if(o=s[n],!Gc(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function $E(e,t,r,i,n){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=Gd(t),o=Gd(e),s=!1,c=o.length-1;c>=0;c--){var u=o[c],l=e[u];if(Hd(t,u)&&!(t[u]===void 0&&l!==void 0&&Array.isArray(t)===!1)){var d=t[u];typeof l=="object"&&l!=null&&typeof d=="object"&&d!=null&&Array.isArray(l)===Array.isArray(d)?$E(l,d,r,i+"/"+Ba(u),n):l!==d&&(n&&r.push({op:"test",path:i+"/"+Ba(u),value:Ir(l)}),r.push({op:"replace",path:i+"/"+Ba(u),value:Ir(d)}))}else Array.isArray(e)===Array.isArray(t)?(n&&r.push({op:"test",path:i+"/"+Ba(u),value:Ir(l)}),r.push({op:"remove",path:i+"/"+Ba(u)}),s=!0):(n&&r.push({op:"test",path:i,value:e}),r.push({op:"replace",path:i,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var u=a[c];!Hd(e,u)&&t[u]!==void 0&&r.push({op:"add",path:i+"/"+Ba(u),value:Ir(t[u])})}}}function Bi(e,t,r=!1){var i=[];return $E(e,t,i,"",r),i}({...SE});var TE=A({LogStreamCallbackHandler:()=>Xd,RunLog:()=>qd,RunLogPatch:()=>jn,isLogStreamHandler:()=>r_}),jn=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=Fi({},t);return new qd({ops:t,state:r[r.length-1].newDocument})}},qd=class t_ extends jn{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),i=Fi(this.state,t.ops);return new t_({ops:r,state:i[i.length-1].newDocument})}static fromRunLogPatch(t){let r=Fi({},t.ops);return new t_({ops:t.ops,state:r[r.length-1].newDocument})}},r_=e=>e.name==="log_stream_tracer";async function IE(e,t){if(t==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:r}=e;if(["retriever","llm","prompt"].includes(e.run_type))return r;if(!(Object.keys(r).length===1&&r?.input===""))return r.input}async function EE(e,t){let{outputs:r}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?r:r!==void 0&&Object.keys(r).length===1&&r?.output!==void 0?r.output:r}function Uz(e){return e!==void 0&&e.message!==void 0}var Xd=class extends At{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;_schemaFormat="original";rootId;keyMapByRunId={};counterMapByRunName={};transformStream;writer;receiveStream;name="log_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=ft.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let i=this.keyMapByRunId[e];i&&await this.writer.write(new jn({ops:[{op:"add",path:`/logs/${i}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new jn({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await IE(e,this._schemaFormat)),await this.writer.write(new jn({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await IE(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await EE(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let i=new jn({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){let t=new jn({ops:[{op:"replace",path:"/final_output",value:await EE(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let i=this.keyMapByRunId[e.id];if(i===void 0)return;let n=e.inputs.messages!==void 0,a;n?Uz(r?.chunk)?a=r?.chunk:a=new Qe({id:`run-${e.id}`,content:t}):a=t;let o=new jn({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:a}]});await this.writer.write(o)}};var AE=A({ChatGenerationChunk:()=>Vi,GenerationChunk:()=>ci,RUN_KEY:()=>Za}),Za="__run",ci=class CE{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new CE({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},Vi=class OE extends ci{message;constructor(t){super(t),this.message=t.message}concat(t){return new OE({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var Lz=Object.prototype.toString,Fz=e=>Lz.call(e)==="[object Error]",Bz=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function PE(e){if(!(e&&Fz(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:r}=e;return t==="Load failed"?r===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:Bz.has(t)}function Vz(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Yd(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var Zz=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}};function Hz(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function NE(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function Gz({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof Zz)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),NE(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=NE(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!PE(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=Hz(r,n),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let g=()=>{clearTimeout(y),n.signal?.removeEventListener("abort",g),m(n.signal.reason)},y=setTimeout(()=>{n.signal?.removeEventListener("abort",g),p()},f);n.unref&&y.unref?.(),n.signal?.addEventListener("abort",g,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Jc(e,t={}){if(t={...t},Vz(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Yd("factor",t.factor,{min:0,allowInfinity:!1}),Yd("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Yd("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Yd("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await Gz({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Qd=$l(Td(),1),RE=A({AsyncCaller:()=>ui}),Jz=[400,401,402,403,404,405,406,407,409],Kz=e=>{if(typeof e!="object"||e===null)return;if("message"in e&&typeof e.message=="string"&&(e.message.startsWith("Cancel")||e.message.startsWith("AbortError"))||"name"in e&&typeof e.name=="string"&&e.name==="AbortError"||"code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t="response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0,r="status"in e&&typeof e.status=="number"?e.status:void 0,i=t??r;if(i&&Jz.includes(+i))throw e;if(("error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0)==="insufficient_quota"){let n=new Error("message"in e&&typeof e.message=="string"?e.message:"Insufficient quota");throw n.name="InsufficientQuotaError",n}},ui=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??Kz;let t="default"in Qd.default?Qd.default.default:Qd.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>Jc(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:({error:r})=>this.onFailedAttempt?.(r),retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){if(e.signal){let i;return Promise.race([this.call(t,...r),new Promise((n,a)=>{i=()=>{a(Ui(e.signal))},e.signal?.addEventListener("abort",i,{once:!0})})]).finally(()=>{e.signal&&i&&e.signal.removeEventListener("abort",i)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var ME=A({isSerializableSchema:()=>Ha,isStandardJsonSchema:()=>ef,isStandardSchema:()=>jE});function jE(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function ef(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Ha(e){return jE(e)&&ef(e)}var fi={};$n(fi,{$ZodAny:()=>Gy,$ZodArray:()=>Wy,$ZodAsyncError:()=>sn,$ZodBase64:()=>jy,$ZodBase64URL:()=>zy,$ZodBigInt:()=>wf,$ZodBigIntFormat:()=>By,$ZodBoolean:()=>ou,$ZodCIDRv4:()=>Ny,$ZodCIDRv6:()=>Ry,$ZodCUID:()=>wy,$ZodCUID2:()=>xy,$ZodCatch:()=>pv,$ZodCheck:()=>Le,$ZodCheckBigIntFormat:()=>X_,$ZodCheckEndsWith:()=>uy,$ZodCheckGreaterThan:()=>hf,$ZodCheckIncludes:()=>sy,$ZodCheckLengthEquals:()=>ny,$ZodCheckLessThan:()=>mf,$ZodCheckLowerCase:()=>ay,$ZodCheckMaxLength:()=>ty,$ZodCheckMaxSize:()=>Y_,$ZodCheckMimeType:()=>dy,$ZodCheckMinLength:()=>ry,$ZodCheckMinSize:()=>Q_,$ZodCheckMultipleOf:()=>W_,$ZodCheckNumberFormat:()=>q_,$ZodCheckOverwrite:()=>fy,$ZodCheckProperty:()=>ly,$ZodCheckRegex:()=>iy,$ZodCheckSizeEquals:()=>ey,$ZodCheckStartsWith:()=>cy,$ZodCheckStringFormat:()=>ms,$ZodCheckUpperCase:()=>oy,$ZodCodec:()=>lu,$ZodCustom:()=>wv,$ZodCustomStringFormat:()=>Ly,$ZodDate:()=>Ky,$ZodDefault:()=>uv,$ZodDiscriminatedUnion:()=>Yy,$ZodE164:()=>Dy,$ZodEmail:()=>_y,$ZodEmoji:()=>vy,$ZodEncodeError:()=>Zi,$ZodEnum:()=>nv,$ZodError:()=>eu,$ZodExactOptional:()=>sv,$ZodFile:()=>av,$ZodFunction:()=>yv,$ZodGUID:()=>hy,$ZodIPv4:()=>Cy,$ZodIPv6:()=>Oy,$ZodISODate:()=>Ey,$ZodISODateTime:()=>Iy,$ZodISODuration:()=>Ay,$ZodISOTime:()=>Ty,$ZodIntersection:()=>Qy,$ZodJWT:()=>Uy,$ZodKSUID:()=>$y,$ZodLazy:()=>bv,$ZodLiteral:()=>iv,$ZodMAC:()=>Py,$ZodMap:()=>tv,$ZodNaN:()=>mv,$ZodNanoID:()=>by,$ZodNever:()=>cu,$ZodNonOptional:()=>dv,$ZodNull:()=>Hy,$ZodNullable:()=>cv,$ZodNumber:()=>bf,$ZodNumberFormat:()=>Fy,$ZodObject:()=>pT,$ZodObjectJIT:()=>qy,$ZodOptional:()=>Xa,$ZodPipe:()=>Sf,$ZodPrefault:()=>lv,$ZodPreprocess:()=>hv,$ZodPromise:()=>vv,$ZodReadonly:()=>gv,$ZodRealError:()=>cr,$ZodRecord:()=>ev,$ZodRegistry:()=>Ef,$ZodSet:()=>rv,$ZodString:()=>qa,$ZodStringFormat:()=>je,$ZodSuccess:()=>fv,$ZodSymbol:()=>Vy,$ZodTemplateLiteral:()=>_v,$ZodTransform:()=>ov,$ZodTuple:()=>xf,$ZodType:()=>de,$ZodULID:()=>Sy,$ZodURL:()=>yy,$ZodUUID:()=>gy,$ZodUndefined:()=>Zy,$ZodUnion:()=>uu,$ZodUnknown:()=>su,$ZodVoid:()=>Jy,$ZodXID:()=>ky,$ZodXor:()=>Xy,$brand:()=>i_,$constructor:()=>S,$input:()=>Sv,$output:()=>xv,Doc:()=>au,JSONSchema:()=>hA,JSONSchemaGenerator:()=>np,NEVER:()=>n_,TimePrecision:()=>Ev,_any:()=>Kv,_array:()=>Qv,_base64:()=>Hf,_base64url:()=>Gf,_bigint:()=>Fv,_boolean:()=>Uv,_catch:()=>_2,_check:()=>mA,_cidrv4:()=>Vf,_cidrv6:()=>Zf,_coercedBigint:()=>Bv,_coercedBoolean:()=>Lv,_coercedDate:()=>Xv,_coercedNumber:()=>Nv,_coercedString:()=>$v,_cuid:()=>jf,_cuid2:()=>zf,_custom:()=>tb,_date:()=>qv,_decode:()=>af,_decodeAsync:()=>sf,_default:()=>m2,_discriminatedUnion:()=>r2,_e164:()=>Jf,_email:()=>Af,_emoji:()=>Rf,_encode:()=>nf,_encodeAsync:()=>of,_endsWith:()=>ws,_enum:()=>c2,_file:()=>eb,_float32:()=>Mv,_float64:()=>jv,_gt:()=>Dn,_gte:()=>qt,_guid:()=>pu,_includes:()=>vs,_int:()=>Rv,_int32:()=>zv,_int64:()=>Vv,_intersection:()=>n2,_ipv4:()=>Ff,_ipv6:()=>Bf,_isoDate:()=>Av,_isoDateTime:()=>Tv,_isoDuration:()=>Ov,_isoTime:()=>Cv,_jwt:()=>Kf,_ksuid:()=>Lf,_lazy:()=>w2,_length:()=>eo,_literal:()=>l2,_lowercase:()=>_s,_lt:()=>zn,_lte:()=>Tr,_mac:()=>Iv,_map:()=>o2,_max:()=>Tr,_maxLength:()=>Qa,_maxSize:()=>Xi,_mime:()=>xs,_min:()=>qt,_minLength:()=>di,_minSize:()=>Un,_multipleOf:()=>qi,_nan:()=>Yv,_nanoid:()=>Mf,_nativeEnum:()=>u2,_negative:()=>qf,_never:()=>gu,_nonnegative:()=>Yf,_nonoptional:()=>h2,_nonpositive:()=>Xf,_normalize:()=>Ss,_null:()=>Jv,_nullable:()=>p2,_number:()=>Pv,_optional:()=>f2,_overwrite:()=>cn,_parse:()=>ls,_parseAsync:()=>ds,_pipe:()=>y2,_positive:()=>Wf,_promise:()=>x2,_property:()=>Qf,_readonly:()=>v2,_record:()=>a2,_refine:()=>rb,_regex:()=>gs,_safeDecode:()=>uf,_safeDecodeAsync:()=>df,_safeEncode:()=>cf,_safeEncodeAsync:()=>lf,_safeParse:()=>fs,_safeParseAsync:()=>ps,_set:()=>s2,_size:()=>Ya,_slugify:()=>Es,_startsWith:()=>bs,_string:()=>kv,_stringFormat:()=>Ts,_stringbool:()=>ob,_success:()=>g2,_superRefine:()=>nb,_symbol:()=>Hv,_templateLiteral:()=>b2,_toLowerCase:()=>$s,_toUpperCase:()=>Is,_transform:()=>d2,_trim:()=>ks,_tuple:()=>i2,_uint32:()=>Dv,_uint64:()=>Zv,_ulid:()=>Df,_undefined:()=>Gv,_union:()=>e2,_unknown:()=>hu,_uppercase:()=>ys,_url:()=>mu,_uuid:()=>Cf,_uuidv4:()=>Of,_uuidv6:()=>Pf,_uuidv7:()=>Nf,_void:()=>Wv,_xid:()=>Uf,_xor:()=>t2,clone:()=>Je,config:()=>it,createStandardJSONSchemaMethod:()=>As,createToJSONSchemaMethod:()=>sb,decode:()=>xD,decodeAsync:()=>kD,describe:()=>ib,encode:()=>wD,encodeAsync:()=>SD,extractDefs:()=>Qi,finalize:()=>ea,flattenError:()=>tu,formatError:()=>ru,globalConfig:()=>Ga,globalRegistry:()=>Pe,initializeContext:()=>Yi,isValidBase64:()=>My,isValidBase64URL:()=>uT,isValidJWT:()=>lT,locales:()=>fu,meta:()=>ab,parse:()=>Wi,parseAsync:()=>Ka,prettifyError:()=>__,process:()=>Re,regexes:()=>Er,registry:()=>Tf,safeDecode:()=>ID,safeDecodeAsync:()=>TD,safeEncode:()=>$D,safeEncodeAsync:()=>ED,safeParse:()=>y_,safeParseAsync:()=>v_,toDotPath:()=>BE,toJSONSchema:()=>to,treeifyError:()=>g_,util:()=>j,version:()=>py});var zE,n_=Object.freeze({status:"aborted"});function S(e,t,r){function i(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=o.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let f=l[d];f in s||(s[f]=u[f].bind(s))}}let n=r?.Parent??Object;class a extends n{}Object.defineProperty(a,"name",{value:e});function o(s){var c;let u=r?.Parent?new a:this;i(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var i_=Symbol("zod_brand"),sn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Zi=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(zE=globalThis).__zod_globalConfig??(zE.__zod_globalConfig={});var Ga=globalThis.__zod_globalConfig;function it(e){return e&&Object.assign(Ga,e),Ga}var j={};$n(j,{BIGINT_FORMAT_RANGES:()=>m_,Class:()=>o_,NUMBER_FORMAT_RANGES:()=>p_,aborted:()=>Ki,allowsEval:()=>u_,assert:()=>Qz,assertEqual:()=>Wz,assertIs:()=>Xz,assertNever:()=>Yz,assertNotEqual:()=>qz,assignProp:()=>Gi,base64ToUint8Array:()=>UE,base64urlToUint8Array:()=>gD,cached:()=>cs,captureStackTrace:()=>rf,cleanEnum:()=>hD,cleanRegex:()=>qc,clone:()=>Je,cloneDef:()=>tD,createTransparentProxy:()=>sD,defineLazy:()=>xe,esc:()=>tf,escapeRegex:()=>Lr,explicitlyAborted:()=>h_,extend:()=>lD,finalizeIssue:()=>Wt,floatSafeRemainder:()=>s_,getElementAtPath:()=>rD,getEnumValues:()=>Wc,getLengthableOrigin:()=>Qc,getParsedType:()=>oD,getSizableOrigin:()=>Yc,hexToUint8Array:()=>yD,isObject:()=>Ja,isPlainObject:()=>Ji,issue:()=>us,joinValues:()=>I,jsonStringifyReplacer:()=>ss,merge:()=>fD,mergeDefs:()=>li,normalizeParams:()=>U,nullish:()=>Hi,numKeys:()=>aD,objectClone:()=>eD,omit:()=>uD,optionalKeys:()=>f_,parsedType:()=>M,partial:()=>pD,pick:()=>cD,prefixIssues:()=>sr,primitiveTypes:()=>d_,promiseAllObject:()=>nD,propertyKeyTypes:()=>Xc,randomString:()=>iD,required:()=>mD,safeExtend:()=>dD,shallowClone:()=>l_,slugify:()=>c_,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>LE,uint8ArrayToBase64url:()=>_D,uint8ArrayToHex:()=>vD,unwrapMessage:()=>Kc});function Wz(e){return e}function qz(e){return e}function Xz(e){}function Yz(e){throw new Error("Unexpected value in exhaustive check")}function Qz(e){}function Wc(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function I(e,t="|"){return e.map(r=>R(r)).join(t)}function ss(e,t){return typeof t=="bigint"?t.toString():t}function cs(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Hi(e){return e==null}function qc(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function s_(e,t){let r=e/t,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var DE=Symbol("evaluating");function xe(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==DE)return i===void 0&&(i=DE,i=r()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function eD(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Gi(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function li(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function tD(e){return li(e._zod.def)}function rD(e,t){return t?t.reduce((r,i)=>r?.[i],e):e}function nD(e){let t=Object.keys(e),r=t.map(i=>e[i]);return Promise.all(r).then(i=>{let n={};for(let a=0;a<t.length;a++)n[t[a]]=i[a];return n})}function iD(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return r}function tf(e){return JSON.stringify(e)}function c_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var rf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ja(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var u_=cs(()=>{if(Ga.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ji(e){if(Ja(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Ja(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function l_(e){return Ji(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function aD(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var oD=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Xc=new Set(["string","number","symbol"]),d_=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Lr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function U(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function sD(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,a){return t??(t=e()),Reflect.set(t,i,n,a)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function R(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function f_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var p_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},m_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function cD(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let a=li(e._zod.def,{get shape(){let o={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=r.shape[s])}return Gi(this,"shape",o),o},checks:[]});return Je(e,a)}function uD(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let a=li(e._zod.def,{get shape(){let o={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return Gi(this,"shape",o),o},checks:[]});return Je(e,a)}function lD(e,t){if(!Ji(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let a=e._zod.def.shape;for(let o in t)if(Object.getOwnPropertyDescriptor(a,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=li(e._zod.def,{get shape(){let a={...e._zod.def.shape,...t};return Gi(this,"shape",a),a}});return Je(e,n)}function dD(e,t){if(!Ji(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=li(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Gi(this,"shape",i),i}});return Je(e,r)}function fD(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=li(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return Gi(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Je(e,r)}function pD(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let o=li(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Gi(this,"shape",c),c},checks:[]});return Je(t,o)}function mD(e,t,r){let i=li(t._zod.def,{get shape(){let n=t._zod.def.shape,a={...n};if(r)for(let o in r){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(a[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)a[o]=new e({type:"nonoptional",innerType:n[o]});return Gi(this,"shape",a),a}});return Je(t,i)}function Ki(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function h_(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function sr(e,t){return t.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Kc(e){return typeof e=="string"?e:e?.message}function Wt(e,t,r){let i=e.message?e.message:Kc(e.inst?._zod.def?.error?.(e))??Kc(t?.error?.(e))??Kc(r.customError?.(e))??Kc(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function Yc(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Qc(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function M(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function us(...e){let[t,r,i]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:i}:{...t}}function hD(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function UE(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function LE(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function gD(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return UE(t+r)}function _D(e){return LE(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function yD(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function vD(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var o_=class{constructor(...t){}};var FE=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ss,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},eu=S("$ZodError",FE),cr=S("$ZodError",FE,{Parent:Error});function tu(e,t=r=>r.message){let r={},i=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}}function ru(e,t=r=>r.message){let r={_errors:[]},i=(n,a=[])=>{for(let o of n.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s},[...a,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...a,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...a,...o.path]);else{let s=[...a,...o.path];if(s.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<s.length;){let l=s[u];u===s.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return i(e),r}function g_(e,t=r=>r.message){let r={errors:[]},i=(n,a=[])=>{var o,s;for(let c of n.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u},[...a,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...a,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...a,...c.path]);else{let u=[...a,...c.path];if(u.length===0){r.errors.push(t(c));continue}let l=r,d=0;for(;d<u.length;){let f=u[d],p=d===u.length-1;typeof f=="string"?(l.properties??(l.properties={}),(o=l.properties)[f]??(o[f]={errors:[]}),l=l.properties[f]):(l.items??(l.items=[]),(s=l.items)[f]??(s[f]={errors:[]}),l=l.items[f]),p&&l.errors.push(t(c)),d++}}};return i(e),r}function BE(e){let t=[],r=e.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function __(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${BE(i.path)}`);return t.join(`
|
|
155
|
+
`)}var ls=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new sn;if(o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>Wt(c,a,it())));throw rf(s,n?.callee),s}return o.value},Wi=ls(cr),ds=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>Wt(c,a,it())));throw rf(s,n?.callee),s}return o.value},Ka=ds(cr),fs=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new sn;return a.issues.length?{success:!1,error:new(e??eu)(a.issues.map(o=>Wt(o,n,it())))}:{success:!0,data:a.value}},y_=fs(cr),ps=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(o=>Wt(o,n,it())))}:{success:!0,data:a.value}},v_=ps(cr),nf=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ls(e)(t,r,n)},wD=nf(cr),af=e=>(t,r,i)=>ls(e)(t,r,i),xD=af(cr),of=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ds(e)(t,r,n)},SD=of(cr),sf=e=>async(t,r,i)=>ds(e)(t,r,i),kD=sf(cr),cf=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return fs(e)(t,r,n)},$D=cf(cr),uf=e=>(t,r,i)=>fs(e)(t,r,i),ID=uf(cr),lf=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ps(e)(t,r,n)},ED=lf(cr),df=e=>async(t,r,i)=>ps(e)(t,r,i),TD=df(cr);var Er={};$n(Er,{base64:()=>M_,base64url:()=>ff,bigint:()=>B_,boolean:()=>Z_,browserEmail:()=>jD,cidrv4:()=>N_,cidrv6:()=>R_,cuid:()=>b_,cuid2:()=>w_,date:()=>D_,datetime:()=>L_,domain:()=>UD,duration:()=>I_,e164:()=>z_,email:()=>T_,emoji:()=>A_,extendedDuration:()=>AD,guid:()=>E_,hex:()=>LD,hostname:()=>DD,html5Email:()=>ND,httpProtocol:()=>j_,idnEmail:()=>MD,integer:()=>V_,ipv4:()=>C_,ipv6:()=>O_,ksuid:()=>k_,lowercase:()=>J_,mac:()=>P_,md5_base64:()=>BD,md5_base64url:()=>VD,md5_hex:()=>FD,nanoid:()=>$_,null:()=>H_,number:()=>pf,rfc5322Email:()=>RD,sha1_base64:()=>HD,sha1_base64url:()=>GD,sha1_hex:()=>ZD,sha256_base64:()=>KD,sha256_base64url:()=>WD,sha256_hex:()=>JD,sha384_base64:()=>XD,sha384_base64url:()=>YD,sha384_hex:()=>qD,sha512_base64:()=>eU,sha512_base64url:()=>tU,sha512_hex:()=>QD,string:()=>F_,time:()=>U_,ulid:()=>x_,undefined:()=>G_,unicodeEmail:()=>VE,uppercase:()=>K_,uuid:()=>Wa,uuid4:()=>CD,uuid6:()=>OD,uuid7:()=>PD,xid:()=>S_});var b_=/^[cC][0-9a-z]{6,}$/,w_=/^[0-9a-z]+$/,x_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,S_=/^[0-9a-vA-V]{20}$/,k_=/^[A-Za-z0-9]{27}$/,$_=/^[a-zA-Z0-9_-]{21}$/,I_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,AD=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,E_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Wa=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,CD=Wa(4),OD=Wa(6),PD=Wa(7),T_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ND=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,RD=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,VE=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,MD=VE,jD=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,zD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function A_(){return new RegExp(zD,"u")}var C_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,O_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,P_=e=>{let t=Lr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},N_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,R_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ff=/^[A-Za-z0-9_-]*$/,DD=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,UD=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,j_=/^https?$/,z_=/^\+[1-9]\d{6,14}$/,ZE="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",D_=new RegExp(`^${ZE}$`);function HE(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function U_(e){return new RegExp(`^${HE(e)}$`)}function L_(e){let t=HE({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${r.join("|")})`;return new RegExp(`^${ZE}T(?:${i})$`)}var F_=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},B_=/^-?\d+n?$/,V_=/^-?\d+$/,pf=/^-?\d+(?:\.\d+)?$/,Z_=/^(?:true|false)$/i,H_=/^null$/i;var G_=/^undefined$/i;var J_=/^[^A-Z]*$/,K_=/^[^a-z]*$/,LD=/^[0-9a-fA-F]*$/;function nu(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function iu(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var FD=/^[0-9a-fA-F]{32}$/,BD=nu(22,"=="),VD=iu(22),ZD=/^[0-9a-fA-F]{40}$/,HD=nu(27,"="),GD=iu(27),JD=/^[0-9a-fA-F]{64}$/,KD=nu(43,"="),WD=iu(43),qD=/^[0-9a-fA-F]{96}$/,XD=nu(64,""),YD=iu(64),QD=/^[0-9a-fA-F]{128}$/,eU=nu(86,"=="),tU=iu(86);var Le=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),JE={number:"number",bigint:"bigint",object:"date"},mf=S("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=JE[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hf=S("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=JE[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),W_=S("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):s_(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),q_=S("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=p_[t.format];e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,s.minimum=n,s.maximum=a,r&&(s.pattern=V_)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),X_=S("$ZodCheckBigIntFormat",(e,t)=>{Le.init(e,t);let[r,i]=m_[t.format];e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,a.minimum=r,a.maximum=i}),e._zod.check=n=>{let a=n.value;a<r&&n.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>i&&n.issues.push({origin:"bigint",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Y_=S("$ZodCheckMaxSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;n.size<=t.maximum||i.issues.push({origin:Yc(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Q_=S("$ZodCheckMinSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;n.size>=t.minimum||i.issues.push({origin:Yc(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ey=S("$ZodCheckSizeEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=i=>{let n=i.value,a=n.size;if(a===t.size)return;let o=a>t.size;i.issues.push({origin:Yc(n),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ty=S("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;if(n.length<=t.maximum)return;let o=Qc(n);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ry=S("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;if(n.length>=t.minimum)return;let o=Qc(n);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ny=S("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Hi(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=i=>{let n=i.value,a=n.length;if(a===t.length)return;let o=Qc(n),s=a>t.length;i.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ms=S("$ZodCheckStringFormat",(e,t)=>{var r,i;Le.init(e,t),e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),iy=S("$ZodCheckRegex",(e,t)=>{ms.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ay=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=J_),ms.init(e,t)}),oy=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=K_),ms.init(e,t)}),sy=S("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=Lr(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(n=>{let a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),cy=S("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${Lr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),uy=S("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${Lr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function GE(e,t,r){e.issues.length&&t.issues.push(...sr(r,e.issues))}var ly=S("$ZodCheckProperty",(e,t)=>{Le.init(e,t),e._zod.check=r=>{let i=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>GE(n,r,t.property));GE(i,r,t.property)}}),dy=S("$ZodCheckMimeType",(e,t)=>{Le.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(i=>{i._zod.bag.mime=t.mime}),e._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),fy=S("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var au=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
|
|
156
|
+
`).filter(o=>o),n=Math.min(...i.map(o=>o.length-o.trimStart().length)),a=i.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(let o of a)this.content.push(o)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,n.join(`
|
|
157
|
+
`))}};var py={major:4,minor:4,patch:3};var de=S("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=py;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let n of i)for(let a of n._zod.onattach)a(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(o,s,c)=>{let u=Ki(o),l;for(let d of s){if(d._zod.def.when){if(h_(o)||!d._zod.def.when(o))continue}else if(u)continue;let f=o.issues.length,p=d._zod.check(o);if(p instanceof Promise&&c?.async===!1)throw new sn;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await p,o.issues.length!==f&&(u||(u=Ki(o,f)))});else{if(o.issues.length===f)continue;u||(u=Ki(o,f))}}return l?l.then(()=>o):o},a=(o,s,c)=>{if(Ki(o))return o.aborted=!0,o;let u=n(s,i,c);if(u instanceof Promise){if(c.async===!1)throw new sn;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if(s.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>a(l,o,s)):a(u,o,s)}let c=e._zod.parse(o,s);if(c instanceof Promise){if(s.async===!1)throw new sn;return c.then(u=>n(u,i,s))}return n(c,i,s)}}xe(e,"~standard",()=>({validate:n=>{try{let a=y_(e,n);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return v_(e,n).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),qa=S("$ZodString",(e,t)=>{de.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??F_(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),je=S("$ZodStringFormat",(e,t)=>{ms.init(e,t),qa.init(e,t)}),hy=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=E_),je.init(e,t)}),gy=S("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wa(i))}else t.pattern??(t.pattern=Wa());je.init(e,t)}),_y=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=T_),je.init(e,t)}),yy=S("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===j_.source&&!/^https?:\/\//i.test(i)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),vy=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=A_()),je.init(e,t)}),by=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=$_),je.init(e,t)}),wy=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=b_),je.init(e,t)}),xy=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=w_),je.init(e,t)}),Sy=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=x_),je.init(e,t)}),ky=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=S_),je.init(e,t)}),$y=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=k_),je.init(e,t)}),Iy=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=L_(t)),je.init(e,t)}),Ey=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=D_),je.init(e,t)}),Ty=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=U_(t)),je.init(e,t)}),Ay=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=I_),je.init(e,t)}),Cy=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=C_),je.init(e,t),e._zod.bag.format="ipv4"}),Oy=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=O_),je.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Py=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=P_(t.delimiter)),je.init(e,t),e._zod.bag.format="mac"}),Ny=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=N_),je.init(e,t)}),Ry=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=R_),je.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(i.length!==2)throw new Error;let[n,a]=i;if(!a)throw new Error;let o=Number(a);if(`${o}`!==a)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function My(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var jy=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=M_),je.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{My(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function uT(e){if(!ff.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return My(r)}var zy=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ff),je.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{uT(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Dy=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=z_),je.init(e,t)});function lT(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Uy=S("$ZodJWT",(e,t)=>{je.init(e,t),e._zod.check=r=>{lT(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ly=S("$ZodCustomStringFormat",(e,t)=>{je.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),bf=S("$ZodNumber",(e,t)=>{de.init(e,t),e._zod.pattern=e._zod.bag.pattern??pf,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),Fy=S("$ZodNumberFormat",(e,t)=>{q_.init(e,t),bf.init(e,t)}),ou=S("$ZodBoolean",(e,t)=>{de.init(e,t),e._zod.pattern=Z_,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),wf=S("$ZodBigInt",(e,t)=>{de.init(e,t),e._zod.pattern=B_,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),By=S("$ZodBigIntFormat",(e,t)=>{X_.init(e,t),wf.init(e,t)}),Vy=S("$ZodSymbol",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Zy=S("$ZodUndefined",(e,t)=>{de.init(e,t),e._zod.pattern=G_,e._zod.values=new Set([void 0]),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),Hy=S("$ZodNull",(e,t)=>{de.init(e,t),e._zod.pattern=H_,e._zod.values=new Set([null]),e._zod.parse=(r,i)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Gy=S("$ZodAny",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),su=S("$ZodUnknown",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),cu=S("$ZodNever",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Jy=S("$ZodVoid",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Ky=S("$ZodDate",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,a=n instanceof Date;return a&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...a?{received:"Invalid Date"}:{},inst:e}),r}});function WE(e,t,r){e.issues.length&&t.issues.push(...sr(r,e.issues)),t.value[r]=e.value}var Wy=S("$ZodArray",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=t.element._zod.run({value:s,issues:[]},i);c instanceof Promise?a.push(c.then(u=>WE(u,r,o))):WE(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function vf(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...sr(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function dT(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let r=f_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function fT(e,t,r,i,n,a){let o=[],s=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||s.has(f))continue;if(u==="never"){o.push(f);continue}let p=c.run({value:t[f],issues:[]},i);p instanceof Promise?e.push(p.then(m=>vf(m,r,f,t,l,d))):vf(p,r,f,t,l,d)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var pT=S("$ZodObject",(e,t)=>{if(de.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let i=cs(()=>dT(t));xe(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let n=Ja,a=t.catchall,o;e._zod.parse=(s,c)=>{o??(o=i.value);let u=s.value;if(!n(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=o.shape;for(let f of o.keys){let p=d[f],m=p._zod.optin==="optional",g=p._zod.optout==="optional",y=p._zod.run({value:u[f],issues:[]},c);y instanceof Promise?l.push(y.then(b=>vf(b,s,f,u,m,g))):vf(y,s,f,u,m,g)}return a?fT(l,u,s,c,i.value,e):l.length?Promise.all(l).then(()=>s):s}}),qy=S("$ZodObjectJIT",(e,t)=>{pT.init(e,t);let r=e._zod.parse,i=cs(()=>dT(t)),n=f=>{let p=new au(["shape","payload","ctx"]),m=i.value,g=x=>{let k=tf(x);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};p.write("const input = payload.value;");let y=Object.create(null),b=0;for(let x of m.keys)y[x]=`key_${b++}`;p.write("const newResult = {};");for(let x of m.keys){let k=y[x],E=tf(x),V=f[x],C=V?._zod?.optin==="optional",v=V?._zod?.optout==="optional";p.write(`const ${k} = ${g(x)};`),C&&v?p.write(`
|
|
158
|
+
if (${k}.issues.length) {
|
|
159
|
+
if (${E} in input) {
|
|
160
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
161
|
+
...iss,
|
|
162
|
+
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
163
|
+
})));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (${k}.value === undefined) {
|
|
168
|
+
if (${E} in input) {
|
|
169
|
+
newResult[${E}] = undefined;
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
newResult[${E}] = ${k}.value;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
`):C?p.write(`
|
|
176
|
+
if (${k}.issues.length) {
|
|
177
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
178
|
+
...iss,
|
|
179
|
+
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
180
|
+
})));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (${k}.value === undefined) {
|
|
184
|
+
if (${E} in input) {
|
|
185
|
+
newResult[${E}] = undefined;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
newResult[${E}] = ${k}.value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
`):p.write(`
|
|
192
|
+
const ${k}_present = ${E} in input;
|
|
193
|
+
if (${k}.issues.length) {
|
|
194
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
195
|
+
...iss,
|
|
196
|
+
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
197
|
+
})));
|
|
198
|
+
}
|
|
199
|
+
if (!${k}_present && !${k}.issues.length) {
|
|
200
|
+
payload.issues.push({
|
|
201
|
+
code: "invalid_type",
|
|
202
|
+
expected: "nonoptional",
|
|
203
|
+
input: undefined,
|
|
204
|
+
path: [${E}]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (${k}_present) {
|
|
209
|
+
if (${k}.value === undefined) {
|
|
210
|
+
newResult[${E}] = undefined;
|
|
211
|
+
} else {
|
|
212
|
+
newResult[${E}] = ${k}.value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let w=p.compile();return(x,k)=>w(f,x,k)},a,o=Ja,s=!Ga.jitless,u=s&&u_.value,l=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=i.value);let m=f.value;return o(m)?s&&u&&p?.async===!1&&p.jitless!==!0?(a||(a=n(t.shape)),f=a(f,p),l?fT([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function qE(e,t,r,i){for(let a of e)if(a.issues.length===0)return t.value=a.value,t;let n=e.filter(a=>!Ki(a));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>Wt(o,i,it())))}),t)}var uu=S("$ZodUnion",(e,t)=>{de.init(e,t),xe(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),xe(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),xe(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),xe(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${i.map(n=>qc(n.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(s=>qE(s,i,e,n)):qE(o,i,e,n)}});function XE(e,t,r,i){let n=e.filter(a=>a.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>Wt(o,i,it())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Xy=S("$ZodXor",(e,t)=>{uu.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);c instanceof Promise?(o.push(c),a=!0):o.push(c)}return a?Promise.all(o).then(s=>XE(s,i,e,n)):XE(o,i,e,n)}}),Yy=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,uu.init(e,t);let r=e._zod.parse;xe(e._zod,"propValues",()=>{let n={};for(let a of t.options){let o=a._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let[s,c]of Object.entries(o)){n[s]||(n[s]=new Set);for(let u of c)n[s].add(u)}}return n});let i=cs(()=>{let n=t.options,a=new Map;for(let o of n){let s=o._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of s){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,o)}}return a});e._zod.parse=(n,a)=>{let o=n.value;if(!Ja(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(n,a):t.unionFallback||a.direction==="backward"?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),n)}}),Qy=S("$ZodIntersection",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value,a=t.left._zod.run({value:n,issues:[]},i),o=t.right._zod.run({value:n,issues:[]},i);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([c,u])=>YE(r,c,u)):YE(r,a,o)}});function my(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ji(e)&&Ji(t)){let r=Object.keys(t),i=Object.keys(e).filter(a=>r.indexOf(a)!==-1),n={...e,...t};for(let a of i){let o=my(e[a],t[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};n[a]=o.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<e.length;i++){let n=e[i],a=t[i],o=my(n,a);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function YE(e,t,r){let i=new Map,n;for(let s of t.issues)if(s.code==="unrecognized_keys"){n??(n=s);for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else e.issues.push(s);let a=[...i].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(a.length&&n&&e.issues.push({...n,keys:a}),Ki(e))return e;let o=my(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var xf=S("$ZodTuple",(e,t)=>{de.init(e,t);let r=t.items;e._zod.parse=(i,n)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let o=[],s=QE(r,"optin"),c=QE(r,"optout");if(!t.rest){if(a.length<s)return i.issues.push({code:"too_small",minimum:s,inclusive:!0,input:a,inst:e,origin:"array"}),i;a.length>r.length&&i.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=new Array(r.length);for(let l=0;l<r.length;l++){let d=r[l]._zod.run({value:a[l],issues:[]},n);d instanceof Promise?o.push(d.then(f=>{u[l]=f})):u[l]=d}if(t.rest){let l=r.length-1,d=a.slice(r.length);for(let f of d){l++;let p=t.rest._zod.run({value:f,issues:[]},n);p instanceof Promise?o.push(p.then(m=>eT(m,i,l))):eT(p,i,l)}}return o.length?Promise.all(o).then(()=>tT(u,i,r,a,c)):tT(u,i,r,a,c)}});function QE(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function eT(e,t,r){e.issues.length&&t.issues.push(...sr(r,e.issues)),t.value[r]=e.value}function tT(e,t,r,i,n){for(let a=0;a<r.length;a++){let o=e[a],s=a<i.length;if(o.issues.length){if(!s&&a>=n){t.value.length=a;break}t.issues.push(...sr(a,o.issues))}t.value[a]=o.value}for(let a=t.value.length-1;a>=i.length&&(r[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}var ev=S("$ZodRecord",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Ji(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){r.value={};let s=new Set;for(let u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Wt(p,i,it())),input:u,path:[u],inst:e});continue}let d=l.value,f=t.valueType._zod.run({value:n[u],issues:[]},i);f instanceof Promise?a.push(f.then(p=>{p.issues.length&&r.issues.push(...sr(u,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...sr(u,f.issues)),r.value[d]=f.value)}let c;for(let u in n)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(n)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&pf.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=n[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Wt(d,i,it())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:n[s],issues:[]},i);l instanceof Promise?a.push(l.then(d=>{d.issues.length&&r.issues.push(...sr(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...sr(s,l.issues)),r.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>r):r}}),tv=S("$ZodMap",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let a=[];r.value=new Map;for(let[o,s]of n){let c=t.keyType._zod.run({value:o,issues:[]},i),u=t.valueType._zod.run({value:s,issues:[]},i);c instanceof Promise||u instanceof Promise?a.push(Promise.all([c,u]).then(([l,d])=>{rT(l,d,r,o,n,e,i)})):rT(c,u,r,o,n,e,i)}return a.length?Promise.all(a).then(()=>r):r}});function rT(e,t,r,i,n,a,o){e.issues.length&&(Xc.has(typeof i)?r.issues.push(...sr(i,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:a,issues:e.issues.map(s=>Wt(s,o,it()))})),t.issues.length&&(Xc.has(typeof i)?r.issues.push(...sr(i,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:a,key:i,issues:t.issues.map(s=>Wt(s,o,it()))})),r.value.set(e.value,t.value)}var rv=S("$ZodSet",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let a=[];r.value=new Set;for(let o of n){let s=t.valueType._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(c=>nT(c,r))):nT(s,r)}return a.length?Promise.all(a).then(()=>r):r}});function nT(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var nv=S("$ZodEnum",(e,t)=>{de.init(e,t);let r=Wc(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=new RegExp(`^(${r.filter(n=>Xc.has(typeof n)).map(n=>typeof n=="string"?Lr(n):n.toString()).join("|")})$`),e._zod.parse=(n,a)=>{let o=n.value;return i.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),iv=S("$ZodLiteral",(e,t)=>{if(de.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Lr(i):i?Lr(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),av=S("$ZodFile",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),ov=S("$ZodTransform",(e,t)=>{de.init(e,t),e._zod.optin="optional",e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Zi(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(o=>(r.value=o,r.fallback=!0,r));if(n instanceof Promise)throw new sn;return r.value=n,r.fallback=!0,r}});function iT(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Xa=S("$ZodOptional",(e,t)=>{de.init(e,t),e._zod.optin="optional",e._zod.optout="optional",xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),xe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${qc(r.source)})?$`):void 0}),e._zod.parse=(r,i)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,a=t.innerType._zod.run(r,i);return a instanceof Promise?a.then(o=>iT(o,n)):iT(a,n)}return r.value===void 0?r:t.innerType._zod.run(r,i)}}),sv=S("$ZodExactOptional",(e,t)=>{Xa.init(e,t),xe(e._zod,"values",()=>t.innerType._zod.values),xe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,i)=>t.innerType._zod.run(r,i)}),cv=S("$ZodNullable",(e,t)=>{de.init(e,t),xe(e._zod,"optin",()=>t.innerType._zod.optin),xe(e._zod,"optout",()=>t.innerType._zod.optout),xe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${qc(r.source)}|null)$`):void 0}),xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,i)=>r.value===null?r:t.innerType._zod.run(r,i)}),uv=S("$ZodDefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>aT(a,t)):aT(n,t)}});function aT(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var lv=S("$ZodPrefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,i))}),dv=S("$ZodNonOptional",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>oT(a,e)):oT(n,e)}});function oT(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var fv=S("$ZodSuccess",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Zi("ZodSuccess");let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),pv=S("$ZodCatch",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"optout",()=>t.innerType._zod.optout),xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(o=>Wt(o,i,it()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(a=>Wt(a,i,it()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),mv=S("$ZodNaN",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Sf=S("$ZodPipe",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>t.in._zod.values),xe(e._zod,"optin",()=>t.in._zod.optin),xe(e._zod,"optout",()=>t.out._zod.optout),xe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if(i.direction==="backward"){let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>gf(o,t.in,i)):gf(a,t.in,i)}let n=t.in._zod.run(r,i);return n instanceof Promise?n.then(a=>gf(a,t.out,i)):gf(n,t.out,i)}});function gf(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var lu=S("$ZodCodec",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>t.in._zod.values),xe(e._zod,"optin",()=>t.in._zod.optin),xe(e._zod,"optout",()=>t.out._zod.optout),xe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let a=t.in._zod.run(r,i);return a instanceof Promise?a.then(o=>_f(o,t,i)):_f(a,t,i)}else{let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>_f(o,t,i)):_f(a,t,i)}}});function _f(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(a=>yf(e,a,t.out,r)):yf(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(a=>yf(e,a,t.in,r)):yf(e,n,t.in,r)}}function yf(e,t,r,i){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},i)}var hv=S("$ZodPreprocess",(e,t)=>{Sf.init(e,t)}),gv=S("$ZodReadonly",(e,t)=>{de.init(e,t),xe(e._zod,"propValues",()=>t.innerType._zod.propValues),xe(e._zod,"values",()=>t.innerType._zod.values),xe(e._zod,"optin",()=>t.innerType?._zod?.optin),xe(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(sT):sT(n)}});function sT(e){return e.value=Object.freeze(e.value),e}var _v=S("$ZodTemplateLiteral",(e,t)=>{de.init(e,t);let r=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let n=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let a=n.startsWith("^")?1:0,o=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(a,o))}else if(i===null||d_.has(typeof i))r.push(Lr(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(i,n)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),yv=S("$ZodFunction",(e,t)=>(de.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...i){let n=e._def.input?Wi(e._def.input,i):i,a=Reflect.apply(r,this,n);return e._def.output?Wi(e._def.output,a):a}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let n=e._def.input?await Ka(e._def.input,i):i,a=await Reflect.apply(r,this,n);return e._def.output?await Ka(e._def.output,a):a}},e._zod.parse=(r,i)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let i=e.constructor;return Array.isArray(r[0])?new i({type:"function",input:new xf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new i({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:r})},e)),vv=S("$ZodPromise",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},i))}),bv=S("$ZodLazy",(e,t)=>{de.init(e,t),xe(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),xe(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),xe(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),xe(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),xe(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,i)=>e._zod.innerType._zod.run(r,i)}),wv=S("$ZodCustom",(e,t)=>{Le.init(e,t),de.init(e,t),e._zod.parse=(r,i)=>r,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(a=>cT(a,r,i,e));cT(n,r,i,e)}});function cT(e,t,r,i){if(!e){let n={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(n.params=i._zod.def.params),t.issues.push(us(n))}}var fu={};$n(fu,{ar:()=>mT,az:()=>hT,be:()=>_T,bg:()=>yT,ca:()=>vT,cs:()=>bT,da:()=>wT,de:()=>xT,el:()=>ST,en:()=>kf,eo:()=>kT,es:()=>$T,fa:()=>IT,fi:()=>ET,fr:()=>TT,frCA:()=>AT,he:()=>CT,hr:()=>OT,hu:()=>PT,hy:()=>RT,id:()=>MT,is:()=>jT,it:()=>zT,ja:()=>DT,ka:()=>UT,kh:()=>LT,km:()=>$f,ko:()=>FT,lt:()=>VT,mk:()=>ZT,ms:()=>HT,nl:()=>GT,no:()=>JT,ota:()=>KT,pl:()=>qT,ps:()=>WT,pt:()=>XT,ro:()=>YT,ru:()=>eA,sl:()=>tA,sv:()=>rA,ta:()=>nA,th:()=>iA,tr:()=>aA,ua:()=>oA,uk:()=>If,ur:()=>sA,uz:()=>cA,vi:()=>uA,yo:()=>fA,zhCN:()=>lA,zhTW:()=>dA});var nU=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${a}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return n.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${R(n.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()} ${o.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`:a.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${a.suffix}"`:a.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${a.includes}"`:a.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${a.pattern}`:`${r[a.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function mT(){return{localeError:nU()}}var iU=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${a}, daxil olan ${s}`}case"invalid_value":return n.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${R(n.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()} ${o.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${a.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:a.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${a.suffix}" il\u0259 bitm\u0259lidir`:a.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${a.includes}" daxil olmal\u0131d\u0131r`:a.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${a.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[a.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function hT(){return{localeError:iU()}}function gT(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var aU=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${a}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${R(n.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=gT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=gT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function _T(){return{localeError:aU()}}var oU=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${R(n.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;if(a.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${a.prefix}"`;if(a.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${a.suffix}"`;if(a.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${a.includes}"`;if(a.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${a.pattern}`;let o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return a.format==="emoji"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="datetime"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="date"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),a.format==="time"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="duration"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${o} ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function yT(){return{localeError:oU()}}var sU=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${a}, s'ha rebut ${s}`}case"invalid_value":return n.values.length===1?`Valor inv\xE0lid: s'esperava ${R(n.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${I(n.values," o ")}`;case"too_big":{let a=n.inclusive?"com a m\xE0xim":"menys de",o=t(n.origin);return o?`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${a} ${n.maximum.toString()} ${o.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"com a m\xEDnim":"m\xE9s de",o=t(n.origin);return o?`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${a} ${n.minimum.toString()} ${o.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${a.prefix}"`:a.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${a.suffix}"`:a.format==="includes"?`Format inv\xE0lid: ha d'incloure "${a.includes}"`:a.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${a.pattern}`:`Format inv\xE0lid per a ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};function vT(){return{localeError:sU()}}var cU=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${a}, obdr\u017Eeno ${s}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${R(n.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.maximum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.minimum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${a.prefix}"`:a.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${a.suffix}"`:a.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${a.includes}"`:a.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${a.pattern}`:`Neplatn\xFD form\xE1t ${r[a.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function bT(){return{localeError:cU()}}var uU=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldigt input: forventede instanceof ${n.expected}, fik ${s}`:`Ugyldigt input: forventede ${a}, fik ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig v\xE6rdi: forventede ${R(n.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For stor: forventede ${s??"value"} ${o.verb} ${a} ${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For lille: forventede ${s} ${o.verb} ${a} ${n.minimum.toString()} ${o.unit}`:`For lille: forventede ${s} havde ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: skal starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: skal ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: skal indeholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};function wT(){return{localeError:uU()}}var lU=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${a}, erhalten ${s}`}case"invalid_value":return n.values.length===1?`Ung\xFCltige Eingabe: erwartet ${R(n.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ${o.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ist`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ${o.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ist`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ung\xFCltiger String: muss mit "${a.prefix}" beginnen`:a.format==="ends_with"?`Ung\xFCltiger String: muss mit "${a.suffix}" enden`:a.format==="includes"?`Ung\xFCltiger String: muss "${a.includes}" enthalten`:a.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${a.pattern} entsprechen`:`Ung\xFCltig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};function xT(){return{localeError:lU()}}var dU=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return typeof n.expected=="string"&&/^[A-Z]/.test(n.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${a}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return n.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${R(n.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.maximum.toString()} ${o.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.minimum.toString()} ${o.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${a.prefix}"`:a.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${a.suffix}"`:a.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${a.includes}"`:a.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${a.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function ST(){return{localeError:dU()}}var fU=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return`Invalid input: expected ${a}, received ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`Invalid option: expected one of ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${a}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${a}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(o=>`'${o}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function kf(){return{localeError:fU()}}var pU=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${a}, ricevi\u011Dis ${s}`}case"invalid_value":return n.values.length===1?`Nevalida enigo: atendi\u011Dis ${R(n.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()} ${o.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${a}${n.minimum.toString()} ${o.unit}`:`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${a.prefix}"`:a.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${a.suffix}"`:a.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${a.includes}"`:a.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${a.pattern}`:`Nevalida ${r[a.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};function kT(){return{localeError:pU()}}var mU=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${a}, recibido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: se esperaba ${R(n.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${a}${n.minimum.toString()} ${o.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${a.prefix}"`:a.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${a.suffix}"`:a.format==="includes"?`Cadena inv\xE1lida: debe incluir "${a.includes}"`:a.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${a.pattern}`:`Inv\xE1lido ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};function $T(){return{localeError:mU()}}var hU=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${a} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return n.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${R(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${I(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:a.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:a.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${a.includes}" \u0628\u0627\u0634\u062F`:a.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${a.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[a.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function IT(){return{localeError:hU()}}var gU=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${a}, oli ${s}`}case"invalid_value":return n.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${R(n.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Liian suuri: ${o.subject} t\xE4ytyy olla ${a}${n.maximum.toString()} ${o.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Liian pieni: ${o.subject} t\xE4ytyy olla ${a}${n.minimum.toString()} ${o.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${a.prefix}"`:a.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${a.suffix}"`:a.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${a.includes}"`:a.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${a.pattern}`:`Virheellinen ${r[a.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function ET(){return{localeError:gU()}}var _U=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : instanceof ${n.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${a} attendu, ${s} re\xE7u`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : ${R(n.values[0])} attendu`:`Option invalide : une valeur parmi ${I(n.values,"|")} attendue`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Trop grand : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Trop petit : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function TT(){return{localeError:_U()}}var yU=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${a}, re\xE7u ${s}`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : attendu ${R(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u2264":"<",o=t(n.origin);return o?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${a}${n.maximum.toString()} ${o.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u2265":">",o=t(n.origin);return o?`Trop petit : attendu que ${n.origin} ait ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : attendu que ${n.origin} soit ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function AT(){return{localeError:yU()}}var vU=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=u=>u?e[u]:void 0,i=u=>{let l=r(u);return l?l.label:u??e.unknown.label},n=u=>`\u05D4${i(u)}`,a=u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",o=u=>u?t[u]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return u=>{switch(u.code){case"invalid_type":{let l=u.expected,d=c[l??""]??i(l),f=M(u.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${R(u.values[0])}`;let l=u.values.map(p=>R(p));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=o(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",g=u.inclusive?`${u.maximum} ${l?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${l?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${g}`.trim()}let f=u.inclusive?"<=":"<",p=a(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{let l=o(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let y=(u.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`}let g=u.inclusive?`${u.minimum} ${l?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${l?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${g}`.trim()}let f=u.inclusive?">=":">",p=a(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${l.pattern}`;let d=s[l.format],f=d?.label??l.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${f} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function CT(){return{localeError:vU()}}var bU=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${a}, a primljeno je ${s}`}case"invalid_value":return n.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${R(n.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${a}${n.maximum.toString()} ${o.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Premalo: o\u010Dekivano da ${s} ima ${a}${n.minimum.toString()} ${o.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${a.prefix}"`:a.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${a.suffix}"`:a.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${a.includes}"`:a.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${a.pattern}`:`Neispravna ${r[a.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[n.origin]??n.origin}`;default:return"Neispravan unos"}}};function OT(){return{localeError:bU()}}var wU=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${a}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return n.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${R(n.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${a}${n.maximum.toString()} ${o.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${a}${n.minimum.toString()} ${o.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xC9rv\xE9nytelen string: "${a.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:a.format==="ends_with"?`\xC9rv\xE9nytelen string: "${a.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:a.format==="includes"?`\xC9rv\xE9nytelen string: "${a.includes}" \xE9rt\xE9ket kell tartalmaznia`:a.format==="regex"?`\xC9rv\xE9nytelen string: ${a.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[a.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function PT(){return{localeError:wU()}}function NT(e,t,r){return Math.abs(e)===1?t:r}function hs(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var xU=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${a}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return n.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${R(n.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=NT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${hs(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${hs(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=NT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${hs(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${hs(n.origin)} \u056C\u056B\u0576\u056B ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${a.prefix}"-\u0578\u057E`:a.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${a.suffix}"-\u0578\u057E`:a.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${a.includes}"`:a.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${a.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[a.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${I(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${hs(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${hs(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function RT(){return{localeError:xU()}}var SU=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${R(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: diharapkan ${n.origin} memiliki ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak valid: harus dimulai dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak valid: harus berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak valid: harus menyertakan "${a.includes}"`:a.format==="regex"?`String tidak valid: harus sesuai pola ${a.pattern}`:`${r[a.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function MT(){return{localeError:SU()}}var kU=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${a}`}case"invalid_value":return n.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${R(n.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${a}${n.maximum.toString()} ${o.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${a}${n.minimum.toString()} ${o.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${a.prefix}"`:a.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${a.suffix}"`:a.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${a.includes}"`:a.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${a.pattern}`:`Rangt ${r[a.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${I(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};function jT(){return{localeError:kU()}}var $U=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input non valido: atteso instanceof ${n.expected}, ricevuto ${s}`:`Input non valido: atteso ${a}, ricevuto ${s}`}case"invalid_value":return n.values.length===1?`Input non valido: atteso ${R(n.values[0])}`:`Opzione non valida: atteso uno tra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Troppo grande: ${n.origin??"valore"} deve avere ${a}${n.maximum.toString()} ${o.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Troppo piccolo: ${n.origin} deve avere ${a}${n.minimum.toString()} ${o.unit}`:`Troppo piccolo: ${n.origin} deve essere ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Stringa non valida: deve iniziare con "${a.prefix}"`:a.format==="ends_with"?`Stringa non valida: deve terminare con "${a.suffix}"`:a.format==="includes"?`Stringa non valida: deve includere "${a.includes}"`:a.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${a.pattern}`:`Input non valido: ${r[a.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${I(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function zT(){return{localeError:$U()}}var IU=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${a}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return n.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${R(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${I(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let a=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",o=t(n.origin);return o?`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${o.unit??"\u8981\u7D20"}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let a=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",o=t(n.origin);return o?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${o.unit}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${a.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function DT(){return{localeError:IU()}}var EU=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${a}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return n.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${R(n.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${I(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.prefix}"-\u10D8\u10D7`:a.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.suffix}"-\u10D8\u10D7`:a.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${a.includes}"-\u10E1`:a.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${a.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function UT(){return{localeError:EU()}}var TU=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${a} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return n.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${R(n.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()} ${o.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()} ${o.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${a.prefix}"`:a.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${a.suffix}"`:a.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${a.includes}"`:a.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${a.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function $f(){return{localeError:TU()}}function LT(){return $f()}var AU=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${a}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return n.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${R(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${I(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let a=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",o=a==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${a}${o}`}case"too_small":{let a=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",o=a==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${a}${o}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:a.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${a.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[a.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function FT(){return{localeError:AU()}}var du=e=>e.charAt(0).toUpperCase()+e.slice(1);function BT(e){let t=Math.abs(e),r=t%10,i=t%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var CU=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,a,o,s){let c=e[n]??null;return c===null?c:{unit:c.unit[a],verb:c.verb[s][o?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${n.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${a}`}case"invalid_value":return n.values.length===1?`Privalo b\u016Bti ${R(n.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${I(n.values,"|")} pasirinkim\u0173`;case"too_big":{let a=i[n.origin]??n.origin,o=t(n.origin,BT(Number(n.maximum)),n.inclusive??!1,"smaller");if(o?.verb)return`${du(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.maximum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${du(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.maximum.toString()} ${o?.unit}`}case"too_small":{let a=i[n.origin]??n.origin,o=t(n.origin,BT(Number(n.minimum)),n.inclusive??!1,"bigger");if(o?.verb)return`${du(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.minimum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${du(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.minimum.toString()} ${o?.unit}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${a.prefix}"`:a.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${a.suffix}"`:a.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${a.includes}"`:a.format==="regex"?`Eilut\u0117 privalo atitikti ${a.pattern}`:`Neteisingas ${r[a.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${I(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let a=i[n.origin]??n.origin;return`${du(a??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function VT(){return{localeError:CU()}}var OU=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${a}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function ZT(){return{localeError:OU()}}var PU=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${s}`:`Input tidak sah: dijangka ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${R(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: dijangka ${n.origin??"nilai"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: dijangka ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak sah: mesti bermula dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak sah: mesti mengandungi "${a.includes}"`:a.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${a.pattern}`:`${r[a.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function HT(){return{localeError:PU()}}var NU=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${a}, ontving ${s}`}case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${R(n.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";return o?`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} ${o.unit??"elementen"} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} is`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";return o?`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} is`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ongeldige tekst: moet met "${a.prefix}" beginnen`:a.format==="ends_with"?`Ongeldige tekst: moet op "${a.suffix}" eindigen`:a.format==="includes"?`Ongeldige tekst: moet "${a.includes}" bevatten`:a.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${a.pattern}`:`Ongeldig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function GT(){return{localeError:NU()}}var RU=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventet instanceof ${n.expected}, fikk ${s}`:`Ugyldig input: forventet ${a}, fikk ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${R(n.values[0])}`:`Ugyldig valg: forventet en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()} ${o.unit}`:`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function JT(){return{localeError:RU()}}var MU=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`F\xE2sit giren: umulan ${R(n.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} ${o.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} ${o.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let a=n;return a.format==="starts_with"?`F\xE2sit metin: "${a.prefix}" ile ba\u015Flamal\u0131.`:a.format==="ends_with"?`F\xE2sit metin: "${a.suffix}" ile bitmeli.`:a.format==="includes"?`F\xE2sit metin: "${a.includes}" ihtiv\xE2 etmeli.`:a.format==="regex"?`F\xE2sit metin: ${a.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[a.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function KT(){return{localeError:MU()}}var jU=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${a} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return n.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${R(n.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${I(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:a.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:a.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${a.includes}" \u0648\u0644\u0631\u064A`:a.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${a.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[a.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function WT(){return{localeError:jU()}}var zU=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${a}, otrzymano ${s}`}case"invalid_value":return n.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${R(n.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.maximum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.minimum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${a.prefix}"`:a.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${a.suffix}"`:a.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${a.includes}"`:a.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${a.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[a.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function qT(){return{localeError:zU()}}var DU=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipo inv\xE1lido: esperado instanceof ${n.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${a}, recebido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: esperado ${R(n.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Muito pequeno: esperado que ${n.origin} tivesse ${a}${n.minimum.toString()} ${o.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`${r[a.format]??n.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${n.origin}`;default:return"Campo inv\xE1lido"}}};function XT(){return{localeError:DU()}}var UU=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return`Intrare invalid\u0103: a\u0219teptat ${a}, primit ${s}`}case"invalid_value":return n.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${R(n.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Prea mic: a\u0219teptat ca ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${a.prefix}"`:a.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${a.suffix}"`:a.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${a.includes}"`:a.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${a.pattern}`:`Format invalid: ${r[a.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${I(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};function YT(){return{localeError:UU()}}function QT(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var LU=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${R(n.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=QT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=QT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function eA(){return{localeError:LU()}}var FU=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${a}, prejeto ${s}`}case"invalid_value":return n.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${R(n.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${a}${n.maximum.toString()} ${o.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${a}${n.minimum.toString()} ${o.unit}`:`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${a.prefix}"`:a.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${a.suffix}"`:a.format==="includes"?`Neveljaven niz: mora vsebovati "${a.includes}"`:a.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${a.pattern}`:`Neveljaven ${r[a.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function tA(){return{localeError:FU()}}var BU=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${a}, fick ${s}`}case"invalid_value":return n.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${R(n.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()} ${o.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()} ${o.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${a.prefix}"`:a.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${a.suffix}"`:a.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${a.includes}"`:a.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${a.pattern}"`:`Ogiltig(t) ${r[a.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function rA(){return{localeError:BU()}}var VU=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return n.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(n.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${I(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} ${o.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} ${o.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${a.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function nA(){return{localeError:VU()}}var ZU=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${a} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return n.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${R(n.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()} ${o.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()} ${o.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${a.prefix}"`:a.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${a.suffix}"`:a.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${a.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:a.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${a.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${I(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function iA(){return{localeError:ZU()}}var HU=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${R(n.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()} ${o.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ge\xE7ersiz metin: "${a.prefix}" ile ba\u015Flamal\u0131`:a.format==="ends_with"?`Ge\xE7ersiz metin: "${a.suffix}" ile bitmeli`:a.format==="includes"?`Ge\xE7ersiz metin: "${a.includes}" i\xE7ermeli`:a.format==="regex"?`Ge\xE7ersiz metin: ${a.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[a.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function aA(){return{localeError:HU()}}var GU=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${a}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${R(n.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function If(){return{localeError:GU()}}function oA(){return If()}var JU=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${a} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return n.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${R(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${a}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${a}${n.minimum.toString()} ${o.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${a}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${a.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function sA(){return{localeError:JU()}}var KU=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${a}, qabul qilingan ${s}`}case"invalid_value":return n.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${R(n.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()} ${o.unit} ${o.verb}`:`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${a.prefix}" bilan boshlanishi kerak`:a.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${a.suffix}" bilan tugashi kerak`:a.format==="includes"?`Noto\u2018g\u2018ri satr: "${a.includes}" ni o\u2018z ichiga olishi kerak`:a.format==="regex"?`Noto\u2018g\u2018ri satr: ${a.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[a.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function cA(){return{localeError:KU()}}var WU=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${a}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return n.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${R(n.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${a.prefix}"`:a.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${a.suffix}"`:a.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${a.includes}"`:a.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${a.pattern}`:`${r[a.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function uA(){return{localeError:WU()}}var qU=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${a}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return n.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${R(n.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()} ${o.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.prefix}" \u5F00\u5934`:a.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.suffix}" \u7ED3\u5C3E`:a.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${a.pattern}`:`\u65E0\u6548${r[a.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function lA(){return{localeError:qU()}}var XU=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${a}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return n.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${R(n.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()} ${o.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()} ${o.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.prefix}" \u958B\u982D`:a.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.suffix}" \u7D50\u5C3E`:a.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${a.pattern}`:`\u7121\u6548\u7684 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function dA(){return{localeError:XU()}}var YU=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${a}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return n.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${R(n.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${o.verb} ${a}${n.maximum} ${o.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.maximum}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${o.verb} ${a}${n.minimum} ${o.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.minimum}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${a.prefix}"`:a.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${a.suffix}"`:a.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${a.includes}"`:a.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${a.pattern}`:`A\u1E63\xEC\u1E63e: ${r[a.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${I(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function fA(){return{localeError:YU()}}var pA,xv=Symbol("ZodOutput"),Sv=Symbol("ZodInput"),Ef=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let i=r[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let n={...i,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Tf(){return new Ef}(pA=globalThis).__zod_globalRegistry??(pA.__zod_globalRegistry=Tf());var Pe=globalThis.__zod_globalRegistry;function kv(e,t){return new e({type:"string",...U(t)})}function $v(e,t){return new e({type:"string",coerce:!0,...U(t)})}function Af(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...U(t)})}function pu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...U(t)})}function Cf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...U(t)})}function Of(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(t)})}function Pf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(t)})}function Nf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(t)})}function mu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function Rf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...U(t)})}function Mf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(t)})}function jf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...U(t)})}function zf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(t)})}function Df(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...U(t)})}function Uf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...U(t)})}function Lf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(t)})}function Ff(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(t)})}function Bf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(t)})}function Iv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...U(t)})}function Vf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(t)})}function Zf(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(t)})}function Hf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...U(t)})}function Gf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...U(t)})}function Jf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...U(t)})}function Kf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...U(t)})}var Ev={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Tv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(t)})}function Av(e,t){return new e({type:"string",format:"date",check:"string_format",...U(t)})}function Cv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...U(t)})}function Ov(e,t){return new e({type:"string",format:"duration",check:"string_format",...U(t)})}function Pv(e,t){return new e({type:"number",checks:[],...U(t)})}function Nv(e,t){return new e({type:"number",coerce:!0,checks:[],...U(t)})}function Rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...U(t)})}function jv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...U(t)})}function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...U(t)})}function Dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...U(t)})}function Uv(e,t){return new e({type:"boolean",...U(t)})}function Lv(e,t){return new e({type:"boolean",coerce:!0,...U(t)})}function Fv(e,t){return new e({type:"bigint",...U(t)})}function Bv(e,t){return new e({type:"bigint",coerce:!0,...U(t)})}function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...U(t)})}function Zv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...U(t)})}function Hv(e,t){return new e({type:"symbol",...U(t)})}function Gv(e,t){return new e({type:"undefined",...U(t)})}function Jv(e,t){return new e({type:"null",...U(t)})}function Kv(e){return new e({type:"any"})}function hu(e){return new e({type:"unknown"})}function gu(e,t){return new e({type:"never",...U(t)})}function Wv(e,t){return new e({type:"void",...U(t)})}function qv(e,t){return new e({type:"date",...U(t)})}function Xv(e,t){return new e({type:"date",coerce:!0,...U(t)})}function Yv(e,t){return new e({type:"nan",...U(t)})}function zn(e,t){return new mf({check:"less_than",...U(t),value:e,inclusive:!1})}function Tr(e,t){return new mf({check:"less_than",...U(t),value:e,inclusive:!0})}function Dn(e,t){return new hf({check:"greater_than",...U(t),value:e,inclusive:!1})}function qt(e,t){return new hf({check:"greater_than",...U(t),value:e,inclusive:!0})}function Wf(e){return Dn(0,e)}function qf(e){return zn(0,e)}function Xf(e){return Tr(0,e)}function Yf(e){return qt(0,e)}function qi(e,t){return new W_({check:"multiple_of",...U(t),value:e})}function Xi(e,t){return new Y_({check:"max_size",...U(t),maximum:e})}function Un(e,t){return new Q_({check:"min_size",...U(t),minimum:e})}function Ya(e,t){return new ey({check:"size_equals",...U(t),size:e})}function Qa(e,t){return new ty({check:"max_length",...U(t),maximum:e})}function di(e,t){return new ry({check:"min_length",...U(t),minimum:e})}function eo(e,t){return new ny({check:"length_equals",...U(t),length:e})}function gs(e,t){return new iy({check:"string_format",format:"regex",...U(t),pattern:e})}function _s(e){return new ay({check:"string_format",format:"lowercase",...U(e)})}function ys(e){return new oy({check:"string_format",format:"uppercase",...U(e)})}function vs(e,t){return new sy({check:"string_format",format:"includes",...U(t),includes:e})}function bs(e,t){return new cy({check:"string_format",format:"starts_with",...U(t),prefix:e})}function ws(e,t){return new uy({check:"string_format",format:"ends_with",...U(t),suffix:e})}function Qf(e,t,r){return new ly({check:"property",property:e,schema:t,...U(r)})}function xs(e,t){return new dy({check:"mime_type",mime:e,...U(t)})}function cn(e){return new fy({check:"overwrite",tx:e})}function Ss(e){return cn(t=>t.normalize(e))}function ks(){return cn(e=>e.trim())}function $s(){return cn(e=>e.toLowerCase())}function Is(){return cn(e=>e.toUpperCase())}function Es(){return cn(e=>c_(e))}function Qv(e,t,r){return new e({type:"array",element:t,...U(r)})}function e2(e,t,r){return new e({type:"union",options:t,...U(r)})}function t2(e,t,r){return new e({type:"union",options:t,inclusive:!1,...U(r)})}function r2(e,t,r,i){return new e({type:"union",options:r,discriminator:t,...U(i)})}function n2(e,t,r){return new e({type:"intersection",left:t,right:r})}function i2(e,t,r,i){let n=r instanceof de,a=n?i:r,o=n?r:null;return new e({type:"tuple",items:t,rest:o,...U(a)})}function a2(e,t,r,i){return new e({type:"record",keyType:t,valueType:r,...U(i)})}function o2(e,t,r,i){return new e({type:"map",keyType:t,valueType:r,...U(i)})}function s2(e,t,r){return new e({type:"set",valueType:t,...U(r)})}function c2(e,t,r){let i=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:i,...U(r)})}function u2(e,t,r){return new e({type:"enum",entries:t,...U(r)})}function l2(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...U(r)})}function eb(e,t){return new e({type:"file",...U(t)})}function d2(e,t){return new e({type:"transform",transform:t})}function f2(e,t){return new e({type:"optional",innerType:t})}function p2(e,t){return new e({type:"nullable",innerType:t})}function m2(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():l_(r)}})}function h2(e,t,r){return new e({type:"nonoptional",innerType:t,...U(r)})}function g2(e,t){return new e({type:"success",innerType:t})}function _2(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function y2(e,t,r){return new e({type:"pipe",in:t,out:r})}function v2(e,t){return new e({type:"readonly",innerType:t})}function b2(e,t,r){return new e({type:"template_literal",parts:t,...U(r)})}function w2(e,t){return new e({type:"lazy",getter:t})}function x2(e,t){return new e({type:"promise",innerType:t})}function tb(e,t,r){let i=U(r);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function rb(e,t,r){return new e({type:"custom",check:"custom",fn:t,...U(r)})}function nb(e,t){let r=mA(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(us(n,i.value,r._zod.def));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=i.value),a.inst??(a.inst=r),a.continue??(a.continue=!r._zod.def.abort),i.issues.push(us(a))}},e(i.value,i)),t);return r}function mA(e,t){let r=new Le({check:"custom",...U(t)});return r._zod.check=e,r}function ib(e){let t=new Le({check:"describe"});return t._zod.onattach=[r=>{let i=Pe.get(r)??{};Pe.add(r,{...i,description:e})}],t._zod.check=()=>{},t}function ab(e){let t=new Le({check:"meta"});return t._zod.onattach=[r=>{let i=Pe.get(r)??{};Pe.add(r,{...i,...e})}],t._zod.check=()=>{},t}function ob(e,t){let r=U(t),i=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));let a=new Set(i),o=new Set(n),s=e.Codec??lu,c=e.Boolean??ou,u=e.String??qa,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:l,out:d,transform:((p,m)=>{let g=p;return r.case!=="sensitive"&&(g=g.toLowerCase()),a.has(g)?!0:o.has(g)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...a,...o],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?i[0]||"true":n[0]||"false"),error:r.error});return f}function Ts(e,t,r,i={}){let n=U(i),a={...U(i),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(a.pattern=r),new e(a)}function Yi(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Pe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Re(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,l);else{let f=o.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(o.ref||(o.ref=d),Re(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Xt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Qi(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of e.seen.entries()){let s=e.metadataRegistry.get(o[0])?.id;if(s){let c=i.get(s);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,o[0])}}let n=o=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(o[1]===r)return{ref:"#"};let u=`#/${s}/`,l=o[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},a=o=>{if(o[1].schema.$ref)return;let s=o[1],{ref:c,defId:u}=n(o);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
217
|
+
|
|
218
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){a(o);continue}if(e.external){let u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function ea(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),s._zod.parent===d)for(let y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(m.$ref&&p.def)for(let y in u)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y])&&delete u[y]}let f=s._zod.parent;if(f&&f!==d){i(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Object.assign(n,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&n.id===a&&delete n.id;let o=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:As(t,"input",e.processors),output:As(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Xt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Xt(i.element,r);if(i.type==="set")return Xt(i.valueType,r);if(i.type==="lazy")return Xt(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Xt(i.innerType,r);if(i.type==="intersection")return Xt(i.left,r)||Xt(i.right,r);if(i.type==="record"||i.type==="map")return Xt(i.keyType,r)||Xt(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xt(i.in,r)||Xt(i.out,r);if(i.type==="object"){for(let n in i.shape)if(Xt(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(Xt(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(Xt(n,r))return!0;return!!(i.rest&&Xt(i.rest,r))}return!1}var sb=(e,t={})=>r=>{let i=Yi({...r,processors:t});return Re(e,i),Qi(i,e),ea(i,e)},As=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=Yi({...n??{},target:a,io:t,processors:r});return Re(e,o),Qi(o,e),ea(o,e)};var S2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cb=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof a=="number"&&(n.minLength=a),typeof o=="number"&&(n.maxLength=o),s&&(n.format=S2[s]??s,n.format===""&&delete n.format,s==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?n.pattern=l[0].source:l.length>1&&(n.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},ub=(e,t,r,i)=>{let n=r,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let d=typeof l=="number"&&l>=(a??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof a=="number"&&(n.minimum=a),f?p?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof o=="number"&&(n.maximum=o),typeof c=="number"&&(n.multipleOf=c)},lb=(e,t,r,i)=>{r.type="boolean"},db=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},fb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},pb=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},mb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},hb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},gb=(e,t,r,i)=>{r.not={}},_b=(e,t,r,i)=>{},yb=(e,t,r,i)=>{},vb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},bb=(e,t,r,i)=>{let n=e._zod.def,a=Wc(n.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},wb=(e,t,r,i)=>{let n=e._zod.def,a=[];for(let o of n.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let o=a[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),a.every(o=>typeof o=="boolean")&&(r.type="boolean"),a.every(o=>o===null)&&(r.type="null"),r.enum=a},xb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Sb=(e,t,r,i)=>{let n=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=a.source},kb=(e,t,r,i)=>{let n=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(n,a)):(Object.assign(n,a),n.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(n,a)},$b=(e,t,r,i)=>{r.type="boolean"},Ib=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Eb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Tb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ab=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Cb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ob=(e,t,r,i)=>{let n=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(n.minItems=o),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Re(a.element,t,{...i,path:[...i.path,"items"]})},Pb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object",n.properties={};let o=a.shape;for(let u in o)n.properties[u]=Re(o[u],t,{...i,path:[...i.path,"properties",u]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(u=>{let l=a.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(n.required=Array.from(c)),a.catchall?._zod.def.type==="never"?n.additionalProperties=!1:a.catchall?a.catchall&&(n.additionalProperties=Re(a.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},tp=(e,t,r,i)=>{let n=e._zod.def,a=n.inclusive===!1,o=n.options.map((s,c)=>Re(s,t,{...i,path:[...i.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},Nb=(e,t,r,i)=>{let n=e._zod.def,a=Re(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=Re(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=c},Rb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((f,p)=>Re(f,t,{...i,path:[...i.path,o,p]})),u=a.rest?Re(a.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=c,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:c},u&&n.items.anyOf.push(u),n.minItems=c.length,u||(n.maxItems=c.length)):(n.items=c,u&&(n.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(n.minItems=l),typeof d=="number"&&(n.maxItems=d)},Mb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object";let o=a.keyType,c=o._zod.bag?.patterns;if(a.mode==="loose"&&c&&c.size>0){let l=Re(a.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=Re(a.keyType,t,{...i,path:[...i.path,"propertyNames"]})),n.additionalProperties=Re(a.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let u=o._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l)}},jb=(e,t,r,i)=>{let n=e._zod.def,a=Re(n.innerType,t,i),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},zb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Db=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Ub=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Lb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Fb=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?a?n.out:n.in:n.out;Re(o,t,i);let s=t.seen.get(e);s.ref=o},Bb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.readOnly=!0},Vb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},rp=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Zb=(e,t,r,i)=>{let n=e._zod.innerType;Re(n,t,i);let a=t.seen.get(e);a.ref=n},ep={string:cb,number:ub,boolean:lb,bigint:db,symbol:fb,null:pb,undefined:mb,void:hb,never:gb,any:_b,unknown:yb,date:vb,enum:bb,literal:wb,nan:xb,template_literal:Sb,file:kb,success:$b,custom:Ib,function:Eb,transform:Tb,map:Ab,set:Cb,array:Ob,object:Pb,union:tp,intersection:Nb,tuple:Rb,record:Mb,nullable:jb,nonoptional:zb,default:Db,prefault:Ub,catch:Lb,pipe:Fb,readonly:Bb,promise:Vb,optional:rp,lazy:Zb};function to(e,t){if("_idmap"in e){let i=e,n=Yi({...t,processors:ep}),a={};for(let c of i._idmap.entries()){let[u,l]=c;Re(l,n)}let o={},s={registry:i,uri:t?.uri,defs:a};n.external=s;for(let c of i._idmap.entries()){let[u,l]=c;Qi(n,l),o[u]=ea(n,l)}if(Object.keys(a).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:a}}return{schemas:o}}let r=Yi({...t,processors:ep});return Re(e,r),Qi(r,e),ea(r,e)}var np=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Yi({processors:ep,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Re(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Qi(this.ctx,t);let i=ea(this.ctx,t),{"~standard":n,...a}=i;return a}};var hA={};function Be(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let r=t._zod;return typeof r=="object"&&r!==null&&"def"in r}function at(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let r=t._def;return typeof r=="object"&&r!=null&&"typeName"in r}function gA(e){return Be(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),at(e)}function ur(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(Be(e)||at(e))}function Hb(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodLiteral"}function Gb(e){return Be(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="literal":!1}function _A(e){return!!(Hb(e)||Gb(e))}async function ap(e,t){if(Be(e))try{return{success:!0,data:await Ka(e,t)}}catch(r){return{success:!1,error:r}}if(at(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function ta(e,t){if(Be(e))return await Ka(e,t);if(at(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function yA(e,t){if(Be(e))try{return{success:!0,data:Wi(e,t)}}catch(r){return{success:!1,error:r}}if(at(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Os(e,t){if(Be(e))return Wi(e,t);if(at(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function pi(e){if(Be(e))return Pe.get(e)?.description;if(at(e)||"description"in e&&typeof e.description=="string")return e.description}function vA(e){if(!ur(e))return!1;if(at(e)){let t=e._def;if(t.typeName==="ZodObject"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(Be(e)){let t=e._zod.def;if(t.type==="object"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function Ps(e){return ur(e)?at(e)?e._def.typeName==="ZodString":Be(e)?e._zod.def.type==="string":!1:!1}function _u(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodObject"}function Fr(e){return Be(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="object":!1}function yu(e){return Be(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="array":!1}function Jb(e){return Be(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="optional":!1}function Kb(e){return Be(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="nullable":!1}function Yt(e){return!!(_u(e)||Fr(e))}function no(e){if(at(e))return e.shape;if(Be(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function op(e,t){if(at(e))return e.extend(t);if(Be(e))return j.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ns(e){if(at(e))return e.partial();if(Be(e))return j.partial(Xa,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Cs(e,t=!1){if(_u(e))return e.strict();if(Fr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Fr(o))r[a]=Cs(o,t);else if(yu(o)){let c=o._zod.def.element;Fr(c)&&(c=Cs(c,t)),r[a]=Je(o,{...o._zod.def,element:c})}else r[a]=o;let s=Pe.get(o);s&&Pe.add(r[a],s)}let i=Je(e,{...e._zod.def,shape:r,catchall:gu(cu)}),n=Pe.get(e);return n&&Pe.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function ip(e,t=!1){if(_u(e))return e.passthrough();if(Fr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Fr(o))r[a]=ip(o,t);else if(yu(o)){let c=o._zod.def.element;Fr(c)&&(c=ip(c,t)),r[a]=Je(o,{...o._zod.def,element:c})}else r[a]=o;let s=Pe.get(o);s&&Pe.add(r[a],s)}let i=Je(e,{...e._zod.def,shape:r,catchall:hu(su)}),n=Pe.get(e);return n&&Pe.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function sp(e){if(at(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(Be(e))try{let t=Wi(e,void 0);return()=>t}catch{return}}function $2(e){return at(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function I2(e){return Be(e)&&e._zod.def.type==="pipe"}function ro(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(at(e))return $2(e)?ro(e._def.schema,t,r):e;if(Be(e)){let n=e;if(I2(e)&&(n=ro(e._zod.def.in,t,r)),t){if(Fr(n)){let o={};for(let[s,c]of Object.entries(n._zod.def.shape))o[s]=ro(c,t,r);n=Je(n,{...n._zod.def,shape:o})}else if(yu(n)){let o=ro(n._zod.def.element,t,r);n=Je(n,{...n._zod.def,element:o})}else if(Jb(n)){let o=ro(n._zod.def.innerType,t,r);n=Je(n,{...n._zod.def,innerType:o})}else if(Kb(n)){let o=ro(n._zod.def.innerType,t,r);n=Je(n,{...n._zod.def,innerType:o})}}let a=Pe.get(e);return a&&Pe.add(n,a),r.set(e,n),n}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function cp(e,t=!1){return ro(e,t,new WeakMap)}function bA(e,t){if(at(e)){let r=no(e),i={};for(let[n,a]of Object.entries(r))t(n,a)?i[n]=a.optional():i[n]=a;return e.extend(i)}if(Be(e)){let r=no(e),i={...e._zod.def.shape};for(let[o,s]of Object.entries(r))t(o,s)&&(i[o]=new Xa({type:"optional",innerType:s}));let n=Je(e,{...e._zod.def,shape:i}),a=Pe.get(e);return a&&Pe.add(n,a),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function up(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var xA=Symbol("Let zodToJsonSchema decide on which parser to use"),wA={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},SA=e=>typeof e=="string"?{...wA,name:e}:{...wA,...e};var kA=e=>{let t=SA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,i],jsonSchema:void 0}]))}};var lp=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function Xe(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?lp(t,e.currentPath):t.join("/")}}function Wb(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ae(e,t,r,i,n){e[t]=r,Wb(e,t,i,n)}var St={};$n(St,{BRAND:()=>Y2,DIRTY:()=>io,EMPTY_PATH:()=>C2,INVALID:()=>oe,NEVER:()=>jL,OK:()=>zt,ParseStatus:()=>Ct,Schema:()=>ye,ZodAny:()=>ia,ZodArray:()=>_i,ZodBigInt:()=>oo,ZodBoolean:()=>so,ZodBranded:()=>bu,ZodCatch:()=>vo,ZodDate:()=>co,ZodDefault:()=>yo,ZodDiscriminatedUnion:()=>pp,ZodEffects:()=>Zr,ZodEnum:()=>go,ZodError:()=>lr,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>hp,ZodIntersection:()=>po,ZodIssueCode:()=>z,ZodLazy:()=>mo,ZodLiteral:()=>ho,ZodMap:()=>Us,ZodNaN:()=>Fs,ZodNativeEnum:()=>_o,ZodNever:()=>un,ZodNull:()=>lo,ZodNullable:()=>Bn,ZodNumber:()=>ao,ZodObject:()=>dr,ZodOptional:()=>Br,ZodParsedType:()=>X,ZodPipeline:()=>wu,ZodPromise:()=>aa,ZodReadonly:()=>bo,ZodRecord:()=>mp,ZodSchema:()=>ye,ZodSet:()=>Ls,ZodString:()=>na,ZodSymbol:()=>zs,ZodTransformer:()=>Zr,ZodTuple:()=>Fn,ZodType:()=>ye,ZodUndefined:()=>uo,ZodUnion:()=>fo,ZodUnknown:()=>gi,ZodVoid:()=>Ds,addIssueToContext:()=>H,any:()=>sL,array:()=>dL,bigint:()=>rL,boolean:()=>MA,coerce:()=>ML,custom:()=>PA,date:()=>nL,datetimeRegex:()=>CA,defaultErrorMap:()=>mi,discriminatedUnion:()=>hL,effect:()=>EL,enum:()=>kL,function:()=>wL,getErrorMap:()=>Rs,getParsedType:()=>Ln,instanceof:()=>eL,intersection:()=>gL,isAborted:()=>dp,isAsync:()=>Ms,isDirty:()=>fp,isValid:()=>ra,late:()=>Q2,lazy:()=>xL,literal:()=>SL,makeIssue:()=>vu,map:()=>vL,nan:()=>tL,nativeEnum:()=>$L,never:()=>uL,null:()=>oL,nullable:()=>AL,number:()=>RA,object:()=>fL,objectUtil:()=>qb,oboolean:()=>RL,onumber:()=>NL,optional:()=>TL,ostring:()=>PL,pipeline:()=>OL,preprocess:()=>CL,promise:()=>IL,quotelessJson:()=>E2,record:()=>yL,set:()=>bL,setErrorMap:()=>A2,strictObject:()=>pL,string:()=>NA,symbol:()=>iL,transformer:()=>EL,tuple:()=>_L,undefined:()=>aL,union:()=>mL,unknown:()=>cL,util:()=>Ie,void:()=>lL});var Ie;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let a={};for(let o of n)a[o]=o;return a},e.getValidEnumValues=n=>{let a=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),o={};for(let s of a)o[s]=n[s];return e.objectValues(o)},e.objectValues=n=>e.objectKeys(n).map(function(a){return n[a]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},e.find=(n,a)=>{for(let o of n)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=i,e.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(Ie||(Ie={}));var qb;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(qb||(qb={}));var X=Ie.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ln=e=>{switch(typeof e){case"undefined":return X.undefined;case"string":return X.string;case"number":return Number.isNaN(e)?X.nan:X.number;case"boolean":return X.boolean;case"function":return X.function;case"bigint":return X.bigint;case"symbol":return X.symbol;case"object":return Array.isArray(e)?X.array:e===null?X.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?X.promise:typeof Map<"u"&&e instanceof Map?X.map:typeof Set<"u"&&e instanceof Set?X.set:typeof Date<"u"&&e instanceof Date?X.date:X.object;default:return X.unknown}};var z=Ie.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),E2=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),lr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(a){return a.message},i={_errors:[]},n=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)i._errors.push(r(o));else{let s=i,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(o))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return n(this),i}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ie.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];r[a]=r[a]||[],r[a].push(t(n))}else i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};lr.create=e=>new lr(e);var T2=(e,t)=>{let r;switch(e.code){case z.invalid_type:e.received===X.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ie.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ie.joinValues(e.keys,", ")}`;break;case z.invalid_union:r="Invalid input";break;case z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ie.joinValues(e.options)}`;break;case z.invalid_enum_value:r=`Invalid enum value. Expected ${Ie.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:r="Invalid function arguments";break;case z.invalid_return_type:r="Invalid function return type";break;case z.invalid_date:r="Invalid date";break;case z.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ie.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case z.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case z.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case z.custom:r="Invalid input";break;case z.invalid_intersection_types:r="Intersection results could not be merged";break;case z.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ie.assertNever(e)}return{message:r}},mi=T2;var $A=mi;function A2(e){$A=e}function Rs(){return $A}var vu=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let s="",c=i.filter(u=>!!u).slice().reverse();for(let u of c)s=u(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}},C2=[];function H(e,t){let r=Rs(),i=vu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===mi?void 0:mi].filter(n=>!!n)});e.common.issues.push(i)}var Ct=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let i=[];for(let n of r){if(n.status==="aborted")return oe;n.status==="dirty"&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let n of r){let a=await n.key,o=await n.value;i.push({key:a,value:o})}return e.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return oe;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(i[a.value]=o.value)}return{status:t.value,value:i}}},oe=Object.freeze({status:"aborted"}),io=e=>({status:"dirty",value:e}),zt=e=>({status:"valid",value:e}),dp=e=>e.status==="aborted",fp=e=>e.status==="dirty",ra=e=>e.status==="valid",Ms=e=>typeof Promise<"u"&&e instanceof Promise;var re;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(re||(re={}));var Vr=class{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},IA=(e,t)=>{if(ra(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new lr(e.common.issues);return this._error=r,this._error}}};function me(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,s)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??i??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:n}}var ye=class{get description(){return this._def.description}_getType(t){return Ln(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Ln(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ct,ctx:{common:t.parent.common,data:t.data,parsedType:Ln(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ms(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ln(t)},n=this._parseSync({data:t,path:i.path,parent:i});return IA(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ln(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return ra(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>ra(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ln(t)},n=this._parse({data:t,path:i.path,parent:i}),a=await(Ms(n)?n:Promise.resolve(n));return IA(i,a)}refine(t,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{let o=t(n),s=()=>a.addIssue({code:z.custom,...i(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((i,n)=>t(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(t){return new Zr({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Br.create(this,this._def)}nullable(){return Bn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _i.create(this)}promise(){return aa.create(this,this._def)}or(t){return fo.create([this,t],this._def)}and(t){return po.create(this,t,this._def)}transform(t){return new Zr({...me(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new yo({...me(this._def),innerType:this,defaultValue:r,typeName:D.ZodDefault})}brand(){return new bu({typeName:D.ZodBranded,type:this,...me(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new vo({...me(this._def),innerType:this,catchValue:r,typeName:D.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return wu.create(this,t)}readonly(){return bo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},O2=/^c[^\s-]{8,}$/i,P2=/^[0-9a-z]+$/,N2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,R2=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,M2=/^[a-z0-9_-]{21}$/i,j2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z2=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D2=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,U2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Xb,L2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,F2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,B2=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,V2=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Z2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,H2=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,TA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",G2=new RegExp(`^${TA}$`);function AA(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function J2(e){return new RegExp(`^${AA(e)}$`)}function CA(e){let t=`${TA}T${AA(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function K2(e,t){return!!((t==="v4"||!t)&&L2.test(e)||(t==="v6"||!t)&&B2.test(e))}function W2(e,t){if(!j2.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function q2(e,t){return!!((t==="v4"||!t)&&F2.test(e)||(t==="v6"||!t)&&V2.test(e))}var na=class e extends ye{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==X.string){let a=this._getOrReturnCtx(t);return H(a,{code:z.invalid_type,expected:X.string,received:a.parsedType}),oe}let i=new Ct,n;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(n=this._getOrReturnCtx(t,n),o?H(n,{code:z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&H(n,{code:z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),i.dirty())}else if(a.kind==="email")D2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"email",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="emoji")Xb||(Xb=new RegExp(U2,"u")),Xb.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"emoji",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="uuid")R2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"uuid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="nanoid")M2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"nanoid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid")O2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cuid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid2")P2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cuid2",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="ulid")N2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"ulid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),H(n,{validation:"url",code:z.invalid_string,message:a.message}),i.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"regex",code:z.invalid_string,message:a.message}),i.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),i.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:{startsWith:a.value},message:a.message}),i.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:{endsWith:a.value},message:a.message}),i.dirty()):a.kind==="datetime"?CA(a).test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:"datetime",message:a.message}),i.dirty()):a.kind==="date"?G2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:"date",message:a.message}),i.dirty()):a.kind==="time"?J2(a).test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_string,validation:"time",message:a.message}),i.dirty()):a.kind==="duration"?z2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"duration",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="ip"?K2(t.data,a.version)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"ip",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="jwt"?W2(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"jwt",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="cidr"?q2(t.data,a.version)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cidr",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="base64"?Z2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"base64",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="base64url"?H2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"base64url",code:z.invalid_string,message:a.message}),i.dirty()):Ie.assertNever(a);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:z.invalid_string,...re.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...re.errToObj(t)})}url(t){return this._addCheck({kind:"url",...re.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...re.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...re.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...re.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...re.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...re.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...re.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...re.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...re.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...re.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...re.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...re.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...re.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...re.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...re.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...re.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...re.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...re.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...re.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...re.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...re.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...re.errToObj(r)})}nonempty(t){return this.min(1,re.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};na.create=e=>new na({checks:[],typeName:D.ZodString,coerce:e?.coerce??!1,...me(e)});function X2(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i,a=Number.parseInt(e.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return a%o/10**n}var ao=class e extends ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==X.number){let a=this._getOrReturnCtx(t);return H(a,{code:z.invalid_type,expected:X.number,received:a.parsedType}),oe}let i,n=new Ct;for(let a of this._def.checks)a.kind==="int"?Ie.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?X2(t.data,a.value)!==0&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.not_finite,message:a.message}),n.dirty()):Ie.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:re.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:re.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:re.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:re.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:re.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ie.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ao.create=e=>new ao({checks:[],typeName:D.ZodNumber,coerce:e?.coerce||!1,...me(e)});var oo=class e extends ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==X.bigint)return this._getInvalidInput(t);let i,n=new Ct;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Ie.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return H(r,{code:z.invalid_type,expected:X.bigint,received:r.parsedType}),oe}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:re.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};oo.create=e=>new oo({checks:[],typeName:D.ZodBigInt,coerce:e?.coerce??!1,...me(e)});var so=class extends ye{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==X.boolean){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.boolean,received:i.parsedType}),oe}return zt(t.data)}};so.create=e=>new so({typeName:D.ZodBoolean,coerce:e?.coerce||!1,...me(e)});var co=class e extends ye{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==X.date){let a=this._getOrReturnCtx(t);return H(a,{code:z.invalid_type,expected:X.date,received:a.parsedType}),oe}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return H(a,{code:z.invalid_date}),oe}let i=new Ct,n;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),i.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),i.dirty()):Ie.assertNever(a);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:re.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:re.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};co.create=e=>new co({checks:[],coerce:e?.coerce||!1,typeName:D.ZodDate,...me(e)});var zs=class extends ye{_parse(t){if(this._getType(t)!==X.symbol){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.symbol,received:i.parsedType}),oe}return zt(t.data)}};zs.create=e=>new zs({typeName:D.ZodSymbol,...me(e)});var uo=class extends ye{_parse(t){if(this._getType(t)!==X.undefined){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.undefined,received:i.parsedType}),oe}return zt(t.data)}};uo.create=e=>new uo({typeName:D.ZodUndefined,...me(e)});var lo=class extends ye{_parse(t){if(this._getType(t)!==X.null){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.null,received:i.parsedType}),oe}return zt(t.data)}};lo.create=e=>new lo({typeName:D.ZodNull,...me(e)});var ia=class extends ye{constructor(){super(...arguments),this._any=!0}_parse(t){return zt(t.data)}};ia.create=e=>new ia({typeName:D.ZodAny,...me(e)});var gi=class extends ye{constructor(){super(...arguments),this._unknown=!0}_parse(t){return zt(t.data)}};gi.create=e=>new gi({typeName:D.ZodUnknown,...me(e)});var un=class extends ye{_parse(t){let r=this._getOrReturnCtx(t);return H(r,{code:z.invalid_type,expected:X.never,received:r.parsedType}),oe}};un.create=e=>new un({typeName:D.ZodNever,...me(e)});var Ds=class extends ye{_parse(t){if(this._getType(t)!==X.undefined){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.void,received:i.parsedType}),oe}return zt(t.data)}};Ds.create=e=>new Ds({typeName:D.ZodVoid,...me(e)});var _i=class e extends ye{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==X.array)return H(r,{code:z.invalid_type,expected:X.array,received:r.parsedType}),oe;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(o||s)&&(H(r,{code:o?z.too_big:z.too_small,minimum:s?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(H(r,{code:z.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(H(r,{code:z.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>n.type._parseAsync(new Vr(r,o,r.path,s)))).then(o=>Ct.mergeArray(i,o));let a=[...r.data].map((o,s)=>n.type._parseSync(new Vr(r,o,r.path,s)));return Ct.mergeArray(i,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:re.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:re.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:re.toString(r)}})}nonempty(t){return this.min(1,t)}};_i.create=(e,t)=>new _i({type:e,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...me(t)});function js(e){if(e instanceof dr){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=Br.create(js(i))}return new dr({...e._def,shape:()=>t})}else return e instanceof _i?new _i({...e._def,type:js(e.element)}):e instanceof Br?Br.create(js(e.unwrap())):e instanceof Bn?Bn.create(js(e.unwrap())):e instanceof Fn?Fn.create(e.items.map(t=>js(t))):e}var dr=class e extends ye{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Ie.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==X.object){let u=this._getOrReturnCtx(t);return H(u,{code:z.invalid_type,expected:X.object,received:u.parsedType}),oe}let{status:i,ctx:n}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof un&&this._def.unknownKeys==="strip"))for(let u in n.data)o.includes(u)||s.push(u);let c=[];for(let u of o){let l=a[u],d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Vr(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof un){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(H(n,{code:z.unrecognized_keys,keys:s}),i.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Vr(n,d,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>Ct.mergeObjectSync(i,u)):Ct.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(t){return re.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:re.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:D.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let i of Ie.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let i of Ie.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}deepPartial(){return js(this)}partial(t){let r={};for(let i of Ie.objectKeys(this.shape)){let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let i of Ie.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let a=this.shape[i];for(;a instanceof Br;)a=a._def.innerType;r[i]=a}return new e({...this._def,shape:()=>r})}keyof(){return OA(Ie.objectKeys(this.shape))}};dr.create=(e,t)=>new dr({shape:()=>e,unknownKeys:"strip",catchall:un.create(),typeName:D.ZodObject,...me(t)});dr.strictCreate=(e,t)=>new dr({shape:()=>e,unknownKeys:"strict",catchall:un.create(),typeName:D.ZodObject,...me(t)});dr.lazycreate=(e,t)=>new dr({shape:e,unknownKeys:"strip",catchall:un.create(),typeName:D.ZodObject,...me(t)});var fo=class extends ye{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function n(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new lr(s.ctx.common.issues));return H(r,{code:z.invalid_union,unionErrors:o}),oe}if(r.common.async)return Promise.all(i.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let a,o=[];for(let c of i){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new lr(c));return H(r,{code:z.invalid_union,unionErrors:s}),oe}}get options(){return this._def.options}};fo.create=(e,t)=>new fo({options:e,typeName:D.ZodUnion,...me(t)});var hi=e=>e instanceof mo?hi(e.schema):e instanceof Zr?hi(e.innerType()):e instanceof ho?[e.value]:e instanceof go?e.options:e instanceof _o?Ie.objectValues(e.enum):e instanceof yo?hi(e._def.innerType):e instanceof uo?[void 0]:e instanceof lo?[null]:e instanceof Br?[void 0,...hi(e.unwrap())]:e instanceof Bn?[null,...hi(e.unwrap())]:e instanceof bu||e instanceof bo?hi(e.unwrap()):e instanceof vo?hi(e._def.innerType):[],pp=class e extends ye{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.object)return H(r,{code:z.invalid_type,expected:X.object,received:r.parsedType}),oe;let i=this.discriminator,n=r.data[i],a=this.optionsMap.get(n);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(H(r,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let a of r){let o=hi(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,a)}}return new e({typeName:D.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...me(i)})}};function Yb(e,t){let r=Ln(e),i=Ln(t);if(e===t)return{valid:!0,data:e};if(r===X.object&&i===X.object){let n=Ie.objectKeys(t),a=Ie.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=Yb(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(r===X.array&&i===X.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=Yb(o,s);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===X.date&&i===X.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var po=class extends ye{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(a,o)=>{if(dp(a)||dp(o))return oe;let s=Yb(a.value,o.value);return s.valid?((fp(a)||fp(o))&&r.dirty(),{status:r.value,value:s.data}):(H(i,{code:z.invalid_intersection_types}),oe)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};po.create=(e,t,r)=>new po({left:e,right:t,typeName:D.ZodIntersection,...me(r)});var Fn=class e extends ye{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.array)return H(i,{code:z.invalid_type,expected:X.array,received:i.parsedType}),oe;if(i.data.length<this._def.items.length)return H(i,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...i.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new Vr(i,o,i.path,s)):null}).filter(o=>!!o);return i.common.async?Promise.all(a).then(o=>Ct.mergeArray(r,o)):Ct.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Fn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fn({items:e,typeName:D.ZodTuple,rest:null,...me(t)})};var mp=class e extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.object)return H(i,{code:z.invalid_type,expected:X.object,received:i.parsedType}),oe;let n=[],a=this._def.keyType,o=this._def.valueType;for(let s in i.data)n.push({key:a._parse(new Vr(i,s,i.path,s)),value:o._parse(new Vr(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?Ct.mergeObjectAsync(r,n):Ct.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return r instanceof ye?new e({keyType:t,valueType:r,typeName:D.ZodRecord,...me(i)}):new e({keyType:na.create(),valueType:t,typeName:D.ZodRecord,...me(r)})}},Us=class extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.map)return H(i,{code:z.invalid_type,expected:X.map,received:i.parsedType}),oe;let n=this._def.keyType,a=this._def.valueType,o=[...i.data.entries()].map(([s,c],u)=>({key:n._parse(new Vr(i,s,i.path,[u,"key"])),value:a._parse(new Vr(i,c,i.path,[u,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return oe;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return oe;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Us.create=(e,t,r)=>new Us({valueType:t,keyType:e,typeName:D.ZodMap,...me(r)});var Ls=class e extends ye{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.set)return H(i,{code:z.invalid_type,expected:X.set,received:i.parsedType}),oe;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(H(i,{code:z.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(H(i,{code:z.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let a=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return oe;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...i.data.values()].map((c,u)=>a._parse(new Vr(i,c,i.path,u)));return i.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:re.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:re.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Ls.create=(e,t)=>new Ls({valueType:e,minSize:null,maxSize:null,typeName:D.ZodSet,...me(t)});var hp=class e extends ye{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.function)return H(r,{code:z.invalid_type,expected:X.function,received:r.parsedType}),oe;function i(s,c){return vu({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rs(),mi].filter(u=>!!u),issueData:{code:z.invalid_arguments,argumentsError:c}})}function n(s,c){return vu({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rs(),mi].filter(u=>!!u),issueData:{code:z.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof aa){let s=this;return zt(async function(...c){let u=new lr([]),l=await s._def.args.parseAsync(c,a).catch(p=>{throw u.addIssue(i(c,p)),u}),d=await Reflect.apply(o,this,l);return await s._def.returns._def.type.parseAsync(d,a).catch(p=>{throw u.addIssue(n(d,p)),u})})}else{let s=this;return zt(function(...c){let u=s._def.args.safeParse(c,a);if(!u.success)throw new lr([i(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=s._def.returns.safeParse(l,a);if(!d.success)throw new lr([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Fn.create(t).rest(gi.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,i){return new e({args:t||Fn.create([]).rest(gi.create()),returns:r||gi.create(),typeName:D.ZodFunction,...me(i)})}},mo=class extends ye{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};mo.create=(e,t)=>new mo({getter:e,typeName:D.ZodLazy,...me(t)});var ho=class extends ye{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return H(r,{received:r.data,code:z.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:t.data}}get value(){return this._def.value}};ho.create=(e,t)=>new ho({value:e,typeName:D.ZodLiteral,...me(t)});function OA(e,t){return new go({values:e,typeName:D.ZodEnum,...me(t)})}var go=class e extends ye{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return H(r,{expected:Ie.joinValues(i),received:r.parsedType,code:z.invalid_type}),oe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return H(r,{received:r.data,code:z.invalid_enum_value,options:i}),oe}return zt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(i=>!t.includes(i)),{...this._def,...r})}};go.create=OA;var _o=class extends ye{_parse(t){let r=Ie.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==X.string&&i.parsedType!==X.number){let n=Ie.objectValues(r);return H(i,{expected:Ie.joinValues(n),received:i.parsedType,code:z.invalid_type}),oe}if(this._cache||(this._cache=new Set(Ie.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=Ie.objectValues(r);return H(i,{received:i.data,code:z.invalid_enum_value,options:n}),oe}return zt(t.data)}get enum(){return this._def.values}};_o.create=(e,t)=>new _o({values:e,typeName:D.ZodNativeEnum,...me(t)});var aa=class extends ye{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.promise&&r.common.async===!1)return H(r,{code:z.invalid_type,expected:X.promise,received:r.parsedType}),oe;let i=r.parsedType===X.promise?r.data:Promise.resolve(r.data);return zt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};aa.create=(e,t)=>new aa({type:e,typeName:D.ZodPromise,...me(t)});var Zr=class extends ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:o=>{H(i,o),o.fatal?r.abort():r.dirty()},get path(){return i.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let o=n.transform(i.data,a);if(i.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return oe;let c=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return c.status==="aborted"?oe:c.status==="dirty"?io(c.value):r.value==="dirty"?io(c.value):c});{if(r.value==="aborted")return oe;let s=this._def.schema._parseSync({data:o,path:i.path,parent:i});return s.status==="aborted"?oe:s.status==="dirty"?io(s.value):r.value==="dirty"?io(s.value):s}}if(n.type==="refinement"){let o=s=>{let c=n.refinement(s,a);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?oe:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?oe:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!ra(o))return oe;let s=n.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>ra(o)?Promise.resolve(n.transform(o.value,a)).then(s=>({status:r.value,value:s})):oe);Ie.assertNever(n)}};Zr.create=(e,t,r)=>new Zr({schema:e,typeName:D.ZodEffects,effect:t,...me(r)});Zr.createWithPreprocess=(e,t,r)=>new Zr({schema:t,effect:{type:"preprocess",transform:e},typeName:D.ZodEffects,...me(r)});var Br=class extends ye{_parse(t){return this._getType(t)===X.undefined?zt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Br.create=(e,t)=>new Br({innerType:e,typeName:D.ZodOptional,...me(t)});var Bn=class extends ye{_parse(t){return this._getType(t)===X.null?zt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Bn.create=(e,t)=>new Bn({innerType:e,typeName:D.ZodNullable,...me(t)});var yo=class extends ye{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===X.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};yo.create=(e,t)=>new yo({innerType:e,typeName:D.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...me(t)});var vo=class extends ye{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Ms(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new lr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new lr(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};vo.create=(e,t)=>new vo({innerType:e,typeName:D.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...me(t)});var Fs=class extends ye{_parse(t){if(this._getType(t)!==X.nan){let i=this._getOrReturnCtx(t);return H(i,{code:z.invalid_type,expected:X.nan,received:i.parsedType}),oe}return{status:"valid",value:t.data}}};Fs.create=e=>new Fs({typeName:D.ZodNaN,...me(e)});var Y2=Symbol("zod_brand"),bu=class extends ye{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},wu=class e extends ye{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?oe:a.status==="dirty"?(r.dirty(),io(a.value)):this._def.out._parseAsync({data:a.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?oe:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(t,r){return new e({in:t,out:r,typeName:D.ZodPipeline})}},bo=class extends ye{_parse(t){let r=this._def.innerType._parse(t),i=n=>(ra(n)&&(n.value=Object.freeze(n.value)),n);return Ms(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};bo.create=(e,t)=>new bo({innerType:e,typeName:D.ZodReadonly,...me(t)});function EA(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function PA(e,t={},r){return e?ia.create().superRefine((i,n)=>{let a=e(i);if(a instanceof Promise)return a.then(o=>{if(!o){let s=EA(t,i),c=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=EA(t,i),s=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:s})}}):ia.create()}var Q2={object:dr.lazycreate},D;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(D||(D={}));var eL=(e,t={message:`Input not instance of ${e.name}`})=>PA(r=>r instanceof e,t),NA=na.create,RA=ao.create,tL=Fs.create,rL=oo.create,MA=so.create,nL=co.create,iL=zs.create,aL=uo.create,oL=lo.create,sL=ia.create,cL=gi.create,uL=un.create,lL=Ds.create,dL=_i.create,fL=dr.create,pL=dr.strictCreate,mL=fo.create,hL=pp.create,gL=po.create,_L=Fn.create,yL=mp.create,vL=Us.create,bL=Ls.create,wL=hp.create,xL=mo.create,SL=ho.create,kL=go.create,$L=_o.create,IL=aa.create,EL=Zr.create,TL=Br.create,AL=Bn.create,CL=Zr.createWithPreprocess,OL=wu.create,PL=()=>NA().optional(),NL=()=>RA().optional(),RL=()=>MA().optional(),ML={string:(e=>na.create({...e,coerce:!0})),number:(e=>ao.create({...e,coerce:!0})),boolean:(e=>so.create({...e,coerce:!0})),bigint:(e=>oo.create({...e,coerce:!0})),date:(e=>co.create({...e,coerce:!0}))};var jL=oe;function jA(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==D.ZodAny&&(r.items=se(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ae(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ae(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ae(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ae(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function zA(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"min":t.target==="jsonSchema7"?i.inclusive?Ae(r,"minimum",i.value,i.message,t):Ae(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ae(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ae(r,"maximum",i.value,i.message,t):Ae(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ae(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ae(r,"multipleOf",i.value,i.message,t);break}return r}function DA(){return{type:"boolean"}}function gp(e,t){return se(e.type._def,t)}var UA=(e,t)=>se(e.innerType._def,t);function Qb(e,t,r){let i=r??t.dateStrategy;if(Array.isArray(i))return{anyOf:i.map(n=>Qb(e,t,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return zL(e,t)}}var zL=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let i of e.checks)switch(i.kind){case"min":Ae(r,"minimum",i.value,i.message,t);break;case"max":Ae(r,"maximum",i.value,i.message,t);break}return r};function LA(e,t){return{...se(e.innerType._def,t),default:e.defaultValue()}}function FA(e,t){return t.effectStrategy==="input"?se(e.schema._def,t):Xe(t)}function BA(e){return{type:"string",enum:Array.from(e.values)}}var DL=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function VA(e,t){let r=[se(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),se(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),i=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(a=>{if(DL(a))n.push(...a.allOf),a.unevaluatedProperties===void 0&&(i=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:s,...c}=a;o=c}else i=void 0;n.push(o)}}),n.length?{allOf:n,...i}:void 0}function ZA(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var ew,ln={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ew===void 0&&(ew=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ew),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function _p(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":dn(r,"email",i.message,t);break;case"format:idn-email":dn(r,"idn-email",i.message,t);break;case"pattern:zod":Qt(r,ln.email,i.message,t);break}break;case"url":dn(r,"uri",i.message,t);break;case"uuid":dn(r,"uuid",i.message,t);break;case"regex":Qt(r,i.regex,i.message,t);break;case"cuid":Qt(r,ln.cuid,i.message,t);break;case"cuid2":Qt(r,ln.cuid2,i.message,t);break;case"startsWith":Qt(r,RegExp(`^${tw(i.value,t)}`),i.message,t);break;case"endsWith":Qt(r,RegExp(`${tw(i.value,t)}$`),i.message,t);break;case"datetime":dn(r,"date-time",i.message,t);break;case"date":dn(r,"date",i.message,t);break;case"time":dn(r,"time",i.message,t);break;case"duration":dn(r,"duration",i.message,t);break;case"length":Ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":Qt(r,RegExp(tw(i.value,t)),i.message,t);break;case"ip":i.version!=="v6"&&dn(r,"ipv4",i.message,t),i.version!=="v4"&&dn(r,"ipv6",i.message,t);break;case"base64url":Qt(r,ln.base64url,i.message,t);break;case"jwt":Qt(r,ln.jwt,i.message,t);break;case"cidr":i.version!=="v6"&&Qt(r,ln.ipv4Cidr,i.message,t),i.version!=="v4"&&Qt(r,ln.ipv6Cidr,i.message,t);break;case"emoji":Qt(r,ln.emoji(),i.message,t);break;case"ulid":Qt(r,ln.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":dn(r,"binary",i.message,t);break;case"contentEncoding:base64":Ae(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":Qt(r,ln.base64,i.message,t);break}break;case"nanoid":Qt(r,ln.nanoid,i.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function tw(e,t){return t.patternStrategy==="escape"?LL(e):e}var UL=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function LL(e){let t="";for(let r=0;r<e.length;r++)UL.has(e[r])||(t+="\\"),t+=e[r];return t}function dn(e,t,r,i){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):Ae(e,"format",t,r,i)}function Qt(e,t,r,i){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:HA(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Ae(e,"pattern",HA(t,i),r,i)}function HA(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",a=!1,o=!1,s=!1;for(let c=0;c<i.length;c++){if(a){n+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){s?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),s=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],s=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
|
|
219
|
+
]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
|
|
220
|
+
]))`;continue}}if(r.s&&i[c]==="."){n+=o?`${i[c]}\r
|
|
221
|
+
`:`[${i[c]}\r
|
|
222
|
+
]`;continue}n+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function yp(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===D.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((i,n)=>({...i,[n]:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??Xe(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===D.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=_p(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===D.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===D.ZodBranded&&e.keyType._def.type._def.typeName===D.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=gp(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function GA(e,t){return t.mapStrategy==="record"?yp(e,t):{type:"array",maxItems:125,items:{type:"array",items:[se(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Xe(t),se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Xe(t)],minItems:2,maxItems:2}}}function JA(e){let t=e.values,r=Object.keys(e.values).filter(n=>typeof t[t[n]]!="number").map(n=>t[n]),i=Array.from(new Set(r.map(n=>typeof n)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function KA(e){return e.target==="openAi"?void 0:{not:Xe({...e,currentPath:[...e.currentPath,"not"]})}}function WA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var xu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function XA(e,t){if(t.target==="openApi3")return qA(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(i=>i._def.typeName in xu&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,a)=>{let o=xu[a._def.typeName];return o&&!n.includes(o)?[...n,o]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...n,o];case"bigint":return[...n,"integer"];case"object":return a._def.value===null?[...n,"null"]:n;default:return n}},[]);if(i.length===r.length){let n=i.filter((a,o,s)=>s.indexOf(a)===o);return{type:n.length>1?n:n[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(a=>!i.includes(a))],[])};return qA(e,t)}var qA=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((i,n)=>se(i._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!t.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0};function YA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:xu[e.innerType._def.typeName],nullable:!0}:{type:[xu[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let i=se(e.innerType._def,{...t,currentPath:[...t.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=se(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function QA(e,t){let r={type:"number"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"int":r.type="integer",Wb(r,"type",i.message,t);break;case"min":t.target==="jsonSchema7"?i.inclusive?Ae(r,"minimum",i.value,i.message,t):Ae(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ae(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ae(r,"maximum",i.value,i.message,t):Ae(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ae(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ae(r,"multipleOf",i.value,i.message,t);break}return r}function eC(e,t){let r=t.target==="openAi",i={type:"object",properties:{}},n=[],a=e.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let u=BL(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=se(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(i.properties[s]=l,u||n.push(s))}n.length&&(i.required=n);let o=FL(e,t);return o!==void 0&&(i.additionalProperties=o),i}function FL(e,t){if(e.catchall._def.typeName!=="ZodNever")return se(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function BL(e){try{return e.isOptional()}catch{return!0}}var tC=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return se(e.innerType._def,t);let r=se(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Xe(t)},r]}:Xe(t)};var rC=(e,t)=>{if(t.pipeStrategy==="input")return se(e.in._def,t);if(t.pipeStrategy==="output")return se(e.out._def,t);let r=se(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,se(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(i=>i!==void 0)}};function nC(e,t){return se(e.type._def,t)}function iC(e,t){let r={type:"array",uniqueItems:!0,items:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ae(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ae(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function aC(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,i)=>se(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:se(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,i)=>se(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}function oC(e){return{not:Xe(e)}}function sC(e){return Xe(e)}var cC=(e,t)=>se(e.innerType._def,t);var uC=(e,t,r)=>{switch(t){case D.ZodString:return _p(e,r);case D.ZodNumber:return QA(e,r);case D.ZodObject:return eC(e,r);case D.ZodBigInt:return zA(e,r);case D.ZodBoolean:return DA();case D.ZodDate:return Qb(e,r);case D.ZodUndefined:return oC(r);case D.ZodNull:return WA(r);case D.ZodArray:return jA(e,r);case D.ZodUnion:case D.ZodDiscriminatedUnion:return XA(e,r);case D.ZodIntersection:return VA(e,r);case D.ZodTuple:return aC(e,r);case D.ZodRecord:return yp(e,r);case D.ZodLiteral:return ZA(e,r);case D.ZodEnum:return BA(e);case D.ZodNativeEnum:return JA(e);case D.ZodNullable:return YA(e,r);case D.ZodOptional:return tC(e,r);case D.ZodMap:return GA(e,r);case D.ZodSet:return iC(e,r);case D.ZodLazy:return()=>e.getter()._def;case D.ZodPromise:return nC(e,r);case D.ZodNaN:case D.ZodNever:return KA(r);case D.ZodEffects:return FA(e,r);case D.ZodAny:return Xe(r);case D.ZodUnknown:return sC(r);case D.ZodDefault:return LA(e,r);case D.ZodBranded:return gp(e,r);case D.ZodReadonly:return cC(e,r);case D.ZodCatch:return UA(e,r);case D.ZodPipeline:return rC(e,r);case D.ZodFunction:case D.ZodVoid:case D.ZodSymbol:return;default:return(i=>{})(t)}};function se(e,t,r=!1){let i=t.seen.get(e);if(t.override){let s=t.override?.(e,t,i,r);if(s!==xA)return s}if(i&&!r){let s=VL(i,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=uC(e,e.typeName,t),o=typeof a=="function"?se(a(),t):a;if(o&&ZL(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var VL=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:lp(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,i)=>t.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Xe(t)):t.$refStrategy==="seen"?Xe(t):void 0}},ZL=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var lC=(e,t)=>{let r=kA(t),i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:se(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Xe(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=se(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??Xe(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function Vn(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=e.length;if(i!==t.length)return!1;for(let n=0;n<i;n++)if(!Vn(e[n],t[n]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let o of i)if(!Vn(e[o],t[o]))return!1;return!0}return e===t}function Ar(e){return encodeURI(HL(e))}function HL(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var GL={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},JL={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},KL={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},WL=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function fn(e,t=Object.create(null),r=WL,i=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let a=e.$id||e.id;if(a){let o=new URL(a,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",i===""?r=o:fn(e,t,r))}}else if(e!==!0&&e!==!1)return t;let n=r.href+(i?"#"+i:"");if(t[n]!==void 0)throw new Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&e.__absolute_ref__===void 0){let a=new URL(e.$ref,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:a.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let a=new URL(e.$recursiveRef,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(e.$anchor){let a=new URL("#"+e.$anchor,r.href);t[a.href]=e}for(let a in e){if(KL[a])continue;let o=`${i}/${Ar(a)}`,s=e[a];if(Array.isArray(s)){if(GL[a]){let c=s.length;for(let u=0;u<c;u++)fn(s[u],t,r,`${o}/${u}`)}}else if(JL[a])for(let c in s)fn(s[c],t,r,`${o}/${Ar(c)}`);else fn(s,t,r,o)}return t}var qL=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,XL=[0,31,28,31,30,31,30,31,31,30,31,30,31],YL=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,QL=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,e6=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,t6=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,r6=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,n6=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,i6=/^(?:\/(?:[^~/]|~0|~1)*)*$/,a6=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,o6=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,s6=e=>{if(e[0]==='"')return!1;let[t,r,...i]=e.split("@");return!t||!r||i.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},c6=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,u6=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,l6=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Zn(e){return e.test.bind(e)}var rw={date:dC,time:fC.bind(void 0,!1),"date-time":p6,duration:l6,uri:g6,"uri-reference":Zn(e6),"uri-template":Zn(t6),url:Zn(r6),email:s6,hostname:Zn(QL),ipv4:Zn(c6),ipv6:Zn(u6),regex:y6,uuid:Zn(n6),"json-pointer":Zn(i6),"json-pointer-uri-fragment":Zn(a6),"relative-json-pointer":Zn(o6)};function d6(e){return e%4===0&&(e%100!==0||e%400===0)}function dC(e){let t=e.match(qL);if(!t)return!1;let r=+t[1],i=+t[2],n=+t[3];return i>=1&&i<=12&&n>=1&&n<=(i==2&&d6(r)?29:XL[i])}function fC(e,t){let r=t.match(YL);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||i==23&&n==59&&a==60)&&(!e||o)}var f6=/t|\s/i;function p6(e){let t=e.split(f6);return t.length==2&&dC(t[0])&&fC(!0,t[1])}var m6=/\/|:/,h6=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function g6(e){return m6.test(e)&&h6.test(e)}var _6=/[^\\]\\Z/;function y6(e){if(_6.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var pC;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(pC||(pC={}));function mC(e){let t=0,r=e.length,i=0,n;for(;i<r;)t++,n=e.charCodeAt(i++),n>=55296&&n<=56319&&i<r&&(n=e.charCodeAt(i),(n&64512)==56320&&i++);return t}function Ve(e,t,r="2019-09",i=fn(t),n=!0,a=null,o="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};let u=typeof e,l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":e===null?l="null":Array.isArray(e)?l="array":l="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:g,enum:y,required:b,not:w,anyOf:x,allOf:k,oneOf:E,if:V,then:C,else:v,format:W,properties:F,patternProperties:T,additionalProperties:B,unevaluatedProperties:Z,minProperties:ne,maxProperties:Oe,propertyNames:ge,dependentRequired:Sn,dependentSchemas:Pr,dependencies:_a,prefixItems:qr,items:ei,additionalItems:_c,unevaluatedItems:yc,contains:vc,minContains:Xr,maxContains:_,minItems:h,maxItems:O,uniqueItems:$,minimum:ke,maximum:Me,exclusiveMinimum:mt,exclusiveMaximum:st,multipleOf:Ot,minLength:Nr,maxLength:ct,pattern:kn,__absolute_ref__:No,__absolute_recursive_ref__:kl}=t,q=[];if(p===!0&&a===null&&(a=t),f==="#"){let ce=a===null?i[kl]:a,ie=`${s}/$recursiveRef`,fe=Ve(e,a===null?t:a,r,i,n,ce,o,ie,c);fe.valid||q.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:ie,error:"A subschema had errors."},...fe.errors)}if(d!==void 0){let ie=i[No||d];if(ie===void 0){let J=`Unresolved $ref "${d}".`;throw No&&No!==d&&(J+=` Absolute URI "${No}".`),J+=`
|
|
223
|
+
Known schemas:
|
|
224
|
+
- ${Object.keys(i).join(`
|
|
225
|
+
- `)}`,new Error(J)}let fe=`${s}/$ref`,Q=Ve(e,ie,r,i,n,a,o,fe,c);if(Q.valid||q.push({instanceLocation:o,keyword:"$ref",keywordLocation:fe,error:"A subschema had errors."},...Q.errors),r==="4"||r==="7")return{valid:q.length===0,errors:q}}if(Array.isArray(m)){let ce=m.length,ie=!1;for(let fe=0;fe<ce;fe++)if(l===m[fe]||m[fe]==="integer"&&l==="number"&&e%1===0&&e===e){ie=!0;break}ie||q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(g!==void 0&&(l==="object"||l==="array"?Vn(e,g)||q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):e!==g&&q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),y!==void 0&&(l==="object"||l==="array"?y.some(ce=>Vn(e,ce))||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(ce=>e===ce)||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),w!==void 0){let ce=`${s}/not`;Ve(e,w,r,i,n,a,o,ce).valid&&q.push({instanceLocation:o,keyword:"not",keywordLocation:ce,error:'Instance matched "not" schema.'})}let ya=[];if(x!==void 0){let ce=`${s}/anyOf`,ie=q.length,fe=!1;for(let Q=0;Q<x.length;Q++){let J=x[Q],le=Object.create(c),ue=Ve(e,J,r,i,n,p===!0?a:null,o,`${ce}/${Q}`,le);q.push(...ue.errors),fe=fe||ue.valid,ue.valid&&ya.push(le)}fe?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:ce,error:"Instance does not match any subschemas."})}if(k!==void 0){let ce=`${s}/allOf`,ie=q.length,fe=!0;for(let Q=0;Q<k.length;Q++){let J=k[Q],le=Object.create(c),ue=Ve(e,J,r,i,n,p===!0?a:null,o,`${ce}/${Q}`,le);q.push(...ue.errors),fe=fe&&ue.valid,ue.valid&&ya.push(le)}fe?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"allOf",keywordLocation:ce,error:"Instance does not match every subschema."})}if(E!==void 0){let ce=`${s}/oneOf`,ie=q.length,fe=E.filter((Q,J)=>{let le=Object.create(c),ue=Ve(e,Q,r,i,n,p===!0?a:null,o,`${ce}/${J}`,le);return q.push(...ue.errors),ue.valid&&ya.push(le),ue.valid}).length;fe===1?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:ce,error:`Instance does not match exactly one subschema (${fe} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...ya),V!==void 0){let ce=`${s}/if`;if(Ve(e,V,r,i,n,a,o,ce,c).valid){if(C!==void 0){let fe=Ve(e,C,r,i,n,a,o,`${s}/then`,c);fe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "then" schema.'},...fe.errors)}}else if(v!==void 0){let fe=Ve(e,v,r,i,n,a,o,`${s}/else`,c);fe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "else" schema.'},...fe.errors)}}if(l==="object"){if(b!==void 0)for(let Q of b)Q in e||q.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${Q}".`});let ce=Object.keys(e);if(ne!==void 0&&ce.length<ne&&q.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${ne} properties.`}),Oe!==void 0&&ce.length>Oe&&q.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${Oe} properties.`}),ge!==void 0){let Q=`${s}/propertyNames`;for(let J in e){let le=`${o}/${Ar(J)}`,ue=Ve(J,ge,r,i,n,a,le,Q);ue.valid||q.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:Q,error:`Property name "${J}" does not match schema.`},...ue.errors)}}if(Sn!==void 0){let Q=`${s}/dependantRequired`;for(let J in Sn)if(J in e){let le=Sn[J];for(let ue of le)ue in e||q.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:Q,error:`Instance has "${J}" but does not have "${ue}".`})}}if(Pr!==void 0)for(let Q in Pr){let J=`${s}/dependentSchemas`;if(Q in e){let le=Ve(e,Pr[Q],r,i,n,a,o,`${J}/${Ar(Q)}`,c);le.valid||q.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:J,error:`Instance has "${Q}" but does not match dependant schema.`},...le.errors)}}if(_a!==void 0){let Q=`${s}/dependencies`;for(let J in _a)if(J in e){let le=_a[J];if(Array.isArray(le))for(let ue of le)ue in e||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${J}" but does not have "${ue}".`});else{let ue=Ve(e,le,r,i,n,a,o,`${Q}/${Ar(J)}`);ue.valid||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${J}" but does not match dependant schema.`},...ue.errors)}}}let ie=Object.create(null),fe=!1;if(F!==void 0){let Q=`${s}/properties`;for(let J in F){if(!(J in e))continue;let le=`${o}/${Ar(J)}`,ue=Ve(e[J],F[J],r,i,n,a,le,`${Q}/${Ar(J)}`);if(ue.valid)c[J]=ie[J]=!0;else if(fe=n,q.push({instanceLocation:o,keyword:"properties",keywordLocation:Q,error:`Property "${J}" does not match schema.`},...ue.errors),fe)break}}if(!fe&&T!==void 0){let Q=`${s}/patternProperties`;for(let J in T){let le=new RegExp(J,"u"),ue=T[J];for(let rr in e){if(!le.test(rr))continue;let yS=`${o}/${Ar(rr)}`,vS=Ve(e[rr],ue,r,i,n,a,yS,`${Q}/${Ar(J)}`);vS.valid?c[rr]=ie[rr]=!0:(fe=n,q.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:Q,error:`Property "${rr}" matches pattern "${J}" but does not match associated schema.`},...vS.errors))}}}if(!fe&&B!==void 0){let Q=`${s}/additionalProperties`;for(let J in e){if(ie[J])continue;let le=`${o}/${Ar(J)}`,ue=Ve(e[J],B,r,i,n,a,le,Q);ue.valid?c[J]=!0:(fe=n,q.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:Q,error:`Property "${J}" does not match additional properties schema.`},...ue.errors))}}else if(!fe&&Z!==void 0){let Q=`${s}/unevaluatedProperties`;for(let J in e)if(!c[J]){let le=`${o}/${Ar(J)}`,ue=Ve(e[J],Z,r,i,n,a,le,Q);ue.valid?c[J]=!0:q.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:Q,error:`Property "${J}" does not match unevaluated properties schema.`},...ue.errors)}}}else if(l==="array"){O!==void 0&&e.length>O&&q.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${O}).`}),h!==void 0&&e.length<h&&q.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${h}).`});let ce=e.length,ie=0,fe=!1;if(qr!==void 0){let Q=`${s}/prefixItems`,J=Math.min(qr.length,ce);for(;ie<J;ie++){let le=Ve(e[ie],qr[ie],r,i,n,a,`${o}/${ie}`,`${Q}/${ie}`);if(c[ie]=!0,!le.valid&&(fe=n,q.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:Q,error:"Items did not match schema."},...le.errors),fe))break}}if(ei!==void 0){let Q=`${s}/items`;if(Array.isArray(ei)){let J=Math.min(ei.length,ce);for(;ie<J;ie++){let le=Ve(e[ie],ei[ie],r,i,n,a,`${o}/${ie}`,`${Q}/${ie}`);if(c[ie]=!0,!le.valid&&(fe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...le.errors),fe))break}}else for(;ie<ce;ie++){let J=Ve(e[ie],ei,r,i,n,a,`${o}/${ie}`,Q);if(c[ie]=!0,!J.valid&&(fe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...J.errors),fe))break}if(!fe&&_c!==void 0){let J=`${s}/additionalItems`;for(;ie<ce;ie++){let le=Ve(e[ie],_c,r,i,n,a,`${o}/${ie}`,J);c[ie]=!0,le.valid||(fe=n,q.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:J,error:"Items did not match additional items schema."},...le.errors))}}}if(vc!==void 0)if(ce===0&&Xr===void 0)q.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Xr!==void 0&&ce<Xr)q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${ce}) than minContains (${Xr}).`});else{let Q=`${s}/contains`,J=q.length,le=0;for(let ue=0;ue<ce;ue++){let rr=Ve(e[ue],vc,r,i,n,a,`${o}/${ue}`,Q);rr.valid?(c[ue]=!0,le++):q.push(...rr.errors)}le>=(Xr||0)&&(q.length=J),Xr===void 0&&_===void 0&&le===0?q.splice(J,0,{instanceLocation:o,keyword:"contains",keywordLocation:Q,error:"Array does not contain item matching schema."}):Xr!==void 0&&le<Xr?q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Xr} items matching schema. Only ${le} items were found.`}):_!==void 0&&le>_&&q.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${_} items matching schema. ${le} items were found.`})}if(!fe&&yc!==void 0){let Q=`${s}/unevaluatedItems`;for(ie;ie<ce;ie++){if(c[ie])continue;let J=Ve(e[ie],yc,r,i,n,a,`${o}/${ie}`,Q);c[ie]=!0,J.valid||q.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:Q,error:"Items did not match unevaluated items schema."},...J.errors)}}if($)for(let Q=0;Q<ce;Q++){let J=e[Q],le=typeof J=="object"&&J!==null;for(let ue=0;ue<ce;ue++){if(Q===ue)continue;let rr=e[ue];(J===rr||le&&(typeof rr=="object"&&rr!==null)&&Vn(J,rr))&&(q.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${Q} and ${ue}.`}),Q=Number.MAX_SAFE_INTEGER,ue=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(ke!==void 0&&(mt===!0&&e<=ke||e<ke)&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${mt?"or equal to ":""} ${ke}.`}),Me!==void 0&&(st===!0&&e>=Me||e>Me)&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${st?"or equal to ":""} ${Me}.`})):(ke!==void 0&&e<ke&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${ke}.`}),Me!==void 0&&e>Me&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Me}.`}),mt!==void 0&&e<=mt&&q.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${mt}.`}),st!==void 0&&e>=st&&q.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${st}.`})),Ot!==void 0){let ce=e%Ot;Math.abs(0-ce)>=11920929e-14&&Math.abs(Ot-ce)>=11920929e-14&&q.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Ot}.`})}}else if(l==="string"){let ce=Nr===void 0&&ct===void 0?0:mC(e);Nr!==void 0&&ce<Nr&&q.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${ce} < ${Nr}).`}),ct!==void 0&&ce>ct&&q.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${ce} > ${ct}).`}),kn!==void 0&&!new RegExp(kn,"u").test(e)&&q.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),W!==void 0&&rw[W]&&!rw[W](e)&&q.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${W}".`})}return{valid:q.length===0,errors:q}}var vp=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=fn(t)}validate(t){return Ve(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),fn(t,this.lookup)}};var gC=A({Validator:()=>vp,deepCompareStrict:()=>Vn,toJsonSchema:()=>yt,validatesOnlyStrings:()=>Bs}),hC=new WeakMap;function yt(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let n=hC.get(e);if(n)return n}let i;if(ef(e)&&!Be(e))i=e["~standard"].jsonSchema.input({target:"draft-07"});else if(Be(e)){let n=cp(e,!0);Fr(n)?i=to(Cs(n,!0),t):i=to(e,t)}else at(e)?i=lC(e):i=e;return r&&i!=null&&typeof i=="object"&&hC.set(e,i),i}function Bs(e){if(!e||typeof e!="object"||Object.keys(e).length===0||Array.isArray(e))return!1;if("type"in e)return typeof e.type=="string"?e.type==="string":Array.isArray(e.type)?e.type.every(t=>t==="string"):!1;if("enum"in e)return Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every(t=>typeof t=="string");if("const"in e)return typeof e.const=="string";if("allOf"in e&&Array.isArray(e.allOf))return e.allOf.some(t=>Bs(t));if("anyOf"in e&&Array.isArray(e.anyOf)||"oneOf"in e&&Array.isArray(e.oneOf)){let t="anyOf"in e?e.anyOf:e.oneOf;return t.length>0&&t.every(r=>Bs(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=fn(e);return r[t]?Bs(r[t]):!1}return!1}function Su(e){return e?e.lc_runnable:!1}var _C=class{includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;constructor(e){this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,i=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||i.some(n=>this.includeTags?.includes(n))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&i.every(n=>!this.excludeTags?.includes(n))),r}},yC=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function nw(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var v6=["*","_","`"];function b6(e){let t="";for(let[r,i]of Object.entries(e))t+=` classDef ${r} ${i};
|
|
226
|
+
`;return t}function vC(e,t,r){let{firstNode:i,lastNode:n,nodeColors:a,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},u=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
|
|
227
|
+
graph TD;
|
|
228
|
+
`:`graph TD;
|
|
229
|
+
`;if(o){let m="default",g={[m]:"{0}({1})"};i!==void 0&&(g[i]="{0}([{1}]):::first"),n!==void 0&&(g[n]="{0}([{1}]):::last");for(let[y,b]of Object.entries(e)){let w=b.name.split(":").pop()??"",x=v6.some(E=>w.startsWith(E)&&w.endsWith(E))?`<p>${w}</p>`:w;Object.keys(b.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(b.metadata??{}).map(([E,V])=>`${E} = ${V}`).join(`
|
|
230
|
+
`)}</em></small>`);let k=(g[y]??g[m]).replace("{0}",nw(y)).replace("{1}",x);u+=` ${k}
|
|
231
|
+
`}}let l={};for(let m of t){let g=m.source.split(":"),y=m.target.split(":"),b=g.filter((w,x)=>w===y[x]).join(":");l[b]||(l[b]=[]),l[b].push(m)}let d=new Set;function f(m){return[...m].sort((g,y)=>g.split(":").length-y.split(":").length)}function p(m,g){let y=m.length===1&&m[0].source===m[0].target;if(g&&!y){let w=g.split(":").pop();if(d.has(g))throw new Error(`Found duplicate subgraph '${w}' at '${g} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(g),u+=` subgraph ${w}
|
|
232
|
+
`}let b=f(Object.keys(l).filter(w=>w.startsWith(`${g}:`)&&w!==g&&w.split(":").length===g.split(":").length+1));for(let w of b)p(l[w],w);for(let w of m){let{source:x,target:k,data:E,conditional:V}=w,C="";if(E!==void 0){let v=E,W=v.split(" ");W.length>c&&(v=Array.from({length:Math.ceil(W.length/c)},(F,T)=>W.slice(T*c,(T+1)*c).join(" ")).join(" <br> ")),C=V?` -. ${v} .-> `:` -- ${v} --> `}else C=V?" -.-> ":" --> ";u+=` ${nw(x)}${C}${nw(k)};
|
|
233
|
+
`}g&&!y&&(u+=` end
|
|
234
|
+
`)}p(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&p(l[m],m);return o&&(u+=b6(a??{})),u}async function bC(e,t){let r=t?.backgroundColor??"white",i=t?.imageType??"png",n=yC(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let a=`https://mermaid.ink/img/${n}?bgColor=${r}&type=${i}`,o=await fetch(a);if(!o.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${o.status}`,`Status text: ${o.statusText}`].join(`
|
|
235
|
+
`));return await o.blob()}var SC=A({Graph:()=>wo});function w6(e,t){if(e!==void 0&&!br(e))return e;if(Su(t))try{let r=t.getName();return r=r.startsWith("Runnable")?r.slice(8):r,r}catch{return t.getName()}else return t.name??"UnknownSchema"}function x6(e){return Su(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...yt(e.data.schema),title:e.data.name}}}var wo=class kC{nodes={};edges=[];constructor(t){this.nodes=t?.nodes??this.nodes,this.edges=t?.edges??this.edges}toJSON(){let t={};return Object.values(this.nodes).forEach((r,i)=>{t[r.id]=br(r.id)?i:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...x6(r)})),edges:this.edges.map(r=>{let i={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(i.data=r.data),typeof r.conditional<"u"&&(i.conditional=r.conditional),i})}}addNode(t,r,i){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let n=r??od(),a={id:n,data:t,name:w6(r,t),metadata:i};return this.nodes[n]=a,a}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,i,n){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[r.id]===void 0)throw new Error(`Target node ${r.id} not in graph`);let a={source:t.id,target:r.id,data:i,conditional:n};return this.edges.push(a),a}firstNode(){return wC(this)}lastNode(){return xC(this)}extend(t,r=""){let i=r;Object.values(t.nodes).map(c=>c.id).every(br)&&(i="");let n=c=>i?`${i}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[n(c)]={...u,id:n(c)}});let a=t.edges.map(c=>({...c,source:n(c.source),target:n(c.target)}));this.edges=[...this.edges,...a];let o=t.firstNode(),s=t.lastNode();return[o?{id:n(o.id),data:o.data}:void 0,s?{id:n(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&wC(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&xC(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(n=>[n.id,n.name])),r=new Map;Object.values(t).forEach(n=>{r.set(n,(r.get(n)||0)+1)});let i=n=>{let a=t[n];return br(n)&&r.get(a)===1?a:n};return new kC({nodes:Object.fromEntries(Object.entries(this.nodes).map(([n,a])=>[i(n),{...a,id:i(n)}])),edges:this.edges.map(n=>({...n,source:i(n.source),target:i(n.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:i,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:a}=t??{},o=this.reid(),s=o.firstNode(),c=o.lastNode();return vC(o.nodes,o.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:i,nodeColors:n,wrapLabelNWords:a})}async drawMermaidPng(t){return bC(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function wC(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.source)).map(n=>n.target)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function xC(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.target)).map(n=>n.source)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function bp({name:e,serialized:t}){return e!==void 0?e:t?.name!==void 0?t.name:t?.id!==void 0&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}var $C=e=>e.name==="event_stream_tracer",IC=class extends At{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;runInfoMap=new Map;tappedPromises=new Map;transformStream;writer;receiveStream;readableStreamClosed=!1;name="event_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream({flush:()=>{this.readableStreamClosed=!0}}),this.writer=this.transformStream.writable.getWriter(),this.receiveStream=ft.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function n(o,s){return o==="llm"&&typeof s=="string"?new ci({text:s}):s}let a=this.tappedPromises.get(e);if(a===void 0){let o;a=new Promise(s=>{o=s}),this.tappedPromises.set(e,a);try{let s={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};await this.send({...s,data:{chunk:n(i.runType,r.value)}},i),yield r.value;for await(let c of t)i.runType!=="tool"&&i.runType!=="retriever"&&await this.send({...s,data:{chunk:n(i.runType,c)}},i),yield c}finally{o?.()}}else{yield r.value;for await(let o of t)yield o}}async send(e,t){this.readableStreamClosed||this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=bp(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);let n=`on_${r}_start`;await this.send({event:n,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onLLMNewToken(e,t,r){let i=this.runInfoMap.get(e.id),n,a;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")a="on_chat_model_stream",r?.chunk===void 0?n=new Qe({content:t,id:`run-${e.id}`}):n=r.chunk.message;else if(i.runType==="llm")a="on_llm_stream",r?.chunk===void 0?n=new ci({text:t}):n=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);await this.send({event:a,data:{chunk:n},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let i=e.outputs?.generations,n;if(t.runType==="chat_model"){for(let a of i??[]){if(n!==void 0)break;n=a[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")n={generations:i?.map(a=>a.map(o=>({text:o.text,generationInfo:o.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:n,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=bp(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},n={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(n={},i.inputs={}):e.inputs.input!==void 0?(n.input=e.inputs.input,i.inputs=e.inputs.input):(n.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),await this.send({event:`on_${r}_start`,data:n,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onChainEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,i=e.inputs??t.inputs??{},n={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(n.input=i.input,t.inputs=i.input),await this.sendEndEvent({event:r,data:n,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=bp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onToolError(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);await this.sendEndEvent({event:"on_tool_error",data:{input:t.inputs,error:e.error},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){let t=bp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,r),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onRetrieverEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){let i=this.runInfoMap.get(r);if(i===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:i.tags,metadata:i.metadata,data:t},i)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var iw=class extends At{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}};function EC(e){let t=new TextEncoder,r=new ReadableStream({async start(i){for await(let n of e)i.enqueue(t.encode(`event: data
|
|
236
|
+
data: ${JSON.stringify(n)}
|
|
237
|
+
|
|
238
|
+
`));i.enqueue(t.encode(`event: end
|
|
239
|
+
|
|
240
|
+
`)),i.close()}});return ft.fromReadableStream(r)}function aw(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var TC=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function wp(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function ow(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function AC(e,t){try{let r=await e.next();for(;!r.done;)await t?.(r.value),r=await e.next();return r.value}finally{await e.return?.(void 0)}}function*sw(e,t){for(;;){let{value:r,done:i}=Te.runWithConfig(or(e),t.next.bind(t),!0);if(i)break;yield r}}async function*xp(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:i,done:n}=await Te.runWithConfig(or(e),r.next.bind(t),!0);if(n)break;yield i}}function pt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var ae=class extends ut{lc_runnable=!0;name;getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}withRetry(e){return new kp({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Hr({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new cw({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(we);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([i])=>i!=="runId"));return Array.from({length:t},(i,n)=>we(n===0?e:r))}return Array.from({length:t},()=>we(e))}async batch(e,t,r){let i=this._getOptionsList(t??{},e.length),n=new ui({maxConcurrency:i[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:o=>{throw o}}),a=e.map((o,s)=>n.call(async()=>{try{return await this.invoke(o,i[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=we(t),i=new Li({generator:this._streamIterator(e,r),config:r});return await i.setup,ft.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=we(e):t=we({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){let i=we(r),n=await(await jt(i))?.handleChainStart(this.toJSON(),pt(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let a;try{a=await kr(e.call(this,t,i,n),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(pt(a,"output")),a}async _batchWithConfig(e,t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(jt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),pt(t[u],"input"),n[u].runId,n[u].runType,void 0,void 0,n[u].runName??this.getName());return delete n[u].runId,l})),s;try{s=await kr(e.call(this,t,n,o,i),n?.[0]?.signal)}catch(c){throw await Promise.all(o.map(u=>u?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(pt(s,"output")))),s}_concatOutputChunks(e,t){return $r(e,t)}async*_transformStreamWithConfig(e,t,r){let i,n=!0,a,o=!0,s=we(r),c=await jt(s),u=this;async function*l(){for await(let f of e){if(n)if(i===void 0)i=f;else try{i=u._concatOutputChunks(i,f)}catch{i=void 0,n=!1}yield f}}let d;try{let f=await e_(t.bind(this),l(),async()=>c?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName(),void 0,{lc_defers_inputs:!0}),s.signal,s);delete s.runId,d=f.setup;let p=d?.handlers.find($C),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let g=d?.handlers.find(r_);g!==void 0&&d!==void 0&&(m=g.tapOutputIterable(d.runId,m));for await(let y of m)if(yield y,o)if(a===void 0)a=y;else try{a=this._concatOutputChunks(a,y)}catch{a=void 0,o=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:pt(i,"input")}),f}await d?.handleChainEnd(a??{},void 0,void 0,void 0,{inputs:pt(i,"input")})}getGraph(e){let t=new wo,r=t.addNode({name:`${this.getName()}Input`,schema:St.any()}),i=t.addNode(this),n=t.addNode({name:`${this.getName()}Output`,schema:St.any()});return t.addEdge(r,i),t.addEdge(i,n),t}pipe(e){return new Cr({first:this,last:tt(e)})}pick(e){return this.pipe(new uw(e))}assign(e){return this.pipe(new $u(new oa({steps:e})))}async*transform(e,t){let r;for await(let i of e)r===void 0?r=i:r=this._concatOutputChunks(r,i);yield*this._streamIterator(r,we(t))}async*streamLog(e,t,r){let i=new Xd({...r,autoClose:!1,_schemaFormat:"original"}),n=we(t);yield*this._streamLog(e,i,n)}async*_streamLog(e,t,r){let{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{let s=i.copy();s.addHandler(t,!0),r.callbacks=s}let n=this.stream(e,r);async function a(){try{let s=await n;for await(let c of s){let u=new jn({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let o=a();try{for await(let s of t)yield s}finally{await o}}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?EC(i):ft.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){let i=new IC({...r,autoClose:!1}),n=we(t),a=n.runId??xr();n.runId=a;let o=n.callbacks;if(o===void 0)n.callbacks=[i];else if(Array.isArray(o))n.callbacks=o.concat(i);else{let p=o.copy();p.addHandler(i,!0),n.callbacks=p}let s=new AbortController,c=this;async function u(){let p;try{if(n.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,n.signal]);else{let y=new AbortController;n.signal.addEventListener("abort",()=>y.abort(),{once:!0}),s.signal.addEventListener("abort",()=>y.abort(),{once:!0}),p=y.signal}else p=s.signal;let m=await c.stream(e,{...n,signal:p}),g=i.tapOutputIterable(a,m);for await(let y of g)if(s.signal.aborted)break}finally{await i.finish()}}let l=u(),d=!1,f;try{for await(let p of i){if(!d){p.data.input=e,d=!0,f=p.run_id,yield p;continue}p.run_id===f&&p.event.endsWith("_end")&&p.data?.input&&delete p.data.input,yield p}}finally{s.abort(),await l}}async*_streamEventsV1(e,t,r){let i,n=!1,a=we(t),o=a.tags??[],s=a.metadata??{},c=a.runName??this.getName(),u=new Xd({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new _C({...r}),d=this._streamLog(e,u,a);for await(let p of d){if(i?i=i.concat(p):i=qd.fromRunLogPatch(p),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!n){n=!0;let b={...i.state},w={run_id:b.id,event:`on_${b.type}_start`,name:c,tags:o,metadata:s,data:{input:e}};l.includeEvent(w,b.type)&&(yield w)}let m=p.ops.filter(b=>b.path.startsWith("/logs/")).map(b=>b.path.split("/")[2]),g=[...new Set(m)];for(let b of g){let w,x={},k=i.state.logs[b];if(k.end_time===void 0?k.streamed_output.length>0?w="stream":w="start":w="end",w==="start")k.inputs!==void 0&&(x.input=k.inputs);else if(w==="end")k.inputs!==void 0&&(x.input=k.inputs),x.output=k.final_output;else if(w==="stream"){let E=k.streamed_output.length;if(E!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${E} instead. Encountered in: "${k.name}"`);x={chunk:k.streamed_output[0]},k.streamed_output=[]}yield{event:`on_${k.type}_${w}`,name:k.name,run_id:k.id,tags:k.tags,metadata:k.metadata,data:x}}let{state:y}=i;if(y.streamed_output.length>0){let b=y.streamed_output.length;if(b!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${b} instead. Encountered in: "${y.name}"`);let w={chunk:y.streamed_output[0]};y.streamed_output=[];let x={event:`on_${y.type}_stream`,run_id:y.id,tags:o,metadata:s,name:c,data:w};l.includeEvent(x,y.type)&&(yield x)}}let f=i?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:o,metadata:s,data:{output:f.final_output}};l.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return Su(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Hr({bound:this,config:{},configFactories:[i=>({callbacks:[new iw({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return $6(this,e)}},Hr=class CC extends ae{static lc_name(){return"RunnableBinding"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;bound;config;kwargs;configFactories;constructor(t){super(t),this.bound=t.bound,this.kwargs=t.kwargs,this.config=t.config,this.configFactories=t.configFactories}getName(t){return this.bound.getName(t)}async _mergeConfig(...t){let r=xt(this.config,...t);return xt(r,...this.configFactories?await Promise.all(this.configFactories.map(async i=>await i(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new kp({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,r){return this.bound.invoke(t,await this._mergeConfig(r,this.kwargs))}async batch(t,r,i){let n=Array.isArray(r)?await Promise.all(r.map(async a=>this._mergeConfig(we(a),this.kwargs))):await this._mergeConfig(we(r),this.kwargs);return this.bound.batch(t,n,i)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(we(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(we(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(we(r),this.kwargs))}streamEvents(t,r,i){let n=this,a=async function*(){yield*n.bound.streamEvents(t,{...await n._mergeConfig(we(r),n.kwargs),version:r.version},i)};return ft.fromAsyncGenerator(a())}static isRunnableBinding(t){return t.bound&&ae.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:i}){return new CC({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new iw({config:n,onStart:t,onEnd:r,onError:i})]})]})}},OC=class PC extends ae{static lc_name(){return"RunnableEach"}lc_serializable=!0;lc_namespace=["langchain_core","runnables"];bound;constructor(t){super(t),this.bound=t.bound}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async _invoke(t,r,i){return this.bound.batch(t,$e(r,{callbacks:i?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:i}){return new PC({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:i})})}},kp=class extends Hr{static lc_name(){return"RunnableRetry"}lc_namespace=["langchain_core","runnables"];maxAttemptNumber=3;onFailedAttempt=()=>{};constructor(e){super(e),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let i=e>1?`retry:attempt:${e}`:void 0;return $e(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return Jc(i=>super.invoke(e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:({error:i})=>this.onFailedAttempt(i,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,i){let n={};try{await Jc(async a=>{let o=e.map((d,f)=>f).filter(d=>n[d.toString()]===void 0||n[d.toString()]instanceof Error),s=o.map(d=>e[d]),c=o.map(d=>this._patchConfigForRetry(a,t?.[d],r?.[d])),u=await super.batch(s,c,{...i,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let f=u[d],p=o[d];f instanceof Error&&l===void 0&&(l=f,l.input=s[d]),n[p.toString()]=f}if(l)throw l;return u},{onFailedAttempt:({error:a})=>this.onFailedAttempt(a,a.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(a){if(i?.returnExceptions!==!0)throw a}return Object.keys(n).sort((a,o)=>parseInt(a,10)-parseInt(o,10)).map(a=>n[parseInt(a,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},Cr=class ku extends ae{static lc_name(){return"RunnableSequence"}first;middle=[];last;omitSequenceTags=!1;lc_serializable=!0;lc_namespace=["langchain_core","runnables"];constructor(t){super(t),this.first=t.first,this.middle=t.middle??this.middle,this.last=t.last,this.name=t.name,this.omitSequenceTags=t.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(t,r){let i=we(r),n=await(await jt(i))?.handleChainStart(this.toJSON(),pt(t,"input"),i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a=t,o;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)a=await kr(s[c].invoke(a,$e(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),i.signal);if(i.signal?.aborted)throw Ui(i.signal);o=await this.last.invoke(a,$e(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await n?.handleChainError(s),s}return await n?.handleChainEnd(pt(o,"output")),o}async batch(t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(jt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),pt(t[u],"input"),n[u].runId,void 0,void 0,void 0,n[u].runName);return delete n[u].runId,l})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await kr(this.steps[c].batch(s,o.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return $e(n[l],{callbacks:d})}),i),n[0]?.signal)}catch(c){throw await Promise.all(o.map(u=>u?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(pt(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let i=await jt(r),{runId:n,...a}=r??{},o=await i?.handleChainStart(this.toJSON(),pt(t,"input"),n,void 0,void 0,void 0,a?.runName),s=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=s[0].transform(l(),$e(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,$e(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(u===void 0)u=f;else try{u=this._concatOutputChunks(u,f)}catch{u=void 0,c=!1}}catch(d){throw await o?.handleChainError(d),d}await o?.handleChainEnd(pt(u,"output"))}getGraph(t){let r=new wo,i=null;return this.steps.forEach((n,a)=>{let o=n.getGraph(t);a!==0&&o.trimFirstNode(),a!==this.steps.length-1&&o.trimLastNode(),r.extend(o);let s=o.firstNode();if(!s)throw new Error(`Runnable ${n} has no first node`);i&&r.addEdge(i,s),i=o.lastNode()}),r}pipe(t){return ku.isRunnableSequence(t)?new ku({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new ku({first:this.first,middle:[...this.middle,this.last],last:tt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&ae.isRunnable(t)}static from([t,...r],i){let n={};return typeof i=="string"?n.name=i:i!==void 0&&(n=i),new ku({...n,first:tt(t),middle:r.slice(0,-1).map(tt),last:tt(r[r.length-1])})}},oa=class NC extends ae{static lc_name(){return"RunnableMap"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;steps;getStepsKeys(){return Object.keys(this.steps)}constructor(t){super(t),this.steps={};for(let[r,i]of Object.entries(t.steps))this.steps[r]=tt(i)}static from(t){return new NC({steps:t})}async invoke(t,r){let i=we(r),n=await(await jt(i))?.handleChainStart(this.toJSON(),{input:t},i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a={};try{let o=Object.entries(this.steps).map(async([s,c])=>{a[s]=await c.invoke(t,$e(i,{callbacks:n?.getChild(`map:key:${s}`)}))});await kr(Promise.all(o),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(a),a}async*_transform(t,r,i){let n={...this.steps},a=Vd(t,Object.keys(n).length),o=new Map(Object.entries(n).map(([s,c],u)=>{let l=c.transform(a[u],$e(i,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,l.next().then(d=>({key:s,gen:l,result:d}))]}));for(;o.size;){let{key:s,result:c,gen:u}=await kr(Promise.race(o.values()),i?.signal);o.delete(s),c.done||(yield{[s]:c.value},o.set(s,u.next().then(l=>({key:s,gen:u,result:l}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=we(r),a=new Li({generator:this.transform(i(),n),config:n});return await a.setup,ft.fromAsyncGenerator(a)}},S6=class RC extends ae{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Fd(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,r){let[i]=this._getOptionsList(r??{},1),n=await jt(i);return kr(this.func($e(i,{callbacks:n}),t),i?.signal)}async*_streamIterator(t,r){let[i]=this._getOptionsList(r??{},1),n=await this.invoke(t,r);if(wp(n)){for await(let a of n)i?.signal?.throwIfAborted(),yield a;return}if(TC(n)){for(;;){i?.signal?.throwIfAborted();let a=n.next();if(a.done)break;yield a.value}return}yield n}static from(t){return new RC({func:t})}};function k6(e){if(Fd(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var Dt=class MC extends ae{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Fd(t.func))return S6.from(t.func);super(t),k6(t.func),this.func=t.func}static from(t){return new MC({func:t})}async _invoke(t,r,i){return new Promise((n,a)=>{let o=$e(r,{callbacks:i?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Te.runWithConfig(or(o),async()=>{try{let s=await this.func(t,{...o});if(s&&ae.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...o,recursionLimit:(o.recursionLimit??25)-1})}else if(wp(s)){let c;for await(let u of xp(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}else if(aw(s)){let c;for(let u of sw(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}n(s)}catch(s){a(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,i){let n;for await(let s of t)if(n===void 0)n=s;else try{n=this._concatOutputChunks(n,s)}catch{n=s}let a=$e(i,{callbacks:r?.getChild(),recursionLimit:(i?.recursionLimit??25)-1}),o=await new Promise((s,c)=>{Te.runWithConfig(or(a),async()=>{try{s(await this.func(n,{...a,config:a}))}catch(u){c(u)}})});if(o&&ae.isRunnable(o)){if(i?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await o.stream(n,a);for await(let c of s)yield c}else if(wp(o))for await(let s of xp(a,o))i?.signal?.throwIfAborted(),yield s;else if(aw(o))for(let s of sw(a,o))i?.signal?.throwIfAborted(),yield s;else yield o}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=we(r),a=new Li({generator:this.transform(i(),n),config:n});return await a.setup,ft.fromAsyncGenerator(a)}},jC=class extends oa{},cw=class extends ae{static lc_name(){return"RunnableWithFallbacks"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnable;fallbacks;constructor(e){super(e),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}async invoke(e,t){let r=we(t),i=await jt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),pt(e,"input"),n,void 0,void 0,void 0,a?.runName),s=$e(a,{callbacks:o?.getChild()});return await Te.runWithConfig(s,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,s);return await o?.handleChainEnd(pt(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await o?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=we(t),i=await jt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),pt(e,"input"),n,void 0,void 0,void 0,a?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=$e(a,{callbacks:o?.getChild()});try{c=xp(d,await l.stream(e,d));break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let l=s??new Error("No error stored at end of fallback.");throw await o?.handleChainError(l),l}let u;try{for await(let l of c){yield l;try{u=u===void 0?u:this._concatOutputChunks(u,l)}catch{u=void 0}}}catch(l){throw await o?.handleChainError(l),l}await o?.handleChainEnd(pt(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let i=this._getOptionsList(t??{},e.length),n=await Promise.all(i.map(s=>jt(s))),a=await Promise.all(n.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),pt(e[c],"input"),i[c].runId,void 0,void 0,void 0,i[c].runName);return delete i[c].runId,u})),o;for(let s of this.runnables()){i[0].signal?.throwIfAborted();try{let c=await s.batch(e,a.map((u,l)=>$e(i[l],{callbacks:u?.getChild()})),r);return await Promise.all(a.map((u,l)=>u?.handleChainEnd(pt(c[l],"output")))),c}catch(c){o===void 0&&(o=c)}}throw o?(await Promise.all(a.map(s=>s?.handleChainError(o))),o):new Error("No error stored at end of fallbacks.")}};function tt(e){if(typeof e=="function")return new Dt({func:e});if(ae.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,i]of Object.entries(e))t[r]=tt(i);return new oa({steps:t})}else throw new Error(`Expected a Runnable, function or object.
|
|
241
|
+
Instead got an unsupported type.`)}var $u=class extends ae{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof oa&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){let i=this.mapper.getStepsKeys(),[n,a]=Vd(e),o=this.mapper.transform(a,$e(r,{callbacks:t?.getChild()})),s=o.next();for await(let c of n){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let u=Object.fromEntries(Object.entries(c).filter(([l])=>!i.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await s).value;for await(let c of o)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=we(t),n=new Li({generator:this.transform(r(),i),config:i});return await n.setup,ft.fromAsyncGenerator(n)}},uw=class extends ae{static lc_name(){return"RunnablePick"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;keys;constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(let t of e){let r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=we(t),n=new Li({generator:this.transform(r(),i),config:i});return await n.setup,ft.fromAsyncGenerator(n)}},Sp=class extends Hr{name;description;schema;constructor(e){let t=Cr.from([Dt.from(async r=>{let i;if(Pi(r))try{i=await ta(this.schema,r.args)}catch{throw new Go("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function $6(e,t){let r=t.name??e.getName(),i=t.description??pi(t.schema);return Ps(t.schema)?new Sp({name:r,description:i,schema:St.object({input:St.string()}).transform(n=>n.input),bound:e}):new Sp({name:r,description:i,schema:t.schema,bound:e})}var $p=(e,t)=>{let r=[...new Set(t?.map(n=>{if(typeof n=="string")return n;let a=new n({});if(!("getType"in a)||typeof a.getType!="function")throw new Error("Invalid type provided.");return a.getType()}))],i=e.getType();return r.some(n=>n===i)};function FC(e,t){return Array.isArray(e)?zC(e,t):Dt.from(r=>zC(r,e))}function zC(e,t={}){let{includeNames:r,excludeNames:i,includeTypes:n,excludeTypes:a,includeIds:o,excludeIds:s}=t,c=[];for(let u of e)if(!(i&&u.name&&i.includes(u.name))){{if(a&&$p(u,a))continue;if(s&&u.id&&s.includes(u.id))continue}n||o||r?(r&&u.name&&r.some(l=>l===u.name)||n&&$p(u,n)||o&&u.id&&o.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function BC(e){return Array.isArray(e)?DC(e):Dt.from(DC)}function DC(e){if(!e.length)return[];let t=[];for(let r of e){let i=r,n=t.pop();if(!n)t.push(i);else if(i.getType()==="tool"||i.getType()!==n.getType())t.push(n,i);else{let a=Pa(n),o=Pa(i),s=a.concat(o);typeof a.content=="string"&&typeof o.content=="string"&&(s.content=`${a.content}
|
|
242
|
+
${o.content}`),t.push(E6(s))}}return t}function VC(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return UC(r,t)}else{let r=e;return Dt.from(i=>UC(i,r)).withConfig({runName:"trim_messages"})}}async function UC(e,t){let{maxTokens:r,tokenCounter:i,strategy:n="last",allowPartial:a=!1,endOn:o,startOn:s,includeSystem:c=!1,textSplitter:u}=t;if(s&&n==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&n==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in i?l=async f=>(await Promise.all(f.map(p=>i.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):l=async f=>i(f);let d=dw;if(u&&("splitText"in u?d=u.splitText:d=async f=>u(f)),n==="first")return ZC(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:a?"first":void 0,endOn:o});if(n==="last")return I6(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:a,includeSystem:c,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${n}'. Must be one of 'first' or 'last'.`)}async function ZC(e,t){let{maxTokens:r,tokenCounter:i,textSplitter:n,partialStrategy:a,endOn:o}=t,s=[...e],c=0;for(let u=0;u<s.length;u+=1)if(await i(u>0?s.slice(0,-u):s)<=r){c=s.length-u;break}if(c<s.length&&a){let u=!1;if(Array.isArray(s[c].content)){let l=s[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,f=a==="last"?[...l.content].reverse():l.content;for(let p=1;p<=d;p+=1){let m=a==="first"?f.slice(0,p):f.slice(-p),g=Object.fromEntries(Object.entries(l).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),y=lw(l.getType(),{...g,content:m}),b=[...s.slice(0,c),y];if(await i(b)<=r)s=b,c+=1,u=!0;else break}u&&a==="last"&&(l.content=[...f].reverse())}if(!u){let l=s[c],d;if(Array.isArray(l.content)&&l.content.some(f=>typeof f=="string"||f.type==="text")?d=l.content.find(f=>f.type==="text"&&f.text)?.text:typeof l.content=="string"&&(d=l.content),d){let f=await n(d),p=f.length;a==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),l.content=f.join(""),await i([...s.slice(0,c),l])<=r){a==="last"&&(l.content=[...f].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(o){let u=Array.isArray(o)?o:[o];for(;c>0&&!$p(s[c-1],u);)c-=1}return s.slice(0,c)}async function I6(e,t){let{allowPartial:r=!1,includeSystem:i=!1,endOn:n,startOn:a,...o}=t,s=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return lw(l.getType(),d,ai(l))});if(n){let l=Array.isArray(n)?n:[n];for(;s.length>0&&!$p(s[s.length-1],l);)s=s.slice(0,-1)}let c=i&&s[0]?.getType()==="system",u=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return u=await ZC(u,{...o,partialStrategy:r?"last":void 0,endOn:a}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var LC={human:{message:rt,messageChunk:Oa},ai:{message:Ee,messageChunk:Qe},system:{message:Gt,messageChunk:oi},developer:{message:Gt,messageChunk:oi},tool:{message:_t,messageChunk:Ho},function:{message:Aa,messageChunk:Ca},generic:{message:nn,messageChunk:Ta},remove:{message:an,messageChunk:an}};function lw(e,t,r){let i,n;switch(e){case"human":r?i=new Oa(t):n=new rt(t);break;case"ai":if(r){let a={...t};"tool_calls"in a&&(a={...a,tool_call_chunks:a.tool_calls?.map(o=>({...o,type:"tool_call_chunk",index:void 0,args:JSON.stringify(o.args)}))}),i=new Qe(a)}else n=new Ee(t);break;case"system":r?i=new oi(t):n=new Gt(t);break;case"developer":r?i=new oi({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):n=new Gt({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?i=new Ho(t):n=new _t(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)i=new Ca(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new Aa(t)}break;case"generic":if("role"in t)r?i=new Ta(t):n=new nn(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(r&&i)return i;if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function E6(e){let t=e.getType(),r,i=Object.fromEntries(Object.entries(e).filter(([n])=>!["type","tool_call_chunks"].includes(n)&&!n.startsWith("lc_")));if(t in LC&&(r=lw(t,i)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(LC)}`);return r}function dw(e){let t=e.split(`
|
|
243
|
+
`);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
|
|
244
|
+
`),t[t.length-1]])}var HC=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var GC=["image","video","audio","text-plain","file"];var JC=["text","reasoning",...HC,...GC];var KC=A({AIMessage:()=>Ee,AIMessageChunk:()=>Qe,BaseMessage:()=>Ce,BaseMessageChunk:()=>bt,ChatMessage:()=>nn,ChatMessageChunk:()=>Ta,DEFAULT_MERGE_IGNORE_KEYS:()=>Dh,FunctionMessage:()=>Aa,FunctionMessageChunk:()=>Ca,HumanMessage:()=>rt,HumanMessageChunk:()=>Oa,KNOWN_BLOCK_TYPES:()=>JC,RemoveMessage:()=>an,SystemMessage:()=>Gt,SystemMessageChunk:()=>oi,ToolMessage:()=>_t,ToolMessageChunk:()=>Ho,_isMessageFieldWithRole:()=>td,_mergeDicts:()=>Ke,_mergeLists:()=>Oi,_mergeObj:()=>ed,_mergeStatus:()=>Ql,coerceMessageLikeToMessage:()=>It,collapseToolCallChunks:()=>nd,convertToChunk:()=>Pa,convertToOpenAIImageBlock:()=>Wl,convertToProviderContentBlock:()=>rk,defaultTextSplitter:()=>dw,defaultToolCallParser:()=>Cc,filterMessages:()=>FC,getBufferString:()=>Wo,iife:()=>Jk,isAIMessage:()=>Ko,isAIMessageChunk:()=>Pc,isBase64ContentBlock:()=>Zo,isBaseMessage:()=>We,isBaseMessageChunk:()=>ai,isChatMessage:()=>Uk,isChatMessageChunk:()=>Lk,isDataContentBlock:()=>An,isDirectToolOutput:()=>Ac,isFunctionMessage:()=>Fk,isFunctionMessageChunk:()=>Bk,isHumanMessage:()=>Vk,isHumanMessageChunk:()=>Zk,isIDContentBlock:()=>Kl,isMessage:()=>Yl,isOpenAIToolCallArray:()=>_k,isPlainTextContentBlock:()=>ek,isSystemMessage:()=>Hk,isSystemMessageChunk:()=>Gk,isToolMessage:()=>Oc,isToolMessageChunk:()=>Uh,isURLContentBlock:()=>Vo,mapChatMessagesToStoredMessages:()=>Wk,mapStoredMessageToChatMessage:()=>Nc,mapStoredMessagesToChatMessages:()=>Kk,mergeContent:()=>Pt,mergeMessageRuns:()=>BC,mergeResponseMetadata:()=>rd,mergeUsageMetadata:()=>Jo,parseBase64DataUrl:()=>Tc,parseMimeType:()=>tk,trimMessages:()=>VC});var WC=A({BaseChatMessageHistory:()=>fw,BaseListChatMessageHistory:()=>Ip,InMemoryChatMessageHistory:()=>T6}),fw=class extends ut{async addMessages(e){for(let t of e)await this.addMessage(t)}},Ip=class extends ut{addUserMessage(e){return this.addMessage(new rt(e))}addAIMessage(e){return this.addMessage(new Ee(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},T6=class extends Ip{lc_namespace=["langchain","stores","message","in_memory"];messages=[];constructor(e){super(...arguments),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}};var Or=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var pw=class extends ae{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},qC=class extends pw{async transformDocuments(e){let t=[];for(let r of e){let i=await this._transformDocument(r);t.push(i)}return t}};var XC=A({BaseDocumentTransformer:()=>pw,Document:()=>Or,MappingDocumentTransformer:()=>qC});var YC=A({BaseDocumentLoader:()=>mw}),mw=class{};var QC=A({LangSmithLoader:()=>A6}),A6=class extends mw{datasetId;datasetName;exampleIds;asOf;splits;inlineS3Urls;offset;limit;metadata;filter;contentKey;formatContent;client;constructor(e){if(super(),e.client&&e.clientConfig)throw new Error("client and clientConfig cannot both be provided.");this.client=e.client??new Nn(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??C6,this.datasetId=e.datasetId,this.datasetName=e.datasetName,this.exampleIds=e.exampleIds,this.asOf=e.asOf,this.splits=e.splits,this.inlineS3Urls=e.inlineS3Urls,this.offset=e.offset,this.limit=e.limit,this.metadata=e.metadata,this.filter=e.filter}async load(){let e=[];for await(let t of this.client.listExamples({datasetId:this.datasetId,datasetName:this.datasetName,exampleIds:this.exampleIds,asOf:this.asOf,splits:this.splits,inlineS3Urls:this.inlineS3Urls,offset:this.offset,limit:this.limit,metadata:this.metadata,filter:this.filter})){let r=t.inputs;for(let a of this.contentKey)r=r[a];let i=this.formatContent(r),n=t;["created_at","modified_at"].forEach(a=>{a in n&&typeof n[a]=="object"&&(n[a]=n[a].toString())}),e.push({pageContent:i,metadata:n})}return e}};function C6(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var eO=A({Embeddings:()=>Ep}),Ep=class{caller;constructor(e){this.caller=new ui(e??{})}};var Vs=class extends ut{lc_namespace=["langchain_core","example_selectors","base"]};var hw=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},tO=class extends hw{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,r]of this.conditionals)if(t(e))return r;return this.defaultPrompt}};function rO(e){return e._modelType()==="base_llm"}function nO(e){return e._modelType()==="base_chat_model"}function iO(e){return e.split(/\n| /).length}var aO=class oO extends Vs{examples=[];examplePrompt;getTextLength=iO;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??iO}async addExample(t){this.examples.push(t);let r=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(r))}async calculateExampleTextLengths(t,r){if(t.length>0)return t;let{examples:i,examplePrompt:n}=r;return(await Promise.all(i.map(a=>n.format(a)))).map(a=>this.getTextLength(a))}async selectExamples(t){let r=Object.values(t).join(" "),i=this.maxLength-this.getTextLength(r),n=0,a=[];for(;i>0&&n<this.examples.length;){let o=i-this.exampleTextLengths[n];if(o<0)break;a.push(this.examples[n]),i=o,n+=1}return a}static async fromExamples(t,r){let i=new oO(r);return await Promise.all(t.map(n=>i.addExample(n))),i}};function gw(e){return Object.keys(e).sort().map(t=>e[t])}var sO=class cO extends Vs{vectorStoreRetriever;exampleKeys;inputKeys;constructor(t){if(super(t),this.exampleKeys=t.exampleKeys,this.inputKeys=t.inputKeys,t.vectorStore!==void 0)this.vectorStoreRetriever=t.vectorStore.asRetriever({k:t.k??4,filter:t.filter});else if(t.vectorStoreRetriever)this.vectorStoreRetriever=t.vectorStoreRetriever;else throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".')}async addExample(t){let r=gw((this.inputKeys??Object.keys(t)).reduce((i,n)=>({...i,[n]:t[n]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new Or({pageContent:r,metadata:t})])}async selectExamples(t){let r=gw((this.inputKeys??Object.keys(t)).reduce((n,a)=>({...n,[a]:t[a]}),{})).join(" "),i=(await this.vectorStoreRetriever.invoke(r)).map(n=>n.metadata);return this.exampleKeys?i.map(n=>this.exampleKeys.reduce((a,o)=>({...a,[o]:n[o]}),{})):i}static async fromExamples(t,r,i,n={}){let a=n.inputKeys??null,o=t.map(s=>gw(a?a.reduce((c,u)=>({...c,[u]:s[u]}),{}):s).join(" "));return new cO({vectorStore:await i.fromTexts(o,t,r,n),k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}};var uO=A({BaseExampleSelector:()=>Vs,BasePromptSelector:()=>hw,ConditionalPromptSelector:()=>tO,LengthBasedExampleSelector:()=>aO,SemanticSimilarityExampleSelector:()=>sO,isChatModel:()=>nO,isLLM:()=>rO});var Iu="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",lO=class extends ut{lc_namespace=["langchain","recordmanagers"]};var _w=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Bo;constructor(e){this.uid=e.uid,this.pageContent=e.pageContent,this.metadata=e.metadata}makeDefaultKeyEncoder(e){this.keyEncoder=e}calculateHashes(){let e=["hash_","content_hash","metadata_hash"];for(let r of e)if(r in this.metadata)throw new Error(`Metadata cannot contain key ${r} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let r=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=r}catch(r){throw new Error(`Failed to hash metadata: ${r}. Please use a dict that can be serialized using json.`)}this.hash_=this._hashStringToUUID(this.contentHash+this.metadataHash),this.uid||(this.uid=this.hash_)}toDocument(){return new Or({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let r=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return r.calculateHashes(),r}_hashStringToUUID(e){return Ra(this.keyEncoder(e),Iu)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return Ra(this.keyEncoder(t),Iu)}};function yw(e,t){let r=[],i=[];return t.forEach(n=>{i.push(n),i.length>=e&&(r.push(i),i=[])}),i.length>0&&r.push(i),r}function vw(e){let t=new Set,r=[];for(let i of e){if(!i.hash_)throw new Error("Hashed document does not have a hash");t.has(i.hash_)||(t.add(i.hash_),r.push(i))}return r}function bw(e){if(e===null)return t=>null;if(typeof e=="string")return t=>t.metadata[e];if(typeof e=="function")return e;throw new Error(`sourceIdKey should be null, a string or a function, got ${typeof e}`)}var ww=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function dO(e){let{docsSource:t,recordManager:r,vectorStore:i,options:n}=e,{batchSize:a=100,cleanup:o,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=n??{};if(o==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=ww(t)?await t.load():t,d=bw(s??null),f=await r.getTime(),p=0,m=0,g=0,y=0,b=yw(a??100,l);for(let w of b){let x=vw(w.map(F=>_w.fromDocument(F))),k=x.map(F=>d(F));o==="incremental"&&x.forEach((F,T)=>{if(k[T]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let E=await r.exists(x.map(F=>F.uid)),V=[],C=[],v=[],W=new Set;if(x.forEach((F,T)=>{if(E[T])if(u)W.add(F.uid);else{v.push(F.uid);return}V.push(F.uid),C.push(F.toDocument())}),v.length>0&&(await r.update(v,{timeAtLeast:f}),y+=v.length),C.length>0&&(await i.addDocuments(C,{ids:V}),p+=C.length-W.size,g+=W.size),await r.update(x.map(F=>F.uid),{timeAtLeast:f,groupIds:k}),o==="incremental"){k.forEach(T=>{if(!T)throw new Error("Source id cannot be null")});let F=await r.listKeys({before:f,groupIds:k});F.length>0&&(await i.delete({ids:F}),await r.deleteKeys(F),m+=F.length)}}if(o==="full"){let w=await r.listKeys({before:f,limit:c});for(;w.length>0;)await i.delete({ids:w}),await r.deleteKeys(w),m+=w.length,w=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:g,numSkipped:y}}var fO=A({RecordManager:()=>lO,UUIDV5_NAMESPACE:()=>Iu,_HashedDocument:()=>_w,_batch:()=>yw,_deduplicateInOrder:()=>vw,_getSourceIdAssigner:()=>bw,_isBaseDocumentLoader:()=>ww,index:()=>dO});var pO=A({BasePromptValue:()=>Tp,ChatPromptValue:()=>Tu,ImagePromptValue:()=>xw,StringPromptValue:()=>Eu}),Tp=class extends ut{},Eu=class extends Tp{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new rt(this.value)]}},Tu=class extends Tp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return Wo(this.messages)}toChatMessages(){return this.messages}},xw=class extends Tp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new rt({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var _O=$l(gO(),1),D6=Object.defineProperty,U6=(e,t,r)=>t in e?D6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L6=(e,t,r)=>(U6(e,typeof t!="symbol"?t+"":t,r),r);function F6(e,t){let r=Array.from({length:e.length},(i,n)=>({start:n,end:n+1}));for(;r.length>1;){let i=null;for(let n=0;n<r.length-1;n++){let a=e.slice(r[n].start,r[n+1].end),o=t.get(a.join(","));o!=null&&(i==null||o<i[0])&&(i=[o,n])}if(i!=null){let n=i[1];r[n]={start:r[n].start,end:r[n+1].end},r.splice(n+1,1)}else break}return r}function B6(e,t){return e.length===1?[t.get(e.join(","))]:F6(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function V6(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var kw=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,t){this.patStr=e.pat_str;let r=e.bpe_ranks.split(`
|
|
245
|
+
`).filter(Boolean).reduce((i,n)=>{let[a,o,...s]=n.split(" "),c=Number.parseInt(o,10);return s.forEach((u,l)=>i[u]=c+l),i},{});for(let[i,n]of Object.entries(r)){let a=_O.default.toByteArray(i);this.rankMap.set(a.join(","),n),this.textMap.set(n,a)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((i,[n,a])=>(i[a]=this.textEncoder.encode(n),i),{})}encode(e,t=[],r="all"){let i=new RegExp(this.patStr,"ug"),n=kw.specialTokenRegex(Object.keys(this.specialTokens)),a=[],o=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!o.has(u)):r);if(s.size>0){let u=kw.specialTokenRegex([...s]),l=e.match(u);if(l!=null)throw new Error(`The text contains a special token that is not allowed: ${l[0]}`)}let c=0;for(;;){let u=null,l=c;for(;n.lastIndex=l,u=n.exec(e),!(u==null||o.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let p of e.substring(c,d).matchAll(i)){let m=this.textEncoder.encode(p[0]),g=this.rankMap.get(m.join(","));if(g!=null){a.push(g);continue}a.push(...B6(m,this.rankMap))}if(u==null)break;let f=this.specialTokens[u[0]];a.push(f),c=u.index+u[0].length}return a}decode(e){let t=[],r=0;for(let a=0;a<e.length;++a){let o=e[a],s=this.textMap.get(o)??this.inverseSpecialTokens[o];s!=null&&(t.push(s),r+=s.length)}let i=new Uint8Array(r),n=0;for(let a of t)i.set(a,n),n+=a.length;return this.textDecoder.decode(i)}},Cp=kw;L6(Cp,"specialTokenRegex",e=>new RegExp(e.map(t=>V6(t)).join("|"),"g"));function $w(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var yO=A({encodingForModel:()=>Pp,getEncoding:()=>vO}),Op={},Z6=new ui({});async function vO(e){return e in Op||(Op[e]=Z6.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Cp(t)).catch(t=>{throw delete Op[e],t})),await Op[e]}async function Pp(e){return vO($w(e))}var bO=A({BaseLangChain:()=>Rp,BaseLanguageModel:()=>Au,calculateMaxTokens:()=>J6,getEmbeddingContextSize:()=>H6,getModelContextSize:()=>wO,getModelNameForTiktoken:()=>Np,isOpenAITool:()=>G6}),Np=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,H6=e=>e==="text-embedding-ada-002"?8191:2046,wO=e=>{switch(Np(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function G6(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}var J6=async({prompt:e,modelName:t})=>{let r;try{r=(await Pp(Np(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),r=Math.ceil(e.length/4)}return wO(t)-r},K6=()=>!1,Rp=class extends ae{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??K6(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.47")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Au=class extends Rp{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:i,...n}=r;super({callbacks:e??t,...n}),typeof i=="object"?this.cache=i:i?this.cache=Vh.global():this.cache=void 0,this.caller=new ui(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await Pp("modelName"in this?Np(this.modelName):"gpt2")}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Eu(e):Array.isArray(e)?new Tu(e.map(It)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([i,n])=>n!==void 0).map(([i,n])=>`${i}:${JSON.stringify(n)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}_filterInvocationParamsForTracing(e){let{tools:t,functions:r,messages:i,response_format:n,...a}=e;return a}};var yi=class extends ae{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,t){let r=we(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){let r=we(t),i,n=!0;for await(let a of this._transformStreamWithConfig(e,o=>o,r))if(yield a,n)if(i===void 0)i=a;else try{i=$r(i,a)}catch{i=void 0,n=!1}this.func&&i!==void 0&&await this.func(i,r)}static assign(e){return new $u(new oa({steps:e}))}};var xO=class extends ae{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.invoke(i,we(t))}async batch(e,t,r){let i=e.map(l=>l.key),n=e.map(l=>l.input);if(i.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let a=i.map(l=>this.runnables[l]),o=this._getOptionsList(t??{},e.length),s=o[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,u=[];for(let l=0;l<n.length;l+=c){let d=n.slice(l,l+c).map((p,m)=>a[m].invoke(p,o[m])),f=await Promise.all(d);u.push(f)}return u.flat()}async stream(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.stream(i,t)}};var SO=class extends ae{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");let t=e.slice(0,-1).map(([i,n])=>[tt(i),tt(n)]),r=tt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let i;for(let n=0;n<this.branches.length;n+=1){let[a,o]=this.branches[n];if(await a.invoke(e,$e(t,{callbacks:r?.getChild(`condition:${n+1}`)}))){i=await o.invoke(e,$e(t,{callbacks:r?.getChild(`branch:${n+1}`)}));break}}return i||(i=await this.default.invoke(e,$e(t,{callbacks:r?.getChild("branch:default")}))),i}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await jt(t))?.handleChainStart(this.toJSON(),pt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),i,n=!0,a;try{for(let o=0;o<this.branches.length;o+=1){let[s,c]=this.branches[o];if(await s.invoke(e,$e(t,{callbacks:r?.getChild(`condition:${o+1}`)}))){a=await c.stream(e,$e(t,{callbacks:r?.getChild(`branch:${o+1}`)}));for await(let u of a)if(yield u,n)if(i===void 0)i=u;else try{i=$r(i,u)}catch{i=void 0,n=!1}break}}if(a===void 0){a=await this.default.stream(e,$e(t,{callbacks:r?.getChild("branch:default")}));for await(let o of a)if(yield o,n)if(i===void 0)i=o;else try{i=$r(i,o)}catch{i=void 0,n=!1}}}catch(o){throw await r?.handleChainError(o),o}await r?.handleChainEnd(i??{})}};var kO=class extends Hr{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=Dt.from((a,o)=>this._enterHistory(a,o??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=yi.assign({[r]:t}).withConfig({runName:"insertHistory"}));let i=t.pipe(e.runnable.withListeners({onEnd:(a,o)=>this._exitHistory(a,o??{})})).withConfig({runName:"RunnableWithMessageHistory"}),n=e.config??{};super({...e,config:n,bound:i}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if(typeof e=="object"&&!Array.isArray(e)&&!We(e)){let r;this.inputMessagesKey?r=this.inputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="input",Array.isArray(e[r])&&Array.isArray(e[r][0])?t=e[r][0]:t=e[r]}else t=e;if(typeof t=="string")return[new rt(t)];if(Array.isArray(t))return t;if(We(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
246
|
+
Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!We(e)&&typeof e!="string"){let r;this.outputMessagesKey!==void 0?r=this.outputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[r]}else t=e;if(typeof t=="string")return[new Ee(t)];if(Array.isArray(t))return t;if(We(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){let r=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,t){let r=t.configurable?.messageHistory,i;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?i=e.inputs[0]:i=e.inputs;let n=this._getInputMessages(i);if(this.historyMessagesKey===void 0){let s=await r.getMessages();n=n.slice(s.length)}let a=e.outputs;if(!a)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let o=this._getOutputMessages(a);await r.addMessages([...n,...o])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let i={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
247
|
+
eg. chain.invoke(${JSON.stringify(i)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var $O=A({RouterRunnable:()=>xO,Runnable:()=>ae,RunnableAssign:()=>$u,RunnableBinding:()=>Hr,RunnableBranch:()=>SO,RunnableEach:()=>OC,RunnableLambda:()=>Dt,RunnableMap:()=>oa,RunnableParallel:()=>jC,RunnablePassthrough:()=>yi,RunnablePick:()=>uw,RunnableRetry:()=>kp,RunnableSequence:()=>Cr,RunnableToolLike:()=>Sp,RunnableWithFallbacks:()=>cw,RunnableWithMessageHistory:()=>kO,_coerceToRunnable:()=>tt,ensureConfig:()=>we,getCallbackManagerForConfig:()=>jt,mergeConfigs:()=>xt,patchConfig:()=>$e,pickRunnableConfigKeys:()=>or,raceWithSignal:()=>kr});var IO=A({applyPatch:()=>Fi,compare:()=>Bi});var Zs=class extends ae{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,i)=>this.parseResult([{text:r}],i?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,i)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],i?.callbacks),e,{...t,runType:"parser"})}},pn=class extends Zs{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}},Ut=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,i=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=i,i&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");ii(this,"OUTPUT_PARSING_FAILURE")}};var vi=class extends pn{async*_transform(e){for await(let t of e)typeof t=="string"?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}},Gn=class extends vi{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let i of e){if(typeof i!="string"&&typeof i.content!="string")throw new Error("Cannot handle non-string output.");let n;if(ai(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Vi({message:i,text:i.content})}else if(We(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Vi({message:Pa(i),text:i.content})}else n=new ci({text:i});r===void 0?r=n:r=r.concat(n);let a=await this.parsePartialResult([r]);a!=null&&!Vn(a,t)&&(this.diff?yield this._diff(t,a):yield a,t=a)}}getFormatInstructions(){return""}};var EO=class extends vi{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}};var Hs=class extends vi{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let i=[...t.matchAll(this.re)];if(i.length>1){let n=0;for(let a of i.slice(0,-1))yield[a[1]],n+=(a.index??0)+a[0].length;t=t.slice(n)}}else{let i=await this.parse(t);if(i.length>1){for(let n of i.slice(0,-1))yield[n];t=i[i.length-1]}}for(let r of await this.parse(t))yield[r]}},TO=class extends Hs{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(t=>t.trim())}catch{throw new Ut(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},AO=class extends Hs{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:t}){super(...arguments),this.length=e,this.separator=t||","}async parse(e){try{let t=e.trim().split(this.separator).map(r=>r.trim());if(this.length!==void 0&&t.length!==this.length)throw new Ut(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===Ut.prototype?t:new Ut(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},CO=class extends Hs{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:
|
|
248
|
+
|
|
249
|
+
1. foo
|
|
250
|
+
|
|
251
|
+
2. bar
|
|
252
|
+
|
|
253
|
+
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},OO=class extends Hs{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:
|
|
254
|
+
|
|
255
|
+
1. foo
|
|
256
|
+
|
|
257
|
+
2. bar
|
|
258
|
+
|
|
259
|
+
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var PO=class extends vi{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;case"reasoning":case"thinking":case"redacted_thinking":return"";default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((t,r)=>t+this._messageContentToString(r),"")}};var Mp=class extends Gn{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,t){return this.diff?super._concatOutputChunks(e,t):t}_diff(e,t){if(t)return e?Bi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Ea(e[0].text)}async parse(e){return Ea(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var jp=class extends pn{static lc_name(){return"StandardSchemaOutputParser"}lc_namespace=["langchain","output_parsers","standard_schema"];schema;constructor(e){super(),this.schema=e}static fromSerializableSchema(e){return new this(e)}async parse(e){try{let t=Ea(e,JSON.parse),r=await this.schema["~standard"].validate(t);if(r.issues)throw new Error(`Validation failed: ${JSON.stringify(r.issues)}`);return r.value}catch(t){throw new Ut(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var Cu=class extends pn{static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=St.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,St.string().describe(i)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
260
|
+
|
|
261
|
+
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
262
|
+
|
|
263
|
+
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
264
|
+
would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
|
|
265
|
+
Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
|
|
266
|
+
|
|
267
|
+
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
268
|
+
|
|
269
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
270
|
+
\`\`\`json
|
|
271
|
+
${JSON.stringify(yt(this.schema))}
|
|
272
|
+
\`\`\`
|
|
273
|
+
`}async parse(e){try{let t=e.trim(),r=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(i,n)=>`"${n.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await ta(this.schema,JSON.parse(r))}catch(t){throw new Ut(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},Iw=class extends Cu{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){let t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
|
|
274
|
+
\`\`\`json
|
|
275
|
+
${this._schemaToInstruction(yt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
|
|
276
|
+
\`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let i=!1,n;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(i=!0,r.type.splice(s,1)),n=r.type.join(" | ")}else n=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
|
|
277
|
+
${Object.entries(r.properties).map(([c,u])=>{let l=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
|
|
278
|
+
`)}
|
|
279
|
+
${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
|
|
280
|
+
${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
|
|
281
|
+
${" ".repeat(t-2)}] ${s}`}let a=i?" (nullable)":"",o=r.description?` // ${r.description}`:"";return`${n}${o}${a}`}if("anyOf"in r)return r.anyOf.map(i=>this._schemaToInstruction(i,t)).join(`
|
|
282
|
+
${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=St.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,St.string().describe(i)])));return new this(t)}},NO=class extends pn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new Iw(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new Ut(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var W6=function(){let e={};e.parser=function(_,h){return new r(_,h)},e.SAXParser=r,e.SAXStream=u,e.createStream=c,e.MAX_BUFFER_LENGTH=65536;let t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(_,h){if(!(this instanceof r))return new r(_,h);var O=this;n(O),O.q=O.c="",O.bufferCheckPosition=e.MAX_BUFFER_LENGTH,O.opt=h||{},O.opt.lowercase=O.opt.lowercase||O.opt.lowercasetags,O.looseCase=O.opt.lowercase?"toLowerCase":"toUpperCase",O.tags=[],O.closed=O.closedRoot=O.sawRoot=!1,O.tag=O.error=null,O.strict=!!_,O.noscript=!!(_||O.opt.noscript),O.state=v.BEGIN,O.strictEntities=O.opt.strictEntities,O.ENTITIES=O.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),O.attribList=[],O.opt.xmlns&&(O.ns=Object.create(m)),O.trackPosition=O.opt.position!==!1,O.trackPosition&&(O.position=O.line=O.column=0),F(O,"onready")}Object.create||(Object.create=function(_){function h(){}return h.prototype=_,new h}),Object.keys||(Object.keys=function(_){var h=[];for(var O in _)_.hasOwnProperty(O)&&h.push(O);return h});function i(_){for(var h=Math.max(e.MAX_BUFFER_LENGTH,10),O=0,$=0,ke=t.length;$<ke;$++){var Me=_[t[$]].length;if(Me>h)switch(t[$]){case"textNode":B(_);break;case"cdata":T(_,"oncdata",_.cdata),_.cdata="";break;case"script":T(_,"onscript",_.script),_.script="";break;default:ne(_,"Max buffer length exceeded: "+t[$])}O=Math.max(O,Me)}_.bufferCheckPosition=e.MAX_BUFFER_LENGTH-O+_.position}function n(_){for(var h=0,O=t.length;h<O;h++)_[t[h]]=""}function a(_){B(_),_.cdata!==""&&(T(_,"oncdata",_.cdata),_.cdata=""),_.script!==""&&(T(_,"onscript",_.script),_.script="")}r.prototype={end:function(){Oe(this)},write:Xr,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o=ReadableStream;o||(o=function(){});var s=e.EVENTS.filter(function(_){return _!=="error"&&_!=="end"});function c(_,h){return new u(_,h)}function u(_,h){if(!(this instanceof u))return new u(_,h);o.apply(this),this._parser=new r(_,h),this.writable=!0,this.readable=!0;var O=this;this._parser.onend=function(){O.emit("end")},this._parser.onerror=function($){O.emit("error",$),O._parser.error=null},this._decoder=null,s.forEach(function($){Object.defineProperty(O,"on"+$,{get:function(){return O._parser["on"+$]},set:function(ke){if(!ke)return O.removeAllListeners($),O._parser["on"+$]=ke,ke;O.on($,ke)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(o.prototype,{constructor:{value:u}}),u.prototype.write=function(_){return this._parser.write(_.toString()),this.emit("data",_),!0},u.prototype.end=function(_){return _&&_.length&&this.write(_),this._parser.end(),!0},u.prototype.on=function(_,h){var O=this;return!O._parser["on"+_]&&s.indexOf(_)!==-1&&(O._parser["on"+_]=function(){var $=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);$.splice(0,0,_),O.emit.apply(O,$)}),o.prototype.on.call(O,_,h)};var l="[CDATA[",d="DOCTYPE",f="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",m={xml:f,xmlns:p},g=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(_){return _===" "||_===`
|
|
283
|
+
`||_==="\r"||_===" "}function k(_){return _==='"'||_==="'"}function E(_){return _===">"||x(_)}function V(_,h){return _.test(h)}function C(_,h){return!V(_,h)}var v=0;e.STATE={BEGIN:v++,BEGIN_WHITESPACE:v++,TEXT:v++,TEXT_ENTITY:v++,OPEN_WAKA:v++,SGML_DECL:v++,SGML_DECL_QUOTED:v++,DOCTYPE:v++,DOCTYPE_QUOTED:v++,DOCTYPE_DTD:v++,DOCTYPE_DTD_QUOTED:v++,COMMENT_STARTING:v++,COMMENT:v++,COMMENT_ENDING:v++,COMMENT_ENDED:v++,CDATA:v++,CDATA_ENDING:v++,CDATA_ENDING_2:v++,PROC_INST:v++,PROC_INST_BODY:v++,PROC_INST_ENDING:v++,OPEN_TAG:v++,OPEN_TAG_SLASH:v++,ATTRIB:v++,ATTRIB_NAME:v++,ATTRIB_NAME_SAW_WHITE:v++,ATTRIB_VALUE:v++,ATTRIB_VALUE_QUOTED:v++,ATTRIB_VALUE_CLOSED:v++,ATTRIB_VALUE_UNQUOTED:v++,ATTRIB_VALUE_ENTITY_Q:v++,ATTRIB_VALUE_ENTITY_U:v++,CLOSE_TAG:v++,CLOSE_TAG_SAW_WHITE:v++,SCRIPT:v++,SCRIPT_ENDING:v++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(_){var h=e.ENTITIES[_],O=typeof h=="number"?String.fromCharCode(h):h;e.ENTITIES[_]=O});for(var W in e.STATE)e.STATE[e.STATE[W]]=W;v=e.STATE;function F(_,h,O){_[h]&&_[h](O)}function T(_,h,O){_.textNode&&B(_),F(_,h,O)}function B(_){_.textNode=Z(_.opt,_.textNode),_.textNode&&F(_,"ontext",_.textNode),_.textNode=""}function Z(_,h){return _.trim&&(h=h.trim()),_.normalize&&(h=h.replace(/\s+/g," ")),h}function ne(_,h){return B(_),_.trackPosition&&(h+=`
|
|
284
|
+
Line: `+_.line+`
|
|
285
|
+
Column: `+_.column+`
|
|
286
|
+
Char: `+_.c),h=new Error(h),_.error=h,F(_,"onerror",h),_}function Oe(_){return _.sawRoot&&!_.closedRoot&&ge(_,"Unclosed root tag"),_.state!==v.BEGIN&&_.state!==v.BEGIN_WHITESPACE&&_.state!==v.TEXT&&ne(_,"Unexpected end"),B(_),_.c="",_.closed=!0,F(_,"onend"),r.call(_,_.strict,_.opt),_}function ge(_,h){if(typeof _!="object"||!(_ instanceof r))throw new Error("bad call to strictFail");_.strict&&ne(_,h)}function Sn(_){_.strict||(_.tagName=_.tagName[_.looseCase]());var h=_.tags[_.tags.length-1]||_,O=_.tag={name:_.tagName,attributes:{}};_.opt.xmlns&&(O.ns=h.ns),_.attribList.length=0,T(_,"onopentagstart",O)}function Pr(_,h){var O=_.indexOf(":")<0?["",_]:_.split(":"),$=O[0],ke=O[1];return h&&_==="xmlns"&&($="xmlns",ke=""),{prefix:$,local:ke}}function _a(_){if(_.strict||(_.attribName=_.attribName[_.looseCase]()),_.attribList.indexOf(_.attribName)!==-1||_.tag.attributes.hasOwnProperty(_.attribName)){_.attribName=_.attribValue="";return}if(_.opt.xmlns){var h=Pr(_.attribName,!0),O=h.prefix,$=h.local;if(O==="xmlns")if($==="xml"&&_.attribValue!==f)ge(_,"xml: prefix must be bound to "+f+`
|
|
287
|
+
Actual: `+_.attribValue);else if($==="xmlns"&&_.attribValue!==p)ge(_,"xmlns: prefix must be bound to "+p+`
|
|
288
|
+
Actual: `+_.attribValue);else{var ke=_.tag,Me=_.tags[_.tags.length-1]||_;ke.ns===Me.ns&&(ke.ns=Object.create(Me.ns)),ke.ns[$]=_.attribValue}_.attribList.push([_.attribName,_.attribValue])}else _.tag.attributes[_.attribName]=_.attribValue,T(_,"onattribute",{name:_.attribName,value:_.attribValue});_.attribName=_.attribValue=""}function qr(_,h){if(_.opt.xmlns){var O=_.tag,$=Pr(_.tagName);O.prefix=$.prefix,O.local=$.local,O.uri=O.ns[$.prefix]||"",O.prefix&&!O.uri&&(ge(_,"Unbound namespace prefix: "+JSON.stringify(_.tagName)),O.uri=$.prefix);var ke=_.tags[_.tags.length-1]||_;O.ns&&ke.ns!==O.ns&&Object.keys(O.ns).forEach(function(ya){T(_,"onopennamespace",{prefix:ya,uri:O.ns[ya]})});for(var Me=0,mt=_.attribList.length;Me<mt;Me++){var st=_.attribList[Me],Ot=st[0],Nr=st[1],ct=Pr(Ot,!0),kn=ct.prefix,No=ct.local,kl=kn===""?"":O.ns[kn]||"",q={name:Ot,value:Nr,prefix:kn,local:No,uri:kl};kn&&kn!=="xmlns"&&!kl&&(ge(_,"Unbound namespace prefix: "+JSON.stringify(kn)),q.uri=kn),_.tag.attributes[Ot]=q,T(_,"onattribute",q)}_.attribList.length=0}_.tag.isSelfClosing=!!h,_.sawRoot=!0,_.tags.push(_.tag),T(_,"onopentag",_.tag),h||(!_.noscript&&_.tagName.toLowerCase()==="script"?_.state=v.SCRIPT:_.state=v.TEXT,_.tag=null,_.tagName=""),_.attribName=_.attribValue="",_.attribList.length=0}function ei(_){if(!_.tagName){ge(_,"Weird empty close tag."),_.textNode+="</>",_.state=v.TEXT;return}if(_.script){if(_.tagName!=="script"){_.script+="</"+_.tagName+">",_.tagName="",_.state=v.SCRIPT;return}T(_,"onscript",_.script),_.script=""}var h=_.tags.length,O=_.tagName;_.strict||(O=O[_.looseCase]());for(var $=O;h--&&_.tags[h].name!==$;)ge(_,"Unexpected close tag");if(h<0){ge(_,"Unmatched closing tag: "+_.tagName),_.textNode+="</"+_.tagName+">",_.state=v.TEXT;return}_.tagName=O;for(var ke=_.tags.length;ke-- >h;){var Me=_.tag=_.tags.pop();_.tagName=_.tag.name,T(_,"onclosetag",_.tagName);var mt={};for(var st in Me.ns)mt[st]=Me.ns[st];var Ot=_.tags[_.tags.length-1]||_;_.opt.xmlns&&Me.ns!==Ot.ns&&Object.keys(Me.ns).forEach(function(Nr){var ct=Me.ns[Nr];T(_,"onclosenamespace",{prefix:Nr,uri:ct})})}h===0&&(_.closedRoot=!0),_.tagName=_.attribValue=_.attribName="",_.attribList.length=0,_.state=v.TEXT}function _c(_){var h=_.entity,O=h.toLowerCase(),$,ke="";return _.ENTITIES[h]?_.ENTITIES[h]:_.ENTITIES[O]?_.ENTITIES[O]:(h=O,h.charAt(0)==="#"&&(h.charAt(1)==="x"?(h=h.slice(2),$=parseInt(h,16),ke=$.toString(16)):(h=h.slice(1),$=parseInt(h,10),ke=$.toString(10))),h=h.replace(/^0+/,""),isNaN($)||ke.toLowerCase()!==h?(ge(_,"Invalid character entity"),"&"+_.entity+";"):String.fromCodePoint($))}function yc(_,h){h==="<"?(_.state=v.OPEN_WAKA,_.startTagPosition=_.position):x(h)||(ge(_,"Non-whitespace before first tag."),_.textNode=h,_.state=v.TEXT)}function vc(_,h){var O="";return h<_.length&&(O=_.charAt(h)),O}function Xr(_){var h=this;if(this.error)throw this.error;if(h.closed)return ne(h,"Cannot write after close. Assign an onready handler.");if(_===null)return Oe(h);typeof _=="object"&&(_=_.toString());for(var O=0,$="";$=vc(_,O++),h.c=$,!!$;)switch(h.trackPosition&&(h.position++,$===`
|
|
289
|
+
`?(h.line++,h.column=0):h.column++),h.state){case v.BEGIN:if(h.state=v.BEGIN_WHITESPACE,$==="\uFEFF")continue;yc(h,$);continue;case v.BEGIN_WHITESPACE:yc(h,$);continue;case v.TEXT:if(h.sawRoot&&!h.closedRoot){for(var ke=O-1;$&&$!=="<"&&$!=="&";)$=vc(_,O++),$&&h.trackPosition&&(h.position++,$===`
|
|
290
|
+
`?(h.line++,h.column=0):h.column++);h.textNode+=_.substring(ke,O-1)}$==="<"&&!(h.sawRoot&&h.closedRoot&&!h.strict)?(h.state=v.OPEN_WAKA,h.startTagPosition=h.position):(!x($)&&(!h.sawRoot||h.closedRoot)&&ge(h,"Text data outside of root node."),$==="&"?h.state=v.TEXT_ENTITY:h.textNode+=$);continue;case v.SCRIPT:$==="<"?h.state=v.SCRIPT_ENDING:h.script+=$;continue;case v.SCRIPT_ENDING:$==="/"?h.state=v.CLOSE_TAG:(h.script+="<"+$,h.state=v.SCRIPT);continue;case v.OPEN_WAKA:if($==="!")h.state=v.SGML_DECL,h.sgmlDecl="";else if(!x($))if(V(g,$))h.state=v.OPEN_TAG,h.tagName=$;else if($==="/")h.state=v.CLOSE_TAG,h.tagName="";else if($==="?")h.state=v.PROC_INST,h.procInstName=h.procInstBody="";else{if(ge(h,"Unencoded <"),h.startTagPosition+1<h.position){var Me=h.position-h.startTagPosition;$=new Array(Me).join(" ")+$}h.textNode+="<"+$,h.state=v.TEXT}continue;case v.SGML_DECL:(h.sgmlDecl+$).toUpperCase()===l?(T(h,"onopencdata"),h.state=v.CDATA,h.sgmlDecl="",h.cdata=""):h.sgmlDecl+$==="--"?(h.state=v.COMMENT,h.comment="",h.sgmlDecl=""):(h.sgmlDecl+$).toUpperCase()===d?(h.state=v.DOCTYPE,(h.doctype||h.sawRoot)&&ge(h,"Inappropriately located doctype declaration"),h.doctype="",h.sgmlDecl=""):$===">"?(T(h,"onsgmldeclaration",h.sgmlDecl),h.sgmlDecl="",h.state=v.TEXT):(k($)&&(h.state=v.SGML_DECL_QUOTED),h.sgmlDecl+=$);continue;case v.SGML_DECL_QUOTED:$===h.q&&(h.state=v.SGML_DECL,h.q=""),h.sgmlDecl+=$;continue;case v.DOCTYPE:$===">"?(h.state=v.TEXT,T(h,"ondoctype",h.doctype),h.doctype=!0):(h.doctype+=$,$==="["?h.state=v.DOCTYPE_DTD:k($)&&(h.state=v.DOCTYPE_QUOTED,h.q=$));continue;case v.DOCTYPE_QUOTED:h.doctype+=$,$===h.q&&(h.q="",h.state=v.DOCTYPE);continue;case v.DOCTYPE_DTD:h.doctype+=$,$==="]"?h.state=v.DOCTYPE:k($)&&(h.state=v.DOCTYPE_DTD_QUOTED,h.q=$);continue;case v.DOCTYPE_DTD_QUOTED:h.doctype+=$,$===h.q&&(h.state=v.DOCTYPE_DTD,h.q="");continue;case v.COMMENT:$==="-"?h.state=v.COMMENT_ENDING:h.comment+=$;continue;case v.COMMENT_ENDING:$==="-"?(h.state=v.COMMENT_ENDED,h.comment=Z(h.opt,h.comment),h.comment&&T(h,"oncomment",h.comment),h.comment=""):(h.comment+="-"+$,h.state=v.COMMENT);continue;case v.COMMENT_ENDED:$!==">"?(ge(h,"Malformed comment"),h.comment+="--"+$,h.state=v.COMMENT):h.state=v.TEXT;continue;case v.CDATA:$==="]"?h.state=v.CDATA_ENDING:h.cdata+=$;continue;case v.CDATA_ENDING:$==="]"?h.state=v.CDATA_ENDING_2:(h.cdata+="]"+$,h.state=v.CDATA);continue;case v.CDATA_ENDING_2:$===">"?(h.cdata&&T(h,"oncdata",h.cdata),T(h,"onclosecdata"),h.cdata="",h.state=v.TEXT):$==="]"?h.cdata+="]":(h.cdata+="]]"+$,h.state=v.CDATA);continue;case v.PROC_INST:$==="?"?h.state=v.PROC_INST_ENDING:x($)?h.state=v.PROC_INST_BODY:h.procInstName+=$;continue;case v.PROC_INST_BODY:if(!h.procInstBody&&x($))continue;$==="?"?h.state=v.PROC_INST_ENDING:h.procInstBody+=$;continue;case v.PROC_INST_ENDING:$===">"?(T(h,"onprocessinginstruction",{name:h.procInstName,body:h.procInstBody}),h.procInstName=h.procInstBody="",h.state=v.TEXT):(h.procInstBody+="?"+$,h.state=v.PROC_INST_BODY);continue;case v.OPEN_TAG:V(y,$)?h.tagName+=$:(Sn(h),$===">"?qr(h):$==="/"?h.state=v.OPEN_TAG_SLASH:(x($)||ge(h,"Invalid character in tag name"),h.state=v.ATTRIB));continue;case v.OPEN_TAG_SLASH:$===">"?(qr(h,!0),ei(h)):(ge(h,"Forward-slash in opening tag not followed by >"),h.state=v.ATTRIB);continue;case v.ATTRIB:if(x($))continue;$===">"?qr(h):$==="/"?h.state=v.OPEN_TAG_SLASH:V(g,$)?(h.attribName=$,h.attribValue="",h.state=v.ATTRIB_NAME):ge(h,"Invalid attribute name");continue;case v.ATTRIB_NAME:$==="="?h.state=v.ATTRIB_VALUE:$===">"?(ge(h,"Attribute without value"),h.attribValue=h.attribName,_a(h),qr(h)):x($)?h.state=v.ATTRIB_NAME_SAW_WHITE:V(y,$)?h.attribName+=$:ge(h,"Invalid attribute name");continue;case v.ATTRIB_NAME_SAW_WHITE:if($==="=")h.state=v.ATTRIB_VALUE;else{if(x($))continue;ge(h,"Attribute without value"),h.tag.attributes[h.attribName]="",h.attribValue="",T(h,"onattribute",{name:h.attribName,value:""}),h.attribName="",$===">"?qr(h):V(g,$)?(h.attribName=$,h.state=v.ATTRIB_NAME):(ge(h,"Invalid attribute name"),h.state=v.ATTRIB)}continue;case v.ATTRIB_VALUE:if(x($))continue;k($)?(h.q=$,h.state=v.ATTRIB_VALUE_QUOTED):(ge(h,"Unquoted attribute value"),h.state=v.ATTRIB_VALUE_UNQUOTED,h.attribValue=$);continue;case v.ATTRIB_VALUE_QUOTED:if($!==h.q){$==="&"?h.state=v.ATTRIB_VALUE_ENTITY_Q:h.attribValue+=$;continue}_a(h),h.q="",h.state=v.ATTRIB_VALUE_CLOSED;continue;case v.ATTRIB_VALUE_CLOSED:x($)?h.state=v.ATTRIB:$===">"?qr(h):$==="/"?h.state=v.OPEN_TAG_SLASH:V(g,$)?(ge(h,"No whitespace between attributes"),h.attribName=$,h.attribValue="",h.state=v.ATTRIB_NAME):ge(h,"Invalid attribute name");continue;case v.ATTRIB_VALUE_UNQUOTED:if(!E($)){$==="&"?h.state=v.ATTRIB_VALUE_ENTITY_U:h.attribValue+=$;continue}_a(h),$===">"?qr(h):h.state=v.ATTRIB;continue;case v.CLOSE_TAG:if(h.tagName)$===">"?ei(h):V(y,$)?h.tagName+=$:h.script?(h.script+="</"+h.tagName,h.tagName="",h.state=v.SCRIPT):(x($)||ge(h,"Invalid tagname in closing tag"),h.state=v.CLOSE_TAG_SAW_WHITE);else{if(x($))continue;C(g,$)?h.script?(h.script+="</"+$,h.state=v.SCRIPT):ge(h,"Invalid tagname in closing tag."):h.tagName=$}continue;case v.CLOSE_TAG_SAW_WHITE:if(x($))continue;$===">"?ei(h):ge(h,"Invalid characters in closing tag");continue;case v.TEXT_ENTITY:case v.ATTRIB_VALUE_ENTITY_Q:case v.ATTRIB_VALUE_ENTITY_U:var mt,st;switch(h.state){case v.TEXT_ENTITY:mt=v.TEXT,st="textNode";break;case v.ATTRIB_VALUE_ENTITY_Q:mt=v.ATTRIB_VALUE_QUOTED,st="attribValue";break;case v.ATTRIB_VALUE_ENTITY_U:mt=v.ATTRIB_VALUE_UNQUOTED,st="attribValue";break}if($===";")if(h.opt.unparsedEntities){var Ot=_c(h);h.entity="",h.state=mt,h.write(Ot)}else h[st]+=_c(h),h.entity="",h.state=mt;else V(h.entity.length?w:b,$)?h.entity+=$:(ge(h,"Invalid character in entity name"),h[st]+="&"+h.entity+$,h.entity="",h.state=mt);continue;default:throw new Error(h,"Unknown state: "+h.state)}return h.position>=h.bufferCheckPosition&&i(h),h}return String.fromCodePoint||(function(){var _=String.fromCharCode,h=Math.floor,O=function(){var $=16384,ke=[],Me,mt,st=-1,Ot=arguments.length;if(!Ot)return"";for(var Nr="";++st<Ot;){var ct=Number(arguments[st]);if(!isFinite(ct)||ct<0||ct>1114111||h(ct)!==ct)throw RangeError("Invalid code point: "+ct);ct<=65535?ke.push(ct):(ct-=65536,Me=(ct>>10)+55296,mt=ct%1024+56320,ke.push(Me,mt)),(st+1===Ot||ke.length>$)&&(Nr+=_.apply(null,ke),ke.length=0)}return Nr};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:O,configurable:!0,writable:!0}):String.fromCodePoint=O})(),e},RO=W6();var zp=`The output should be formatted as a XML file.
|
|
291
|
+
1. Output should conform to the tags below.
|
|
292
|
+
2. If tags are not given, make them on your own.
|
|
293
|
+
3. Remember to always open and close all the tags.
|
|
294
|
+
|
|
295
|
+
As an example, for the tags ["foo", "bar", "baz"]:
|
|
296
|
+
1. String "<foo>
|
|
297
|
+
<bar>
|
|
298
|
+
<baz></baz>
|
|
299
|
+
</bar>
|
|
300
|
+
</foo>" is a well-formatted instance of the schema.
|
|
301
|
+
2. String "<foo>
|
|
302
|
+
<bar>
|
|
303
|
+
</foo>" is a badly-formatted instance.
|
|
304
|
+
3. String "<foo>
|
|
305
|
+
<tag>
|
|
306
|
+
</tag>
|
|
307
|
+
</foo>" is a badly-formatted instance.
|
|
308
|
+
|
|
309
|
+
Here are the output tags:
|
|
310
|
+
\`\`\`
|
|
311
|
+
{tags}
|
|
312
|
+
\`\`\``,MO=class extends Gn{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,t){if(t)return e?Bi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Dp(e[0].text)}async parse(e){return Dp(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?zp.replace("{tags}",this.tags?.join(", ")??""):zp}},q6=e=>e.split(`
|
|
313
|
+
`).map(t=>t.replace(/^\s+/,"")).join(`
|
|
314
|
+
`).trim(),jO=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(jO),t):(t[e.name]=e.text??void 0,t)};function Dp(e){let t=q6(e),r=RO.parser(!0),i={},n=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};n.length>0?n[n.length-1].children.push(c):i=c,s.isSelfClosing||n.push(c)},r.onclosetag=()=>{if(n.length>0){let s=n.pop();n.length===0&&s&&(i=s)}},r.ontext=s=>{if(n.length>0){let c=n[n.length-1];c.text+=s}},r.onattribute=s=>{if(n.length>0){let c=n[n.length-1];c.attributes[s.name]=s.value}};let a=/```(xml)?(.*)```/s.exec(t),o=a?a[2]:t;return r.write(o).close(),i&&i.name==="?xml"&&(i=i.children[0]),jO(i)}var zO=A({AsymmetricStructuredOutputParser:()=>NO,BaseCumulativeTransformOutputParser:()=>Gn,BaseLLMOutputParser:()=>Zs,BaseOutputParser:()=>pn,BaseTransformOutputParser:()=>vi,BytesOutputParser:()=>EO,CommaSeparatedListOutputParser:()=>TO,CustomListOutputParser:()=>AO,JsonMarkdownStructuredOutputParser:()=>Iw,JsonOutputParser:()=>Mp,ListOutputParser:()=>Hs,MarkdownListOutputParser:()=>OO,NumberedListOutputParser:()=>CO,OutputParserException:()=>Ut,StandardSchemaOutputParser:()=>jp,StringOutputParser:()=>PO,StructuredOutputParser:()=>Cu,XMLOutputParser:()=>MO,XML_FORMAT_INSTRUCTIONS:()=>zp,parseJsonMarkdown:()=>Ea,parsePartialJson:()=>Cn,parseXMLMarkdown:()=>Dp});var DO=A({extendInteropZodObject:()=>op,getInteropZodDefaultGetter:()=>sp,getInteropZodObjectShape:()=>no,getSchemaDescription:()=>pi,interopParse:()=>Os,interopParseAsync:()=>ta,interopSafeParse:()=>yA,interopSafeParseAsync:()=>ap,interopZodObjectMakeFieldsOptional:()=>bA,interopZodObjectPartial:()=>Ns,interopZodObjectPassthrough:()=>ip,interopZodObjectStrict:()=>Cs,interopZodTransformInputSchema:()=>cp,isInteropZodError:()=>up,isInteropZodLiteral:()=>_A,isInteropZodObject:()=>Yt,isInteropZodSchema:()=>ur,isShapelessZodSchema:()=>vA,isSimpleStringZodSchema:()=>Ps,isZodArrayV4:()=>yu,isZodLiteralV3:()=>Hb,isZodLiteralV4:()=>Gb,isZodNullableV4:()=>Kb,isZodObjectV3:()=>_u,isZodObjectV4:()=>Fr,isZodOptionalV4:()=>Jb,isZodSchema:()=>gA,isZodSchemaV3:()=>at,isZodSchemaV4:()=>Be});function Ew(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=Cn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(n){throw new Ut([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${n.message}`].join(`
|
|
315
|
+
`))}let i={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(i.id=e.id),i}function UO(e){if(e.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function LO(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var Tw=class extends Gn{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let r=e[0].message,i;if(Ko(r)&&r.tool_calls?.length?i=r.tool_calls.map(a=>{let{id:o,...s}=a;return this.returnId?{id:o,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(i=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(a=>Ew(a,{returnId:this.returnId,partial:t}))),!i)return[];let n=[];for(let a of i)if(a!==void 0){let o={type:a.name,args:a.args,id:a.id};n.push(o)}return n}},Up=class extends Tw{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,"zodSchema"in e&&(this.zodSchema=e.zodSchema),"serializableSchema"in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let r=await this.serializableSchema["~standard"].validate(e);if(r.issues)throw new Ut(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(r.issues)}`,JSON.stringify(e,null,2));return r.value}if(this.zodSchema===void 0)return e;let t=await ap(this.zodSchema,e);if(t.success)return t.data;throw new Ut(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(i=>this._validateResult(i)))}};var FO=A({assembleStructuredOutputPipeline:()=>Aw,createContentParser:()=>X6,createFunctionCallingParser:()=>Y6});function X6(e){return ur(e)?Cu.fromZodSchema(e):Ha(e)?jp.fromSerializableSchema(e):new Mp}function Y6(e,t,r){let i=r??Up;return ur(e)?new i({returnSingle:!0,keyName:t,zodSchema:e}):Ha(e)?new i({returnSingle:!0,keyName:t,serializableSchema:e}):new i({returnSingle:!0,keyName:t})}function Aw(e,t,r,i){if(!r){let c=e.pipe(t);return i?c.withConfig({runName:i}):c}let n=yi.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),a=yi.assign({parsed:()=>null}),o=n.withFallbacks({fallbacks:[a]}),s=Cr.from([{raw:e},o]);return i?s.withConfig({runName:i}):s}var VO=A({ChatModelStream:()=>sa,ReasoningContentStream:()=>GO,TextContentStream:()=>ZO,ToolCallsStream:()=>HO,UsageMetadataStream:()=>JO}),Q6=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let r of t)r()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let r of t)r()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function eF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Ou(e){if(e.event!=="content-block-delta")return;if("delta"in e&&e.delta)return e.delta;let t=e.content;if(t==null||typeof t!="object")return;let r=t;if(r.type==="text"&&typeof r.text=="string")return{type:"text-delta",text:r.text};if(r.type==="reasoning"&&typeof r.reasoning=="string")return{type:"reasoning-delta",reasoning:r.reasoning};if(r.type==="thinking"&&typeof r.thinking=="string")return{type:"reasoning-delta",reasoning:r.thinking};if(typeof r.data=="string")return{type:"data-delta",data:r.data,encoding:"base64"};if(typeof r.type=="string")return{type:"block-delta",fields:{...r,type:r.type}}}function BO(e){if(e==null||typeof e!="object")return;let t=e;if(t.type==="reasoning"&&typeof t.reasoning=="string")return t.reasoning;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking}function Lp(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function Gs(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function tF(e){if(e!=null&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function rF(e){let t=e;if(e.type==="tool_call"||e.type!=="tool_call_chunk"&&e.type!=="tool_use"&&e.type!=="input_json_delta")return e;let r=typeof t.name=="string"?t.name:void 0;if(r==null)return e;let i=t.args??t.input;return{...t,type:"tool_call",name:r,args:tF(i)}}var ZO=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="";for await(let r of e.iterate()){let i=Ou(r);i?.type==="text-delta"&&(t+=i.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let i=Ou(r);i?.type==="text-delta"&&(yield i.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},HO=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(t.push(r.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(yield r.content)}return t()}then(e,t){return(async()=>{let r=[];for await(let i of this)r.push(i);return r})().then(e,t)}},GO=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Lp(i.content)){if(r)return;continue}r=!0;let n=BO(i.content);if(n==null||n.length===0)continue;t+=n,yield t}else if(i.event==="content-block-delta"){let n=Ou(i);if(n?.type!=="reasoning-delta")continue;r=!0;let a=n.reasoning;if(a==null||a.length===0)continue;t+=a,yield t}else{if(i.event==="content-block-finish"&&Lp(i.content))return;if(i.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Lp(i.content)){if(r)return;continue}r=!0;let n=BO(i.content);n!=null&&n.length>0&&(yield n)}else if(i.event==="content-block-delta"){let n=Ou(i);if(n?.type!=="reasoning-delta")continue;r=!0;let a=n.reasoning;a!=null&&a.length>0&&(yield a)}else{if(i.event==="content-block-finish"&&Lp(i.content))return;if(i.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},JO=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())if(r.event==="usage"){let i=Gs(r.usage);i&&(yield i)}else if(r.event==="message-start"&&r.usage){let i=Gs(r.usage);i&&(yield i)}else if(r.event==="message-finish"&&r.usage){let i=Gs(r.usage);i&&(yield i)}}return t()}then(e,t){return(async()=>{let r;for await(let i of this)r=i;return r})().then(e,t)}},sa=class{_buffer;constructor(e){this._buffer=new Q6,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(t){this._buffer.setError(t instanceof Error?t:new Error(String(t)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new ZO(this._buffer)}get toolCalls(){return new HO(this._buffer)}get reasoning(){return new GO(this._buffer)}get usage(){return new JO(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,i={},n;for await(let o of this._buffer.iterate())switch(o.event){case"message-start":t=o.id??t,o.usage&&(r=Gs(o.usage));break;case"content-block-start":e[o.index]=o.content;break;case"content-block-delta":{let s=e[o.index],c=Ou(o);s&&c&&(e[o.index]=eF(s,c));break}case"content-block-finish":e[o.index]=o.content;break;case"usage":r=Gs(o.usage);break;case"message-finish":n=o.reason,o.usage&&(r=Gs(o.usage)),o.responseMetadata&&(i={...i,...o.responseMetadata});break;default:break}let a=e.filter(o=>o!=null).map(rF);return new Ee({id:t,content:a,usage_metadata:r,response_metadata:{...i,...n?{finish_reason:n}:{},output_version:"v1"}})}};var WO=A({convertChunksToEvents:()=>Cw,finalizeContentBlock:()=>XO}),nF={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},iF={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function KO(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function qO(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function aF(e){let t=qO(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let i of t){if(i==null||typeof i!="object")continue;let n=i;if(n.type!=="image_generation_call")continue;let a=typeof n.result=="string"?n.result:void 0,o=typeof n.url=="string"?n.url:void 0;if(a==null&&o==null)continue;let s=typeof n.output_format=="string"?n.output_format.toLowerCase():void 0,c=(s!=null?iF[s]:void 0)??"image/png";r.push({type:"image",...typeof n.id=="string"?{id:n.id}:{},...o!=null?{url:o}:{},...a!=null?{data:a}:{},mimeType:c})}return r}function oF(e){let t=qO(e).audio;if(t==null||typeof t!="object")return;let r=t,i=typeof r.data=="string"?r.data:void 0,n=typeof r.url=="string"?r.url:void 0,a=typeof r.transcript=="string"?r.transcript:void 0;if(i==null&&n==null&&a==null)return;let o=typeof r.mime_type=="string"?r.mime_type:typeof r.mimeType=="string"?r.mimeType:void 0,s=typeof r.format=="string"?r.format.toLowerCase():void 0,c=o??(s!=null?nF[s]:void 0)??(i!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...i!=null?{data:i}:{},...n!=null?{url:n}:{},...a!=null?{transcript:a}:{},mimeType:c}}async function*Cw(e,t){let r=new Map,i=!1,n,a,o=new Set;for await(let s of e){t?.signal?.throwIfAborted();let c=s.message,u=!1;if(!i){i=!0;let f={event:"message-start",id:c.id??void 0};Qe.isInstance(c)&&c.usage_metadata&&(f.usage=c.usage_metadata,n={...c.usage_metadata},u=!0),yield f}let l=c.content;if(typeof l=="string"){if(l!==""){if(!r.has(0)){let m={type:"text",text:""};r.set(0,{type:"text",accumulated:m}),yield{event:"content-block-start",index:0,content:m}}let p=r.get(0);p.accumulated={...p.accumulated,text:(p.accumulated.text??"")+l},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:l}}}}else if(Array.isArray(l))for(let f of l){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p))r.set(p,{type:f.type,accumulated:{...f}}),yield{event:"content-block-start",index:p,content:{...f}};else{let m=r.get(p),g=cF(f);m.accumulated=sF(m.accumulated,g),yield{event:"content-block-delta",index:p,delta:g}}}if(Qe.isInstance(c)&&c.tool_call_chunks&&c.tool_call_chunks.length>0)for(let f of c.tool_call_chunks){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p)){let g={type:"tool_call_chunk",id:f.id,name:f.name,args:"",index:p};r.set(p,{type:"tool_call_chunk",accumulated:g}),yield{event:"content-block-start",index:p,content:g}}let m=r.get(p).accumulated;f.id!=null&&(m.id=f.id),f.name!=null&&(m.name=f.name),m.args=(m.args??"")+(f.args??""),yield{event:"content-block-delta",index:p,delta:{type:"block-delta",fields:{type:"tool_call_chunk",..."id"in m&&m.id!=null?{id:m.id}:{},..."name"in m&&m.name!=null?{name:m.name}:{},args:m.args}}}}let d=oF(c);if(d!=null){if(a==null){let p=KO(r);a={index:p,id:d.id,mimeType:d.mimeType,transcript:""};let m={type:"audio",...d.id!=null?{id:d.id}:{},...d.url!=null?{url:d.url}:{},data:"",mimeType:d.mimeType};r.set(p,{type:"audio",accumulated:m}),yield{event:"content-block-start",index:p,content:m}}let f=r.get(a.index);if(f!=null){let p=f.accumulated;d.id!=null&&a.id==null&&(a.id=d.id,p.id=d.id),d.transcript!=null&&(a.transcript+=d.transcript,p.transcript=a.transcript,yield{event:"content-block-delta",index:a.index,delta:{type:"block-delta",fields:{type:"audio",transcript:a.transcript}}}),d.data!=null&&d.data.length>0&&(p.data=(p.data??"")+d.data,yield{event:"content-block-delta",index:a.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let f of aF(c)){let p=f,m=p.id??p.url??(p.data!=null?`${p.data.length}:${p.data.slice(0,32)}`:void 0);if(m!=null&&o.has(m))continue;m!=null&&o.add(m);let g=KO(r);r.set(g,{type:"image",accumulated:f}),yield{event:"content-block-start",index:g,content:f}}if(!u&&Qe.isInstance(c)&&c.usage_metadata){let f=c.usage_metadata;n?n={input_tokens:n.input_tokens+f.input_tokens,output_tokens:n.output_tokens+f.output_tokens,total_tokens:n.total_tokens+f.total_tokens}:n={...f},yield{event:"usage",usage:{...n}}}}for(let[s,c]of r)yield{event:"content-block-finish",index:s,content:XO(c.accumulated)};yield{event:"message-finish",reason:"stop",...n?{usage:n}:{}}}function sF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function cF(e){if(e.type==="text")return{type:"text-delta",text:e.text};if(e.type==="reasoning")return{type:"reasoning-delta",reasoning:e.reasoning};if(e.type==="thinking"&&typeof e.thinking=="string")return{type:"reasoning-delta",reasoning:e.thinking};if(typeof e.data=="string")return{type:"data-delta",data:e.data,encoding:"base64"};if(typeof e.type=="string")return{type:"block-delta",fields:{...e}};throw new Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function XO(e){if(e.type==="tool_call_chunk"){let t=e,r;try{r=JSON.parse(t.args??"{}")}catch{return{type:"invalid_tool_call",id:t.id,name:t.name,args:t.args,error:"Failed to parse tool call arguments as JSON"}}return{type:"tool_call",id:t.id,name:t.name,args:r}}return e}var YO=e=>e();function Pu(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var QO=A({BaseChatModel:()=>ca,SimpleChatModel:()=>uF});function Ow(e){let t=[];for(let r of e){let i=r;if(Array.isArray(r.content))for(let n=0;n<r.content.length;n++){let a=r.content[n];(Vo(a)||Zo(a))&&i===r&&(i=new r.constructor({...i,content:[...r.content.slice(0,n),Wl(a),...r.content.slice(n+1)]}))}t.push(i)}return t}var ca=class Jn extends Au{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=YO(()=>{let r=t.outputVersion??Ht("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async invoke(t,r){let i=Jn._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,i){yield*Cw(this._streamResponseChunks(t,r,i),{signal:r.signal})}streamV2(t,r){let i=Jn._convertInputToPromptValue(t).toChatMessages(),[,n]=this._separateRunnableConfigFromCallOptionsCompat(r);return new sa(this._streamChatModelEvents(i,n))}async*_streamIterator(t,r){if(this._streamResponseChunks===Jn.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let i=Jn._convertInputToPromptValue(t).toChatMessages(),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o={...n.metadata,...this.getLsParamsWithDefaults(a)},s=this.invocationParams(a),c=await et.configure(n.callbacks,this.callbacks,n.tags,this.tags,o,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:a,invocation_params:s,batch_size:1},l=a.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[Ow(i)],n.runId,void 0,u,void 0,void 0,n.runName),f,p;try{for await(let m of this._streamResponseChunks(i,a,d?.[0])){if(a.signal?.throwIfAborted(),m.message.id==null){let g=d?.at(0)?.runId;g!=null&&m.message._updateId(`run-${g}`)}m.message.response_metadata={...m.generationInfo,...m.message.response_metadata},l==="v1"?yield Pu(m.message):yield m.message,f?f=f.concat(m):f=m,Pc(m.message)&&m.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(g=>g?.handleLLMError(m))),m}await Promise.all((d??[]).map(m=>m?.handleLLMEnd({generations:[[f]],llmOutput:p})))}}getLsParams(t){let r=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:r}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,r,i,n){let a=t.map(p=>p.map(It)),o;if(n!==void 0&&n.length===a.length)o=n;else{let p={...i.metadata,...this.getLsParamsWithDefaults(r)},m=this.invocationParams(r),g=await et.configure(i.callbacks,this.callbacks,i.tags,this.tags,p,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),y={options:r,invocation_params:m,batch_size:1};o=await g?.handleChatModelStart(this.toJSON(),a.map(Ow),i.runId,void 0,y,void 0,void 0,i.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[],l=!!o?.[0].handlers.find(Gh),d=!!o?.[0].handlers.find(Mc);if(l&&!this.disableStreaming&&a.length===1&&(this._streamChatModelEvents!==Jn.prototype._streamChatModelEvents||this._streamResponseChunks!==Jn.prototype._streamResponseChunks))try{let p=!1,m=o?.[0],g=this._streamChatModelEvents(a[0],r),y=await new sa({async*[Symbol.asyncIterator](){for await(let x of g){r.signal?.throwIfAborted(),p=!0;let k=x.event==="message-start"&&x.id==null&&m?.runId!=null?{...x,id:`run-${m.runId}`}:x;await m?.handleChatModelStreamEvent(k),yield k}}});if(r.signal?.throwIfAborted(),!p)throw new Error("Received empty response from chat model call.");if(y.id==null){let x=o?.at(0)?.runId;x!=null&&y._updateId(`run-${x}`)}let b={text:y.text,message:y};c.push([b]);let w=y.usage_metadata!==void 0?{tokenUsage:{promptTokens:y.usage_metadata.input_tokens,completionTokens:y.usage_metadata.output_tokens,totalTokens:y.usage_metadata.total_tokens}}:void 0;await o?.[0].handleLLMEnd({generations:c,llmOutput:w})}catch(p){throw await o?.[0].handleLLMError(p),p}else if(d&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==Jn.prototype._streamResponseChunks)try{let p=await this._streamResponseChunks(a[0],r,o?.[0]),m,g;for await(let y of p){if(r.signal?.aborted){let b=m?.message;throw new Jl("Model invocation was aborted.",b)}if(y.message.id==null){let b=o?.at(0)?.runId;b!=null&&y.message._updateId(`run-${b}`)}m===void 0?m=y:m=$r(m,y),Pc(y.message)&&y.message.usage_metadata!==void 0&&(g={tokenUsage:{promptTokens:y.message.usage_metadata.input_tokens,completionTokens:y.message.usage_metadata.output_tokens,totalTokens:y.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let y=m?.message;throw new Jl("Model invocation was aborted.",y)}if(m===void 0)throw new Error("Received empty response from chat model call.");s==="v1"&&(m.message=Pu(m.message)),c.push([m]),await o?.[0].handleLLMEnd({generations:c,llmOutput:g})}catch(p){throw await o?.[0].handleLLMError(p),p}else{let p=await Promise.allSettled(a.map(async(m,g)=>{let y=await this._generate(m,{...r,promptIndex:g},o?.[g]);if(s==="v1")for(let b of y.generations)b.message=Pu(b.message);return y}));await Promise.all(p.map(async(m,g)=>{if(m.status==="fulfilled"){let y=m.value;for(let b of y.generations){if(b.message.id==null){let w=o?.at(0)?.runId;w!=null&&b.message._updateId(`run-${w}`)}b.message.response_metadata={...b.generationInfo,...b.message.response_metadata}}return y.generations.length===1&&(y.generations[0].message.response_metadata={...y.llmOutput,...y.generations[0].message.response_metadata}),c[g]=y.generations,u[g]=y.llmOutput,o?.[g]?.handleLLMEnd({generations:[y.generations],llmOutput:y.llmOutput})}else return await o?.[g]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let f={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(f,Za,{value:o?{runIds:o?.map(p=>p.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a}){let o=t.map(b=>b.map(It)),s={...a.metadata,...this.getLsParamsWithDefaults(n)},c=this.invocationParams(n),u=await et.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),l={options:n,invocation_params:c,batch_size:1},d=await u?.handleChatModelStart(this.toJSON(),o.map(Ow),a.runId,void 0,l,void 0,void 0,a.runName),f=[],p=(await Promise.allSettled(o.map(async(b,w)=>{let x=Jn._convertInputToPromptValue(b).toString(),k=await r.lookup(x,i);return k==null&&f.push(w),k}))).map((b,w)=>({result:b,runManager:d?.[w]})).filter(({result:b})=>b.status==="fulfilled"&&b.value!=null||b.status==="rejected"),m=n.outputVersion??this.outputVersion,g=[];await Promise.all(p.map(async({result:b,runManager:w},x)=>{if(b.status==="fulfilled"){let k=b.value;return g[x]=k.map(E=>("message"in E&&We(E.message)&&Ko(E.message)&&(E.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&(E.message=Pu(E.message))),E.generationInfo={...E.generationInfo,tokenUsage:{}},E)),k.length&&await w?.handleLLMNewToken(k[0].text),w?.handleLLMEnd({generations:[k]},void 0,void 0,void 0,{cached:!0})}else return await w?.handleLLMError(b.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(b.reason)}));let y={generations:g,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(y,Za,{value:d?{runIds:d?.map(b=>b.runId)}:void 0,configurable:!0}),y}async generate(t,r,i){let n;Array.isArray(r)?n={stop:r}:n=r;let a=t.map(m=>m.map(It)),[o,s]=this._separateRunnableConfigFromCallOptionsCompat(n);if(o.callbacks=o.callbacks??i,!this.cache)return this._generateUncached(a,s,o);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(s),{generations:l,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:a,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:o}),p={};if(d.length>0){let m=await this._generateUncached(d.map(g=>a[g]),s,o,f!==void 0?d.map(g=>f?.[g]):void 0);await Promise.all(m.generations.map(async(g,y)=>{let b=d[y];l[b]=g;let w=Jn._convertInputToPromptValue(a[b]).toString();return c.update(w,u,g)})),p=m.llmOutput??{}}return{generations:l,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,i){let n=t.map(a=>a.toChatMessages());return this.generate(n,r,i)}withStructuredOutput(t,r){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(r?.strict)throw new Error('"strict" mode is not supported for this model by default.');let i=t,n=r?.name,a=pi(i)??"A function available to call.",o=r?.method,s=r?.includeRaw;if(o==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=n??"extract";!ur(i)&&!Ha(i)&&"name"in i&&(c=i.name);let u=ur(i)||Ha(i)?yt(i):i,l=[{type:"function",function:{name:c,description:a,parameters:u}}];return Aw(this.bindTools(l),Dt.from(d=>{if(!Qe.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let f=d.tool_calls.find(p=>p.name===c);if(!f)throw new Error(`No tool call found with name ${c}.`);return f.args}),s,s?"StructuredOutputRunnable":"StructuredOutput")}},uF=class extends ca{async _generate(e,t,r){let i=new Ee(await this._call(e,t,r));if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}};var eP=A({});var tP=A({BaseLLM:()=>rP,LLM:()=>Fp}),rP=class Nu extends Au{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let i=Nu._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async*_streamIterator(t,r){if(this._streamResponseChunks===Nu.prototype._streamResponseChunks)yield this.invoke(t,r);else{let i=Nu._convertInputToPromptValue(t),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o=this.invocationParams(a),s=await et.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(o)}),c={options:a,invocation_params:o,batch_size:1},u=await s?.handleLLMStart(this.toJSON(),[i.toString()],n.runId,void 0,c,void 0,void 0,n.runName),l=new ci({text:""});try{for await(let d of this._streamResponseChunks(i.toString(),a,u?.[0]))l?l=l.concat(d):l=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((u??[]).map(f=>f?.handleLLMError(d))),d}await Promise.all((u??[]).map(d=>d?.handleLLMEnd({generations:[[l]]})))}}async generatePrompt(t,r,i){let n=t.map(a=>a.toString());return this.generate(n,r,i)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let i=0;i<t.generations.length;i+=1){let n=t.generations[i];if(i===0)r.push({generations:[n],llmOutput:t.llmOutput});else{let a=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[n],llmOutput:a})}}return r}async _generateUncached(t,r,i,n){let a;if(n!==void 0&&n.length===t.length)a=n;else{let u=this.invocationParams(r),l=await et.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(u)}),d={options:r,invocation_params:u,batch_size:t.length};a=await l?.handleLLMStart(this.toJSON(),t,i.runId,void 0,d,void 0,void 0,i?.runName)}let o=!!a?.[0].handlers.find(Mc),s;if(o&&t.length===1&&this._streamResponseChunks!==Nu.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,a?.[0]),l;for await(let d of u)l===void 0?l=d:l=$r(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[l]],llmOutput:{}},await a?.[0].handleLLMEnd(s)}catch(u){throw await a?.[0].handleLLMError(u),u}else{try{s=await this._generate(t,r,a?.[0])}catch(l){throw await Promise.all((a??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(s);await Promise.all((a??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=a?.map(u=>u.runId)||void 0;return Object.defineProperty(s,Za,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a,runId:o}){let s=this.invocationParams(n),c=await et.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:n,invocation_params:s,batch_size:t.length},l=await c?.handleLLMStart(this.toJSON(),t,o,void 0,u,void 0,void 0,a?.runName),d=[],f=(await Promise.allSettled(t.map(async(g,y)=>{let b=await r.lookup(g,i);return b==null&&d.push(y),b}))).map((g,y)=>({result:g,runManager:l?.[y]})).filter(({result:g})=>g.status==="fulfilled"&&g.value!=null||g.status==="rejected"),p=[];await Promise.all(f.map(async({result:g,runManager:y},b)=>{if(g.status==="fulfilled"){let w=g.value;return p[b]=w.map(x=>(x.generationInfo={...x.generationInfo,tokenUsage:{}},x)),w.length&&await y?.handleLLMNewToken(w[0].text),y?.handleLLMEnd({generations:[w]},void 0,void 0,void 0,{cached:!0})}else return await y?.handleLLMError(g.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(g.reason)}));let m={generations:p,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(m,Za,{value:l?{runIds:l?.map(g=>g.runId)}:void 0,configurable:!0}),m}async generate(t,r,i){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let n;Array.isArray(r)?n={stop:r}:n=r;let[a,o]=this._separateRunnableConfigFromCallOptionsCompat(n);if(a.callbacks=a.callbacks??i,!this.cache)return this._generateUncached(t,o,a);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(o),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:o,handledOptions:a,runId:a.runId}),f={};if(l.length>0){let p=await this._generateUncached(l.map(m=>t[m]),o,a,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,g)=>{let y=l[g];return u[y]=m,s.update(t[y],c,m)})),f=p.llmOutput??{}}return{generations:u,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},Fp=class extends rP{async _generate(e,t,r){return{generations:await Promise.all(e.map((i,n)=>this._call(i,{...t,promptIndex:n},r).then(a=>[{text:a}])))}}};var nP=A({});var iP=A({BaseMemory:()=>lF,getInputValue:()=>dF,getOutputValue:()=>fF,getPromptInputKey:()=>pF}),lF=class{},aP=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},dF=(e,t)=>{let r=aP(e,t);if(!r)throw new Error(`input values have ${Object.keys(e).length} keys, you must specify an input key or pass only 1 key as input`);return r},fF=(e,t)=>{let r=aP(e,t);if(!r&&r!=="")throw new Error(`output values have ${Object.keys(e).length} keys, you must specify an output key or pass only 1 key as output`);return r};function pF(e,t){let r=Object.keys(e).filter(i=>!t.includes(i)&&i!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var Pw=class extends Zs{static lc_name(){return"OutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;argsOnly=!0;constructor(e){super(),this.argsOnly=e?.argsOnly??this.argsOnly}async parseResult(e){if("message"in e[0]){let t=e[0].message.additional_kwargs.function_call;if(!t)throw new Error(`No function_call in message ${JSON.stringify(e)}`);if(!t.arguments)throw new Error(`No arguments in function_call ${JSON.stringify(e)}`);return this.argsOnly?t.arguments:JSON.stringify(t)}else throw new Error(`No message in generations ${JSON.stringify(e)}`)}},Nw=class extends Gn{static lc_name(){return"JsonOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser;argsOnly=!0;constructor(e){super(e),this.argsOnly=e?.argsOnly??this.argsOnly,this.outputParser=new Pw(e)}_diff(e,t){if(t)return Bi(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,i=r.additional_kwargs.function_call;if(i)return this.argsOnly?Cn(i.arguments):{...i,arguments:Cn(i.arguments)}}async parseResult(e){let t=await this.outputParser.parseResult(e);if(!t)throw new Error(`No result from "OutputFunctionsParser" ${JSON.stringify(e)}`);return this.parse(t)}async parse(e){let t=JSON.parse(e);return this.argsOnly||(t.arguments=JSON.parse(t.arguments)),t}getFormatInstructions(){return""}},oP=class extends Zs{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new Nw;attrName;get lc_aliases(){return{attrName:"key_name"}}constructor(e){super(e),this.attrName=e.attrName}async parseResult(e){return(await this.outputParser.parseResult(e))[this.attrName]}};var sP=A({JsonKeyOutputFunctionsParser:()=>oP,JsonOutputFunctionsParser:()=>Nw,OutputFunctionsParser:()=>Pw});var cP=A({JsonOutputKeyToolsParser:()=>Up,JsonOutputToolsParser:()=>Tw,convertLangChainToolCallToOpenAI:()=>UO,makeInvalidToolCall:()=>LO,parseToolCall:()=>Ew});var Kn=class extends ae{lc_serializable=!0;lc_namespace=["langchain_core","prompts",this._getPromptType()];get lc_attributes(){return{partialVariables:void 0}}inputVariables;outputParser;partialVariables;metadata;tags;constructor(e){super(e);let{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){let t=this.partialVariables??{},r={};for(let[i,n]of Object.entries(t))typeof n=="string"?r[i]=n:r[i]=await n();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},i=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(n=>this.formatPromptValue(n),e,{...t,tags:i,metadata:r,runType:"prompt"})}};var bi=class extends Kn{async formatPromptValue(e){return new Eu(await this.format(e))}};var mF=Object.prototype.toString,Ks=Array.isArray||function(t){return mF.call(t)==="[object Array]"};function Mw(e){return typeof e=="function"}function hF(e){return Ks(e)?"array":typeof e}function Rw(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function uP(e,t){return e!=null&&typeof e=="object"&&t in e}function gF(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var _F=RegExp.prototype.test;function yF(e,t){return _F.call(e,t)}var vF=/\S/;function bF(e){return!yF(vF,e)}var wF={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function xF(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return wF[r]})}var SF=/\s*/,kF=/\s+/,lP=/\s*=/,$F=/\s*\}/,IF=/#|\^|\/|>|\{|&|=|!/;function EF(e,t){if(!e)return[];var r=!1,i=[],n=[],a=[],o=!1,s=!1,c="",u=0;function l(){if(o&&!s)for(;a.length;)delete n[a.pop()];else a=[];o=!1,s=!1}var d,f,p;function m(v){if(typeof v=="string"&&(v=v.split(kF,2)),!Ks(v)||v.length!==2)throw new Error("Invalid tags: "+v);d=new RegExp(Rw(v[0])+"\\s*"),f=new RegExp("\\s*"+Rw(v[1])),p=new RegExp("\\s*"+Rw("}"+v[1]))}m(t||Jr.tags);for(var g=new Mu(e),y,b,w,x,k,E;!g.eos();){if(y=g.pos,w=g.scanUntil(d),w)for(var V=0,C=w.length;V<C;++V)x=w.charAt(V),bF(x)?(a.push(n.length),c+=x):(s=!0,r=!0,c+=" "),n.push(["text",x,y,y+1]),y+=1,x===`
|
|
316
|
+
`&&(l(),c="",u=0,r=!1);if(!g.scan(d))break;if(o=!0,b=g.scan(IF)||"name",g.scan(SF),b==="="?(w=g.scanUntil(lP),g.scan(lP),g.scanUntil(f)):b==="{"?(w=g.scanUntil(p),g.scan($F),g.scanUntil(f),b="&"):w=g.scanUntil(f),!g.scan(f))throw new Error("Unclosed tag at "+g.pos);if(b==">"?k=[b,w,y,g.pos,c,u,r]:k=[b,w,y,g.pos],u++,n.push(k),b==="#"||b==="^")i.push(k);else if(b==="/"){if(E=i.pop(),!E)throw new Error('Unopened section "'+w+'" at '+y);if(E[1]!==w)throw new Error('Unclosed section "'+E[1]+'" at '+y)}else b==="name"||b==="{"||b==="&"?s=!0:b==="="&&m(w)}if(l(),E=i.pop(),E)throw new Error('Unclosed section "'+E[1]+'" at '+g.pos);return AF(TF(n))}function TF(e){for(var t=[],r,i,n=0,a=e.length;n<a;++n)r=e[n],r&&(r[0]==="text"&&i&&i[0]==="text"?(i[1]+=r[1],i[3]=r[3]):(t.push(r),i=r));return t}function AF(e){for(var t=[],r=t,i=[],n,a,o=0,s=e.length;o<s;++o)switch(n=e[o],n[0]){case"#":case"^":r.push(n),i.push(n),r=n[4]=[];break;case"/":a=i.pop(),a[5]=n[2],r=i.length>0?i[i.length-1][4]:t;break;default:r.push(n)}return t}function Mu(e){this.string=e,this.tail=e,this.pos=0}Mu.prototype.eos=function(){return this.tail===""};Mu.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};Mu.prototype.scanUntil=function(t){var r=this.tail.search(t),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function Js(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Js.prototype.push=function(t){return new Js(t,this)};Js.prototype.lookup=function(t){var r=this.cache,i;if(r.hasOwnProperty(t))i=r[t];else{for(var n=this,a,o,s,c=!1;n;){if(t.indexOf(".")>0)for(a=n.view,o=t.split("."),s=0;a!=null&&s<o.length;)s===o.length-1&&(c=uP(a,o[s])||gF(a,o[s])),a=a[o[s++]];else a=n.view[t],c=uP(n.view,t);if(c){i=a;break}n=n.parent}r[t]=i}return Mw(i)&&(i=i.call(this.view)),i};function er(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}er.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};er.prototype.parse=function(t,r){var i=this.templateCache,n=t+":"+(r||Jr.tags).join(":"),a=typeof i<"u",o=a?i.get(n):void 0;return o==null&&(o=EF(t,r),a&&i.set(n,o)),o};er.prototype.render=function(t,r,i,n){var a=this.getConfigTags(n),o=this.parse(t,a),s=r instanceof Js?r:new Js(r,void 0);return this.renderTokens(o,s,i,t,n)};er.prototype.renderTokens=function(t,r,i,n,a){for(var o="",s,c,u,l=0,d=t.length;l<d;++l)u=void 0,s=t[l],c=s[0],c==="#"?u=this.renderSection(s,r,i,n,a):c==="^"?u=this.renderInverted(s,r,i,n,a):c===">"?u=this.renderPartial(s,r,i,a):c==="&"?u=this.unescapedValue(s,r):c==="name"?u=this.escapedValue(s,r,a):c==="text"&&(u=this.rawValue(s)),u!==void 0&&(o+=u);return o};er.prototype.renderSection=function(t,r,i,n,a){var o=this,s="",c=r.lookup(t[1]);function u(f){return o.render(f,r,i,a)}if(c){if(Ks(c))for(var l=0,d=c.length;l<d;++l)s+=this.renderTokens(t[4],r.push(c[l]),i,n,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),i,n,a);else if(Mw(c)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,n.slice(t[3],t[5]),u),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,i,n,a);return s}};er.prototype.renderInverted=function(t,r,i,n,a){var o=r.lookup(t[1]);if(!o||Ks(o)&&o.length===0)return this.renderTokens(t[4],r,i,n,a)};er.prototype.indentPartial=function(t,r,i){for(var n=r.replace(/[^ \t]/g,""),a=t.split(`
|
|
317
|
+
`),o=0;o<a.length;o++)a[o].length&&(o>0||!i)&&(a[o]=n+a[o]);return a.join(`
|
|
318
|
+
`)};er.prototype.renderPartial=function(t,r,i,n){if(i){var a=this.getConfigTags(n),o=Mw(i)?i(t[1]):i[t[1]];if(o!=null){var s=t[6],c=t[5],u=t[4],l=o;c==0&&u&&(l=this.indentPartial(o,u,s));var d=this.parse(l,a);return this.renderTokens(d,r,i,l,n)}}};er.prototype.unescapedValue=function(t,r){var i=r.lookup(t[1]);if(i!=null)return i};er.prototype.escapedValue=function(t,r,i){var n=this.getConfigEscape(i)||Jr.escape,a=r.lookup(t[1]);if(a!=null)return typeof a=="number"&&n===Jr.escape?String(a):n(a)};er.prototype.rawValue=function(t){return t[1]};er.prototype.getConfigTags=function(t){return Ks(t)?t:t&&typeof t=="object"?t.tags:void 0};er.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Ks(t))return t.escape};var Jr={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){Ru.templateCache=e},get templateCache(){return Ru.templateCache}},Ru=new er;Jr.clearCache=function(){return Ru.clearCache()};Jr.parse=function(t,r){return Ru.parse(t,r)};Jr.render=function(t,r,i,n){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+hF(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Ru.render(t,r,i,n)};Jr.escape=xF;Jr.Scanner=Mu;Jr.Context=Js;Jr.Writer=er;var Bp=Jr;function dP(){Bp.escape=e=>e}var So=e=>{let t=e.split(""),r=[],i=(a,o)=>{for(let s=o;s<t.length;s+=1)if(a.includes(t[s]))return s;return-1},n=0;for(;n<t.length;)if(t[n]==="{"&&n+1<t.length&&t[n+1]==="{")r.push({type:"literal",text:"{"}),n+=2;else if(t[n]==="}"&&n+1<t.length&&t[n+1]==="}")r.push({type:"literal",text:"}"}),n+=2;else if(t[n]==="{"){let a=i("}",n);if(a<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(n+1,a).join("")}),n=a+1}else{if(t[n]==="}")throw new Error("Single '}' in template.");{let a=i("{}",n),o=(a<0?t.slice(n):t.slice(n,a)).join("");r.push({type:"literal",text:o}),n=a<0?t.length:a}}return r},fP=(e,t=[])=>{let r=[];for(let i of e)if(i[0]==="name"){let n=i[1].includes(".")?i[1].split(".")[0]:i[1];r.push({type:"variable",name:n})}else if(["#","&","^",">"].includes(i[0])){if(r.push({type:"variable",name:i[1]}),i[0]==="#"&&i.length>4&&Array.isArray(i[4])){let n=[...t,i[1]],a=fP(i[4],n);r.push(...a)}}else r.push({type:"literal",text:i[1]});return r},Ws=e=>(dP(),fP(Bp.parse(e))),jw=(e,t)=>So(e).reduce((r,i)=>{if(i.type==="variable"){if(i.name in t)return r+(typeof t[i.name]=="string"?t[i.name]:JSON.stringify(t[i.name]));throw new Error(`(f-string) Missing value for input ${i.name}`)}return r+i.text},""),zw=(e,t)=>(dP(),Bp.render(e,t)),ju={"f-string":jw,mustache:zw},Dw={"f-string":So,mustache:Ws},Lt=(e,t,r)=>{try{return ju[t](e,r)}catch(i){throw ii(i,"INVALID_PROMPT_INPUT")}},ko=(e,t)=>Dw[t](e),wi=(e,t,r)=>{if(!(t in ju))throw new Error(`Invalid template format. Got \`${t}\`;
|
|
319
|
+
should be one of ${Object.keys(ju)}`);try{let i=Object.fromEntries(r.map(n=>[n,"foo"]));Array.isArray(e)?e.forEach(n=>{if(n.type==="text"&&"text"in n&&typeof n.text=="string")Lt(n.text,t,i);else if(n.type==="image_url"){if(typeof n.image_url=="string")Lt(n.image_url,t,i);else if(typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"){let a=n.image_url.url;Lt(a,t,i)}}else throw new Error(`Invalid message template received. ${JSON.stringify(n,null,2)}`)}):Lt(e,t,i)}catch(i){throw new Error(`Invalid prompt schema: ${i.message}`)}};var mn=class zu extends bi{static lc_name(){return"PromptTemplate"}template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),wi(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return Lt(this.template,this.templateFormat,r)}static fromExamples(t,r,i,n=`
|
|
320
|
+
|
|
321
|
+
`,a=""){return new zu({inputVariables:i,template:[a,...t,r].join(n)})}static fromTemplate(t,r){let{templateFormat:i="f-string",...n}=r??{},a=new Set;return ko(t,i).forEach(o=>{o.type==="variable"&&a.add(o.name)}),new zu({inputVariables:[...a],templateFormat:i,template:t,...n})}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new zu({...this,inputVariables:r,partialVariables:i})}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(t){if(!t.template)throw new Error("Prompt template must have a template");return new zu({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var qs=class pP extends Kn{static lc_name(){return"ImagePromptTemplate"}lc_namespace=["langchain_core","prompts","image"];template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),this.template=t.template,this.templateFormat=t.templateFormat??this.templateFormat,this.validateTemplate=t.validateTemplate??this.validateTemplate,this.additionalContentFields=t.additionalContentFields,this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),wi([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new pP({...this,inputVariables:r,partialVariables:i})}async format(t){let r={};for(let[o,s]of Object.entries(this.template))typeof s=="string"?r[o]=Lt(s,this.templateFormat,t):r[o]=s;let i=t.url||r.url,n=t.detail||r.detail;if(!i)throw new Error("Must provide either an image URL.");if(typeof i!="string")throw new Error("url must be a string.");let a={url:i};return n&&(a.detail=n),a}async formatPromptValue(t){return new xw(await this.format(t))}};var Du=class extends ae{lc_namespace=["langchain_core","prompts","dict"];lc_serializable=!0;template;templateFormat;inputVariables;static lc_name(){return"DictPromptTemplate"}constructor(e){let t=e.templateFormat??"f-string",r=Uw(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return Lw(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function Uw(e,t){let r=[];for(let i of Object.values(e))if(typeof i=="string")ko(i,t).forEach(n=>{n.type==="variable"&&r.push(n.name)});else if(Array.isArray(i))for(let n of i)typeof n=="string"?ko(n,t).forEach(a=>{a.type==="variable"&&r.push(a.name)}):typeof n=="object"&&r.push(...Uw(n,t));else typeof i=="object"&&i!==null&&r.push(...Uw(i,t));return Array.from(new Set(r))}function Lw(e,t,r){let i={};for(let[n,a]of Object.entries(e))if(typeof a=="string")i[n]=Lt(a,r,t);else if(Array.isArray(a)){let o=[];for(let s of a)typeof s=="string"?o.push(Lt(s,r,t)):typeof s=="object"&&o.push(Lw(s,t,r));i[n]=o}else typeof a=="object"&&a!==null?i[n]=Lw(a,t,r):i[n]=a;return i}var Uu=class extends ae{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},Zp=class extends Uu{static lc_name(){return"MessagesPlaceholder"}variableName;optional;constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){let t=e[this.variableName];if(this.optional&&!t)return[];if(!t){let i=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw i.name="InputFormatError",i}let r;try{Array.isArray(t)?r=t.map(It):r=[It(t)]}catch(i){let n=typeof t=="string"?t:JSON.stringify(t,null,2),a=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${n}`,`Additional message: ${i.message}`].join(`
|
|
322
|
+
|
|
323
|
+
`));throw a.name="InputFormatError",a.lc_error_code=i.lc_error_code,a}return r}},Fw=class extends Uu{prompt;constructor(e){"prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}},Lu=class extends Kn{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Tu(await this.formatMessages(e))}},Bw=class extends Fw{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new nn(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(mn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function CF(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function OF(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:"image_url"in e&&(typeof e.image_url=="string"||typeof e.image_url=="object"&&e.image_url!==null&&"url"in e.image_url&&typeof e.image_url.url=="string")}var Vw=class extends Uu{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;inputVariables=[];additionalOptions={};prompt;messageClass;static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}chatMessageClass;constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(i=>{"inputVariables"in i&&(r=r.concat(i.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){let t=this.constructor;if(t._messageClass())return new(t._messageClass())({content:e});if(t.chatMessageClass){let r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(mn.fromTemplate(e,t));let r=[];for(let i of e)if(typeof i=="string")r.push(mn.fromTemplate(i,t));else if(i!==null)if(CF(i)){let n="";typeof i.text=="string"&&(n=i.text??"");let a={...t,additionalContentFields:i};r.push(mn.fromTemplate(n,a))}else if(OF(i)){let n=i.image_url??"",a,o=[];if(typeof n=="string"){let s;t?.templateFormat==="mustache"?s=Ws(n):s=So(n);let c=s.flatMap(u=>u.type==="variable"?[u.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
|
|
324
|
+
Got: ${c}
|
|
325
|
+
From: ${n}`);o=[c[0]]}else o=[];n={url:n},a=new qs({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof n=="object"){if("url"in n){let s;t?.templateFormat==="mustache"?s=Ws(n.url):s=So(n.url),o=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else o=[];a=new qs({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else throw new Error("Invalid image template");r.push(a)}else typeof i=="object"&&r.push(new Du({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof bi){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let i={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let n of r.inputVariables)i||(i={[n]:e[n]}),i={...i,[n]:e[n]};if(r instanceof bi){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),n!==""&&t.push({...a,type:"text",text:n})}else if(r instanceof qs){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,type:"image_url",image_url:n})}else if(r instanceof Du){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,...n})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},Hp=class extends Vw{static _messageClass(){return rt}static lc_name(){return"HumanMessagePromptTemplate"}},Zw=class extends Vw{static _messageClass(){return Ee}static lc_name(){return"AIMessagePromptTemplate"}},Hw=class extends Vw{static _messageClass(){return Gt}static lc_name(){return"SystemMessagePromptTemplate"}};function PF(e){return typeof e.formatMessages=="function"}function NF(e,t){if(PF(e)||We(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let n=e[1];if(t?.templateFormat==="mustache"&&typeof n=="string"&&n.slice(0,2)==="{{"&&n.slice(-2)==="}}")return new Zp({variableName:n.slice(2,-2),optional:!0});if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")return new Zp({variableName:n.slice(1,-1),optional:!0});throw new Error(`Invalid placeholder template for format ${t?.templateFormat??'"f-string"'}: "${e[1]}". Expected a variable name surrounded by ${t?.templateFormat==="mustache"?"double":"single"} curly braces.`)}let r=It(e),i;if(typeof r.content=="string"?i=r.content:i=r.content.map(n=>"text"in n?{...n,text:n.text}:"image_url"in n?{...n,image_url:n.image_url}:n),r._getType()==="human")return Hp.fromTemplate(i,t);if(r._getType()==="ai")return Zw.fromTemplate(i,t);if(r._getType()==="system")return Hw.fromTemplate(i,t);if(nn.isInstance(r))return Bw.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function RF(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Xs=class Vp extends Lu{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}promptMessages;validateTemplate=!0;templateFormat="f-string";constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){let r=new Set;for(let s of this.promptMessages)if(!(s instanceof Ce))for(let c of s.inputVariables)r.add(c);let i=this.inputVariables,n=new Set(this.partialVariables?i.concat(Object.keys(this.partialVariables)):i),a=new Set([...n].filter(s=>!r.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` are not used in any of the prompt messages.`);let o=new Set([...r].filter(s=>!n.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(t,r){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async i=>{if(i.type!=="image_url")return i;let n="";typeof i.image_url=="string"?n=i.image_url:typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"&&(n=i.image_url.url);let a=await mn.fromTemplate(n,{templateFormat:this.templateFormat}).format(r);return typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url?i.image_url.url=a:i.image_url=a,i}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=[];for(let n of this.promptMessages)if(n instanceof Ce)i.push(await this._parseImagePrompts(n,r));else{let a;this.templateFormat==="mustache"?a={...r}:a=n.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(RF(n)&&n.optional))throw ii(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let o=await n.formatMessages(a);i=i.concat(o)}return i}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Vp({...this,inputVariables:r,partialVariables:i})}static fromTemplate(t,r){let i=new Hp({prompt:mn.fromTemplate(t,r)});return this.fromMessages([i])}static fromMessages(t,r){let i=t.reduce((o,s)=>o.concat(s instanceof Vp?s.promptMessages:[NF(s,r)]),[]),n=t.reduce((o,s)=>s instanceof Vp?Object.assign(o,s.partialVariables):o,Object.create(null)),a=new Set;for(let o of i)if(!(o instanceof Ce))for(let s of o.inputVariables)s in n||a.add(s);return new this({...r,inputVariables:[...a],promptMessages:i,partialVariables:n,templateFormat:r?.templateFormat})}};var mP=class Gw extends bi{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
326
|
+
|
|
327
|
+
`;prefix="";templateFormat="f-string";validateTemplate=!0;constructor(t){if(super(t),Object.assign(this,t),this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),wi(this.prefix+this.suffix,this.templateFormat,r)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Gw({...this,inputVariables:r,partialVariables:i})}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=await Promise.all(i.map(a=>this.examplePrompt.format(a)));return Lt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(this.outputParser!==void 0)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(t){let{example_prompt:r}=t;if(!r)throw new Error("Missing example prompt");let i=await mn.deserialize(r),n;if(Array.isArray(t.examples))n=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new Gw({inputVariables:t.input_variables,examplePrompt:i,examples:n,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},hP=class gP extends Lu{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
328
|
+
|
|
329
|
+
`;prefix="";templateFormat="f-string";validateTemplate=!0;_getPromptType(){return"few_shot_chat"}static lc_name(){return"FewShotChatMessagePromptTemplate"}constructor(t){if(super(t),this.examples=t.examples,this.examplePrompt=t.examplePrompt,this.exampleSeparator=t.exampleSeparator??`
|
|
330
|
+
|
|
331
|
+
`,this.exampleSelector=t.exampleSelector,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.templateFormat=t.templateFormat??"f-string",this.validateTemplate=t.validateTemplate??!0,this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),wi(this.prefix+this.suffix,this.templateFormat,r)}}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r);i=i.map(a=>{let o={};return this.examplePrompt.inputVariables.forEach(s=>{o[s]=a[s]}),o});let n=[];for(let a of i){let o=await this.examplePrompt.formatMessages(a);n.push(...o)}return n}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=(await Promise.all(i.map(a=>this.examplePrompt.formatMessages(a)))).flat().map(a=>a.content);return Lt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new gP({...this,inputVariables:r,partialVariables:i})}};var _P=class Gp extends Kn{static lc_name(){return"PipelinePromptTemplate"}pipelinePrompts;finalPrompt;constructor(t){super({...t,inputVariables:[]}),this.pipelinePrompts=t.pipelinePrompts,this.finalPrompt=t.finalPrompt,this.inputVariables=this.computeInputValues()}computeInputValues(){let t=this.pipelinePrompts.map(i=>i.name),r=this.pipelinePrompts.map(i=>i.prompt.inputVariables.filter(n=>!t.includes(n))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((i,n)=>(i[n]=t[n],i),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:i,prompt:n}of this.pipelinePrompts){let a=Gp.extractRequiredInputValues(r,n.inputVariables);n instanceof Xs?r[i]=await n.formatMessages(a):r[i]=await n.format(a)}return Gp.extractRequiredInputValues(r,this.finalPrompt.inputVariables)}async formatPromptValue(t){return this.finalPrompt.formatPromptValue(await this.formatPipelinePrompts(t))}async format(t){return this.finalPrompt.format(await this.formatPipelinePrompts(t))}async partial(t){let r={...this};return r.inputVariables=this.inputVariables.filter(i=>!(i in t)),r.partialVariables={...this.partialVariables??{},...t},new Gp(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function yP(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function MF(e){return typeof e=="object"&&e!=null&&"lc_id"in e&&Array.isArray(e.lc_id)&&e.lc_id.join("/")==="langchain_core/runnables/RunnableBinding"}var vP=class bP extends Xs{schema;method;lc_namespace=["langchain_core","prompts","structured"];get lc_aliases(){return{...super.lc_aliases,schema:"schema_"}}constructor(t){super(t),this.schema=t.schema,this.method=t.method}pipe(t){if(yP(t))return super.pipe(t.withStructuredOutput(this.schema));if(MF(t)&&yP(t.bound))return super.pipe(new Hr({bound:t.bound.withStructuredOutput(this.schema,...this.method?[{method:this.method}]:[]),kwargs:t.kwargs??{},config:t.config,configFactories:t.configFactories}));throw new Error('Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.')}static fromMessagesAndSchema(t,r,i){return bP.fromMessages(t,{schema:r,method:i})}};var wP=A({AIMessagePromptTemplate:()=>Zw,BaseChatPromptTemplate:()=>Lu,BaseMessagePromptTemplate:()=>Uu,BaseMessageStringPromptTemplate:()=>Fw,BasePromptTemplate:()=>Kn,BaseStringPromptTemplate:()=>bi,ChatMessagePromptTemplate:()=>Bw,ChatPromptTemplate:()=>Xs,DEFAULT_FORMATTER_MAPPING:()=>ju,DEFAULT_PARSER_MAPPING:()=>Dw,DictPromptTemplate:()=>Du,FewShotChatMessagePromptTemplate:()=>hP,FewShotPromptTemplate:()=>mP,HumanMessagePromptTemplate:()=>Hp,ImagePromptTemplate:()=>qs,MessagesPlaceholder:()=>Zp,PipelinePromptTemplate:()=>_P,PromptTemplate:()=>mn,StructuredPrompt:()=>vP,SystemMessagePromptTemplate:()=>Hw,checkValidTemplate:()=>wi,interpolateFString:()=>jw,interpolateMustache:()=>zw,parseFString:()=>So,parseMustache:()=>Ws,parseTemplate:()=>ko,renderTemplate:()=>Lt});var xP=A({BaseDocumentCompressor:()=>jF}),jF=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var SP=A({BaseRetriever:()=>Fu}),Fu=class extends ae{callbacks;tags;metadata;verbose;constructor(e){super(e),this.callbacks=e?.callbacks,this.tags=e?.tags??[],this.metadata=e?.metadata??{},this.verbose=e?.verbose??!1}_getRelevantDocuments(e,t){throw new Error("Not implemented!")}async invoke(e,t){let r=we(Fa(t)),i=await(await et.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,r.runId,void 0,void 0,void 0,r.runName);try{let n=await this._getRelevantDocuments(e,i);return await i?.handleRetrieverEnd(n),n}catch(n){throw await i?.handleRetrieverError(n),n}}};var kP=A({BaseStore:()=>$P,InMemoryStore:()=>zF}),$P=class extends ut{},zF=class extends $P{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,r]of e)this.store[t]=r}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let r of t)(e===void 0||r.startsWith(e))&&(yield r)}};var hn={and:"and",or:"or",not:"not"},Se={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},Jp=class{},Kp=class{accept(e){if(this.exprName==="Operation")return e.visitOperation(this);if(this.exprName==="Comparison")return e.visitComparison(this);if(this.exprName==="StructuredQuery")return e.visitStructuredQuery(this);throw new Error("Unknown Expression type")}},Wp=class extends Kp{},IP=class extends Wp{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},EP=class extends Wp{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},TP=class extends Kp{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function Jw(e){return e&&typeof e=="object"&&!Array.isArray(e)}function fr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:Jw(e)&&Object.keys(e).length===0:!0}function Kw(e){if(typeof e=="number")return e%1===0;if(typeof e=="string"){let t=parseInt(e,10);return!Number.isNaN(t)&&t%1===0&&t.toString()===e}return!1}function Ww(e){if(typeof e=="number")return e%1!==0;if(typeof e=="string"){let t=parseFloat(e);return!Number.isNaN(t)&&t%1!==0&&t.toString()===e}return!1}function qw(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function Xw(e){return typeof e=="boolean"}function Ys(e){let t;if(qw(e))t=e;else if(Kw(e))t=parseInt(e,10);else if(Ww(e))t=parseFloat(e);else if(Xw(e))t=!!e;else throw new Error("Unsupported value type");return t}var Bu=class extends Jp{},AP=class extends Bu{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[hn.and,hn.or],this.allowedComparators=e?.allowedComparators??[Se.eq,Se.ne,Se.gt,Se.gte,Se.lt,Se.lte]}formatFunction(e){if(e in Se){if(this.allowedComparators.length>0&&this.allowedComparators.indexOf(e)===-1)throw new Error(`Comparator ${e} not allowed. Allowed comparators: ${this.allowedComparators.join(", ")}`)}else if(e in hn){if(this.allowedOperators.length>0&&this.allowedOperators.indexOf(e)===-1)throw new Error(`Operator ${e} not allowed. Allowed operators: ${this.allowedOperators.join(", ")}`)}else throw new Error("Unknown comparator or operator");return`$${e}`}visitOperation(e){let t=e.args?.map(r=>r.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:Ys(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",i=!1){if(!(fr(e)&&fr(t))){if(fr(e)||r==="replace")return fr(t)?void 0:t;if(fr(t))return i?e:r==="and"?void 0:e;if(r==="and")return{$and:[e,t]};if(r==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}};var CP=class extends Bu{allowedOperators=[hn.and,hn.or];allowedComparators=[Se.eq,Se.ne,Se.gt,Se.gte,Se.lt,Se.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Se.eq,Se.ne,Se.gt,Se.gte,Se.lt,Se.lte];case"number":return[Se.eq,Se.ne,Se.gt,Se.gte,Se.lt,Se.lte];case"boolean":return[Se.eq,Se.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Se.eq:return(t,r)=>t===r;case Se.ne:return(t,r)=>t!==r;case Se.gt:return(t,r)=>t>r;case Se.gte:return(t,r)=>t>=r;case Se.lt:return(t,r)=>t<r;case Se.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case hn.and:return(t,r)=>t&&r;case hn.or:return(t,r)=>t||r;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:r}=e;if(this.allowedOperators.includes(t)){let i=this.getOperatorFunction(t);return n=>r?r.reduce((a,o)=>{let s=o.accept(this);if(typeof s=="function")return i(a,s(n));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:r,value:i}=e,n=[Se.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof i).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof i}`);let a=this.getComparatorFunction(t);return o=>{let s=o.metadata[r];return s===void 0?!!n.includes(t):a(s,Ys(i))}}else throw new Error("Comparator not allowed")}visitStructuredQuery(e){if(!e.filter)return{};let t=e.filter?.accept(this);if(typeof t!="function")throw new Error("Structured query filter is not a function");return{filter:t}}mergeFilters(e,t,r="and"){if(!(fr(e)&&fr(t))){if(fr(e)||r==="replace")return fr(t)?void 0:t;if(fr(t))return r==="and"?void 0:e;if(r==="and")return i=>e(i)&&t(i);if(r==="or")return i=>e(i)||t(i);throw new Error("Unknown merge type")}}};var OP=A({BaseTranslator:()=>Bu,BasicTranslator:()=>AP,Comparators:()=>Se,Comparison:()=>IP,Expression:()=>Kp,FilterDirective:()=>Wp,FunctionalTranslator:()=>CP,Operation:()=>EP,Operators:()=>hn,StructuredQuery:()=>TP,Visitor:()=>Jp,castValue:()=>Ys,isBoolean:()=>Xw,isFilterEmpty:()=>fr,isFloat:()=>Ww,isInt:()=>Kw,isObject:()=>Jw,isString:()=>qw});function Vu(e){return Ce.isInstance(e)?e.constructor.name||e.type:typeof e}function qp(e,t){return function(r,i){let{isNot:n,utils:a}=this;if(!t(r))return{pass:!1,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
332
|
+
|
|
333
|
+
Expected: ${n?"not ":""}${e}
|
|
334
|
+
Received: ${Vu(r)}`,actual:Vu(r),expected:e};if(i===void 0)return{pass:!0,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
335
|
+
|
|
336
|
+
Expected: not ${e}
|
|
337
|
+
Received: ${e}`};let o=r;return typeof i=="string"?{pass:o.content===i,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
338
|
+
|
|
339
|
+
Expected: ${e} with content ${a.printExpected(i)}
|
|
340
|
+
Received: ${e} with content ${a.printReceived(o.content)}`,actual:o.content,expected:i}:{pass:Object.entries(i).every(([s,c])=>this.equals(o[s],c)),message:()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
341
|
+
|
|
342
|
+
Expected: ${e} matching ${a.printExpected(i)}
|
|
343
|
+
Received: ${e} with ${a.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return s})(),expected:i}}}var Yw=qp("HumanMessage",rt.isInstance),Qw=qp("AIMessage",Ee.isInstance),ex=qp("SystemMessage",Gt.isInstance),tx=qp("ToolMessage",_t.isInstance);function rx(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
344
|
+
|
|
345
|
+
Expected: AIMessage
|
|
346
|
+
Received: ${Vu(e)}`};let n=e.tool_calls??[];if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
347
|
+
|
|
348
|
+
Expected ${r?"not ":""}${t.length} tool call(s), received ${n.length}`,actual:n.length,expected:t.length};let a=t.filter(o=>!n.some(s=>Object.entries(o).every(([c,u])=>this.equals(s[c],u))));return a.length>0?{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
349
|
+
|
|
350
|
+
Could not find matching tool call(s) for:
|
|
351
|
+
${i.printExpected(a)}
|
|
352
|
+
Received tool calls: ${i.printReceived(n.map(o=>({name:o.name,id:o.id,args:o.args})))}`,actual:n.map(o=>({name:o.name,id:o.id,args:o.args})),expected:t}:{pass:!0,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
353
|
+
|
|
354
|
+
Expected AIMessage not to have matching tool calls`}}function nx(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCallCount")}
|
|
355
|
+
|
|
356
|
+
Expected: AIMessage
|
|
357
|
+
Received: ${Vu(e)}`};let n=e.tool_calls?.length??0;return{pass:n===t,message:()=>`${i.matcherHint("toHaveToolCallCount")}
|
|
358
|
+
|
|
359
|
+
Expected ${r?"not ":""}${t} tool call(s)
|
|
360
|
+
Received: ${n}`,actual:n,expected:t}}function ix(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toContainToolCall")}
|
|
361
|
+
|
|
362
|
+
Expected: AIMessage
|
|
363
|
+
Received: ${Vu(e)}`};let n=e.tool_calls??[];return{pass:n.some(a=>Object.entries(t).every(([o,s])=>this.equals(a[o],s))),message:()=>`${i.matcherHint("toContainToolCall")}
|
|
364
|
+
|
|
365
|
+
Expected AIMessage ${r?"not ":""}to contain a tool call matching ${i.printExpected(t)}
|
|
366
|
+
Received tool calls: ${i.printReceived(n.map(a=>({name:a.name,id:a.id})))}`,actual:n.map(a=>({name:a.name,id:a.id})),expected:t}}function ax(e,t){let{isNot:r,utils:i}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
367
|
+
|
|
368
|
+
Expected an array of messages
|
|
369
|
+
Received: ${typeof e}`};let n=e.filter(_t.isInstance);if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
370
|
+
|
|
371
|
+
Expected ${r?"not ":""}${t.length} tool message(s), found ${n.length}`,actual:n.length,expected:t.length};for(let a=0;a<t.length;a++)if(!Object.entries(t[a]).every(([o,s])=>this.equals(n[a][o],s)))return{pass:!1,message:()=>{let o={};for(let s of Object.keys(t[a]))o[s]=n[a][s];return`${i.matcherHint("toHaveToolMessages")}
|
|
372
|
+
|
|
373
|
+
Tool message at index ${a} did not match:
|
|
374
|
+
Expected: ${i.printExpected(t[a])}
|
|
375
|
+
Received: ${i.printReceived(o)}`},actual:n[a],expected:t[a]};return{pass:!0,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
376
|
+
|
|
377
|
+
Expected messages not to contain matching tool messages`}}function ox(e,t){let{isNot:r,utils:i}=this,n=e?.__interrupt__;if(!(Array.isArray(n)&&n.length>0))return{pass:!1,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
378
|
+
|
|
379
|
+
Expected result ${r?"not ":""}to have been interrupted
|
|
380
|
+
Received __interrupt__: ${i.printReceived(n)}`};if(t===void 0)return{pass:!0,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
381
|
+
|
|
382
|
+
Expected result not to have been interrupted
|
|
383
|
+
Received ${n.length} interrupt(s)`};let a=n[0]?.value;return{pass:this.equals(a,t),message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
384
|
+
|
|
385
|
+
Expected interrupt value: ${i.printExpected(t)}
|
|
386
|
+
Received interrupt value: ${i.printReceived(a)}`,actual:a,expected:t}}function sx(e,t){let{isNot:r,utils:i}=this,n=e?.structuredResponse;return n===void 0?{pass:!1,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
387
|
+
|
|
388
|
+
Expected result ${r?"not ":""}to have a structured response
|
|
389
|
+
Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
390
|
+
|
|
391
|
+
Expected result not to have a structured response`}:{pass:Object.entries(t).every(([a,o])=>this.equals(n[a],o)),message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
392
|
+
|
|
393
|
+
Expected structured response: ${i.printExpected(t)}
|
|
394
|
+
Received structured response: ${i.printReceived(n)}`,actual:n,expected:t}}var PP={toBeHumanMessage:Yw,toBeAIMessage:Qw,toBeSystemMessage:ex,toBeToolMessage:tx,toHaveToolCalls:rx,toHaveToolCallCount:nx,toContainToolCall:ix,toHaveToolMessages:ax,toHaveBeenInterrupted:ox,toHaveStructuredResponse:sx};function DF(e){return e.map(t=>t.text).filter(Boolean).join("-")}var NP=0;function UF(){return NP+=1,`fake_tc_${NP}`}var cx=class RP extends ca{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_state={callIndex:0,calls:[]};get calls(){return this._state.calls}get callCount(){return this._state.calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Ce.isInstance(t)?this.queue.push({kind:"message",message:t}):this.queue.push({kind:"error",error:t}),this}respondWithTools(t){return this.queue.push({kind:"toolCalls",toolCalls:t.map(r=>({name:r.name,args:r.args,id:r.id??UF(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let r=[...this._tools,...t],i=new RP;return i.queue=this.queue,i._alwaysThrowError=this._alwaysThrowError,i._structuredResponseValue=this._structuredResponseValue,i._tools=r,i._state=this._state,i.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:i}=this;return Dt.from(async()=>i)}async _generate(t,r,i){this._state.calls.push({messages:[...t],options:r});let n=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let a=this.queue[n];if(!a)throw new Error(`FakeModel: no response queued for invocation ${n} (${this.queue.length} total queued).`);if(a.kind==="error")throw a.error;if(a.kind==="factory"){let s=a.factory(t);if(!Ce.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(a.kind==="message")return{generations:[{text:"",message:a.message}]};let o=DF(t);return{generations:[{text:o,message:new Ee({content:o,id:n.toString(),tool_calls:a.toolCalls.length>0?a.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function MP(){return new cx}var jP=A({FakeBuiltModel:()=>cx,fakeModel:()=>MP,langchainMatchers:()=>PP,toBeAIMessage:()=>Qw,toBeHumanMessage:()=>Yw,toBeSystemMessage:()=>ex,toBeToolMessage:()=>tx,toContainToolCall:()=>ix,toHaveBeenInterrupted:()=>ox,toHaveStructuredResponse:()=>sx,toHaveToolCallCount:()=>nx,toHaveToolCalls:()=>rx,toHaveToolMessages:()=>ax});function Zu(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function Hu(e){return e!==void 0&&ae.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function Gu(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(ur(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function Ju(e){return Gu(e)||Hu(e)||Zu(e)}var Kr={};$n(Kr,{$brand:()=>i_,$input:()=>Sv,$output:()=>xv,NEVER:()=>n_,TimePrecision:()=>Ev,ZodAny:()=>Px,ZodArray:()=>jx,ZodBase64:()=>_m,ZodBase64URL:()=>ym,ZodBigInt:()=>oc,ZodBigIntFormat:()=>wm,ZodBoolean:()=>ac,ZodCIDRv4:()=>hm,ZodCIDRv6:()=>gm,ZodCUID:()=>cm,ZodCUID2:()=>um,ZodCatch:()=>i0,ZodCodec:()=>ol,ZodCustom:()=>sl,ZodCustomStringFormat:()=>nc,ZodDate:()=>tl,ZodDefault:()=>Yx,ZodDiscriminatedUnion:()=>Dx,ZodE164:()=>vm,ZodEmail:()=>am,ZodEmoji:()=>om,ZodEnum:()=>tc,ZodError:()=>LF,ZodExactOptional:()=>Wx,ZodFile:()=>Jx,ZodFirstPartyTypeKind:()=>_0,ZodFunction:()=>m0,ZodGUID:()=>qu,ZodIPv4:()=>pm,ZodIPv6:()=>mm,ZodISODate:()=>Qp,ZodISODateTime:()=>Yp,ZodISODuration:()=>tm,ZodISOTime:()=>em,ZodIntersection:()=>Ux,ZodIssueCode:()=>BF,ZodJWT:()=>bm,ZodKSUID:()=>fm,ZodLazy:()=>d0,ZodLiteral:()=>Gx,ZodMAC:()=>$x,ZodMap:()=>Zx,ZodNaN:()=>o0,ZodNanoID:()=>sm,ZodNever:()=>Rx,ZodNonOptional:()=>Em,ZodNull:()=>Cx,ZodNullable:()=>Xx,ZodNumber:()=>ic,ZodNumberFormat:()=>Io,ZodObject:()=>nl,ZodOptional:()=>Im,ZodPipe:()=>al,ZodPrefault:()=>e0,ZodPreprocess:()=>s0,ZodPromise:()=>p0,ZodReadonly:()=>c0,ZodRealError:()=>pr,ZodRecord:()=>ec,ZodSet:()=>Hx,ZodString:()=>rc,ZodStringFormat:()=>ze,ZodSuccess:()=>n0,ZodSymbol:()=>Tx,ZodTemplateLiteral:()=>l0,ZodTransform:()=>Kx,ZodTuple:()=>Fx,ZodType:()=>he,ZodULID:()=>lm,ZodURL:()=>el,ZodUUID:()=>Wn,ZodUndefined:()=>Ax,ZodUnion:()=>il,ZodUnknown:()=>Nx,ZodVoid:()=>Mx,ZodXID:()=>dm,ZodXor:()=>zx,_ZodString:()=>im,_default:()=>Qx,_function:()=>H1,any:()=>x1,array:()=>rl,base64:()=>a1,base64url:()=>o1,bigint:()=>_1,boolean:()=>Ex,catch:()=>a0,check:()=>G1,cidrv4:()=>n1,cidrv6:()=>i1,clone:()=>Je,codec:()=>F1,coerce:()=>y0,config:()=>it,core:()=>fi,cuid:()=>WP,cuid2:()=>qP,custom:()=>J1,date:()=>k1,decode:()=>yx,decodeAsync:()=>bx,describe:()=>K1,discriminatedUnion:()=>C1,e164:()=>s1,email:()=>UP,emoji:()=>JP,encode:()=>_x,encodeAsync:()=>vx,endsWith:()=>ws,enum:()=>km,exactOptional:()=>qx,file:()=>z1,flattenError:()=>tu,float32:()=>p1,float64:()=>m1,formatError:()=>ru,fromJSONSchema:()=>tN,function:()=>H1,getErrorMap:()=>ZF,globalRegistry:()=>Pe,gt:()=>Dn,gte:()=>qt,guid:()=>LP,hash:()=>f1,hex:()=>d1,hostname:()=>l1,httpUrl:()=>GP,includes:()=>vs,instanceof:()=>q1,int:()=>rm,int32:()=>h1,int64:()=>y1,intersection:()=>Lx,invertCodec:()=>B1,ipv4:()=>e1,ipv6:()=>r1,iso:()=>Qs,json:()=>Y1,jwt:()=>c1,keyof:()=>$1,ksuid:()=>QP,lazy:()=>f0,length:()=>eo,literal:()=>j1,locales:()=>fu,looseObject:()=>T1,looseRecord:()=>P1,lowercase:()=>_s,lt:()=>zn,lte:()=>Tr,mac:()=>t1,map:()=>N1,maxLength:()=>Qa,maxSize:()=>Xi,meta:()=>W1,mime:()=>xs,minLength:()=>di,minSize:()=>Un,multipleOf:()=>qi,nan:()=>L1,nanoid:()=>KP,nativeEnum:()=>M1,negative:()=>qf,never:()=>xm,nonnegative:()=>Yf,nonoptional:()=>r0,nonpositive:()=>Xf,normalize:()=>Ss,null:()=>Ox,nullable:()=>Yu,nullish:()=>D1,number:()=>Ix,object:()=>I1,optional:()=>Xu,overwrite:()=>cn,parse:()=>px,parseAsync:()=>mx,partialRecord:()=>O1,pipe:()=>nm,positive:()=>Wf,prefault:()=>t0,preprocess:()=>Q1,prettifyError:()=>__,promise:()=>Z1,property:()=>Qf,readonly:()=>u0,record:()=>Vx,refine:()=>h0,regex:()=>gs,regexes:()=>Er,registry:()=>Tf,safeDecode:()=>xx,safeDecodeAsync:()=>kx,safeEncode:()=>wx,safeEncodeAsync:()=>Sx,safeParse:()=>hx,safeParseAsync:()=>gx,set:()=>R1,setErrorMap:()=>VF,size:()=>Ya,slugify:()=>Es,startsWith:()=>bs,strictObject:()=>E1,string:()=>Wu,stringFormat:()=>u1,stringbool:()=>X1,success:()=>U1,superRefine:()=>g0,symbol:()=>b1,templateLiteral:()=>V1,toJSONSchema:()=>to,toLowerCase:()=>$s,toUpperCase:()=>Is,transform:()=>$m,treeifyError:()=>g_,trim:()=>ks,tuple:()=>Bx,uint32:()=>g1,uint64:()=>v1,ulid:()=>XP,undefined:()=>w1,union:()=>Sm,unknown:()=>$o,uppercase:()=>ys,url:()=>HP,util:()=>j,uuid:()=>FP,uuidv4:()=>BP,uuidv6:()=>VP,uuidv7:()=>ZP,void:()=>S1,xid:()=>YP,xor:()=>A1});var Ku={};$n(Ku,{ZodAny:()=>Px,ZodArray:()=>jx,ZodBase64:()=>_m,ZodBase64URL:()=>ym,ZodBigInt:()=>oc,ZodBigIntFormat:()=>wm,ZodBoolean:()=>ac,ZodCIDRv4:()=>hm,ZodCIDRv6:()=>gm,ZodCUID:()=>cm,ZodCUID2:()=>um,ZodCatch:()=>i0,ZodCodec:()=>ol,ZodCustom:()=>sl,ZodCustomStringFormat:()=>nc,ZodDate:()=>tl,ZodDefault:()=>Yx,ZodDiscriminatedUnion:()=>Dx,ZodE164:()=>vm,ZodEmail:()=>am,ZodEmoji:()=>om,ZodEnum:()=>tc,ZodExactOptional:()=>Wx,ZodFile:()=>Jx,ZodFunction:()=>m0,ZodGUID:()=>qu,ZodIPv4:()=>pm,ZodIPv6:()=>mm,ZodIntersection:()=>Ux,ZodJWT:()=>bm,ZodKSUID:()=>fm,ZodLazy:()=>d0,ZodLiteral:()=>Gx,ZodMAC:()=>$x,ZodMap:()=>Zx,ZodNaN:()=>o0,ZodNanoID:()=>sm,ZodNever:()=>Rx,ZodNonOptional:()=>Em,ZodNull:()=>Cx,ZodNullable:()=>Xx,ZodNumber:()=>ic,ZodNumberFormat:()=>Io,ZodObject:()=>nl,ZodOptional:()=>Im,ZodPipe:()=>al,ZodPrefault:()=>e0,ZodPreprocess:()=>s0,ZodPromise:()=>p0,ZodReadonly:()=>c0,ZodRecord:()=>ec,ZodSet:()=>Hx,ZodString:()=>rc,ZodStringFormat:()=>ze,ZodSuccess:()=>n0,ZodSymbol:()=>Tx,ZodTemplateLiteral:()=>l0,ZodTransform:()=>Kx,ZodTuple:()=>Fx,ZodType:()=>he,ZodULID:()=>lm,ZodURL:()=>el,ZodUUID:()=>Wn,ZodUndefined:()=>Ax,ZodUnion:()=>il,ZodUnknown:()=>Nx,ZodVoid:()=>Mx,ZodXID:()=>dm,ZodXor:()=>zx,_ZodString:()=>im,_default:()=>Qx,_function:()=>H1,any:()=>x1,array:()=>rl,base64:()=>a1,base64url:()=>o1,bigint:()=>_1,boolean:()=>Ex,catch:()=>a0,check:()=>G1,cidrv4:()=>n1,cidrv6:()=>i1,codec:()=>F1,cuid:()=>WP,cuid2:()=>qP,custom:()=>J1,date:()=>k1,describe:()=>K1,discriminatedUnion:()=>C1,e164:()=>s1,email:()=>UP,emoji:()=>JP,enum:()=>km,exactOptional:()=>qx,file:()=>z1,float32:()=>p1,float64:()=>m1,function:()=>H1,guid:()=>LP,hash:()=>f1,hex:()=>d1,hostname:()=>l1,httpUrl:()=>GP,instanceof:()=>q1,int:()=>rm,int32:()=>h1,int64:()=>y1,intersection:()=>Lx,invertCodec:()=>B1,ipv4:()=>e1,ipv6:()=>r1,json:()=>Y1,jwt:()=>c1,keyof:()=>$1,ksuid:()=>QP,lazy:()=>f0,literal:()=>j1,looseObject:()=>T1,looseRecord:()=>P1,mac:()=>t1,map:()=>N1,meta:()=>W1,nan:()=>L1,nanoid:()=>KP,nativeEnum:()=>M1,never:()=>xm,nonoptional:()=>r0,null:()=>Ox,nullable:()=>Yu,nullish:()=>D1,number:()=>Ix,object:()=>I1,optional:()=>Xu,partialRecord:()=>O1,pipe:()=>nm,prefault:()=>t0,preprocess:()=>Q1,promise:()=>Z1,readonly:()=>u0,record:()=>Vx,refine:()=>h0,set:()=>R1,strictObject:()=>E1,string:()=>Wu,stringFormat:()=>u1,stringbool:()=>X1,success:()=>U1,superRefine:()=>g0,symbol:()=>b1,templateLiteral:()=>V1,transform:()=>$m,tuple:()=>Bx,uint32:()=>g1,uint64:()=>v1,ulid:()=>XP,undefined:()=>w1,union:()=>Sm,unknown:()=>$o,url:()=>HP,uuid:()=>FP,uuidv4:()=>BP,uuidv6:()=>VP,uuidv7:()=>ZP,void:()=>S1,xid:()=>YP,xor:()=>A1});var Xp={};$n(Xp,{endsWith:()=>ws,gt:()=>Dn,gte:()=>qt,includes:()=>vs,length:()=>eo,lowercase:()=>_s,lt:()=>zn,lte:()=>Tr,maxLength:()=>Qa,maxSize:()=>Xi,mime:()=>xs,minLength:()=>di,minSize:()=>Un,multipleOf:()=>qi,negative:()=>qf,nonnegative:()=>Yf,nonpositive:()=>Xf,normalize:()=>Ss,overwrite:()=>cn,positive:()=>Wf,property:()=>Qf,regex:()=>gs,size:()=>Ya,slugify:()=>Es,startsWith:()=>bs,toLowerCase:()=>$s,toUpperCase:()=>Is,trim:()=>ks,uppercase:()=>ys});var Qs={};$n(Qs,{ZodISODate:()=>Qp,ZodISODateTime:()=>Yp,ZodISODuration:()=>tm,ZodISOTime:()=>em,date:()=>lx,datetime:()=>ux,duration:()=>fx,time:()=>dx});var Yp=S("ZodISODateTime",(e,t)=>{Iy.init(e,t),ze.init(e,t)});function ux(e){return Tv(Yp,e)}var Qp=S("ZodISODate",(e,t)=>{Ey.init(e,t),ze.init(e,t)});function lx(e){return Av(Qp,e)}var em=S("ZodISOTime",(e,t)=>{Ty.init(e,t),ze.init(e,t)});function dx(e){return Cv(em,e)}var tm=S("ZodISODuration",(e,t)=>{Ay.init(e,t),ze.init(e,t)});function fx(e){return Ov(tm,e)}var zP=(e,t)=>{eu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ru(e,r)},flatten:{value:r=>tu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ss,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ss,2)}},isEmpty:{get(){return e.issues.length===0}}})},LF=S("ZodError",zP),pr=S("ZodError",zP,{Parent:Error});var px=ls(pr),mx=ds(pr),hx=fs(pr),gx=ps(pr),_x=nf(pr),yx=af(pr),vx=of(pr),bx=sf(pr),wx=cf(pr),xx=uf(pr),Sx=lf(pr),kx=df(pr);var DP=new WeakMap;function Qu(e,t,r){let i=Object.getPrototypeOf(e),n=DP.get(i);if(n||(n=new Set,DP.set(i,n)),!n.has(t)){n.add(t);for(let a in r){let o=r[a];Object.defineProperty(i,a,{configurable:!0,enumerable:!1,get(){let s=o.bind(this);return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var he=S("ZodType",(e,t)=>(de.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:As(e,"input"),output:As(e,"output")}}),e.toJSONSchema=sb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,i)=>px(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>hx(e,r,i),e.parseAsync=async(r,i)=>mx(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>gx(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>_x(e,r,i),e.decode=(r,i)=>yx(e,r,i),e.encodeAsync=async(r,i)=>vx(e,r,i),e.decodeAsync=async(r,i)=>bx(e,r,i),e.safeEncode=(r,i)=>wx(e,r,i),e.safeDecode=(r,i)=>xx(e,r,i),e.safeEncodeAsync=async(r,i)=>Sx(e,r,i),e.safeDecodeAsync=async(r,i)=>kx(e,r,i),Qu(e,"ZodType",{check(...r){let i=this.def;return this.clone(j.mergeDefs(i,{checks:[...i.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,i){return Je(this,r,i)},brand(){return this},register(r,i){return r.add(this,i),this},refine(r,i){return this.check(h0(r,i))},superRefine(r,i){return this.check(g0(r,i))},overwrite(r){return this.check(cn(r))},optional(){return Xu(this)},exactOptional(){return qx(this)},nullable(){return Yu(this)},nullish(){return Xu(Yu(this))},nonoptional(r){return r0(this,r)},array(){return rl(this)},or(r){return Sm([this,r])},and(r){return Lx(this,r)},transform(r){return nm(this,$m(r))},default(r){return Qx(this,r)},prefault(r){return t0(this,r)},catch(r){return a0(this,r)},pipe(r){return nm(this,r)},readonly(){return u0(this)},describe(r){let i=this.clone();return Pe.add(i,{description:r}),i},meta(...r){if(r.length===0)return Pe.get(this);let i=this.clone();return Pe.add(i,r[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Pe.get(e)?.description},configurable:!0}),e)),im=S("_ZodString",(e,t)=>{qa.init(e,t),he.init(e,t),e._zod.processJSONSchema=(i,n,a)=>cb(e,i,n,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Qu(e,"_ZodString",{regex(...i){return this.check(gs(...i))},includes(...i){return this.check(vs(...i))},startsWith(...i){return this.check(bs(...i))},endsWith(...i){return this.check(ws(...i))},min(...i){return this.check(di(...i))},max(...i){return this.check(Qa(...i))},length(...i){return this.check(eo(...i))},nonempty(...i){return this.check(di(1,...i))},lowercase(i){return this.check(_s(i))},uppercase(i){return this.check(ys(i))},trim(){return this.check(ks())},normalize(...i){return this.check(Ss(...i))},toLowerCase(){return this.check($s())},toUpperCase(){return this.check(Is())},slugify(){return this.check(Es())}})}),rc=S("ZodString",(e,t)=>{qa.init(e,t),im.init(e,t),e.email=r=>e.check(Af(am,r)),e.url=r=>e.check(mu(el,r)),e.jwt=r=>e.check(Kf(bm,r)),e.emoji=r=>e.check(Rf(om,r)),e.guid=r=>e.check(pu(qu,r)),e.uuid=r=>e.check(Cf(Wn,r)),e.uuidv4=r=>e.check(Of(Wn,r)),e.uuidv6=r=>e.check(Pf(Wn,r)),e.uuidv7=r=>e.check(Nf(Wn,r)),e.nanoid=r=>e.check(Mf(sm,r)),e.guid=r=>e.check(pu(qu,r)),e.cuid=r=>e.check(jf(cm,r)),e.cuid2=r=>e.check(zf(um,r)),e.ulid=r=>e.check(Df(lm,r)),e.base64=r=>e.check(Hf(_m,r)),e.base64url=r=>e.check(Gf(ym,r)),e.xid=r=>e.check(Uf(dm,r)),e.ksuid=r=>e.check(Lf(fm,r)),e.ipv4=r=>e.check(Ff(pm,r)),e.ipv6=r=>e.check(Bf(mm,r)),e.cidrv4=r=>e.check(Vf(hm,r)),e.cidrv6=r=>e.check(Zf(gm,r)),e.e164=r=>e.check(Jf(vm,r)),e.datetime=r=>e.check(ux(r)),e.date=r=>e.check(lx(r)),e.time=r=>e.check(dx(r)),e.duration=r=>e.check(fx(r))});function Wu(e){return kv(rc,e)}var ze=S("ZodStringFormat",(e,t)=>{je.init(e,t),im.init(e,t)}),am=S("ZodEmail",(e,t)=>{_y.init(e,t),ze.init(e,t)});function UP(e){return Af(am,e)}var qu=S("ZodGUID",(e,t)=>{hy.init(e,t),ze.init(e,t)});function LP(e){return pu(qu,e)}var Wn=S("ZodUUID",(e,t)=>{gy.init(e,t),ze.init(e,t)});function FP(e){return Cf(Wn,e)}function BP(e){return Of(Wn,e)}function VP(e){return Pf(Wn,e)}function ZP(e){return Nf(Wn,e)}var el=S("ZodURL",(e,t)=>{yy.init(e,t),ze.init(e,t)});function HP(e){return mu(el,e)}function GP(e){return mu(el,{protocol:Er.httpProtocol,hostname:Er.domain,...j.normalizeParams(e)})}var om=S("ZodEmoji",(e,t)=>{vy.init(e,t),ze.init(e,t)});function JP(e){return Rf(om,e)}var sm=S("ZodNanoID",(e,t)=>{by.init(e,t),ze.init(e,t)});function KP(e){return Mf(sm,e)}var cm=S("ZodCUID",(e,t)=>{wy.init(e,t),ze.init(e,t)});function WP(e){return jf(cm,e)}var um=S("ZodCUID2",(e,t)=>{xy.init(e,t),ze.init(e,t)});function qP(e){return zf(um,e)}var lm=S("ZodULID",(e,t)=>{Sy.init(e,t),ze.init(e,t)});function XP(e){return Df(lm,e)}var dm=S("ZodXID",(e,t)=>{ky.init(e,t),ze.init(e,t)});function YP(e){return Uf(dm,e)}var fm=S("ZodKSUID",(e,t)=>{$y.init(e,t),ze.init(e,t)});function QP(e){return Lf(fm,e)}var pm=S("ZodIPv4",(e,t)=>{Cy.init(e,t),ze.init(e,t)});function e1(e){return Ff(pm,e)}var $x=S("ZodMAC",(e,t)=>{Py.init(e,t),ze.init(e,t)});function t1(e){return Iv($x,e)}var mm=S("ZodIPv6",(e,t)=>{Oy.init(e,t),ze.init(e,t)});function r1(e){return Bf(mm,e)}var hm=S("ZodCIDRv4",(e,t)=>{Ny.init(e,t),ze.init(e,t)});function n1(e){return Vf(hm,e)}var gm=S("ZodCIDRv6",(e,t)=>{Ry.init(e,t),ze.init(e,t)});function i1(e){return Zf(gm,e)}var _m=S("ZodBase64",(e,t)=>{jy.init(e,t),ze.init(e,t)});function a1(e){return Hf(_m,e)}var ym=S("ZodBase64URL",(e,t)=>{zy.init(e,t),ze.init(e,t)});function o1(e){return Gf(ym,e)}var vm=S("ZodE164",(e,t)=>{Dy.init(e,t),ze.init(e,t)});function s1(e){return Jf(vm,e)}var bm=S("ZodJWT",(e,t)=>{Uy.init(e,t),ze.init(e,t)});function c1(e){return Kf(bm,e)}var nc=S("ZodCustomStringFormat",(e,t)=>{Ly.init(e,t),ze.init(e,t)});function u1(e,t,r={}){return Ts(nc,e,t,r)}function l1(e){return Ts(nc,"hostname",Er.hostname,e)}function d1(e){return Ts(nc,"hex",Er.hex,e)}function f1(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=Er[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Ts(nc,i,n,t)}var ic=S("ZodNumber",(e,t)=>{bf.init(e,t),he.init(e,t),e._zod.processJSONSchema=(i,n,a)=>ub(e,i,n,a),Qu(e,"ZodNumber",{gt(i,n){return this.check(Dn(i,n))},gte(i,n){return this.check(qt(i,n))},min(i,n){return this.check(qt(i,n))},lt(i,n){return this.check(zn(i,n))},lte(i,n){return this.check(Tr(i,n))},max(i,n){return this.check(Tr(i,n))},int(i){return this.check(rm(i))},safe(i){return this.check(rm(i))},positive(i){return this.check(Dn(0,i))},nonnegative(i){return this.check(qt(0,i))},negative(i){return this.check(zn(0,i))},nonpositive(i){return this.check(Tr(0,i))},multipleOf(i,n){return this.check(qi(i,n))},step(i,n){return this.check(qi(i,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ix(e){return Pv(ic,e)}var Io=S("ZodNumberFormat",(e,t)=>{Fy.init(e,t),ic.init(e,t)});function rm(e){return Rv(Io,e)}function p1(e){return Mv(Io,e)}function m1(e){return jv(Io,e)}function h1(e){return zv(Io,e)}function g1(e){return Dv(Io,e)}var ac=S("ZodBoolean",(e,t)=>{ou.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lb(e,r,i,n)});function Ex(e){return Uv(ac,e)}var oc=S("ZodBigInt",(e,t)=>{wf.init(e,t),he.init(e,t),e._zod.processJSONSchema=(i,n,a)=>db(e,i,n,a),e.gte=(i,n)=>e.check(qt(i,n)),e.min=(i,n)=>e.check(qt(i,n)),e.gt=(i,n)=>e.check(Dn(i,n)),e.gte=(i,n)=>e.check(qt(i,n)),e.min=(i,n)=>e.check(qt(i,n)),e.lt=(i,n)=>e.check(zn(i,n)),e.lte=(i,n)=>e.check(Tr(i,n)),e.max=(i,n)=>e.check(Tr(i,n)),e.positive=i=>e.check(Dn(BigInt(0),i)),e.negative=i=>e.check(zn(BigInt(0),i)),e.nonpositive=i=>e.check(Tr(BigInt(0),i)),e.nonnegative=i=>e.check(qt(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(qi(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function _1(e){return Fv(oc,e)}var wm=S("ZodBigIntFormat",(e,t)=>{By.init(e,t),oc.init(e,t)});function y1(e){return Vv(wm,e)}function v1(e){return Zv(wm,e)}var Tx=S("ZodSymbol",(e,t)=>{Vy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>fb(e,r,i,n)});function b1(e){return Hv(Tx,e)}var Ax=S("ZodUndefined",(e,t)=>{Zy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>mb(e,r,i,n)});function w1(e){return Gv(Ax,e)}var Cx=S("ZodNull",(e,t)=>{Hy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pb(e,r,i,n)});function Ox(e){return Jv(Cx,e)}var Px=S("ZodAny",(e,t)=>{Gy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>_b(e,r,i,n)});function x1(){return Kv(Px)}var Nx=S("ZodUnknown",(e,t)=>{su.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>yb(e,r,i,n)});function $o(){return hu(Nx)}var Rx=S("ZodNever",(e,t)=>{cu.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>gb(e,r,i,n)});function xm(e){return gu(Rx,e)}var Mx=S("ZodVoid",(e,t)=>{Jy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>hb(e,r,i,n)});function S1(e){return Wv(Mx,e)}var tl=S("ZodDate",(e,t)=>{Ky.init(e,t),he.init(e,t),e._zod.processJSONSchema=(i,n,a)=>vb(e,i,n,a),e.min=(i,n)=>e.check(qt(i,n)),e.max=(i,n)=>e.check(Tr(i,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function k1(e){return qv(tl,e)}var jx=S("ZodArray",(e,t)=>{Wy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ob(e,r,i,n),e.element=t.element,Qu(e,"ZodArray",{min(r,i){return this.check(di(r,i))},nonempty(r){return this.check(di(1,r))},max(r,i){return this.check(Qa(r,i))},length(r,i){return this.check(eo(r,i))},unwrap(){return this.element}})});function rl(e,t){return Qv(jx,e,t)}function $1(e){let t=e._zod.def.shape;return km(Object.keys(t))}var nl=S("ZodObject",(e,t)=>{qy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Pb(e,r,i,n),j.defineLazy(e,"shape",()=>t.shape),Qu(e,"ZodObject",{keyof(){return km(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:$o()})},loose(){return this.clone({...this._zod.def,catchall:$o()})},strict(){return this.clone({...this._zod.def,catchall:xm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return j.extend(this,r)},safeExtend(r){return j.safeExtend(this,r)},merge(r){return j.merge(this,r)},pick(r){return j.pick(this,r)},omit(r){return j.omit(this,r)},partial(...r){return j.partial(Im,this,r[0])},required(...r){return j.required(Em,this,r[0])}})});function I1(e,t){let r={type:"object",shape:e??{},...j.normalizeParams(t)};return new nl(r)}function E1(e,t){return new nl({type:"object",shape:e,catchall:xm(),...j.normalizeParams(t)})}function T1(e,t){return new nl({type:"object",shape:e,catchall:$o(),...j.normalizeParams(t)})}var il=S("ZodUnion",(e,t)=>{uu.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>tp(e,r,i,n),e.options=t.options});function Sm(e,t){return new il({type:"union",options:e,...j.normalizeParams(t)})}var zx=S("ZodXor",(e,t)=>{il.init(e,t),Xy.init(e,t),e._zod.processJSONSchema=(r,i,n)=>tp(e,r,i,n),e.options=t.options});function A1(e,t){return new zx({type:"union",options:e,inclusive:!1,...j.normalizeParams(t)})}var Dx=S("ZodDiscriminatedUnion",(e,t)=>{il.init(e,t),Yy.init(e,t)});function C1(e,t,r){return new Dx({type:"union",options:t,discriminator:e,...j.normalizeParams(r)})}var Ux=S("ZodIntersection",(e,t)=>{Qy.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Nb(e,r,i,n)});function Lx(e,t){return new Ux({type:"intersection",left:e,right:t})}var Fx=S("ZodTuple",(e,t)=>{xf.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Rb(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Bx(e,t,r){let i=t instanceof de,n=i?r:t,a=i?t:null;return new Fx({type:"tuple",items:e,rest:a,...j.normalizeParams(n)})}var ec=S("ZodRecord",(e,t)=>{ev.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Mb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function Vx(e,t,r){return!t||!t._zod?new ec({type:"record",keyType:Wu(),valueType:e,...j.normalizeParams(t)}):new ec({type:"record",keyType:e,valueType:t,...j.normalizeParams(r)})}function O1(e,t,r){let i=Je(e);return i._zod.values=void 0,new ec({type:"record",keyType:i,valueType:t,...j.normalizeParams(r)})}function P1(e,t,r){return new ec({type:"record",keyType:e,valueType:t,mode:"loose",...j.normalizeParams(r)})}var Zx=S("ZodMap",(e,t)=>{tv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ab(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Un(...r)),e.nonempty=r=>e.check(Un(1,r)),e.max=(...r)=>e.check(Xi(...r)),e.size=(...r)=>e.check(Ya(...r))});function N1(e,t,r){return new Zx({type:"map",keyType:e,valueType:t,...j.normalizeParams(r)})}var Hx=S("ZodSet",(e,t)=>{rv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cb(e,r,i,n),e.min=(...r)=>e.check(Un(...r)),e.nonempty=r=>e.check(Un(1,r)),e.max=(...r)=>e.check(Xi(...r)),e.size=(...r)=>e.check(Ya(...r))});function R1(e,t){return new Hx({type:"set",valueType:e,...j.normalizeParams(t)})}var tc=S("ZodEnum",(e,t)=>{nv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(i,n,a)=>bb(e,i,n,a),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let a={};for(let o of i)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new tc({...t,checks:[],...j.normalizeParams(n),entries:a})},e.exclude=(i,n)=>{let a={...t.entries};for(let o of i)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new tc({...t,checks:[],...j.normalizeParams(n),entries:a})}});function km(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new tc({type:"enum",entries:r,...j.normalizeParams(t)})}function M1(e,t){return new tc({type:"enum",entries:e,...j.normalizeParams(t)})}var Gx=S("ZodLiteral",(e,t)=>{iv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wb(e,r,i,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function j1(e,t){return new Gx({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}var Jx=S("ZodFile",(e,t)=>{av.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>kb(e,r,i,n),e.min=(r,i)=>e.check(Un(r,i)),e.max=(r,i)=>e.check(Xi(r,i)),e.mime=(r,i)=>e.check(xs(Array.isArray(r)?r:[r],i))});function z1(e){return eb(Jx,e)}var Kx=S("ZodTransform",(e,t)=>{ov.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tb(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Zi(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(j.issue(a,r.value,t));else{let o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(j.issue(o))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(a=>(r.value=a,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function $m(e){return new Kx({type:"transform",transform:e})}var Im=S("ZodOptional",(e,t)=>{Xa.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>rp(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Xu(e){return new Im({type:"optional",innerType:e})}var Wx=S("ZodExactOptional",(e,t)=>{sv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>rp(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function qx(e){return new Wx({type:"optional",innerType:e})}var Xx=S("ZodNullable",(e,t)=>{cv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>jb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Yu(e){return new Xx({type:"nullable",innerType:e})}function D1(e){return Xu(Yu(e))}var Yx=S("ZodDefault",(e,t)=>{uv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Db(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Qx(e,t){return new Yx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var e0=S("ZodPrefault",(e,t)=>{lv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ub(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function t0(e,t){return new e0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Em=S("ZodNonOptional",(e,t)=>{dv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>zb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function r0(e,t){return new Em({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}var n0=S("ZodSuccess",(e,t)=>{fv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$b(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function U1(e){return new n0({type:"success",innerType:e})}var i0=S("ZodCatch",(e,t)=>{pv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Lb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function a0(e,t){return new i0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var o0=S("ZodNaN",(e,t)=>{mv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>xb(e,r,i,n)});function L1(e){return Yv(o0,e)}var al=S("ZodPipe",(e,t)=>{Sf.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Fb(e,r,i,n),e.in=t.in,e.out=t.out});function nm(e,t){return new al({type:"pipe",in:e,out:t})}var ol=S("ZodCodec",(e,t)=>{al.init(e,t),lu.init(e,t)});function F1(e,t,r){return new ol({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function B1(e){let t=e._zod.def;return new ol({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var s0=S("ZodPreprocess",(e,t)=>{al.init(e,t),hv.init(e,t)}),c0=S("ZodReadonly",(e,t)=>{gv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Bb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function u0(e){return new c0({type:"readonly",innerType:e})}var l0=S("ZodTemplateLiteral",(e,t)=>{_v.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Sb(e,r,i,n)});function V1(e,t){return new l0({type:"template_literal",parts:e,...j.normalizeParams(t)})}var d0=S("ZodLazy",(e,t)=>{bv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Zb(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function f0(e){return new d0({type:"lazy",getter:e})}var p0=S("ZodPromise",(e,t)=>{vv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Vb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Z1(e){return new p0({type:"promise",innerType:e})}var m0=S("ZodFunction",(e,t)=>{yv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eb(e,r,i,n)});function H1(e){return new m0({type:"function",input:Array.isArray(e?.input)?Bx(e?.input):e?.input??rl($o()),output:e?.output??$o()})}var sl=S("ZodCustom",(e,t)=>{wv.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ib(e,r,i,n)});function G1(e){let t=new Le({check:"custom"});return t._zod.check=e,t}function J1(e,t){return tb(sl,e??(()=>!0),t)}function h0(e,t={}){return rb(sl,e,t)}function g0(e,t){return nb(e,t)}var K1=ib,W1=ab;function q1(e,t={}){let r=new sl({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...j.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var X1=(...e)=>ob({Codec:ol,Boolean:ac,String:rc},...e);function Y1(e){let t=f0(()=>Sm([Wu(e),Ix(),Ex(),Ox(),rl(t),Vx(Wu(),t)]));return t}function Q1(e,t){return new s0({type:"pipe",in:$m(e),out:t})}var BF={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function VF(e){it({customError:e})}function ZF(){return it().customError}var _0;_0||(_0={});var G={...Ku,...Xp,iso:Qs},HF=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function GF(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function JF(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function eN(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return G.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return G.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let a=JF(n,t),o=Ft(a,t);return t.refs.set(n,o),t.processing.delete(n),o}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return G.null();if(n.length===0)return G.never();if(n.length===1)return G.literal(n[0]);if(n.every(o=>typeof o=="string"))return G.enum(n);let a=n.map(o=>G.literal(o));return a.length<2?a[0]:G.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return G.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(a=>{let o={...e,type:a};return eN(o,t)});return n.length===0?G.never():n.length===1?n[0]:G.union(n)}if(!r)return G.any();let i;switch(r){case"string":{let n=G.string();if(e.format){let a=e.format;a==="email"?n=n.check(G.email()):a==="uri"||a==="uri-reference"?n=n.check(G.url()):a==="uuid"||a==="guid"?n=n.check(G.uuid()):a==="date-time"?n=n.check(G.iso.datetime()):a==="date"?n=n.check(G.iso.date()):a==="time"?n=n.check(G.iso.time()):a==="duration"?n=n.check(G.iso.duration()):a==="ipv4"?n=n.check(G.ipv4()):a==="ipv6"?n=n.check(G.ipv6()):a==="mac"?n=n.check(G.mac()):a==="cidr"?n=n.check(G.cidrv4()):a==="cidr-v6"?n=n.check(G.cidrv6()):a==="base64"?n=n.check(G.base64()):a==="base64url"?n=n.check(G.base64url()):a==="e164"?n=n.check(G.e164()):a==="jwt"?n=n.check(G.jwt()):a==="emoji"?n=n.check(G.emoji()):a==="nanoid"?n=n.check(G.nanoid()):a==="cuid"?n=n.check(G.cuid()):a==="cuid2"?n=n.check(G.cuid2()):a==="ulid"?n=n.check(G.ulid()):a==="xid"?n=n.check(G.xid()):a==="ksuid"&&(n=n.check(G.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?G.number().int():G.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=G.boolean();break}case"null":{i=G.null();break}case"object":{let n={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(a)){let l=Ft(u,t);n[c]=o.has(c)?l:l.optional()}if(e.propertyNames){let c=Ft(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Ft(e.additionalProperties,t):G.any();if(Object.keys(n).length===0){i=G.record(c,u);break}let l=G.object(n).passthrough(),d=G.looseRecord(c,u);i=G.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let p=Ft(c[f],t),m=G.string().regex(new RegExp(f));l.push(G.looseRecord(m,p))}let d=[];if(Object.keys(n).length>0&&d.push(G.object(n).passthrough()),d.push(...l),d.length===0)i=G.object({}).passthrough();else if(d.length===1)i=d[0];else{let f=G.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=G.intersection(f,d[p]);i=f}break}let s=G.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(Ft(e.additionalProperties,t)):i=s.passthrough();break}case"array":{let n=e.prefixItems,a=e.items;if(n&&Array.isArray(n)){let o=n.map(c=>Ft(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?Ft(a,t):void 0;s?i=G.tuple(o).rest(s):i=G.tuple(o),typeof e.minItems=="number"&&(i=i.check(G.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(G.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>Ft(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Ft(e.additionalItems,t):void 0;s?i=G.tuple(o).rest(s):i=G.tuple(o),typeof e.minItems=="number"&&(i=i.check(G.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(G.maxLength(e.maxItems)))}else if(a!==void 0){let o=Ft(a,t),s=G.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=G.array(G.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function Ft(e,t){if(typeof e=="boolean")return e?G.any():G.never();let r=eN(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>Ft(u,t)),c=G.union(s);r=i?G.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>Ft(u,t)),c=G.xor(s);r=i?G.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:G.any();else{let s=i?r:Ft(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=G.intersection(s,Ft(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=G.nullable(r)),e.readOnly===!0&&(r=G.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},a=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of a)s in e&&(n[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(n[s]=e[s]);for(let s of Object.keys(e))HF.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function tN(e,t){if(typeof e=="boolean")return e?G.any():G.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=GF(r,t?.defaultTarget),n=r.$defs||r.definitions||{},a={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Pe};return Ft(r,a)}var y0={};$n(y0,{bigint:()=>XF,boolean:()=>qF,date:()=>YF,number:()=>WF,string:()=>KF});function KF(e){return $v(rc,e)}function WF(e){return Nv(ic,e)}function qF(e){return Lv(ac,e)}function XF(e){return Bv(oc,e)}function YF(e){return Xv(tl,e)}it(kf());var rN=A({BaseToolkit:()=>QF,DynamicStructuredTool:()=>aN,DynamicTool:()=>iN,StructuredTool:()=>cl,Tool:()=>nN,ToolInputParsingException:()=>Go,isLangChainTool:()=>Ju,isRunnableToolLike:()=>Hu,isStructuredTool:()=>Zu,isStructuredToolParams:()=>Gu,tool:()=>eB}),cl=class extends Rp{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let r,i=we(xt(this.defaultConfig,t));return Pi(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){let i=Pi(e)?e.args:e,n;if(ur(this.schema))try{n=await ta(this.schema,i)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
395
|
+
Details: ${p.message}`),up(p)&&(m=`${m}
|
|
396
|
+
|
|
397
|
+
${Kr.prettifyError(p)}`),new Go(m,JSON.stringify(e))}else{let p=Ve(i,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
398
|
+
Details: ${p.errors.map(g=>`${g.keywordLocation}: ${g.error}`).join(`
|
|
399
|
+
`)}`),new Go(m,JSON.stringify(e))}n=i}let a=Fa(t),o=et.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Pi(e)&&(s=e.id),!s&&bk(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let u;try{let p=await this._call(n,c,a);u=ow(p)?await AC(p,async m=>{try{await c?.handleToolEvent(m)}catch(g){await c?.handleToolError(g)}}):p}catch(p){throw await c?.handleToolError(p),p}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
|
|
400
|
+
Result: ${JSON.stringify(u)}`);else l=u;let f=tB({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},nN=class extends cl{schema=St.object({input:St.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},iN=class extends nN{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=Fa(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},aN=class extends cl{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let i=Fa(t);return i.runName===void 0&&(i.runName=this.name),super.call(e,i,r)}_call(e,t,r){return this.func(e,t,r)}},QF=class{getTools(){return this.tools}};function eB(e,t){let r=Ps(t.schema),i=Bs(t.schema);if(!t.schema||r||i)return new iN({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(o,s,c)=>new Promise((u,l)=>{let d=$e(c,{callbacks:s?.getChild()});Te.runWithConfig(or(d),async()=>{try{u(e(o,d))}catch(f){l(f)}})})});let n=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new aN({...t,description:a,schema:n,func:async(o,s,c)=>new Promise((u,l)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),l(Ui(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=$e(c,{callbacks:s?.getChild()});Te.runWithConfig(or(p),async()=>{try{let m=await e(o,p);if(ow(m)){u(m);return}if(c?.signal?.aborted){f();return}f(),u(m)}catch(m){f(),l(m)}})})})}function tB(e){let{content:t,artifact:r,toolCallId:i,metadata:n}=e;return i&&!Ac(t)?typeof t=="string"||Array.isArray(t)&&t.every(a=>typeof a=="object")?new _t({status:"success",content:t,artifact:r,tool_call_id:i,name:e.name,metadata:n}):new _t({status:"success",content:rB(t),artifact:r,tool_call_id:i,name:e.name,metadata:n}):t}function rB(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var oN=A({RunCollectorCallbackHandler:()=>nB}),nB=class extends At{name="run_collector";exampleId;tracedRuns;constructor({exampleId:e}={}){super({_awaitHandler:!0}),this.exampleId=e,this.tracedRuns=[]}async persistRun(e){let t={...e};t.reference_example_id=this.exampleId,this.tracedRuns.push(t)}};var sN=A({});var cN=A({chunkArray:()=>iB}),iB=(e,t)=>e.reduce((r,i,n)=>{let a=Math.floor(n/t);return r[a]=(r[a]||[]).concat([i]),r},[]);var uN=A({context:()=>aB});function aB(e,...t){let r=e.raw,i="";for(let n=0;n<r.length;n++){let a=r[n].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(i+=a,n<t.length){let o=oB(t[n],i);i+=typeof o=="string"?o:JSON.stringify(o)}}return i=sB(i),i=i.trim(),i=i.replace(/\\n/g,`
|
|
401
|
+
`),i}function oB(e,t){if(typeof e!="string"||!e.includes(`
|
|
402
|
+
`))return e;let r=t.slice(t.lastIndexOf(`
|
|
403
|
+
`)+1).match(/^(\s+)/);if(r){let i=r[1];return e.replace(/\n/g,`
|
|
404
|
+
${i}`)}return e}function sB(e){let t=e.split(`
|
|
405
|
+
`),r=null;for(let i of t){let n=i.match(/^(\s+)\S+/);if(n){let a=n[1].length;r===null?r=a:r=Math.min(r,a)}}return r===null?e:t.map(i=>i[0]===" "||i[0]===" "?i.slice(r):i).join(`
|
|
406
|
+
`)}var lN=A({EventStreamContentType:()=>cB,convertEventStreamToIterableReadableDataStream:()=>lB,getBytes:()=>dN,getLines:()=>fN,getMessages:()=>pN}),cB="text/event-stream";async function dN(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let i=await r.read();if(i.done){t(new Uint8Array,!0);break}t(i.value)}}else try{for await(let r of e)t(new Uint8Array(r));t(new Uint8Array,!0)}catch(r){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${r.message}`].join(`
|
|
407
|
+
`))}}function fN(e){let t,r,i,n=!1;return function(o,s){if(s){e(o,0,!0);return}t===void 0?(t=o,r=0,i=-1):t=uB(t,o);let c=t.length,u=0;for(;r<c;){n&&(t[r]===10&&(u=++r),n=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case 58:i===-1&&(i=r-u);break;case 13:n=!0;case 10:l=r;break}if(l===-1)break;e(t.subarray(u,l),i),u=r,i=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function pN(e,t,r){let i=v0(),n=new TextDecoder;return function(o,s,c){if(c){dB(i)||(e?.(i),i=v0());return}if(o.length===0)e?.(i),i=v0();else if(s>0){let u=n.decode(o.subarray(0,s)),l=s+(o[s+1]===32?2:1),d=n.decode(o.subarray(l));switch(u){case"data":i.data=i.data?i.data+`
|
|
408
|
+
`+d:d;break;case"event":i.event=d;break;case"id":t?.(i.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(i.retry=f);break}}}}}function uB(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function v0(){return{data:"",event:"",id:"",retry:void 0}}function lB(e,t){let r=new ReadableStream({async start(i){let n=pN(o=>{if(o.event==="error")throw new Error(o.data??"Unspecified event streaming error.");o.event==="metadata"?t?.(o):o.data&&i.enqueue(o.data)});await dN(e,fN((o,s,c)=>{n(o,s,c),c&&i.close()}))}});return ft.fromReadableStream(r)}function dB(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var mN=A({});var hN=A({convertToOpenAIFunction:()=>gN,convertToOpenAITool:()=>fB,isLangChainTool:()=>Ju,isRunnableToolLike:()=>Hu,isStructuredTool:()=>Zu,isStructuredToolParams:()=>Gu});function gN(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:yt(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function fB(e,t){let r=typeof t=="number"?void 0:t,i;return Ju(e)?i={type:"function",function:gN(e)}:i=e,r?.strict!==void 0&&(i.function.strict=r.strict),i}function Tm(e,t){let r=0,i=0,n=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],i+=e[a]*e[a],n+=t[a]*t[a];return r/(Math.sqrt(i)*Math.sqrt(n))}function _N(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}function pB(e,t){let r=0;for(let i=0;i<e.length;i++)r+=(e[i]-t[i])*(e[i]-t[i]);return r}function yN(e,t){return Math.sqrt(pB(e,t))}var vN=A({cosineSimilarity:()=>b0,euclideanDistance:()=>gB,innerProduct:()=>hB,matrixFunc:()=>Am,maximalMarginalRelevance:()=>_B,normalize:()=>mB});function Am(e,t,r){if(e.length===0||e[0].length===0||t.length===0||t[0].length===0)return[[]];if(e[0].length!==t[0].length)throw new Error(`Number of columns in X and Y must be the same. X has shape ${[e.length,e[0].length]} and Y has shape ${[t.length,t[0].length]}.`);return e.map(i=>t.map(n=>r(i,n)).map(n=>Number.isNaN(n)?0:n))}function mB(e,t=!1){let r=yB(e);return e.map(i=>i.map(n=>t?1-n/r:n/r))}function b0(e,t){return Am(e,t,Tm)}function hB(e,t){return Am(e,t,_N)}function gB(e,t){return Am(e,t,yN)}function _B(e,t,r=.5,i=4){if(Math.min(i,t.length)<=0)return[];let n=b0(Array.isArray(e[0])?e:[e],t)[0],a=bN(n).maxIndex,o=[t[a]],s=[a];for(;s.length<Math.min(i,t.length);){let c=-1/0,u=-1,l=b0(t,o);n.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...l[f]),m=r*d-(1-r)*p;m>c&&(c=m,u=f)}),o.push(t[u]),s.push(u)}return s}function bN(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let i=1;i<e.length;i+=1)e[i]>t&&(r=i,t=e[i]);return{maxIndex:r,maxValue:t}}function yB(e){return e.reduce((t,r)=>Math.max(t,bN(r).maxValue),0)}var wN=A({isCloudMetadata:()=>w0,isLocalhost:()=>x0,isPrivateIp:()=>IN,isSafeUrl:()=>IB,isSameOrigin:()=>EB,validateSafeUrl:()=>EN}),vB=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8","169.254.0.0/16","0.0.0.0/8","::1/128","fc00::/7","fe80::/10","ff00::/8"],bB=["169.254.169.254","169.254.170.2","100.100.100.200"],wB=["metadata.google.internal","metadata","instance-data"],xB=["localhost","localhost.localdomain"],SB=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function xN(e){return SB.test(e)}function Cm(e){return $N(e)!==null}function SN(e){return xN(e)||Cm(e)}function kN(e){if(xN(e))return e.split(".").map(t=>parseInt(t,10));if(Cm(e)){let t=$N(e);if(!t)return null;let r=t.split(":"),i=[];for(let n of r)i.push(parseInt(n,16));return i}return null}function $N(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let i=t.split("::");if(i.length>2)return null;let[n,a]=i,o=n?n.split(":"):[],s=a?a.split(":"):[],c=8-(o.length+s.length);if(c<0)return null;let u=Array(c).fill("0");t=[...o,...u,...s].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let i of r)if(i.length===0||i.length>4||!/^[0-9a-fA-F]+$/.test(i))return null;return r.map(i=>i.padStart(4,"0").toLowerCase()).join(":")}function kB(e){let[t,r]=e.split("/");if(!t||!r)return null;let i=kN(t);if(!i)return null;let n=parseInt(r,10);if(isNaN(n))return null;let a=Cm(t);return a&&n>128||!a&&n>32?null:{addr:i,prefixLen:n,isIpv6:a}}function $B(e,t){let r=kN(e);if(!r)return!1;let i=kB(t);if(!i)return!1;let n=Cm(e);if(n!==i.isIpv6)return!1;let{addr:a,prefixLen:o}=i;if(n)for(let s=0;s<Math.ceil(o/16);s++){let c=65535<<16-Math.min(16,o-s*16)&65535;if((r[s]&c)!==(a[s]&c))return!1}else for(let s=0;s<Math.ceil(o/8);s++){let c=255<<8-Math.min(8,o-s*8)&255;if((r[s]&c)!==(a[s]&c))return!1}return!0}function IN(e){if(!SN(e))return!1;for(let t of vB)if($B(e,t))return!0;return!1}function w0(e,t){if(bB.includes(t||""))return!0;let r=e.toLowerCase();return!!wB.includes(r)}function x0(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let r=e.toLowerCase();return!!xB.includes(r)}function EN(e,t){let r=t?.allowPrivate??!1,i=t?.allowHttp??!1;try{let n;try{n=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let a=n.hostname;if(!a)throw new Error("URL missing hostname.");if(w0(a))throw new Error(`URL points to cloud metadata endpoint: ${a}`);if(x0(a)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}let o=n.protocol;if(o!=="http:"&&o!=="https:")throw new Error(`Invalid URL scheme: ${o}. Only http and https are allowed.`);if(o==="http:"&&!i)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(SN(a)){let s=a;if(x0(a,s)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}if(w0(a,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${a})`);if(IN(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${a}). Set allowPrivate: true to allow.`);return e}return e}catch(n){throw n&&typeof n=="object"&&"message"in n?n:new Error(`URL validation failed: ${n}`)}}function IB(e,t){try{return EN(e,t),!0}catch{return!1}}function EB(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var TN=A({SaveableVectorStore:()=>TB,VectorStore:()=>Pm,VectorStoreRetriever:()=>Om}),Om=class extends Fu{static lc_name(){return"VectorStoreRetriever"}get lc_namespace(){return["langchain_core","vectorstores"]}vectorStore;k=4;searchType="similarity";searchKwargs;filter;_vectorstoreType(){return this.vectorStore._vectorstoreType()}constructor(e){super(e),this.vectorStore=e.vectorStore,this.k=e.k??this.k,this.searchType=e.searchType??this.searchType,this.filter=e.filter,e.searchType==="mmr"&&(this.searchKwargs=e.searchKwargs)}async _getRelevantDocuments(e,t){if(this.searchType==="mmr"){if(typeof this.vectorStore.maxMarginalRelevanceSearch!="function")throw new Error(`The vector store backing this retriever, ${this._vectorstoreType()} does not support max marginal relevance search.`);return this.vectorStore.maxMarginalRelevanceSearch(e,{k:this.k,filter:this.filter,...this.searchKwargs},t?.getChild("vectorstore"))}return this.vectorStore.similaritySearch(e,this.k,this.filter,t?.getChild("vectorstore"))}async addDocuments(e,t){return this.vectorStore.addDocuments(e,t)}},Pm=class extends ut{lc_namespace=["langchain","vectorstores",this._vectorstoreType()];embeddings;constructor(e,t){super(t),this.embeddings=e}async delete(e){throw new Error("Not implemented.")}async similaritySearch(e,t=4,r=void 0,i=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(n=>n[0])}async similaritySearchWithScore(e,t=4,r=void 0,i=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,i){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,r,i,n,a){if(typeof e=="number")return new Om({vectorStore:this,k:e,filter:t,tags:[...i??[],this._vectorstoreType()],metadata:n,verbose:a,callbacks:r});{let o={vectorStore:this,k:e?.k,filter:e?.filter,tags:[...e?.tags??[],this._vectorstoreType()],metadata:e?.metadata,verbose:e?.verbose,callbacks:e?.callbacks,searchType:e?.searchType};return e?.searchType==="mmr"?new Om({...o,searchKwargs:e.searchKwargs}):new Om({...o})}}},TB=class extends Pm{static load(e,t){throw new Error("Not implemented")}};var AN=class extends ca{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Ee(t.stop[0]),text:t.stop[0]}]};let i=e.map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content,null,2)).join(`
|
|
409
|
+
`);return await r?.handleLLMNewToken(i),{generations:[{message:new Ee(i),text:i}],llmOutput:{}}}},CN=class ON extends ca{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:i=[],toolStyle:n="openai",thrownErrorString:a,...o}){super(o),this.sleep=t,this.responses=r,this.chunks=i,this.toolStyle=n,this.thrownErrorString=a}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:yt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:yt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:yt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:yt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new ON({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return a.tools=r,a.withConfig({tools:n})}async _generate(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Ee({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let o of this.chunks){let s=new Vi({message:new Qe({content:o.content,tool_calls:o.tool_calls,additional_kwargs:o.additional_kwargs??{}}),text:o.content?.toString()??""});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let n=this.responses?.[0]??new Ee(typeof t[0].content=="string"?t[0].content:""),a=typeof n.content=="string"?n.content:"";for(let o of a){await new Promise(c=>setTimeout(c,this.sleep));let s=new Vi({message:new Qe({content:o}),text:o});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o,void 0,void 0,void 0,void 0,{chunk:s})}}},PN=class NN extends ca{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:r,sleep:i,emitCustomEvent:n,generationInfo:a}=t;this.responses=r,this.sleep=i,this.emitCustomEvent=n??this.emitCustomEvent,this.generationInfo=a}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,i){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let n=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(n)],llmOutput:{}}}}_formatGeneration(t){return{message:new Ee(t),text:t}}async*_streamResponseChunks(t,r,i){let n=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0});let a=[...n];for(let o=0;o<a.length;o++){let s=a[o],c=o===a.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let u=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield u,i?.handleLLMNewToken(s)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,r){return new Vi({message:new Qe({content:t}),text:t,generationInfo:r})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:yt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:yt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:yt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:yt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new NN({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return a.tools=r,a.toolStyle=this.toolStyle,a.i=this.i,a.withConfig({tools:n})}withStructuredOutput(t,r){return Dt.from(async i=>{let n=await this.invoke(i);if(n.tool_calls?.[0]?.args)return n.tool_calls[0].args;if(typeof n.content=="string")return JSON.parse(n.content);throw new Error("No structured output found")})}};var RN=class extends Ep{vectorSize;constructor(e){super(e??{}),this.vectorSize=e?.vectorSize??4}async embedDocuments(e){return Promise.all(e.map(t=>this.embedQuery(t)))}async embedQuery(e){let t=e;t=t.toLowerCase().replaceAll(/[^a-z ]/g,"");let r=t.length%this.vectorSize,i=r===0?0:this.vectorSize-r,n=t.length+i;t=t.padEnd(n," ");let a=t.length/this.vectorSize,o=[];for(let s=0;s<t.length;s+=a)o.push(t.slice(s,s+a));return o.map(s=>{let c=0;for(let u=0;u<s.length;u+=1)c+=s===" "?0:s.charCodeAt(u);return c%26/26})}},MN=class extends Ep{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}};var jN=class extends Fp{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.response??e;return await r?.handleLLMNewToken(i),i}},zN=class extends Fp{sleep=50;responses;thrownErrorString;constructor(e){super(e),this.sleep=e.sleep??this.sleep,this.responses=e.responses,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let t=this.responses?.[0];return this.responses=this.responses?.slice(1),t??e}async*_streamResponseChunks(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.responses?.[0];this.responses=this.responses?.slice(1);for(let n of i??e)await new Promise(a=>setTimeout(a,this.sleep)),yield{text:n,generationInfo:{}},await r?.handleLLMNewToken(n)}};var DN=class extends fw{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async addUserMessage(e){this.messages.push(new rt(e))}async addAIMessage(e){this.messages.push(new Ee(e))}async clear(){this.messages=[]}},UN=class extends Ip{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},LN=class extends At{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var FN=class extends pn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var BN=class extends Fu{lc_namespace=["test","fake"];output=[new Or({pageContent:"foo"}),new Or({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var VN=class extends ae{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var ZN=class extends cl{name;description;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.schema=e.schema}async _call(e,t){return JSON.stringify(e)}};var HN=class extends At{runPromiseResolver;runPromise;name="single_run_extractor";constructor(){super(),this.runPromise=new Promise(e=>{this.runPromiseResolver=e})}async persistRun(e){this.runPromiseResolver(e)}async extract(){return this.runPromise}};var GN=class JN extends Pm{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...i}={}){super(t,i),this.similarity=r??Tm}async addDocuments(t){let r=t.map(({pageContent:i})=>i);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let i=t.map((n,a)=>({content:r[a].pageContent,embedding:n,metadata:r[a].metadata}));this.memoryVectors=this.memoryVectors.concat(i)}async similaritySearchVectorWithScore(t,r,i){let n=o=>i?i(new Or({metadata:o.metadata,pageContent:o.content})):!0,a=this.memoryVectors.filter(n);return a.map((o,s)=>({similarity:this.similarity(t,o.embedding),index:s})).sort((o,s)=>o.similarity>s.similarity?-1:0).slice(0,r).map(o=>[new Or({metadata:a[o.index].metadata,pageContent:a[o.index].content}),o.similarity])}static async fromTexts(t,r,i,n){let a=[];for(let o=0;o<t.length;o+=1){let s=Array.isArray(r)?r[o]:r,c=new Or({pageContent:t[o],metadata:s});a.push(c)}return JN.fromDocuments(a,i,n)}static async fromDocuments(t,r,i){let n=new this(r,i);return await n.addDocuments(t),n}static async fromExistingIndex(t,r){return new this(t,r)}};var KN=A({FakeChatMessageHistory:()=>DN,FakeChatModel:()=>AN,FakeEmbeddings:()=>MN,FakeLLM:()=>jN,FakeListChatMessageHistory:()=>UN,FakeListChatModel:()=>PN,FakeRetriever:()=>BN,FakeRunnable:()=>VN,FakeSplitIntoListParser:()=>FN,FakeStreamingChatModel:()=>CN,FakeStreamingLLM:()=>zN,FakeTool:()=>ZN,FakeTracer:()=>LN,FakeVectorStore:()=>GN,SingleRunExtractor:()=>HN,SyntheticEmbeddings:()=>RN});var WN=A({agents:()=>KS,caches:()=>qk,callbacks__base:()=>m$,callbacks__manager:()=>fE,callbacks__promises:()=>uE,chat_history:()=>WC,document_loaders__base:()=>YC,document_loaders__langsmith:()=>QC,documents:()=>XC,embeddings:()=>eO,errors:()=>YS,example_selectors:()=>uO,index:()=>JS,indexing:()=>fO,language_models__base:()=>bO,language_models__chat_models:()=>QO,language_models__compat:()=>WO,language_models__event:()=>eP,language_models__llms:()=>tP,language_models__profile:()=>nP,language_models__stream:()=>VO,language_models__structured_output:()=>FO,load__serializable:()=>DS,memory:()=>iP,messages:()=>KC,messages__tool:()=>vk,output_parsers:()=>zO,output_parsers__openai_functions:()=>sP,output_parsers__openai_tools:()=>cP,outputs:()=>AE,prompt_values:()=>pO,prompts:()=>wP,retrievers:()=>SP,retrievers__document_compressors:()=>xP,runnables:()=>$O,runnables__graph:()=>SC,singletons:()=>yE,stores:()=>kP,structured_query:()=>OP,testing:()=>jP,tools:()=>rN,tracers__base:()=>QI,tracers__console:()=>tE,tracers__log_stream:()=>TE,tracers__run_collector:()=>oN,tracers__tracer_langchain:()=>aE,types__stream:()=>sN,utils__async_caller:()=>RE,utils__chunk_array:()=>cN,utils__context:()=>uN,utils__env:()=>LS,utils__event_source_parse:()=>lN,utils__format:()=>mN,utils__function_calling:()=>hN,utils__hash:()=>WS,utils__json_patch:()=>IO,utils__json_schema:()=>gC,utils__math:()=>vN,utils__ssrf:()=>wN,utils__standard_schema:()=>ME,utils__stream:()=>vE,utils__testing:()=>KN,utils__tiktoken:()=>yO,utils__types:()=>DO,utils__uuid:()=>p$,vectorstores:()=>TN});var AB=50;function CB(e){let t={};for(let r=e;r&&r.prototype;r=Object.getPrototypeOf(r))Object.assign(t,Reflect.get(r.prototype,"lc_aliases"));return Object.entries(t).reduce((r,[i,n])=>(r[n]=i,r),{})}async function Nm(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:i,secretsMap:n,secretsFromEnv:a,path:o,depth:s,maxDepth:c}=this,u=o.join(".");if(s>c)throw new Error(`Maximum recursion depth (${c}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);if(typeof e!="object"||e==null)return e;if(Array.isArray(e))return Promise.all(e.map((f,p)=>Nm.call({...this,path:[...o,`${p}`],depth:s+1},f)));let l=e;if(Ph(l))return Vl(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[f]=l.id;if(f in n)return n[f];if(a){let p=Ht(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let f=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${f}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let f=l,p=JSON.stringify(f),[m,...g]=f.id.slice().reverse(),y=g.reverse(),b={langchain_core:WN,langchain:i},w=null,x=[y.join("/")];y[0]==="langchain_community"&&x.push(["langchain",...y.slice(1)].join("/"));let k=x.find(C=>C in t);if(GS.concat(r).includes(y.join("/"))||k)if(k!==void 0)w=await t[k];else throw new Error(`Missing key "${y.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let C;if(y[0]==="langchain"||y[0]==="langchain_core")C=b[y[0]],y.shift();else throw new Error(`Invalid namespace: ${u} -> ${p}`);if(y.length===0)throw new Error(`Invalid namespace: ${u} -> ${p}`);let v;do{if(v=y.join("__"),v in C)break;y.pop()}while(y.length>0);v in C&&(w=C[v])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${u} -> ${p}`);let E=w[m]??Object.values(w).find(C=>typeof C=="function"&&Fo(C)===m);if(typeof E!="function")throw new Error(`Invalid identifer: ${u} -> ${p}`);let V=new E(Fl(await Nm.call({...this,path:[...o,"kwargs"],depth:s+1},f.kwargs),RS,CB(E)));return Object.defineProperty(V.constructor,"name",{value:m}),V}let d={};for(let[f,p]of Object.entries(l))d[f]=await Nm.call({...this,path:[...o,f],depth:s+1},p);return d}async function qN(e,t){let r=JSON.parse(e),i={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??AB};return Nm.call(i,r)}function OB(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function S0(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>S0(t)));{let t={};for(let[r,i]of Object.entries(e))t[r]=await S0(i);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let r=t.id[t.id.length-1],i;switch(r){case"Set":i=Set;break;case"Map":i=Map;break;case"RegExp":i=RegExp;break;case"Error":i=Error;break;case"Uint8Array":i=Uint8Array;break;default:return t}return t.method?i[t.method](...t.args||[]):new i(...t.args||[])}catch{return t}else if(OB(t))return qN(JSON.stringify(t));return t}}return e}function Rm(e,t,r,i){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:i??{}}}function PB(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Set||e instanceof Map?Rm(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?Rm(RegExp,void 0,[e.source,e.flags]):e instanceof Error?Rm(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args}:e instanceof Uint8Array?Rm(Uint8Array,"from",[Array.from(e)]):e}var Mm=class{_dumps(e){return new TextEncoder().encode(OS(e,(t,r)=>PB(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return S0(JSON.parse(e))}async loadsTyped(e,t){if(e==="bytes")return typeof t=="string"?new TextEncoder().encode(t):t;if(e==="json")return this._loads(typeof t=="string"?t:new TextDecoder().decode(t));throw new Error(`Unknown serialization type: ${e}`)}};function k0(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=k0(e[r]));return t}function sc(){return{v:4,id:Ic(-2),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function gn(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:k0(e.versions_seen)}}var jm=class{serde=new Mm;constructor(e){this.serde=e||this.serde}async get(e){let t=await this.getTuple(e);return t?t.checkpoint:void 0}getNextVersion(e){if(typeof e=="string")throw new Error("Please override this method to use string versions.");return e!==void 0&&typeof e=="number"?e+1:1}};function zm(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function ul(...e){return e.reduce((t,r,i)=>i===0?r:zm(t,r)>=0?t:r)}var ll={[Eh]:-1,[Ia]:-2,[Th]:-3,[Ah]:-4};function $0(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}function dl(e,t,r){return JSON.stringify([e,t,r])}function NB(e){let[t,r,i]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:i}}var XN=class extends jm{storage={};writes={};constructor(e){super(e)}async _migratePendingSends(e,t,r,i){let n=e,a=dl(t,r,i),o=await Promise.all(Object.values(this.writes[a]??{}).filter(([s,c])=>c===Ec).map(async([s,c,u])=>await this.serde.loadsTyped("json",u)));n.channel_values??={},n.channel_values[Ec]=o,n.channel_versions??={},n.channel_versions[Ec]=Object.keys(n.channel_versions).length>0?ul(...Object.values(n.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",i=$0(e);if(i){let n=this.storage[t]?.[r]?.[i];if(n!==void 0){let[a,o,s]=n,c=dl(t,r,i),u=await this.serde.loadsTyped("json",a);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:e,checkpoint:u,metadata:await this.serde.loadsTyped("json",o),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let n=this.storage[t]?.[r];if(n!==void 0){i=Object.keys(n).sort((f,p)=>p.localeCompare(f))[0];let[a,o,s]=n[i],c=dl(t,r,i),u=await this.serde.loadsTyped("json",a);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:{configurable:{thread_id:t,checkpoint_id:i,checkpoint_ns:r}},checkpoint:u,metadata:await this.serde.loadsTyped("json",o),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}}async*list(e,t){let{before:r,limit:i,filter:n}=t??{},a=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),o=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of a)for(let u of Object.keys(this.storage[c]??{})){if(o!==void 0&&u!==o)continue;let l=this.storage[c]?.[u]??{},d=Object.entries(l).sort((f,p)=>p[0].localeCompare(f[0]));for(let[f,[p,m,g]]of d){if(s&&f!==s||r&&r.configurable?.checkpoint_id&&f>=r.configurable.checkpoint_id)continue;let y=await this.serde.loadsTyped("json",m);if(n&&!Object.entries(n).every(([V,C])=>y[V]===C))continue;if(i!==void 0){if(i<=0)break;i-=1}let b=dl(c,u,f),w=Object.values(this.writes[b]||{}),x=await Promise.all(w.map(async([V,C,v])=>[V,C,await this.serde.loadsTyped("json",v)])),k=await this.serde.loadsTyped("json",p);k.v<4&&g!==void 0&&await this._migratePendingSends(k,c,u,g);let E={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:f}},checkpoint:k,metadata:y,pendingWrites:x};g!==void 0&&(E.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:g}}),yield E}}}async put(e,t,r){let i=gn(t),n=e.configurable?.thread_id,a=e.configurable?.checkpoint_ns??"";if(n===void 0)throw new Error('Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');this.storage[n]||(this.storage[n]={}),this.storage[n][a]||(this.storage[n][a]={});let[[,o],[,s]]=await Promise.all([this.serde.dumpsTyped(i),this.serde.dumpsTyped(r)]);return this.storage[n][a][t.id]=[o,s,e.configurable?.checkpoint_id],{configurable:{thread_id:n,checkpoint_ns:a,checkpoint_id:t.id}}}async putWrites(e,t,r){let i=e.configurable?.thread_id,n=e.configurable?.checkpoint_ns,a=e.configurable?.checkpoint_id;if(i===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');if(a===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');let o=dl(i,n,a),s=this.writes[o];this.writes[o]===void 0&&(this.writes[o]={}),await Promise.all(t.map(async([c,u],l)=>{let[,d]=await this.serde.dumpsTyped(u),f=[r,ll[c]||l],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[o][p]=[r,c,d])}))}async deleteThread(e){delete this.storage[e];for(let t of Object.keys(this.writes))NB(t).threadId===e&&delete this.writes[t]}};var cc=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function RB(e){if(e.length===0)throw new cc("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new cc(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new cc(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new cc(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new cc(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var uc=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:i=10,offset:n=0,query:a}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:i,offset:n,query:a}]))[0]}async put(e,t,r,i){RB(e),await this.batch([{namespace:e,key:t,value:r,index:i}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:i,limit:n=100,offset:a=0}=e,o=[];return t&&o.push({matchType:"prefix",path:t}),r&&o.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:o.length?o:void 0,maxDepth:i,limit:n,offset:a}]))[0]}start(){}stop(){}};var MB=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,Dm=class extends uc{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=MB(e)}get isRunning(){return this.running}async batch(e){throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.")}async get(e,t){return this.enqueueOperation({namespace:e,key:t})}async search(e,t){let{filter:r,limit:i=10,offset:n=0,query:a}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:i,offset:n,query:a})}async put(e,t,r){return this.enqueueOperation({namespace:e,key:t,value:r})}async delete(e,t){return this.enqueueOperation({namespace:e,key:t,value:null})}start(){this.running||(this.running=!0,this.processingTask=this.processBatchQueue())}async stop(){this.running=!1,this.processingTask&&await this.processingTask}enqueueOperation(e){return new Promise((t,r)=>{let i=this.nextKey;this.nextKey+=1,this.queue.set(i,{operation:e,resolve:t,reject:r})})}async processBatchQueue(){for(;this.running;){if(await new Promise(t=>{setTimeout(t,0)}),this.queue.size===0)continue;let e=new Map(this.queue);this.queue.clear();try{let t=Array.from(e.values()).map(({operation:i})=>i),r=await this.store.batch(t);e.forEach(({resolve:i},n)=>{i(r[Array.from(e.keys()).indexOf(n)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function fl(e){if(!e)return[];let t=[],r=[],i=0;for(;i<e.length;){let n=e[i];if(n==="["){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["["];for(i+=1;i<e.length&&a>0;)e[i]==="["?a+=1:e[i]==="]"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else if(n==="{"){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["{"];for(i+=1;i<e.length&&a>0;)e[i]==="{"?a+=1:e[i]==="}"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else n==="."?r.length&&(t.push(r.join("")),r=[]):r.push(n);i+=1}return r.length&&t.push(r.join("")),t}function jB(e){return typeof e=="object"&&e!==null&&Object.keys(e).every(t=>t==="$eq"||t==="$ne"||t==="$gt"||t==="$gte"||t==="$lt"||t==="$lte"||t==="$in"||t==="$nin")}function YN(e,t){return jB(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let i=t[r];switch(r){case"$eq":return e===i;case"$ne":return e!==i;case"$gt":return Number(e)>Number(i);case"$gte":return Number(e)>=Number(i);case"$lt":return Number(e)<Number(i);case"$lte":return Number(e)<=Number(i);case"$in":return Array.isArray(i)?i.includes(e):!1;case"$nin":return Array.isArray(i)?!i.includes(e):!0;default:return!1}}):e===t}function QN(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:fl(t);function i(n,a,o){if(o>=a.length)return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?[String(n)]:n==null?[]:Array.isArray(n)||typeof n=="object"?[JSON.stringify(n,null,2)]:[];let s=a[o],c=[];if(o===0&&s==="$"&&c.push(JSON.stringify(n,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(n))return[];let u=s.slice(1,-1);if(u==="*")for(let l of n)c.push(...i(l,a,o+1));else try{let l=parseInt(u,10);l<0&&(l=n.length+l),l>=0&&l<n.length&&c.push(...i(n[l],a,o+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof n!="object"||n===null)return[];let u=s.slice(1,-1).split(",").map(l=>l.trim());for(let l of u){let d=fl(l);if(d.length){let f=n;for(let p of d)if(f&&typeof f=="object"&&p in f)f=f[p];else{f=void 0;break}f!==void 0&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean"?c.push(String(f)):(Array.isArray(f)||typeof f=="object")&&c.push(JSON.stringify(f,null,2)))}}}else if(s==="*"){if(Array.isArray(n))for(let u of n)c.push(...i(u,a,o+1));else if(typeof n=="object"&&n!==null)for(let u of Object.values(n))c.push(...i(u,a,o+1))}else typeof n=="object"&&n!==null&&s in n&&c.push(...i(n[s],a,o+1));return c}return i(e,r,0)}var eR=class extends uc{data=new Map;vectors=new Map;_indexConfig;constructor(e){super(),e?.index&&(this._indexConfig={...e.index,__tokenizedFields:(e.index.fields??["$"]).map(t=>[t,t==="$"?[t]:fl(t)])})}async batch(e){let t=[],r=new Map,i=new Map;for(let n=0;n<e.length;n+=1){let a=e[n];if("key"in a&&"namespace"in a&&!("value"in a))t.push(this.getOperation(a));else if("namespacePrefix"in a){let o=this.filterItems(a);i.set(n,[a,o]),t.push(null)}else if("value"in a){let o=`${a.namespace.join(":")}:${a.key}`;r.set(o,a),t.push(null)}else"matchConditions"in a&&t.push(this.listNamespacesOperation(a))}if(i.size>0)if(this._indexConfig?.embeddings){let n=new Set;for(let[s]of i.values())s.query&&n.add(s.query);let a=n.size>0?await Promise.all(Array.from(n).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],o=Object.fromEntries(Array.from(n).map((s,c)=>[s,a[c]]));for(let[s,[c,u]]of i.entries())if(c.query&&o[c.query]){let l=o[c.query];t[s]=this.scoreResults(u,l,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(u.map(l=>({...l,score:void 0})),c.offset??0,c.limit??10)}else for(let[n,[a,o]]of i.entries())t[n]=this.paginateResults(o.map(s=>({...s,score:void 0})),a.offset??0,a.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let n=this.extractTexts(Array.from(r.values()));if(Object.keys(n).length>0){let a=await this._indexConfig.embeddings.embedDocuments(Object.keys(n));this.insertVectors(n,a)}}for(let n of r.values())this.putOperation(n);return t}getOperation(e){let t=e.namespace.join(":");return this.data.get(t)?.get(e.key)??null}putOperation(e){let t=e.namespace.join(":");this.data.has(t)||this.data.set(t,new Map);let r=this.data.get(t);if(e.value===null)r.delete(e.key);else{let i=new Date;if(r.has(e.key)){let n=r.get(e.key);n.value=e.value,n.updatedAt=i}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:i,updatedAt:i})}}listNamespacesOperation(e){let t=Array.from(this.data.keys()).map(r=>r.split(":"));return e.matchConditions&&e.matchConditions.length>0&&(t=t.filter(r=>e.matchConditions.every(i=>this.doesMatch(i,r)))),e.maxDepth!==void 0&&(t=Array.from(new Set(t.map(r=>r.slice(0,e.maxDepth).join(":")))).map(r=>r.split(":"))),t.sort((r,i)=>r.join(":").localeCompare(i.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:i}=e;if(r==="prefix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[a];return n==="*"||o===n});if(r==="suffix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[t.length-i.length+a];return n==="*"||o===n});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[i,n]of this.data.entries())i.startsWith(e.namespacePrefix.join(":"))&&t.push(...n.values());let r=t;return e.filter&&(r=t.filter(i=>Object.entries(e.filter).every(([n,a])=>YN(i.value[n],a)))),r}scoreResults(e,t,r=0,i=10){let n=[],a=[],o=[];for(let l of e){let d=this.getVectors(l);if(d.length)for(let f of d)n.push(l),a.push(f);else o.push(l)}let s=this.cosineSimilarity(t,a).map((l,d)=>[l,n[d]]).sort((l,d)=>d[0]-l[0]),c=new Set,u=[];for(let[l,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+i)break;if(p<r){c.add(f);continue}c.add(f),u.push([l,d])}if(o.length&&u.length<i)for(let l of o.slice(0,i-u.length)){let d=`${l.namespace.join(":")}:${l.key}`;c.has(d)||(c.add(d),u.push([void 0,l]))}return u.map(([l,d])=>({...d,score:l}))}paginateResults(e,t,r){return e.slice(t,t+r)}extractTexts(e){if(!e.length||!this._indexConfig)return{};let t={};for(let r of e)if(r.value!==null&&r.index!==!1){let i=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(n=>[n,fl(n)]);for(let[n,a]of i){let o=QN(r.value,a);o.length&&(o.length>1?o.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${n}.${c}`])}):(t[o[0]]||(t[o[0]]=[]),t[o[0]].push([r.namespace,r.key,n])))}}return t}insertVectors(e,t){for(let[r,i]of Object.entries(e)){let n=t.shift();if(!n)throw new Error(`No embedding found for text: ${r}`);for(let[a,o,s]of i){let c=a.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let u=this.vectors.get(c);u.has(o)||u.set(o,new Map),u.get(o).set(s,n)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let i=this.vectors.get(t);if(!i.has(r))return[];let n=i.get(r),a=Array.from(n.values());return a.length?a:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(a=>a.reduce((o,s,c)=>o+s*e[c],0)),i=Math.sqrt(e.reduce((a,o)=>a+o*o,0)),n=t.map(a=>Math.sqrt(a.reduce((o,s)=>o+s*s,0)));return r.map((a,o)=>{let s=n[o];return i&&s?a/(i*s):0})}get indexConfig(){return this._indexConfig}};var Um=class{serde=new Mm;constructor(e){this.serde=e||this.serde}};function E0(e){return e!=null&&e.lg_is_channel===!0}var kt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Ne.unminifiable_name)return!1;throw e}}equals(e){return this===e}},I0=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function pl(e){if(e[I0]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];E0(i)&&(t[r]=i)}return Object.assign(t,{[I0]:!0}),t}function ua(e,t){let r=pl(e),i={};for(let n in r){if(!Object.prototype.hasOwnProperty.call(r,n))continue;let a=t.channel_values[n];i[n]=r[n].fromCheckpoint(a)}return Object.assign(i,{[I0]:!0}),i}function _n(e,t,r,i){let n;if(t===void 0)n=e.channel_values;else{n={};for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))try{n[a]=t[a].checkpoint()}catch(o){if(o.name!==Ne.unminifiable_name)throw o}}return{v:4,id:i?.id??Ic(r),ts:new Date().toISOString(),channel_values:n,channel_versions:e.channel_versions,versions_seen:e.versions_seen}}var zB=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",xi=class tR extends kt{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,r){super(),this.operator=t,this.initialValueFactory=r,this.value=r?.()}fromCheckpoint(t){let r=new tR(this.operator,this.initialValueFactory);return typeof t<"u"&&(r.value=t),r}update(t){let r=t;if(!r.length)return!1;if(this.value===void 0){let n=r[0],[a,o]=Cl(n);a?this.value=o:this.value=n,r=r.slice(1)}let i=!1;for(let n of r)if(kS(n)){if(i)throw new be("Can receive only one Overwrite value per step.");let[,a]=Cl(n);this.value=a,i=!0;continue}else!i&&this.value!==void 0&&(this.value=this.operator(this.value,n));return!0}get(){if(this.value===void 0)throw new Ne;return this.value}checkpoint(){if(this.value===void 0)throw new Ne;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:zB(t)?this.operator===t.operator:!1}};var yn=class rR extends kt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new rR(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new be("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ne;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ne;return this.value[0]}isAvailable(){return this.value.length!==0}},T0=class nR extends kt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new nR;if(typeof t<"u"){let[i,n]=t;r.value=[i],r.finished=n}return r}update(t){return t.length===0?!1:(this.finished=!1,this.value=[t[t.length-1]],!0)}get(){if(this.value.length===0||!this.finished)throw new Ne;return this.value[0]}checkpoint(){if(this.value.length!==0)return[this.value[0],this.finished]}consume(){return this.finished?(this.finished=!1,this.value=[],!0):!1}finish(){return!this.finished&&this.value.length>0?(this.finished=!0,!0):!1}isAvailable(){return this.value.length!==0&&this.finished}};var Lm=class{lc_graph_name="AnnotationRoot";spec;constructor(e){this.spec=e}static isInstance(e){return typeof e=="object"&&e!==null&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"}},ml=function(e){return e?Fm(e):new yn};ml.Root=e=>new Lm(e);function Fm(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new xi(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new xi(e.value,e.default):new yn}var DB=["tags","metadata","callbacks","configurable"],UB=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","executionInfo","serverInfo"],LB=25,FB=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function BB(e,t){if(!e)return t;let r=t??{};for(let i of FB){if(i in r)continue;let n=e[i];n!==void 0&&(r[i]=n)}return r}function lc(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:LB,configurable:{}},r=Te.getRunnableConfig();if(r!==void 0){for(let[i,n]of Object.entries(r))if(n!==void 0)if(DB.includes(i)){let a;Array.isArray(n)?a=[...n]:typeof n=="object"?i==="callbacks"&&"copy"in n&&typeof n.copy=="function"?a=n.copy():a={...n}:a=n,t[i]=a}else t[i]=n}for(let i of e)if(i!==void 0)for(let[n,a]of Object.entries(i))a!==void 0&&UB.includes(n)&&(t[n]=a);return t.metadata=BB(t.configurable,t.metadata)??{},t}function VB(e){let t=e??Te.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getStore` in such environment, pass the `config` from the node function directly."].join(`
|
|
410
|
+
`));return t?.store}function ZB(e){let t=e??Te.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getWriter` in such environment, pass the `config` from the node function directly."].join(`
|
|
411
|
+
`));return t?.writer||t?.configurable?.writer}function A0(){return Te.getRunnableConfig()}function HB(e){let t=e??Te.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
|
|
412
|
+
`));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[ir].currentTaskInput}function Bm(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function iR(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var C0=Symbol.for("langgraph.stream_channel"),Wr=class O0{[C0]=!0;channelName;#e=[];#o=[];#r=!1;#i;#n;constructor(t){this.channelName=t}static local(){return new O0}static remote(t){return new O0(t)}static isInstance(t){return typeof t=="object"&&t!==null&&C0 in t&&t[C0]===!0}push(t){this.#e.push(t),this.#t(),this.#n?.(t)}iterate(t=0){let r=t;return{next:async()=>{for(;;){if(r<this.#e.length)return{value:this.#e[r++],done:!1};if(this.#r){if(this.#i)throw this.#i;return{value:void 0,done:!0}}await new Promise(i=>this.#o.push(i))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,i=this.iterate(t.startAt),n=t.event??this.channelName,a=t.serialize??(o=>JSON.stringify(o)??"null");return new ReadableStream({async pull(o){try{let s=await i.next();if(s.done){o.close();return}let c=[];n!=null&&c.push(`event: ${n}`);for(let u of a(s.value).split(/\r\n|\r|\n/))c.push(`data: ${u}`);o.enqueue(r.encode(`${c.join(`
|
|
413
|
+
`)}
|
|
414
|
+
|
|
415
|
+
`))}catch(s){o.error(s)}},async cancel(){await i.return?.()}})}get(t){if(t<0||t>=this.#e.length)throw new RangeError(`StreamChannel index ${t} out of bounds (size=${this.#e.length})`);return this.#e[t]}get size(){return this.#e.length}get done(){return this.#r}close(){this.#r=!0,this.#t()}fail(t){this.#i=t,this.#r=!0,this.#t()}_wire(t){this.#n=t}_close(){this.close()}_fail(t){this.fail(t)}[Symbol.asyncIterator](){return this.iterate()}#t(){let t=this.#o.splice(0);for(let r of t)r()}};function aR(e){return Wr.isInstance(e)}var P0=["values","updates","messages","tools","custom","tasks"];function GB(e){if(!Array.isArray(e)||e.length!==2)return{data:e};let[t,r]=e;if(r==null||typeof r!="object")return{data:e};let i=r,n=typeof i.langgraph_node=="string"?i.langgraph_node:void 0,a=typeof i.run_id=="string"?i.run_id:void 0;return{data:a!=null&&t!=null&&typeof t=="object"?{...t,run_id:a}:t,node:n}}function N0({namespace:e,mode:t,payload:r,seq:i,meta:n}){let a=Date.now(),o={type:"event"};switch(t){case"messages":{let{data:s,node:c}=GB(r);return[{...o,seq:i,method:"messages",params:{namespace:e,timestamp:a,...c?{node:c}:{},data:s}}]}case"tools":return[{...o,seq:i,method:"tools",params:{namespace:e,timestamp:a,data:JB(r)}}];case"values":{let s=[];return n?.checkpoint!=null&&s.push({...o,seq:i,method:"checkpoints",params:{namespace:e,timestamp:a,data:n.checkpoint}}),s.push({...o,seq:n?.checkpoint!=null?i+1:i,method:"values",params:{namespace:e,timestamp:a,data:r}}),s}case"updates":{let s=KB(r);return[{...o,seq:i,method:"updates",params:{namespace:e,timestamp:a,...typeof s.node=="string"?{node:s.node}:{},data:s}}]}case"custom":{let s=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...o,seq:i,method:"custom",params:{namespace:e,timestamp:a,data:s}}]}case"tasks":return[{...o,seq:i,method:"tasks",params:{namespace:e,timestamp:a,data:r}}];default:return[]}}function JB(e){if(typeof e!="object"||e===null)return{event:"tool-error",tool_call_id:"",message:"Unexpected tools payload shape"};let t=e,r=String(t.toolCallId??"");switch(t.event){case"on_tool_start":return{event:"tool-started",tool_call_id:r,tool_name:String(t.name??"unknown"),input:t.input};case"on_tool_event":return{event:"tool-output-delta",tool_call_id:r,delta:typeof t.data=="string"?t.data:JSON.stringify(t.data??"")};case"on_tool_end":return{event:"tool-finished",tool_call_id:r,output:t.output};case"on_tool_error":{let i=t.error;return{event:"tool-error",tool_call_id:r,message:typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:String(i??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function KB(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,i]=t[0];return{node:r,values:typeof i=="object"&&i!==null?i:{value:i}}}function WB(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var Vm=Symbol("resolveValues"),R0=Symbol("rejectValues"),oR=class{_events=Wr.local();_discoveries=Wr.local();#e=0;#o=!1;#r;#i=!1;#n=[];#t=[];#s=[];#a=new Map;#u=new Map;#c=[];#l=[];register(e,t){this.#a.set(Bt(e),t)}addTransformer(e){let t=this._events.size;this.#t.push(e),e.onRegister&&e.onRegister({push:(r,i)=>this.push(r,i)});for(let r=0;r<t;r+=1)e.process(this._events.get(r));this.#o&&(this.#r!==void 0?e.fail?.(this.#r):e.finalize?.())}wireChannels(e){for(let[t,r]of Object.entries(e)){if(aR(r)){if(this.#s.push(r),typeof r.channelName!="string")continue;r._wire(i=>{this._events.push({type:"event",seq:this.#e++,method:r.channelName,params:{namespace:this.#n,timestamp:Date.now(),data:i}})});continue}WB(r)&&this.#l.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#u.set(Bt(e),t.params.data);let r=this.#n;this.#n=e;let i=!0;for(let n of this.#t)n.process(t)||(i=!1);this.#n=r,i&&this._events.push({...t,seq:this.#e++})}close(){this.#o=!0;for(let[r,i]of this.#u.entries()){let n=r?r.split("\0"):[];this.#a.get(Bt(n))?.[Vm](i)}let e=[];for(let r of this.#t){let i=r.finalize?.();i!=null&&typeof i.then=="function"&&e.push(i)}for(let r of this.#s)r._close();let t=this.#l;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:i})=>{try{let n=await i;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:n}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#a.values())r[Vm](void 0)}fail(e){this.#o=!0,this.#r=e;for(let t of this.#t)t.fail?.(e);for(let t of this.#s)t._fail(e);this._events.fail(e),this._discoveries.fail(e);for(let t of this.#a.values())t[R0](e)}markInterrupted(e){this.#i=!0,this.#c.push(...e)}get interrupted(){return this.#i}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let i=await r.next();if(i.done||qn(i.value.params.namespace,e))return i}}}}};async function sR(e,t){let r=0;try{for await(let i of e){let[n,a,o,s]=i;if(a==="values"&&Sa(o)){let u=o[Ue];t.markInterrupted(u.map(l=>({interruptId:l.id??"",payload:l.value})))}let c=N0({namespace:n,mode:a,payload:o,seq:r,meta:s});r+=c.length;for(let u of c)t.push(n,u)}}catch(i){t.fail(i);return}t.close()}function Bt(e){return e.join("\0")}function qn(e,t){if(t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(e[r]!==t[r])return!1;return!0}function Hm(e,t,r=0){return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let n=await i.next();if(n.done)return{value:void 0,done:!0};if(qn(n.value.namespace,t))return{value:n.value,done:!1}}}}}}}var cR="root";function qB(e){if(e.length===0)return cR;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function XB(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Zm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function YB(e){if(!Zm(e)||e.event!=="started")return;let t=e.cause;if(Zm(t)&&typeof t.type=="string")return t}function QB(e){if(Zm(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function M0(e={}){let t=e.rootGraphName??cR,r=e.initialStatus??"running",i=e.emitRootOnRegister??!0,n=e.getGraphName??qB,a=e.serializeError??XB,o=e.getTerminalStatusOverride,s=Wr.local(),c=new Map,u=new Map,l=new Set,d=[],f,p=0,m=!1,g=T=>T.length===0?t:n(T),y=(T,B,Z)=>{let ne=Bt(T),Oe=c.get(ne),ge=Oe?.graphName??g(T);if(Oe!=null&&Oe.status===B&&Oe.graphName===ge&&Z?.error==null)return;Oe==null?(Oe={namespace:T,graphName:ge,status:B},c.set(ne,Oe)):Oe.status=B;let Sn={event:B,graph_name:ge,...Z?.cause!=null?{cause:Z.cause}:{},...Z?.error!=null?{error:Z.error}:{}},Pr=Date.now();if(s.push({namespace:T,timestamp:Pr,...Sn}),!(T.length===0&&!i)&&f!=null){p+=1;try{f.push(T,{type:"event",seq:0,method:"lifecycle",params:{namespace:T,timestamp:Pr,data:Sn}})}finally{p-=1}}},b=T=>{let B=Bt(T),Z=c.get(B);return Z==null&&(Z={namespace:T,graphName:g(T),status:void 0},c.set(B,Z)),Z},w=()=>{if(d.length===0)return;let T=d.splice(0,d.length);for(let B of T){let Z=Bt(B.namespace),ne=c.get(Z);ne==null||ne.status!=="started"||y(B.namespace,"completed")}},x=T=>{let B=Bt(T.namespace),Z=c.get(B);Z==null||Z.status!=="started"||d.some(ne=>Bt(ne.namespace)===B)||d.push(T)},k=(T,B)=>{for(let Z=d.length-1;Z>=0;Z-=1){let ne=d[Z];ne.source.type==="node"&&ne.source.node===B&&Bt(ne.source.parent)===Bt(T)&&d.splice(Z,1)}},E=T=>{for(let B=1;B<=T.length;B+=1){let Z=T.slice(0,B),ne=Bt(Z);if(c.has(ne))continue;b(Z);let Oe=u.get(ne);y(Z,"started",Oe!=null?{cause:Oe}:void 0)}},V=()=>l.size>0?"interrupted":"completed",C=T=>{for(let B of c.values())B.namespace.length!==0&&B.status==="started"&&y(B.namespace,T);y([],T),s.close()},v=async()=>{if(o==null)return V();try{return await o()??V()}catch{return V()}},W=(T,B)=>{let Z=`${B}:`;for(let ne of c.values()){if(ne.namespace.length!==T.length+1||ne.status!=="started"||!qn(ne.namespace,T))continue;let Oe=ne.namespace[ne.namespace.length-1];if(Oe===B||Oe.startsWith(Z))return ne.namespace}},F=(T,B)=>{let Z=[...T,`${B.name}:${B.id}`];return c.get(Bt(Z))?.status==="started"?Z:void 0};return{__native:!0,init(){return{_lifecycleLog:s,lifecycle:Hm(s,[],0)}},onRegister(T){f=T,b([]),i&&y([],r)},process(T){let B=T.params.namespace;if(p>0)return!0;let Z=T.method==="tasks"?QB(T.params.data):void 0;if(Z!=null&&k(B,Z.name),w(),T.method==="lifecycle"){let ne=YB(T.params.data);return ne!=null&&u.set(Bt(B),ne),E(B),!1}if(E(B),T.method==="input"&&Zm(T.params.data)&&T.params.data.event==="requested"){let ne=T.params.data.id;typeof ne=="string"&&l.add(ne)}if(Z!=null){let ne=F(B,Z);ne!=null&&x({namespace:ne,source:{type:"task"}})}if(T.method==="updates"){let ne=T.params.node;if(typeof ne=="string"&&!ne.startsWith("__")){let Oe=W(B,ne);Oe!=null&&x({namespace:Oe,source:{type:"node",parent:B,node:ne}})}}return!0},finalize(){if(!m){if(m=!0,w(),o==null){C(V());return}return v().then(C).catch(T=>{s.fail(T)})}},fail(T){if(m)return;m=!0;let B=a(T);for(let Z of c.values())Z.namespace.length!==0&&Z.status==="started"&&y(Z.namespace,"failed");y([],"failed",{error:B}),s.fail(T)}}}function dc(e){let t=e;return typeof t.run_id=="string"?`run:${t.run_id}`:e.event==="message-start"&&typeof t.id=="string"?`message:${t.id}`:"__default__"}function hl(e,t){let r=Wr.local(),i=new Map,n=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(a){if(a.method!=="messages"||!qn(a.params.namespace,e)||a.params.namespace.length!==e.length+1||t!==void 0&&a.params.node!==t)return!0;let o=a.params.data;switch(o.event){case"message-start":{let s=dc(o);if(o.role==="tool"){n.add(s);break}let c=Wr.local(),u=Object.assign(new sa(c.toAsyncIterable()),{namespace:a.params.namespace,node:a.params.node});i.set(s,{source:c,stream:u}),c.push(o),r.push(u);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(n.has(dc(o)))break;i.get(dc(o))?.source.push(o);break;case"message-finish":{let s=dc(o);if(n.delete(s))break;let c=i.get(s);c&&(c.source.push(o),c.source.close(),i.delete(s));break}case"error":if(n.has(dc(o)))break;i.get(dc(o))?.source.push(o);break}return!0},finalize(){for(let[a,o]of i)o.source.push({event:"message-finish"}),o.source.close(),i.delete(a);n.clear(),r.close()},fail(a){for(let[o,s]of i)s.source.fail(a),i.delete(o);n.clear(),r.fail(a)}}}function gl(e,t,r=0){let i=t.length+1;return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let a=await n.next();if(a.done)return{value:void 0,done:!0};let{ns:o,stream:s}=a.value;if(o.length===i&&qn(o,t))return{value:s,done:!1}}}}}}}function j0(e,t){let{createStream:r}=t,i=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:gl(e._discoveries,[],0)}},process(n){let a=n.params.namespace;if(a.length===0)return!0;let o=a.slice(0,1),s=Bt(o);if(i.has(s))return!0;i.add(s);let c=r(o,e._discoveries.size,e._events.size);return e.register(o,c),e._discoveries.push({ns:o,stream:c}),!0}}}function z0(e){let t=Wr.local();return{init:()=>({_valuesLog:t}),process(r){return r.method!=="values"||r.params.namespace.length!==e.length||!qn(r.params.namespace,e)||t.push(r.params.data),!0},finalize(){t.close()},fail(r){t.fail(r)}}}function Gm(e){return"__native"in e&&e.__native===!0}var uR=Symbol("setValuesLog"),lR=Symbol("setMessagesIterable"),D0=Symbol("setLifecycleIterable"),U0=Symbol("setSubgraphsIterable"),e9={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},L0=class{path;extensions;_mux;#e;#o;#r;#i;#n;#t;#s;#a;#u;#c;constructor(e,t,r=0,i=0,n,a){this.path=e,this._mux=t,this.#o=r,this.#e=i,this.extensions=n??{},this.#r=a??new AbortController,this.#t=new Promise((o,s)=>{this.#i=o,this.#n=s}),this.#t.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:gl(this._mux._discoveries,this.path,this.#o)}get values(){let e=this.#s,t=this.#t,r=this._mux,i=this.#e,n=this.path,a=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let o=r.subscribeEvents(n,i);return{async next(){for(;;){let s=await o.next();if(s.done)return{value:void 0,done:!0};if(s.value.method==="values"&&s.value.params.namespace.length===n.length)return{value:s.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>a[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#a)return this.#a;let e=hl(this.path),t=e.init();return this._mux.addTransformer(e),this.#a=t.messages,this.#a}get lifecycle(){return this.#u??e9}messagesFrom(e){let t=hl(this.path,e),r=t.init();return this._mux.addTransformer(t),r.messages}get output(){return this.#t}get interrupted(){return this._mux.interrupted}get interrupts(){return this._mux.interrupts}abort(e){this.#r.abort(e)}get signal(){return this.#r.signal}[Vm](e){this.#i?.(e),this.#i=void 0}[R0](e){this.#n?.(e),this.#n=void 0}[uR](e){this.#s=e}[lR](e){this.#a=e}[D0](e){this.#u=e}[U0](e){this.#c=e}},dR=class extends L0{name;index;constructor(e,t,r=0,i=0,n,a){super(e,t,r,i,n,a);let o=e[e.length-1]??"",s=o.lastIndexOf(":");if(s>=0){this.name=o.slice(0,s);let c=o.slice(s+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=o,this.index=0}};function F0(e,t=[],r){let{abortController:i}=r instanceof AbortController?{abortController:r}:r??{},n=new oR,a=M0(),o=a.init(),s=o._lifecycleLog,c=j0(n,{createStream:(b,w,x)=>{let k=new dR(b,n,w,x);return k[U0](gl(n._discoveries,b,w)),k[D0](Hm(s,b,s.size)),k}}),u=c.init();n.addTransformer(c),n.addTransformer(a);let l=z0([]),d=hl([]);n.addTransformer(l),n.addTransformer(d);let f={},p=[];for(let b of t){let w=b();n.addTransformer(w);let x=w.init();Gm(w)?p.push(x):Object.assign(f,x),typeof x=="object"&&x!==null&&!Gm(w)&&n.wireChannels(x)}let m=new L0([],n,0,0,f,i);for(let b of p)Object.assign(m,b);let g=l.init();m[uR](g._valuesLog);let y=d.init();return m[lR](y.messages),m[D0](o.lifecycle),m[U0](u.subgraphs),n.register([],m),sR(e,n).catch(b=>{}),m}var L=e=>BigInt(e),De=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),hR=L("0x9E3779B1"),gR=L("0x85EBCA77"),t9=L("0xC2B2AE3D"),la=L("0x9E3779B185EBCA87"),Eo=L("0xC2B2AE3D27D4EB4F"),_R=L("0x165667B19E3779F9"),Z0=L("0x85EBCA77C2B2AE63"),r9=L("0x27D4EB2F165667C5"),n9=L("0x165667919E3779F9"),i9=L("0x9FB21C651E98DF25"),a9=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,i=new Uint8Array(r),n=0,a=0;for(;a<r;){let o=e.slice(n,n+=2);i[a]=Number.parseInt(o,16),a+=1}return De(i)},Xn=a9("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),fc=(L(1)<<L(128))-L(1),ve=(L(1)<<L(64))-L(1),qm=(L(1)<<L(32))-L(1),Si=64,yR=Si/8,o9=8,Jm=4;function pc(e){if(!e)throw new Error("Assert failed")}function s9(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function c9(e){let t=e;return t=(t&L(65535))<<L(16)|(t&L(4294901760))>>L(16),t=(t&L(16711935))<<L(8)|(t&L(4278255360))>>L(8),t}function u9(e,t){return(e&qm)*(t&qm)&ve}function l9(e,t){return(e<<t|e>>L(32)-t)&qm}function vR(e,t,r){for(let i=0;i<yR;i+=1){let n=t.getBigUint64(i*8,!0),a=n^r.getBigUint64(i*8,!0);e[i^1]+=n,e[i]+=u9(a,a>>L(32))}return e}function fR(e,t,r,i){for(let n=0;n<i;n+=1)vR(e,De(t,n*Si),De(r,n*8));return e}function d9(e,t){for(let r=0;r<yR;r+=1){let i=t.getBigUint64(r*8,!0),n=e[r];n=B0(n,L(47)),n^=i,n*=hR,e[r]=n&ve}return e}function Km(e,t){return bR(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(o9,!0))}function pR(e,t,r){let i=r;return i+=Km(e.slice(0),De(t,0*Jm)),i+=Km(e.slice(2),De(t,4*Jm)),i+=Km(e.slice(4),De(t,8*Jm)),i+=Km(e.slice(6),De(t,12*Jm)),Yn(i&ve)}function f9(e,t,r,i,n){let a=e,o=Math.floor((r.byteLength-Si)/8),s=Si*o,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)a=fR(a,De(t,u*s),r,o),a=n(a,De(r,r.byteLength-Si));{let u=Math.floor((t.byteLength-1-s*c)/Si);a=fR(a,De(t,c*s),r,u),a=i(a,De(t,t.byteLength-Si),De(r,r.byteLength-Si-7))}return a}function p9(e,t){let r=new BigUint64Array([t9,la,Eo,_R,Z0,gR,r9,hR]);pc(e.byteLength>128),r=f9(r,e,t,vR,d9),pc(r.length*8===64);{let i=pR(r,De(t,11),L(e.byteLength)*la&ve);return pR(r,De(t,t.byteLength-Si-11),~(L(e.byteLength)*Eo)&ve)<<L(64)|i}}function bR(e,t){let r=e*t&fc;return r&ve^r>>L(64)}function mR(e,t,r){return bR((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&ve,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&ve)}function Wm(e,t,r,i,n){let a=e&ve,o=e>>L(64)&ve;return a+=mR(t,i,n),a^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),a&=ve,o+=mR(r,De(i,16),n),o^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),o&=ve,o<<L(64)|a}function Yn(e){let t=e;return t^=t>>L(37),t*=n9,t&=ve,t^=t>>L(32),t}function Xm(e){let t=e;return t^=t>>L(33),t*=Eo,t&=ve,t^=t>>L(29),t*=_R,t&=ve,t^=t>>L(32),t}function m9(e,t,r){let i=e.byteLength;pc(i>0&&i<=3);let n=L(e.getUint8(i-1))|L(i<<8)|L(e.getUint8(0)<<16)|L(e.getUint8(i>>1)<<24),a=(n^(L(t.getUint32(0,!0))^L(t.getUint32(4,!0)))+r)&ve,o=(L(t.getUint32(8,!0))^L(t.getUint32(12,!0)))-r;return(Xm((l9(c9(n),L(13))^o)&ve)&ve)<<L(64)|Xm(a)}function B0(e,t){return e^e>>t}function h9(e,t,r){let i=e.byteLength;pc(i>=4&&i<=8);{let n=e.getUint32(0,!0),a=e.getUint32(i-4,!0),o=((L(n)|L(a)<<L(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&ve)*(la+(L(i)<<L(2)))&fc;return o+=(o&ve)<<L(65),o&=fc,o^=o>>L(67),B0(B0(o&ve,L(35))*i9&ve,L(28))|Yn(o>>L(64))<<L(64)}}function g9(e,t,r){let i=e.byteLength;pc(i>=9&&i<=16);{let n=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&ve,a=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&ve,o=e.getBigUint64(0,!0),s=e.getBigUint64(i-8,!0),c=(o^s^n)*la,u=(c&ve)+(L(i-1)<<L(54));c=c&(fc^ve)|u,s^=a,c+=s+(s&qm)*(gR-L(1))<<L(64),c&=fc,c^=s9(c>>L(64));let l=(c&ve)*Eo;return l+=(c>>L(64))*Eo<<L(64),l&=fc,Yn(l&ve)|Yn(l>>L(64))<<L(64)}}function _9(e,t){let r=e.byteLength;return pc(r<=16),r>8?g9(e,Xn,t):r>=4?h9(e,Xn,t):r>0?m9(e,Xn,t):Xm(t^Xn.getBigUint64(64,!0)^Xn.getBigUint64(72,!0))|Xm(t^Xn.getBigUint64(80,!0)^Xn.getBigUint64(88,!0))<<L(64)}function V0(e){return~e+L(1)&ve}function y9(e,t,r){let i=L(e.byteLength)*la&ve,n=L(e.byteLength-1)/L(32);for(;n>=0;){let s=Number(n);i=Wm(i,De(e,16*s),De(e,e.byteLength-16*(s+1)),De(t,32*s),r),n-=L(1)}let a=i+(i>>L(64))&ve;a=Yn(a);let o=(i&ve)*la+(i>>L(64))*Z0+(L(e.byteLength)-r&ve)*Eo;return o&=ve,o=V0(Yn(o)),a|o<<L(64)}function v9(e,t,r){let i=L(e.byteLength)*la&ve;for(let o=32;o<160;o+=32)i=Wm(i,De(e,o-32),De(e,o-16),De(t,o-32),r);i=Yn(i&ve)|Yn(i>>L(64))<<L(64);for(let o=160;o<=e.byteLength;o+=32)i=Wm(i,De(e,o-32),De(e,o-16),De(t,3+o-160),r);i=Wm(i,De(e,e.byteLength-16),De(e,e.byteLength-32),De(t,103),V0(r));let n=i+(i>>L(64))&ve;n=Yn(n);let a=(i&ve)*la+(i>>L(64))*Z0+(L(e.byteLength)-r&ve)*Eo;return a&=ve,a=V0(Yn(a)),n|a<<L(64)}function ki(e,t=L(0)){let r=new TextEncoder,i=De(typeof e=="string"?r.encode(e):e),n=i.byteLength,a=o=>o.toString(16).padStart(32,"0");return n<=16?a(_9(i,t)):n<=128?a(y9(i,Xn,t)):n<=240?a(v9(i,Xn,t)):a(p9(i,Xn))}function Ym(e){return/^[0-9a-f]{32}$/.test(e)}function H0(e){let t=Te.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");if(!r.__pregel_checkpointer)throw new ka("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=r[ir];i.interruptCounter+=1;let n=i.interruptCounter;if(i.resume.length>0&&n<i.resume.length)return r[Rr]?.([[gr,i.resume]]),i.resume[n];if(i.nullResume!==void 0){if(i.resume.length!==n)throw new Error(`Resume length mismatch: ${i.resume.length} !== ${n}`);let o=i.consumeNullResume();return i.resume.push(o),r[Rr]?.([[gr,i.resume]]),o}let a=r[Mr]?.split("|");throw new ti([{id:a?ki(a.join("|")):void 0,value:e}])}var Vt=class extends ae{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.trace=e.trace??this.trace,this.recurse=e.recurse??this.recurse}async _tracedInvoke(e,t,r){return new Promise((i,n)=>{let a=$e(t,{callbacks:r?.getChild()});Te.runWithConfig(a,async()=>{try{i(await this.func(e,a))}catch(o){n(o)}})})}async invoke(e,t){let r,i=lc(t),n=xt(this.config,i);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,n):r=await Te.runWithConfig(n,async()=>this.func(e,n)),ae.isRunnable(r)&&this.recurse?await Te.runWithConfig(n,async()=>r.invoke(e,n)):r}};function*$i(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function vn(e){let t=[];for await(let r of await e)t.push(r);return t}function To(e){let t=[];for(let r of e)t.push(r);return t}function Ao(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function G0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function J0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function b9(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var mr={[Symbol.for("LG_PASSTHROUGH")]:!0};function Qm(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var K0=Symbol("IS_WRITER"),ot=class q0 extends Vt{writes;constructor(t,r){let i=`ChannelWrite<${t.map(n=>dt(n)?n.node:"channel"in n?n.channel:"...").join(",")}>`;super({writes:t,name:i,tags:r,trace:!1,func:async(n,a)=>this._write(n,a??{})}),this.writes=t}async _write(t,r){let i=this.writes.map(n=>W0(n)&&Qm(n.value)?{mapper:n.mapper,value:t}:eh(n)&&Qm(n.value)?{channel:n.channel,value:t,skipNone:n.skipNone,mapper:n.mapper}:n);return await q0.doWrite(r,i),t}static async doWrite(t,r){for(let a of r){if(eh(a)){if(a.channel==="__pregel_tasks")throw new be("Cannot write to the reserved channel TASKS");if(Qm(a.value))throw new be("PASSTHROUGH value must be replaced")}if(W0(a)&&Qm(a.value))throw new be("PASSTHROUGH value must be replaced")}let i=[];for(let a of r)if(dt(a))i.push([En,a]);else if(W0(a)){let o=await a.mapper.invoke(a.value,t);o!=null&&o.length>0&&i.push(...o)}else if(eh(a)){let o=a.mapper!==void 0?await a.mapper.invoke(a.value,t):a.value;if(b9(o)||a.skipNone&&o===void 0)continue;i.push([a.channel,o])}else throw new Error(`Invalid write entry: ${JSON.stringify(a)}`);let n=t.configurable?.[Rr];n(i)}static isWriter(t){return t instanceof q0||K0 in t&&!!t[K0]}static registerWriter(t){return Object.defineProperty(t,K0,{value:!0})}};function eh(e){return e!==void 0&&typeof e.channel=="string"}function W0(e){return e!==void 0&&!eh(e)&&ae.isRunnable(e.mapper)}var wR=class xR extends Vt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,i=!1){super({trace:!1,func:(n,a)=>xR.doRead(a,this.channel,this.fresh,this.mapper)}),this.fresh=i,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,i,n){let a=t.configurable?.[Yr];if(!a)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return n?n(a(r,i)):a(r,i)}},mc=new yi,bn=class _l extends Hr{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=mc;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor(t){let{channels:r,triggers:i,mapper:n,writers:a,bound:o,kwargs:s,metadata:c,retryPolicy:u,cachePolicy:l,tags:d,subgraphs:f,ends:p}=t,m=[...t.config?.tags?t.config.tags:[],...d??[]];super({...t,bound:t.bound??mc,config:{...t.config?t.config:{},tags:m}}),this.channels=r,this.triggers=i,this.mapper=n,this.writers=a??this.writers,this.bound=o??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=m,this.retryPolicy=u,this.cachePolicy=l,this.subgraphs=f,this.ends=p}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof ot&&t[t.length-2]instanceof ot;){let r=t.slice(-2),i=r[0].writes.concat(r[1].writes);t[t.length-2]=new ot(i,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===mc&&t.length===0))return this.bound===mc&&t.length===1?t[0]:this.bound===mc?new Cr({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new Cr({first:this.bound,middle:t.slice(0,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):this.bound}join(t){if(!Array.isArray(t))throw new Error("channels must be a list");if(typeof this.channels!="object")throw new Error("all channels must be named when using .join()");return new _l({channels:{...this.channels,...Object.fromEntries(t.map(r=>[r,r]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}pipe(t){return ot.isWriter(t)?new _l({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,t],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):this.bound===mc?new _l({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:tt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):new _l({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}};function w9(e){return"steps"in e&&Array.isArray(e.steps)}function yl(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function th(e){let t=[e];for(let r of t){if(yl(r))return r;w9(r)&&t.push(...r.steps)}}function Co(e,t,r=!0,i=!1){try{return e[t].get()}catch(n){if(n.name===Ne.unminifiable_name){if(i)return n;if(r)return null}throw n}}function wn(e,t,r=!0){if(Array.isArray(t)){let i={};for(let n of t)try{i[n]=Co(e,n,!r)}catch(a){if(a.name===Ne.unminifiable_name)continue}return i}else return Co(e,t)}function*SR(e,t){if(e.graph===nr.PARENT)throw new be("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let i of r)if(dt(i))yield[_r,En,i];else if(typeof i=="string")yield[_r,`branch:to:${i}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof i}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(Ym))for(let[r,i]of Object.entries(e.resume)){let n=t.filter(a=>a[0]===r&&a[1]==="__resume__").map(a=>a[2]).slice(0,1)??[];n.push(i),yield[r,gr,n]}else yield[_r,gr,e.resume];if(e.update){if(typeof e.update!="object"||!e.update)throw new Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(e.update))for(let[r,i]of e.update)yield[_r,r,i];else for(let[r,i]of Object.entries(e.update))yield[_r,r,i]}}function*rh(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let r in t)e.includes(r)&&(yield[r,t[r]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*nh(e,t,r){Array.isArray(e)?(t===!0||t.find(([i,n])=>e.includes(i)))&&(yield wn(r,e)):(t===!0||t.some(([i,n])=>i===e))&&(yield Co(r,e))}function*kR(e,t,r){let i=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!i.length)return;let n;i.some(([s])=>s.writes.some(([c,u])=>c==="__return__"))?n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===Ci).map(([c,u])=>[s.name,u])):Array.isArray(e)?n=i.flatMap(([s])=>{let{writes:c}=s,u={};for(let[l]of c)e.includes(l)&&(u[l]=(u[l]||0)+1);return Object.values(u).some(l=>l>1)?c.filter(([l])=>e.includes(l)).map(([l,d])=>[s.name,{[l]:d}]):[[s.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===e).map(([c,u])=>[s.name,u]));let a={};for(let[s,c]of n)s in a||(a[s]=[]),a[s].push(c);let o={};for(let s in a)if(a[s].length===1){let[c]=a[s];o[s]=c}else o[s]=a[s];r&&(o.__metadata__={cached:r}),yield o}function ih(e){let t=typeof e[Ze];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=typeof e[r];if(i==="number")return 0;if(i==="string")return"";break}}function hc(e,t){if(Object.keys(e).length>0){let r=ih(t);return Object.fromEntries(Object.entries(t).filter(([i,n])=>n>(e[i]??r)))}else return t}function $R(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function hr(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function da(e,t){let r=t?.parents??{};return Object.keys(r).length>0?hr(e,{[jr]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function gc(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let r=new AbortController,i=()=>{let a=t.find(o=>o.aborted)?.reason;r.abort(a),t.forEach(o=>o.removeEventListener("abort",i))};t.forEach(a=>a.addEventListener("abort",i,{once:!0}));let n=t.find(a=>a.aborted);return n&&r.abort(n.reason),{signal:r.signal,dispose:()=>{t.forEach(a=>a.removeEventListener("abort",i))}}}var IR=(e,t)=>{if(!(!e&&!t))return e?t?Array.isArray(e)&&Array.isArray(t)?[...e,...t]:Array.isArray(e)?[...e,t]:Array.isArray(t)?[e,...t]:[e,t]:e:t};var ER=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:i,cache:n,callbacks:a}){this.func=e,this.name=t,this.input=r,this.retry=i,this.cache=n,this.callbacks=a}};function TR(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function AR(e,t){return new Cr({name:e,first:new Vt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new ot([{channel:Ci,value:mr}],[lt])})}function CR(e,t){return new Vt({func:(r,i)=>t(r,i),name:e,trace:!1,recurse:!1})}function OR({func:e,name:t,cache:r,retry:i},...n){let a=Te.getRunnableConfig();if(typeof a.configurable?.__pregel_call=="function")return a.configurable[jo](e,t,n,{retry:i,cache:r,callbacks:a.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var PR=e=>e!==void 0?e+1:1;function x9(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function S9(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=ul(t,e[r]));return t}function bl(e,t,r){let i=ih(e.channel_versions),n=e.versions_seen.__interrupt__??{},a=!1;if((e.channel_versions.__start__??i)>(n.__start__??i))a=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(n[s]??i)){a=!0;break}let o=r.some(s=>t==="*"?!s.config?.tags?.includes(lt):t.includes(s.name));return a&&o}function vl(e,t,r,i,n=!1){let a=new Set;if(Array.isArray(i))a=new Set(i.filter(s=>r.writes.some(([c,u])=>c===s)));else{for(let[s]of r.writes)if(s===i){a=new Set([s]);break}a=a||new Set}let o;if(n&&a.size>0){let s=Object.fromEntries(Object.entries(t).filter(([l,d])=>a.has(l))),c=_n(e,s,-1),u=ua(s,c);tr(gn(c),u,[r],void 0,void 0),o=wn({...t,...u},i)}else o=wn(t,i);return o}function X0(e,t,r){for(let[i,n]of r)if(["__pregel_push","__pregel_tasks"].includes(i)&&n!=null){if(!dt(n))throw new be(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(n)}`);if(!(n.node in t))throw new be(`Invalid node name "${n.node}" in Send packet`)}e(r)}var k9=new Set([Sc,zr,gr,Ue,Ci,Mo]);function tr(e,t,r,i,n){r.sort((f,p)=>{let m=f.path?.slice(0,3)||[],g=p.path?.slice(0,3)||[];for(let y=0;y<Math.min(m.length,g.length);y+=1){if(m[y]<g[y])return-1;if(m[y]>g[y])return 1}return m.length-g.length});let a=r.some(f=>f.triggers.length>0),o=pl(t);for(let f of r){e.versions_seen[f.name]??={};for(let p of f.triggers)p in e.channel_versions&&(e.versions_seen[f.name][p]=e.channel_versions[p])}let s=S9(e.channel_versions),c=new Set(r.flatMap(f=>f.triggers).filter(f=>!xS.includes(f))),u=!1;for(let f of c)f in o&&o[f].consume()&&i!==void 0&&(e.channel_versions[f]=i(s),u=!0);let l={};for(let f of r)for(let[p,m]of f.writes)k9.has(p)||p in o&&(l[p]??=[],l[p].push(m));s!=null&&i!=null&&(s=u?i(s):s);let d=new Set;for(let[f,p]of Object.entries(l))if(f in o){let m=o[f],g;try{g=m.update(p)}catch(y){if(y.name===be.unminifiable_name){let b=new be(`Invalid update for channel "${f}" with values ${JSON.stringify(p)}: ${y.message}`);throw b.lc_error_code=y.lc_error_code,b}else throw y}g&&i!==void 0&&(e.channel_versions[f]=i(s),m.isAvailable()&&d.add(f))}if(a)for(let f in o){if(!Object.prototype.hasOwnProperty.call(o,f))continue;let p=o[f];p.isAvailable()&&!d.has(f)&&p.update([])&&i!==void 0&&(e.channel_versions[f]=i(s),p.isAvailable()&&d.add(f))}if(a&&!x9(d,n))for(let f in o){if(!Object.prototype.hasOwnProperty.call(o,f))continue;let p=o[f];p.finish()&&i!==void 0&&(e.channel_versions[f]=i(s),p.isAvailable()&&d.add(f))}return d}function*$9(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let i=new Set;for(let n of r.updatedChannels){let a=r.triggerToNodes[n];for(let o of a??[])i.add(o)}yield*[...i].sort();return}if(!(()=>{for(let i in e.channel_versions)if(e.channel_versions[i]!==null)return!1;return!0})())for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(yield i)}function fa(e,t,r,i,n,a,o){let s={},c=i[En];if(c?.isAvailable()){let u=c.get().length;for(let l=0;l<u;l+=1){let d=ah([zr,l],e,t,r,i,n,a,o);d!==void 0&&(s[d.id]=d)}}for(let u of $9(e,r,o)){let l=ah([Tl,u],e,t,r,i,n,a,o);l!==void 0&&(s[l.id]=l)}return s}function ah(e,t,r,i,n,a,o,s){let{step:c,checkpointer:u,manager:l}=s,d=a.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&TR(e[e.length-1])){let p=e[e.length-1],m=AR(p.name,p.func),g=[zr],y=f===""?p.name:`${f}|${p.name}`,b=ni(JSON.stringify([y,c.toString(),p.name,zr,e[1],e[2]]),t.id),w=`${y}:${b}`,x=[...e.slice(0,3),!0],k={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:g,langgraph_path:x,langgraph_checkpoint_ns:w,checkpoint_ns:w};if(o){let E=[],V={checkpointId:t.id,checkpointNs:w,taskId:b,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:E,config:{...$e(xt(a,{metadata:k,store:s.store??a.store}),{runName:p.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[wc]:b,[Rr]:C=>X0(v=>E.push(...v),i,C),[Yr]:(C,v=!1)=>vl(t,n,{name:p.name,writes:E,triggers:g,path:x},C,v),[Qr]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[f]:t.id},[ir]:Y0({pendingWrites:r??[],taskId:b,currentTaskInput:p.input,resumeMap:a.configurable?.[Do],namespaceHash:ki(w)}),[wa]:t.channel_values[xa],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:V},triggers:g,retry_policy:p.retry,cache_key:p.cache?{key:ki((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[Il,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:b,path:x,writers:[]}}else return{id:b,name:p.name,interrupts:[],path:x}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!n.__pregel_tasks?.isAvailable())return;let m=n[En].get();if(p<0||p>=m.length)return;let g=Al(m[p])&&!dt(m[p])?new ba(m[p].node,m[p].args):m[p];if(!Al(g)){console.warn(`Ignoring invalid packet ${JSON.stringify(g)} in pending sends.`);return}if(!(g.node in i)){console.warn(`Ignoring unknown node name ${g.node} in pending sends.`);return}let y=[zr],b=f===""?g.node:`${f}|${g.node}`,w=ni(JSON.stringify([b,c.toString(),g.node,zr,p.toString()]),t.id),x=`${b}:${w}`,k={langgraph_step:c,langgraph_node:g.node,langgraph_triggers:y,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x,checkpoint_ns:x};if(o){let E=i[g.node],V=E.getNode();if(V!==void 0){E.metadata!==void 0&&(k={...k,...E.metadata});let C=[],v={checkpointId:t.id,checkpointNs:x,taskId:w,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:g.node,input:g.args,proc:V,subgraphs:E.subgraphs,writes:C,config:{...$e(xt(a,{metadata:k,tags:E.tags,store:s.store??a.store}),{runName:g.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[wc]:w,[Rr]:W=>X0(F=>C.push(...F),i,W),[Yr]:(W,F=!1)=>vl(t,n,{name:g.node,writes:C,triggers:y,path:e},W,F),[Qr]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[f]:t.id},[ir]:Y0({pendingWrites:r??[],taskId:w,currentTaskInput:g.args,resumeMap:a.configurable?.[Do],namespaceHash:ki(x)}),[wa]:t.channel_values[xa],checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:v},triggers:y,retry_policy:E.retryPolicy,cache_key:E.cachePolicy?{key:ki((E.cachePolicy.keyFunc??JSON.stringify)([g.args])),ns:[Il,E.name??"__dynamic__",g.node],ttl:E.cachePolicy.ttl}:void 0,id:w,path:e,writers:E.getWriters()}}}else return{id:w,name:g.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=i[p];if(m===void 0)return;if(r?.length){let w=f===""?p:`${f}|${p}`,x=ni(JSON.stringify([w,c.toString(),p,Tl,p]),t.id);if(r.some(k=>k[0]===x&&k[1]!=="__error__"))return}let g=ih(t.channel_versions);if(g===void 0)return;let y=t.versions_seen[p]??{},b=m.triggers.find(w=>n[w].isAvailable()?(t.channel_versions[w]??g)>(y[w]??g):!1);if(b!==void 0){let w=I9(m,n,o);if(w===void 0)return;let x=f===""?p:`${f}|${p}`,k=ni(JSON.stringify([x,c.toString(),p,Tl,[b]]),t.id),E=`${x}:${k}`,V={langgraph_step:c,langgraph_node:p,langgraph_triggers:[b],langgraph_path:e,langgraph_checkpoint_ns:E,checkpoint_ns:E};if(o){let C=m.getNode();if(C!==void 0){m.metadata!==void 0&&(V={...V,...m.metadata});let v=[],W={checkpointId:t.id,checkpointNs:E,taskId:k,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p,input:w,proc:C,subgraphs:m.subgraphs,writes:v,config:{...$e(xt(a,{metadata:V,tags:m.tags,store:s.store??a.store}),{runName:p,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[wc]:k,[Rr]:F=>X0(T=>{v.push(...T)},i,F),[Yr]:(F,T=!1)=>vl(t,n,{name:p,writes:v,triggers:[b],path:e},F,T),[Qr]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[f]:t.id},[ir]:Y0({pendingWrites:r??[],taskId:k,currentTaskInput:w,resumeMap:a.configurable?.[Do],namespaceHash:ki(E)}),[wa]:t.channel_values[xa],checkpoint_id:void 0,checkpoint_ns:E}}),executionInfo:W},triggers:[b],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:ki((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[Il,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:k,path:e,writers:m.getWriters()}}}else return{id:k,name:p,interrupts:[],path:e}}}}function I9(e,t,r){let i;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){i={};for(let[n,a]of Object.entries(e.channels))if(e.triggers.includes(a))try{i[n]=Co(t,a,!1)}catch(o){if(o.name===Ne.unminifiable_name)return;throw o}else if(a in t)try{i[n]=Co(t,a,!1)}catch(o){if(o.name===Ne.unminifiable_name)continue;throw o}}else if(Array.isArray(e.channels)){let n=!1;for(let a of e.channels)try{i=Co(t,a,!1),n=!0;break}catch(o){if(o.name===Ne.unminifiable_name)continue;throw o}if(!n)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(i=e.mapper(i)),i}function NR(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[i,n]of Object.entries(e.args)){let a=t[i];(!a||a.lc_graph_name!=="UntrackedValue")&&(r[i]=n)}return new ba(e.node,r)}function Y0({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:i,namespaceHash:n}){let a=e.find(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__")?.[2],o={callCounter:0,interruptCounter:-1,resume:(()=>{let s=e.filter(([c,u])=>c===t&&u==="__resume__").flatMap(([c,u,l])=>l);if(i!=null&&n in i){let c=i[n];s.push(c)}return s})(),nullResume:a,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(o.nullResume)return delete o.nullResume,e.splice(e.findIndex(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__"),1),a}};return o}var wl={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},xl=(e,t)=>`${e.start}${t}${e.end}`;function*Q0(e){for(let{id:t,name:r,input:i,config:n,triggers:a,writes:o}of e)n?.tags?.includes("langsmith:hidden")||(yield{id:t,name:r,input:i,triggers:a,interrupts:o.filter(([s,c])=>s===t&&c==="__interrupt__").map(([,s])=>s)})}function E9(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function RR(e){let t={};for(let[r,i]of e){let n=String(r);if(n in t){let a=E9(t[n])?t[n].$writes:[t[n]];a.push(i),t[n]={$writes:a}}else t[n]=i}return t}function*MR(e,t){for(let[{id:r,name:i,config:n},a]of e)n?.tags?.includes("langsmith:hidden")||(yield{id:r,name:i,result:RR(a.filter(([o])=>Array.isArray(t)?t.includes(o):o===t)),interrupts:a.filter(o=>o[0]===Ue).map(o=>o[1])})}function*jR(e,t,r,i,n,a,o,s){function c(d){let f={};return d.callbacks!=null&&(f.callbacks=d.callbacks),d.configurable!=null&&(f.configurable=d.configurable),d.maxConcurrency!=null&&(f.max_concurrency=d.maxConcurrency),d.metadata!=null&&(f.metadata=d.metadata),d.recursionLimit!=null&&(f.recursion_limit=d.recursionLimit),d.runId!=null&&(f.run_id=d.runId),d.runName!=null&&(f.run_name=d.runName),d.tags!=null&&(f.tags=d.tags),f}let u=e.configurable?.checkpoint_ns,l={};for(let d of n){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(th))continue;let f=`${d.name}:${d.id}`;u&&(f=`${u}|${f}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:wn(t,r),metadata:i,next:n.map(d=>d.name),tasks:eS(n,a,l,s),parentConfig:o?c(o):void 0}}function eS(e,t,r,i){return e.map(n=>{let a=t.find(([u,l])=>u===n.id&&l==="__error__")?.[2],o=t.filter(([u,l])=>u===n.id&&l==="__interrupt__").map(([,,u])=>u),s=(()=>{if(a||o.length||!t.length)return;let u=t.findIndex(([l,d])=>l===n.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof i=="string")return t.find(([l,d])=>l===n.id&&d===i)?.[2];if(Array.isArray(i)){let l=t.filter(([d,f])=>d===n.id&&i.includes(f)).map(([,d,f])=>[d,f]);return l.length?RR(l):void 0}})();if(a)return{id:n.id,name:n.name,path:n.path,error:a,interrupts:o,result:s};let c=r?.[n.id];return{id:n.id,name:n.name,path:n.path,interrupts:o,...c!==void 0?{state:c}:{},result:s}})}function zR(e,t,r){console.log([`${xl(wl.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
|
|
416
|
+
`,JSON.stringify(wn(t,r),null,2)].join(""))}function oh(e,t){let r=t.length;console.log([`${xl(wl.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
|
|
417
|
+
`,t.map(i=>`- ${xl(wl.green,String(i.name))} -> ${JSON.stringify(i.input,null,2)}`).join(`
|
|
418
|
+
`)].join(""))}function DR(e,t,r){let i={};for(let[n,a]of t)r.includes(n)&&(i[n]||(i[n]=[]),i[n].push(a));console.log([`${xl(wl.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(i).length} channel${Object.keys(i).length!==1?"s":""}:\x1B[0m
|
|
419
|
+
`,Object.entries(i).map(([n,a])=>`- ${xl(wl.yellow,n)} -> ${a.map(o=>JSON.stringify(o)).join(", ")}`).join(`
|
|
420
|
+
`)].join(""))}var sh=class extends ft{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),i=t??new AbortController;super({start(n){return a();function a(){return r.read().then(({done:o,value:s})=>{if(o){n.close();return}return n.enqueue(s),a()})}}}),this._abortController=i,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},ch=class extends ft{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(i=>{t=i});super({start:i=>{t(i)}}),r.then(i=>{this.controller=i}),this.passthroughFn=e.passthroughFn,this.modes=e.modes}push(e){this.passthroughFn?.(e),this.controller.enqueue(e)}close(){try{this.controller.close()}catch{}finally{this._closed=!0}}error(e){this.controller.error(e)}},FR=class extends Sr{name="StreamToolsHandler";streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,i,n,a,o,s){if(!a||n&&n.includes("langsmith:hidden"))return;let c=a.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:s,toolName:o??"unknown",input:t};this.runs[r]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.toolName,input:t}])}handleToolEvent(e,t){let r=this.runs[t];r&&this.streamFn([r.ns,"tools",{event:"on_tool_event",toolCallId:r.toolCallId,name:r.toolName,data:e}])}handleToolEnd(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_end",toolCallId:r.toolCallId,name:r.toolName,output:e}])}handleToolError(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_error",toolCallId:r.toolCallId,name:r.toolName,error:e}])}};function T9(e){return JSON.stringify(e,function(t,r){let i=this[t];if(i!=null&&typeof i=="object"&&"toDict"in i&&typeof i.toDict=="function"){let{type:n,data:a}=i.toDict();return{...a,type:n}}return r})}function A9(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function rS(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function tS(e){return!rS(e)||!e.configurable.thread_id?null:{thread_id:e.configurable.thread_id,checkpoint_ns:e.configurable.checkpoint_ns||"",checkpoint_id:e.configurable.checkpoint_id||null,checkpoint_map:e.configurable.checkpoint_map||null}}function UR(e){if(rS(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([i])=>!i.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function LR(e){let t={...e,checkpoint:tS(e.config),parent_checkpoint:tS(e.parentConfig),config:UR(e.config),parent_config:UR(e.parentConfig),tasks:e.tasks.map(r=>{if(rS(r.state)){let i=tS(r.state);if(i!=null){let n={...r,checkpoint:i};return delete n.state,n}}return r})};return delete t.parentConfig,t}function BR(e){let t=new TextEncoder;return new ReadableStream({async start(r){let i=n=>{r.enqueue(t.encode(`event: ${n.event}
|
|
421
|
+
data: ${T9(n.data)}
|
|
422
|
+
|
|
423
|
+
`))};try{for await(let n of e){let[a,o,s]=n,c=s;if(o==="debug"){let u=s;u.type==="checkpoint"&&(c={...u,payload:LR(u.payload)})}o==="checkpoints"&&(c=LR(s)),i({event:a?.length?`${o}|${a.join("|")}`:o,data:c})}}catch(n){i({event:"error",data:A9(n)})}r.close()}})}var uh=Symbol.for("INPUT_DONE"),nS=Symbol.for("INPUT_RESUMING"),C9=25;function O9(...e){return new ch({passthroughFn:t=>{for(let r of e)r.modes.has(t[1])&&r.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var P9=class extends Um{cache;queue=Promise.resolve();constructor(e){super(),this.cache=e}async get(e){return this.enqueueOperation("get",e)}async set(e){return this.enqueueOperation("set",e)}async clear(e){return this.enqueueOperation("clear",e)}async stop(){await this.queue}enqueueOperation(e,...t){let r=this.queue.then(()=>this.cache[e](...t));return this.queue=r.then(()=>{},()=>{}),r}},VR=class ZR{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";tasks={};stream;checkpointerPromises=new Set;isNested;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let r=t.then(i=>(this.checkpointerPromises.delete(r),i),i=>{throw i});this.checkpointerPromises.add(r)}store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let t=!1;if("__start__"in this.checkpoint.channel_versions)t=!0;else for(let s in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,s)){t=!0;break}let r=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,i=this.input===null||this.input===void 0,n=ht(this.input)&&this.input.resume!=null,a=this.input===nS,o=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return t&&(r||i||n||a||o)}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=PR,this.checkpoint=t.checkpoint,this.checkpointMetadata=t.checkpointMetadata,this.checkpointPreviousVersions=t.checkpointPreviousVersions,this.channels=t.channels,this.checkpointPendingWrites=t.checkpointPendingWrites,this.step=t.step,this.stop=t.stop,this.config=t.config,this.checkpointConfig=t.checkpointConfig,this.isNested=t.isNested,this.manager=t.manager,this.outputKeys=t.outputKeys,this.streamKeys=t.streamKeys,this.nodes=t.nodes,this.skipDoneTasks=t.skipDoneTasks,this.store=t.store,this.cache=t.cache?new P9(t.cache):void 0,this.stream=t.stream,this.checkpointNamespace=t.checkpointNamespace,this.prevCheckpointConfig=t.prevCheckpointConfig,this.interruptAfter=t.interruptAfter,this.interruptBefore=t.interruptBefore,this.durability=t.durability,this.debug=t.debug,this.triggerToNodes=t.triggerToNodes}static async initialize(t){let{config:r,stream:i}=t;i!==void 0&&r.configurable?.__pregel_stream!==void 0&&(i=O9(i,r.configurable[xc]));let n=r.configurable?!("checkpoint_id"in r.configurable):!0,a=r.configurable?.[ir];r.configurable&&a&&(a.subgraphCounter>0&&(r=hr(r,{[Mr]:[r.configurable[Mr],a.subgraphCounter.toString()].join("|")})),a.subgraphCounter+=1);let o=Yr in(r.configurable??{});!o&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=hr(r,{checkpoint_ns:"",checkpoint_id:void 0}));let s=r;r.configurable?.checkpoint_map!==void 0&&r.configurable?.checkpoint_map?.[r.configurable?.checkpoint_ns]&&(s=hr(r,{checkpoint_id:r.configurable[jr][r.configurable?.checkpoint_ns]}));let c=r.configurable?.checkpoint_ns?.split("|")??[],u=await t.checkpointer?.getTuple(s)??{config:r,checkpoint:sc(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};s={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let l=u.parentConfig,d=gn(u.checkpoint),f={...u.metadata},p=u.pendingWrites??[],m=ua(t.channelSpecs,d),g=(f.step??0)+1,y=g+(r.recursionLimit??C9)+1,b={...d.channel_versions},w=t.store?new Dm(t.store):void 0;return w&&await w.start(),new ZR({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:d,checkpointMetadata:f,checkpointConfig:s,prevCheckpointConfig:l,checkpointNamespace:c,channels:m,isNested:o,manager:t.manager,skipDoneTasks:n,step:g,stop:y,checkpointPreviousVersions:b,checkpointPendingWrites:p,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:i,store:w,cache:t.cache,interruptAfter:t.interruptAfter,interruptBefore:t.interruptBefore,durability:t.durability,debug:t.debug,triggerToNodes:t.triggerToNodes})}_checkpointerPutAfterPrevious(t){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>this.checkpointer?.put(t.config,t.checkpoint,t.metadata,t.newVersions)),this._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,r){let i=r;if(i.length===0)return;i.every(([c])=>c in ll)&&(i=Array.from(new Map(i.map(c=>[c[0],c])).values()));let n=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){n=!0;break}let a=i;n&&(a=i.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&dt(u)?[c,NR(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of a)this.checkpointPendingWrites.push([t,c,u]);let o=hr(this.checkpointConfig,{[Mr]:this.config.configurable?.checkpoint_ns??"",[El]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a,t)),this.tasks&&this._outputWrites(t,i),!r.length||!this.cache||!this.tasks)return;let s=this.tasks[t];s==null||s.cache_key==null||r[0][0]==="__error__"||r[0][0]==="__interrupt__"||this.cache.set([{key:[s.cache_key.ns,s.cache_key.key],value:s.writes,ttl:s.cache_key.ttl}])}_outputWrites(t,r,i=!1){let n=this.tasks[t];if(n!==void 0){if(n.config!==void 0&&(n.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(n.path?.[0]==="__pregel_push"&&n.path?.[n.path.length-1]===!0)return;let a=r.filter(o=>o[0]===Ue).flatMap(o=>o[1]);this._emit([["updates",{[Ue]:a}],["values",{[Ue]:a}]])}else r[0][0]!=="__error__"&&this._emit(To($i(kR(this.outputKeys,[[n,r]],i),"updates")));i||this._emit(To($i(MR([[n,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([o,s])=>`ns:${o.join(",")}|key:${s}`,i=[],n={};for(let o of Object.values(this.tasks))o.cache_key!=null&&!o.writes.length&&(i.push([o.cache_key.ns,o.cache_key.key]),n[r([o.cache_key.ns,o.cache_key.key])]=o);if(i.length===0)return[];let a=await this.cache.get(i);for(let{key:o,value:s}of a){let c=n[r(o)];c!=null&&(c.writes.push(...s),t.push({task:c,result:s}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:r=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![uh,nS].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new ti;if(Object.values(this.tasks).every(n=>n.writes.length>0)){let n=Object.values(this.tasks).flatMap(o=>o.writes);this.updatedChannels=tr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let a=await vn($i(nh(this.outputKeys,n,this.channels),"values"));if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this._emitValuesWithCheckpointMeta(a),bl(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new ti;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[zo]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=fa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels}),this.checkpointer&&this._emit(await vn($i(jR(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,Object.values(this.tasks),this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),Object.values(this.tasks).length===0)return this.status="done",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[n,a,o]of this.checkpointPendingWrites){if(a==="__error__"||a==="__interrupt__"||a==="__resume__")continue;let s=Object.values(this.tasks).find(c=>c.id===n);s&&s.writes.push([a,o])}for(let n of Object.values(this.tasks))n.writes.length>0&&this._outputWrites(n.id,n.writes,!0)}if(Object.values(this.tasks).every(n=>n.writes.length>0))return this.tick({inputKeys:r});if(bl(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new ti;let i=await vn($i(Q0(Object.values(this.tasks)),"tasks"));return this._emit(i),!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(i=>!i.includes(":")))&&(this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=wn(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(i=>i.writes.length>0)&&(this.updatedChannels=tr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(To($i(nh(this.outputKeys,Object.values(this.tasks).flatMap(i=>i.writes),this.channels),"values")))),ri(t)&&!t.interrupts.length&&this._emit([["updates",{[Ue]:[]}],["values",{[Ue]:[]}]])),r}async acceptPush(t,r,i){if(this.interruptAfter?.length>0&&bl(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let n=ah([zr,t.path??[],r,t.id,i],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!n)return;if(this.interruptBefore?.length>0&&bl(this.checkpoint,this.interruptBefore,[n])){this.toInterrupt.push(n);return}this._emit(To($i(Q0([n]),"tasks"))),this.debug&&oh(this.step,[n]),this.tasks[n.id]=n,this.skipDoneTasks&&this._matchWrites({[n.id]:n});let a=await this._matchCachedWrites();for(let{task:o}of a)this._outputWrites(o.id,o.writes,!0);return n}_suppressInterrupt(t){return ri(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,i=r?.[ir];if(i&&i.nullResume!==void 0&&this.putWrites(_r,[[gr,i.nullResume]]),ht(this.input)){let o=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(Ym)&&(this.config.configurable??={},this.config.configurable[Do]=this.input.resume),o&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let s={};for(let[c,u,l]of SR(this.input,this.checkpointPendingWrites))s[c]??=[],s[c].push([u,l]);if(Object.keys(s).length===0)throw new Nl("Received empty Command input");for(let[c,u]of Object.entries(s))this.putWrites(c,u)}let n=(this.checkpointPendingWrites??[]).filter(o=>o[0]===_r).map(o=>o.slice(1));n.length>0&&tr(this.checkpoint,this.channels,[{name:In,writes:n,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let a=ht(this.input)&&n.length>0;if(this.isResuming||a){for(let s in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,s)&&this.checkpoint.channel_versions[s]!==void 0){let c=this.checkpoint.channel_versions[s];this.checkpoint.versions_seen[Ue]={...this.checkpoint.versions_seen[Ue],[s]:c}}let o=await vn($i(nh(this.outputKeys,!0,this.channels),"values"));this.isResuming?this.input=nS:a&&(await this._putCheckpoint({source:"input"}),this.input=uh),this._emitValuesWithCheckpointMeta(o)}else{let o=await vn(rh(t,this.input));if(o.length>0){let s=fa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=tr(this.checkpoint,this.channels,Object.values(s).concat([{name:In,writes:o,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=uh}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=uh;else throw new Nl(`Received no input writes for ${JSON.stringify(t,null,2)}`)}this.isNested||(this.config=hr(this.config,{[zo]:this.isResuming}))}_emit(t){for(let r of t){let[i,n,a]=r;if(this.stream.modes.has(i)&&this.stream.push([this.checkpointNamespace,i,n,a]),(i==="checkpoints"||i==="tasks")&&this.stream.modes.has("debug")){let o=i==="checkpoints"?this.step-1:this.step,s=new Date().toISOString(),c=i==="checkpoints"?"checkpoint":typeof n=="object"&&n!=null&&"result"in n?"task_result":"task";this.stream.push([this.checkpointNamespace,"debug",{step:o,type:c,timestamp:s,payload:n}])}}}_currentCheckpointMeta(){if(!this.checkpointMetadata||!this.checkpoint?.id)return;let t=this.prevCheckpointConfig?.configurable?.checkpoint_id;return{checkpoint:{id:this.checkpoint.id,...t?{parent_id:t}:{},step:this.checkpointMetadata.step,source:this.checkpointMetadata.source}}}_emitValuesWithCheckpointMeta(t){let r=this._currentCheckpointMeta();if(!r){this._emit(t);return}this._emit(t.map(([i,n])=>i==="values"?[i,n,r]:[i,n]))}_putCheckpoint(t){let r=this.checkpointMetadata===t,i=this.checkpointer!=null&&(this.durability!=="exit"||r),n=a=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=hr(this.checkpointConfig,{[Mr]:this.config.configurable?.checkpoint_ns??""});let o={...this.checkpoint.channel_versions},s=hc(this.checkpointPreviousVersions,o);this.checkpointPreviousVersions=o,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:gn(a),metadata:{...this.checkpointMetadata},newVersions:s}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}};r||(this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}),this.checkpoint=_n(this.checkpoint,i?this.channels:void 0,this.step,r?{id:this.checkpoint.id}:void 0),i&&n(this.checkpoint),r||(this.step+=1)}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=hr(this.checkpointConfig,{[Mr]:this.config.configurable?.checkpoint_ns??"",[El]:this.checkpoint.id}),r={};for(let[i,n,a]of this.checkpointPendingWrites)r[i]??=[],r[i].push([n,a]);for(let[i,n]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,n,i))}_matchWrites(t){for(let[r,i,n]of this.checkpointPendingWrites){if(i==="__error__"||i==="__interrupt__"||i==="__resume__")continue;let a=Object.values(t).find(o=>o.id===r);a&&a.writes.push([i,n])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function N9(e){return We(e?.message)}function HR(e,t,r){if(!e)return;let i=e.langgraph_checkpoint_ns,n=e.checkpoint_ns,a=i??n;if(a)return[a.split("|"),{tags:t,name:r,...e}]}var GR=class extends Sr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,i=!1){if(i&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let n=t.id;r!=null&&(Oc(t)?n??=`run-${r}-tool-${t.tool_call_id}`:((n==null||n===`run-${r}`)&&(n=this.stableMessageIdMap[r]??n??`run-${r}`),this.stableMessageIdMap[r]??=n)),n!==t.id&&(t.id=n,t.lc_kwargs.id=n),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,i,n,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=HR(o,a,s))}handleLLMNewToken(e,t,r,i,n,a){let o=a?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(N9(o)?this._emit(this.metadatas[r],o.message,r):this._emit(this.metadatas[r],new Qe({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];We(r?.message)&&this._emit(this.metadatas[t],r?.message,t,!0),delete this.emittedChatModelRunIds[t]}delete this.metadatas[t],delete this.stableMessageIdMap[t]}}handleLLMError(e,t){delete this.metadatas[t]}handleChainStart(e,t,r,i,n,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=HR(a,n,s),typeof t=="object")){for(let c of Object.values(t))if((We(c)||ai(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(We(u)||ai(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(We(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let i of e)We(i)&&this._emit(r,i,t,!0);else if(e!=null&&typeof e=="object"){for(let i of Object.values(e))if(We(i))this._emit(r,i,t,!0);else if(Array.isArray(i))for(let n of i)We(n)&&this._emit(r,n,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function JR(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function KR(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function R9(e){switch(e.type){case"text":return{type:"text",text:""};case"reasoning":return{type:"reasoning",reasoning:""};case"tool_call":case"tool_call_chunk":return{type:"tool_call_chunk",...e.id!=null?{id:e.id}:{},...e.name!=null?{name:e.name}:{},args:""};default:return e}}function M9(e){switch(e.type){case"text":{let t=typeof e.text=="string"?e.text:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"text-delta",text:t}}:void 0}case"reasoning":{let t=typeof e.reasoning=="string"?e.reasoning:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"reasoning-delta",reasoning:t}}:void 0}case"tool_call_chunk":return{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"block-delta",fields:{...e,type:"tool_call_chunk"}}};default:return}}var WR=class extends Sr{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;constructor(e){super(),this.streamFn=e}normalizeMessageId(e,t){let r=e.id;return t!=null&&(_t.isInstance(e)?r??=`run-${t}-tool-${e.tool_call_id}`:((r==null||r===`run-${t}`)&&(r=this.stableMessageIdMap[t]??r??`run-${t}`),this.stableMessageIdMap[t]??=r)),r!==e.id&&(e.id=r,e.lc_kwargs.id=r),e.id!=null&&(this.seen[e.id]=e),e.id}emit(e,t,r){let i=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,i]])}emitFinalMessage(e,t,r,i=!1){let n=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(i&&n!=null&&this.seen[n]!==void 0)return;let a=this.normalizeMessageId(t,r),o=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",s=o==="tool"&&_t.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...a!=null?{id:a}:{},...o!=="ai"?{role:o}:{},...typeof s=="string"?{tool_call_id:s}:{}},r),(Array.isArray(t.content)?t.content:typeof t.content=="string"&&t.content.length>0?[{type:"text",text:t.content}]:[]).forEach((c,u)=>{let l=typeof c.index=="number"?c.index:u;this.emit(e,{event:"content-block-start",index:l,content:R9(c)},r);let d=M9({...c,index:l});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:l,content:c},r)}),this.emit(e,{event:"message-finish",...KR(t)!=null?{usage:KR(t)}:{},...JR(t)!=null?{responseMetadata:JR(t)}:{}},r)}handleChatModelStart(e,t,r,i,n,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:a,name:s,...o}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let n=e.id??`run-${t}`;this.seen[n]=!0,this.stableMessageIdMap[t]??=n,e.id==null&&(i={...e,id:n})}this.emit(r,i,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e.generations?.[0]?.[0],n=Ce.isInstance(i?.message)?i.message:void 0;if(n!=null)if(this.streamedRunIds.has(t)){let a=this.normalizeMessageId(n,t);a!=null&&(this.seen[a]=n)}else this.emitFinalMessage(r,n,t,!0);this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleLLMError(e,t){this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleChainStart(e,t,r,i,n,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:n,name:s,...a}],typeof t=="object")){for(let c of Object.values(t))if((Ce.isInstance(c)||bt.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(Ce.isInstance(u)||bt.isInstance(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let i=n=>{Ce.isInstance(n)&&!_t.isInstance(n)&&this.emitFinalMessage(r,n,t,!0)};if(Ce.isInstance(e))i(e);else if(Array.isArray(e))for(let n of e)i(n);else if(e!=null&&typeof e=="object")for(let n of Object.values(e))if(Array.isArray(n))for(let a of n)i(a);else i(n);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var j9=[400,401,402,403,404,405,406,407,409],z9=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||e.name==="AbortError"||e.name==="GraphValueError"||e?.code==="ECONNABORTED")return!1;let t=e?.response?.status??e?.status;return!(t&&j9.includes(+t)||e?.error?.code==="insufficient_quota")};async function iS(e,t,r,i){let n=e.retry_policy??t,a=n!==void 0?n.initialInterval??500:0,o=0,s,c,u=e.config??{};r&&(u=hr(u,r)),u={...u,signal:i};let l=Date.now();for(u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeFirstAttemptTime:l});!i?.aborted;){e.writes.splice(0,e.writes.length),s=void 0;try{c=await e.proc.invoke(e.input,u);break}catch(d){if(s=d,s.pregelTaskId=e.id,_h(s)){let m=u?.configurable?.checkpoint_ns,g=s.command;if(g.graph===m){for(let y of e.writers)await y.invoke(g,u);s=void 0;break}else if(g.graph===nr.PARENT){let y=iR(m);s.command=new nr({...s.command,graph:y})}}if($a(s)||n===void 0||(o+=1,o>=(n.maxAttempts??3))||!(n.retryOn??z9)(s))break;a=Math.min(n.maxInterval??128e3,a*(n.backoffFactor??2));let f=n.jitter?Math.floor(a+Math.random()*1e3):a;await new Promise(m=>setTimeout(m,f));let p=s.name??s.constructor.unminifiable_name??s.constructor.name;(n?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${a.toFixed(2)}ms (attempt ${o}) after ${p}: ${s}`),u=hr(u,{[zo]:!0}),u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:l})}}return{task:e,result:c,error:s,signalAborted:i?.aborted}}var aS=Symbol.for("promiseAdded");function D9(){let e={next:()=>{},wait:Promise.resolve(aS)};function t(r){e.next=()=>{e.wait=new Promise(t),r(aS)}}return e.wait=new Promise(t),e}var qR=class{nodeFinished;loop;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:i,maxConcurrency:n}=e,a=new Set,o,s=new AbortController,c=s.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks).filter(m=>m.writes.length===0),{signals:d,disposeCombinedSignal:f}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),p=this._executeTasksWithRetry(l,{signals:d,retryPolicy:r,maxConcurrency:n});for await(let{task:m,error:g,signalAborted:y}of p)this._commit(m,g),ri(g)||$a(g)&&!ri(o)?o=g:g&&(a.size===0||!y)&&(s.abort(),a.add(g));if(f?.(),i?.(this.loop.step,Object.values(this.loop.tasks).map(m=>m.writes).flat()),a.size===1)throw Array.from(a)[0];if(a.size>1)throw new AggregateError(Array.from(a),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(ri(o)||$a(o)&&this.loop.isNested)throw o}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let i=this.loop.config.configurable?.__pregel_abort_signals??{},n=i.externalAbortSignal??r,a=t??i.timeoutAbortSignal,{signal:o,dispose:s}=gc(n,a,e),c={externalAbortSignal:n,timeoutAbortSignal:a,composedAbortSignal:o};return this.loop.config=hr(this.loop.config,{[wS]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:i,signals:n}=t??{},a=D9(),o={},s={executingTasksMap:o,barrier:a,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(n?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=gc(n?.externalAbortSignal,n?.timeoutAbortSignal),d=l.signal?new Promise((f,p)=>{u=()=>p(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(o).length>0)&&e.length;){for(;Object.values(o).length<(i??e.length)&&c<e.length;c+=1){let p=e[c];o[p.id]=iS(p,r,{[jo]:XR?.bind(s,this,p)},n?.composedAbortSignal).catch(m=>({task:p,error:m,signalAborted:n?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(o),...d?[d]:[],a.wait]);f!==aS&&(yield f,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete o[f.task.id])}}_commit(e,t){if(t!==void 0)if(ri(t)){if(t.interrupts.length){let r=t.interrupts.map(n=>[Ue,n]),i=e.writes.filter(n=>n[0]===gr);i.length&&r.push(...i),this.loop.putWrites(e.id,r)}}else $a(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):this.loop.putWrites(e.id,[[Mo,{message:t.message,name:t.name}]]);else this.nodeFinished&&(e.config?.tags==null||!e.config.tags.includes("langsmith:hidden"))&&this.nodeFinished(String(e.name)),e.writes.length===0&&e.writes.push([Sc,null]),this.loop.putWrites(e.id,e.writes)}};async function XR(e,t,r,i,n,a={}){let o=t.config?.configurable?.[ir];if(!o)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=o.callCounter;o.callCounter+=1;let c=new ER({func:r,name:i,input:n,cache:a.cache,retry:a.retry,callbacks:a.callbacks}),u=await this.scheduleTask(t,s,c);if(!u)return;let l=this.executingTasksMap[u.id];if(l!==void 0)return l;if(u.writes.length>0){let d=u.writes.filter(([p])=>p===Ci),f=u.writes.filter(([p])=>p===Mo);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${u.name}__${u.id}`)}if(f.length>0){if(f.length===1){let p=f[0][1],m=p instanceof Error?p:new Error(String(p));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${u.name}__${u.id}`)}return}else{let d=iS(u,a.retry,{[jo]:XR.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var Ii=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function YR({nodes:e,channels:t,inputChannels:r,outputChannels:i,streamChannels:n,interruptAfterNodes:a,interruptBeforeNodes:o}){if(!t)throw new Ii("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Ii(`"Node name ${Ue} is reserved"`);if(l.constructor===bn)l.triggers.forEach(d=>s.add(d));else throw new Ii(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new Ii(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new Ii(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Ii(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(i)?i.forEach(u=>c.add(u)):c.add(i),n&&!Array.isArray(n)?c.add(n):Array.isArray(n)&&n.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new Ii(`Output channel '${String(u)}' not in channels`);if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new Ii(`Node ${String(u)} not in nodes`)}if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new Ii(`Node ${String(u)} not in nodes`)}}function oS(e,t){if(Array.isArray(e)){for(let r of e)if(!(r in t))throw new Error(`Key ${String(r)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}var sS=class QR extends kt{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor(t){super(),this.unique=t?.unique??this.unique,this.accumulate=t?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint(t){let r=new QR({unique:this.unique,accumulate:this.accumulate});return typeof t<"u"&&(r.seen=new Set(t[0]),r.values=t[1]),r}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let i=t.flat();if(i.length>0)if(this.unique)for(let n of i)this.seen.has(n)||(r=!0,this.seen.add(n),this.values.push(n));else r=!0,this.values.push(...i);return r}get(){if(this.values.length===0)throw new Ne;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function U9(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let i of e){let n=i.params.namespace,a=n.length?`${i.method}|${n.join("|")}`:i.method;r.enqueue(t.encode(`event: ${a}
|
|
424
|
+
data: ${JSON.stringify(i.params.data??{})}
|
|
425
|
+
|
|
426
|
+
`))}}catch(i){r.enqueue(t.encode(`event: error
|
|
427
|
+
data: ${JSON.stringify({message:String(i)})}
|
|
428
|
+
|
|
429
|
+
`))}finally{r.close()}}})}var eM=class{static subscribeTo(e,t){let{key:r,tags:i}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&r!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let n;return typeof e=="string"?r?n={[r]:e}:n=[e]:n=Object.fromEntries(e.map(a=>[a,a])),new bn({channels:n,triggers:Array.isArray(e)?e:[e],tags:i})}static writeTo(e,t){let r=[];for(let i of e)r.push({channel:i,value:mr,skipNone:!1});for(let[i,n]of Object.entries(t??{}))ae.isRunnable(n)||typeof n=="function"?r.push({channel:i,value:mr,skipNone:!0,mapper:tt(n)}):r.push({channel:i,value:n,skipNone:!1});return new ot(r)}},L9=class extends ae{lc_namespace=["langgraph","pregel"];invoke(e,t){throw new Error("Not implemented")}withConfig(e){return super.withConfig(e)}stream(e,t){return super.stream(e,t)}},lh=class extends L9{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;streamTransformers;triggerToNodes={};constructor(e){super(e);let{streamMode:t}=e;if(t!=null&&!Array.isArray(t)&&(t=[t]),this.nodes=e.nodes,this.channels=e.channels,"__pregel_tasks"in this.channels&&"lc_graph_name"in this.channels.__pregel_tasks&&this.channels.__pregel_tasks.lc_graph_name!=="Topic")throw new Error(`Channel '${En}' is reserved and cannot be used in the graph.`);this.channels[En]=new sS({accumulate:!1}),this.autoValidate=e.autoValidate??this.autoValidate,this.streamMode=t??this.streamMode,this.inputChannels=e.inputChannels,this.outputChannels=e.outputChannels,this.streamChannels=e.streamChannels??this.streamChannels,this.interruptAfter=e.interruptAfter,this.interruptBefore=e.interruptBefore,this.stepTimeout=e.stepTimeout??this.stepTimeout,this.debug=e.debug??this.debug,this.checkpointer=e.checkpointer,this.retryPolicy=e.retryPolicy,this.config=e.config,this.store=e.store,this.cache=e.cache,this.name=e.name,this.triggerToNodes=e.triggerToNodes??this.triggerToNodes,this.userInterrupt=e.userInterrupt,this.streamTransformers=e.streamTransformers??[],this.autoValidate&&this.validate()}withConfig(e){let{streamTransformers:t,...r}=e,i=xt(this.config,r),n=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:i,streamTransformers:n})}validate(){YR({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[e,t]of Object.entries(this.nodes))for(let r of t.triggers)this.triggerToNodes[r]??=[],this.triggerToNodes[r].push(e);return this}get streamChannelsList(){return Array.isArray(this.streamChannels)?this.streamChannels:this.streamChannels?[this.streamChannels]:Object.keys(this.channels)}get streamChannelsAsIs(){return this.streamChannels?this.streamChannels:Object.keys(this.channels)}async getGraphAsync(e){return this.getGraph(e)}*getSubgraphs(e,t){for(let[r,i]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let n=i.subgraphs?.length?i.subgraphs:[i.bound];for(let a of n){let o=th(a);if(o!==void 0){if(r===e){yield[r,o];return}if(e===void 0&&(yield[r,o]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,u]of o.getSubgraphs(s,t))yield[`${r}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:i=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let n=ua(this.channels,t.checkpoint);if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([f,p])=>f===_r).map(([f,p,m])=>[String(p),m]);d.length>0&&tr(t.checkpoint,n,[{name:In,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let a=Object.values(fa(t.checkpoint,t.pendingWrites,this.nodes,n,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),o=await vn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of a){let f=o.find(([m])=>m===d.name);if(!f)continue;let p=`${String(d.name)}:${d.id}`;if(s&&(p=`${s}|${p}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}};c[d.id]=m}else{let m={configurable:{[Qr]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},g=f[1];c[d.id]=await g.getState(m,{subgraphs:!0})}}if(i&&t.pendingWrites?.length){let d=Object.fromEntries(a.map(p=>[p.id,p]));for(let[p,m,g]of t.pendingWrites)["__error__","__interrupt__",Ia].includes(m)||p in d&&d[p].writes.push([String(m),g]);let f=a.filter(p=>p.writes.length>0);f.length>0&&tr(t.checkpoint,n,f,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=a.filter(d=>d.writes.length===0).map(d=>d.name);return{values:wn(n,this.streamChannelsAsIs),next:l,tasks:eS(a,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:da(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new ka("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Bm(i);for await(let[s,c]of this.getSubgraphsAsync(o,!0))if(s===o)return await c.getState(Ao(e,{[Qr]:r}),{subgraphs:t?.subgraphs})}let n=xt(this.config,e),a=await r.getTuple(e);return await this._prepareStateSnapshot({config:n,saved:a,subgraphCheckpointer:t?.subgraphs?r:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new ka("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Bm(i);for await(let[o,s]of this.getSubgraphsAsync(a,!0))if(o===a){yield*s.getStateHistory(Ao(e,{[Qr]:r}),t);return}}let n=xt(this.config,e,{configurable:{checkpoint_ns:i}});for await(let a of r.list(n,t))yield this._prepareStateSnapshot({config:a.config,saved:a})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new ka("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(o=>o.updates.length===0))throw new Error("No updates provided");let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Bm(i);for await(let[,s]of this.getSubgraphsAsync(o,!0))return await s.bulkUpdateState(Ao(e,{[Qr]:r}),t);throw new Error(`Subgraph "${o}" not found`)}let n=async(o,s)=>{let c=this.config?xt(this.config,o):o,u=await r.getTuple(c),l=u!==void 0?gn(u.checkpoint):sc(),d={...u?.checkpoint.channel_versions},f=u?.metadata?.step??-1,p=Ao(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(p=Ao(c,u.config.configurable),m={...u.metadata,...m});let{values:g,asNode:y}=s[0];if(g==null&&y===void 0){if(s.length>1)throw new be("Cannot create empty checkpoint with multiple updates");return da(await r.put(p,_n(l,void 0,f),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let b=ua(this.channels,l);if(g===null&&y==="__end__"){if(s.length>1)throw new be("Cannot apply multiple updates when clearing state");if(u){let C=fa(l,u.pendingWrites||[],this.nodes,b,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),v=(u.pendingWrites||[]).filter(W=>W[0]===_r).map(W=>W.slice(1));v.length>0&&tr(l,b,[{name:In,writes:v,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[W,F,T]of u.pendingWrites||[])["__error__","__interrupt__",Ia].includes(F)||W in C&&C[W].writes.push([F,T]);tr(l,b,Object.values(C),r.getNextVersion.bind(r),this.triggerToNodes)}return da(await r.put(p,_n(l,b,f),{...m,source:"update",step:f+1,parents:u?.metadata?.parents??{}},hc(d,l.channel_versions)),u?u.metadata:void 0)}if(y==="__copy__"){if(s.length>1)throw new be("Cannot copy checkpoint with multiple updates");if(u==null)throw new be("Cannot copy a non-existent checkpoint");let C=F=>!Array.isArray(F)||F.length===0?!1:F.every(T=>Array.isArray(T)&&T.length===2),v=_n(l,void 0,f),W=await r.put(u.parentConfig??Ao(u.config,{checkpoint_id:void 0}),v,{source:"fork",step:f+1,parents:u.metadata?.parents??{}},{});if(C(g)){let F=fa(v,u.pendingWrites,this.nodes,b,W,!1,{step:f+2}),T=Object.values(F).reduce((Z,{name:ne,id:Oe})=>(Z[ne]??=[],Z[ne].push({id:Oe}),Z),{}),B=g.reduce((Z,ne)=>{let[Oe,ge]=ne;Z[ge]??=[];let Sn=Z[ge].length,Pr=T[ge]?.[Sn]?.id;return Z[ge].push({values:Oe,asNode:ge,taskId:Pr}),Z},{});return n(da(W,u.metadata),Object.values(B).flat())}return da(W,u.metadata)}if(y==="__input__"){if(s.length>1)throw new be("Cannot apply multiple updates when updating as input");let C=await vn(rh(this.inputChannels,g));if(C.length===0)throw new be(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);tr(l,b,[{name:In,writes:C,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let v=u?.metadata?.step!=null?u.metadata.step+1:-1,W=await r.put(p,_n(l,b,v),{source:"input",step:v,parents:u?.metadata?.parents??{}},hc(d,l.channel_versions));return await r.putWrites(W,C,ni(In,l.id)),da(W,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let C=fa(l,u.pendingWrites,this.nodes,b,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),v=(u.pendingWrites??[]).filter(F=>F[0]===_r).map(F=>F.slice(1));v.length>0&&tr(u.checkpoint,b,[{name:In,writes:v,triggers:[]}],void 0,this.triggerToNodes);for(let[F,T,B]of u.pendingWrites)["__error__","__interrupt__",Ia].includes(T)||C[F]===void 0||C[F].writes.push([T,B]);let W=Object.values(C).filter(F=>F.writes.length>0);W.length>0&&tr(l,b,W,void 0,this.triggerToNodes)}let w=Object.values(l.versions_seen).map(C=>Object.values(C)).flat().find(C=>!!C),x=[];if(s.length===1){let{values:C,asNode:v,taskId:W}=s[0];if(v===void 0&&Object.keys(this.nodes).length===1)[v]=Object.keys(this.nodes);else if(v===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(v=this.inputChannels);else if(v===void 0){let F=Object.entries(l.versions_seen).map(([T,B])=>Object.values(B).map(Z=>[Z,T])).flat().filter(([T,B])=>B!==Ue).sort(([T],[B])=>zm(T,B));F&&(F.length===1?v=F[0][1]:F[F.length-1][0]!==F[F.length-2][0]&&(v=F[F.length-1][1]))}if(v===void 0)throw new be('Ambiguous update, specify "asNode"');x.push({values:C,asNode:v,taskId:W})}else for(let{asNode:C,values:v,taskId:W}of s){if(C==null)throw new be('"asNode" is required when applying multiple updates');x.push({values:v,asNode:C,taskId:W})}let k=[];for(let{asNode:C,values:v,taskId:W}of x){if(this.nodes[C]===void 0)throw new be(`Node "${C.toString()}" does not exist`);let F=this.nodes[C].getWriters();if(!F.length)throw new be(`No writers found for node "${C.toString()}"`);k.push({name:C,input:v,proc:F.length>1?Cr.from(F,{omitSequenceTags:!0}):F[0],writes:[],triggers:[Ue],id:W??ni("__interrupt__",l.id),writers:[]})}for(let C of k)await C.proc.invoke(C.input,$e({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[Rr]:v=>C.writes.push(...v),[Yr]:(v,W=!1)=>vl(l,b,C,v,W)}}));for(let C of k){let v=C.writes.filter(W=>W[0]!==zr);u!==void 0&&v.length>0&&await r.putWrites(p,v,C.id)}tr(l,b,k,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let E=hc(d,l.channel_versions),V=await r.put(p,_n(l,b,f+1),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},E);for(let C of k){let v=C.writes.filter(W=>W[0]===zr);v.length>0&&await r.putWrites(V,v,C.id)}return da(V,u?u.metadata:void 0)},a=e;for(let{updates:o}of t)a=await n(a,o);return a}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:i,outputKeys:n,interruptAfter:a,interruptBefore:o,...s}=e,c=!0,u=t!==void 0?t:this.debug,l=n;l===void 0?l=this.streamChannelsAsIs:oS(l,this.channels);let d=i;d===void 0?d=this.inputChannels:oS(d,this.channels);let f=o??this.interruptBefore??[],p=a??this.interruptAfter??[],m;r!==void 0?(m=Array.isArray(r)?r:[r],c=typeof r=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let g;if(this.checkpointer===!1)g=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)g=e.configurable[Qr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");g=this.checkpointer}let y=e.store??this.store,b=e.cache??this.cache;if(e.durability!=null&&e.checkpointDuring!=null)throw new Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let w=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),x=e.durability??w??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,s,f,p,g,y,c,b,x]}async stream(e,t){let r=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:gc(t?.signal,r.signal).signal},n=await super.stream(e,i);return new sh(t?.encoding==="text/event-stream"?BR(n):n,r)}async#e(e,t){let{version:r,encoding:i,transformers:n,...a}=t,o={recursionLimit:this.config?.recursionLimit,...a,configurable:{...this.config?.configurable,...a?.configurable},version:r,streamMode:P0,subgraphs:!0,encoding:void 0},s=this.stream(e,o),c=F0({[Symbol.asyncIterator]:async function*(){let u=await s;for await(let l of u)yield l}},[...this.streamTransformers??[],...n??[]]);if(i==="text/event-stream"){let u=new AbortController;return u.signal.addEventListener("abort",()=>c.abort(u.signal.reason),{once:!0}),new sh(U9(c),u)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let i=new AbortController,n={recursionLimit:this.config?.recursionLimit,...t,callbacks:IR(this.config?.callbacks,t?.callbacks),signal:gc(t?.signal,i.signal).signal};return new sh(super.streamEvents(e,n,r),i)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let r="version"in(t??{})?void 0:t?.encoding??void 0,i=t?.subgraphs,n=lc(this.config,t);if(n.recursionLimit===void 0||n.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&n.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let a=await this._validateInput(e),{runId:o,...s}=n,[c,u,,l,d,f,p,m,g,y,b,w]=this._defaults(s);d.metadata={ls_integration:"langgraph",...d.metadata},typeof d.context<"u"?d.context=await this._validateContext(d.context):d.configurable=await this._validateContext(d.configurable);let x=new ch({modes:new Set(u)});if(this.checkpointer===!0){d.configurable??={};let T=d.configurable.checkpoint_ns??"";d.configurable[Mr]=T.split("|").map(B=>B.split(":")[0]).join("|")}if(u.includes("messages")){let T=t?.version==="v3"?new WR(Z=>x.push(Z)):new GR(Z=>x.push(Z)),{callbacks:B}=d;if(B===void 0)d.callbacks=[T];else if(Array.isArray(B))d.callbacks=B.concat(T);else{let Z=B.copy();Z.addHandler(T,!0),d.callbacks=Z}}if(u.includes("tools")){let T=new FR(Z=>x.push(Z)),{callbacks:B}=d;if(B===void 0)d.callbacks=[T];else if(Array.isArray(B))d.callbacks=B.concat(T);else{let Z=B.copy();Z.addHandler(T,!0),d.callbacks=Z}}d.writer??=T=>{if(!u.includes("custom"))return;let B=A0()?.configurable?.[Mr]?.split("|").slice(0,-1);x.push([B??[],"custom",T])},d.interrupt??=this.userInterrupt??H0,d.serverInfo==null&&(d.serverInfo=F9(d));let k={tracerInheritableMetadata:Z9(d)},E=await(await et._configureSync(d?.callbacks,void 0,d?.tags,void 0,d?.metadata,void 0,k))?.handleChainStart(this.toJSON(),$R(e,"input"),o,void 0,void 0,void 0,d?.runName??this.getName()),V=pl(this.channels),C,v,F=(async()=>{try{C=await VR.initialize({input:a,config:d,checkpointer:m,nodes:this.nodes,channelSpecs:V,outputKeys:l,streamKeys:this.streamChannelsAsIs,store:g,cache:b,stream:x,interruptAfter:p,interruptBefore:f,manager:E,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:w});let T=new qR({loop:C,nodeFinished:d.configurable?.[bS]});t?.subgraphs&&(C.config.configurable={...C.config.configurable,[xc]:C.stream}),await this._runLoop({loop:C,runner:T,debug:c,config:d}),w==="sync"&&await Promise.all(C?.checkpointerPromises??[])}catch(T){v=T}finally{try{C&&(await C.store?.stop(),await C.cache?.stop()),await Promise.all(C?.checkpointerPromises??[])}catch(T){v=v??T}v?x.error(v):x.close()}})();try{for await(let T of x){if(T===void 0)throw new Error("Data structure error.");let[B,Z,ne,Oe]=T;if(u.includes(Z)){if(r==="text/event-stream"){i?yield[B,Z,ne]:yield[null,Z,ne];continue}i&&!y?yield Oe!==void 0?[B,Z,ne,Oe]:[B,Z,ne]:y?i?yield[B,ne]:yield ne:yield[Z,ne]}}}catch(T){throw await E?.handleChainError(v),T}finally{await F}await E?.handleChainEnd(C?.output??{},o,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",i={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},n=[],a=await this.stream(e,i),o=[],s;for await(let c of a)r==="values"?Sa(c)?o.push(c[Ue]):s=c:n.push(c);if(r==="values"){if(o.length>0){let c=o.flat(1);if(s==null)return{[Ue]:c};if(typeof s=="object")return{...s,[Ue]:c}}return s}return n}async _runLoop(e){let{loop:t,runner:r,debug:i,config:n}=e,a;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:o}of await t._matchCachedWrites())t._outputWrites(o.id,o.writes,!0);i&&zR(t.checkpointMetadata.step,t.channels,this.streamChannelsList),i&&oh(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(o,s)=>{i&&DR(o,s,this.streamChannelsList)},maxConcurrency:n.maxConcurrency,signal:n.signal})}if(t.status==="out_of_steps")throw new gh([`Recursion limit of ${n.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(o){if(a=o,!await t.finishAndHandleError(a))throw o}finally{a===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function F9(e){let t=e.metadata??{},r=e.configurable??{},i=r.assistant_id??t.assistant_id,n=r.graph_id??t.graph_id,a=r.langgraph_auth_user,o;if(a!=null&&typeof a=="object"&&"identity"in a&&(o=a),i!=null||n!=null||o!=null)return{assistantId:i!=null?String(i):"",graphId:n!=null?String(n):"",user:o}}var B9=new Set(["key","token","secret","password","auth"]);function V9(e,t){let r=e.toLowerCase(),i=!1;for(let n of B9)if(r.includes(n)){i=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||i}function Z9(e){let t=e.configurable;if(!t)return;let r={};for(let[i,n]of Object.entries(t))V9(i,n)||(r[i]=n);return Object.keys(r).length>0?r:void 0}var xn=class tM extends kt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new tM(this.guard);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0){let r=this.value.length>0;return this.value=[],r}if(t.length!==1&&this.guard)throw new be("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ne;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ne;return this.value[0]}isAvailable(){return this.value.length!==0}};var cS=class{path;ends;constructor(e){ae.isRunnable(e.path)?this.path=e.path:this.path=tt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return ot.registerWriter(new Vt({name:"<branch_run>",trace:!1,func:async(r,i)=>{try{return await this._route(r,i,e,t)}catch(n){throw n.name===Ol.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
430
|
+
NodeInterrupt should only be thrown inside a node, not in edge conditions.`),n}}}))}async _route(e,t,r,i){let n=await this.path.invoke(i?i(t):e,t);Array.isArray(n)||(n=[n]);let a;if(this.ends?a=n.map(o=>dt(o)?o:this.ends[o]):a=n,a.some(o=>!o))throw new Error("Branch condition returned unknown or null destination");if(a.filter(dt).some(o=>o.node==="__end__"))throw new be("Cannot send a packet to the END node");return await r(a,t)??e}},uS=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(e){this.compiled&&console.warn(e)}get allEdges(){return this.edges}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){for(let s of["|",":"])if(i.includes(s))throw new Error(`"${s}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__")throw new Error(`Node \`${i}\` is reserved.`);let o=tt(n);this.nodes[i]={runnable:o,metadata:a?.metadata,subgraphs:yl(o)?[o]:a?.subgraphs,ends:a?.ends}}return this}addEdge(e,t){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),e==="__end__")throw new Error("END cannot be a start node");if(t==="__start__")throw new Error("START cannot be an end node");if(Array.from(this.edges).some(([r])=>r===e)&&!("channels"in this))throw new Error(`Already found path for ${e}. For multiple edges, use StateGraph.`);return this.edges.add([e,t]),this}addConditionalEdges(e,t,r){let i=typeof e=="object"?e:{source:e,path:t,pathMap:r};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),ae.isRunnable(i.path)||(i.path=tt(i.path));let n=i.path.getName()==="RunnableLambda"?"condition":i.path.getName();if(this.branches[i.source]&&this.branches[i.source][n])throw new Error(`Condition \`${n}\` already present for node \`${e}\``);return this.branches[i.source]??={},this.branches[i.source][n]=new cS(i),this}setEntryPoint(e){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Ze,e)}setFinishPoint(e){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(e,Ye)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:i,transformers:n}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let a=new lS({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Ze]:new xn,[Ye]:new xn},inputChannels:Ze,outputChannels:Ye,streamChannels:[],streamMode:"values",name:i,streamTransformers:n});for(let[o,s]of Object.entries(this.nodes))a.attachNode(o,s);for(let[o,s]of this.edges)a.attachEdge(o,s);for(let[o,s]of Object.entries(this.branches))for(let[c,u]of Object.entries(s))a.attachBranch(o,c,u);return a.validate()}validate(e){let t=new Set([...this.allEdges].map(([i,n])=>i));for(let[i]of Object.entries(this.branches))t.add(i);for(let i of t)if(i!=="__start__"&&!(i in this.nodes))throw new Error(`Found edge starting at unknown node \`${i}\``);let r=new Set([...this.allEdges].map(([i,n])=>n));for(let[i,n]of Object.entries(this.branches))for(let a of Object.values(n))if(a.ends!=null)for(let o of Object.values(a.ends))r.add(o);else{r.add(Ye);for(let o of Object.keys(this.nodes))o!==i&&r.add(o)}for(let i of Object.values(this.nodes))for(let n of i.ends??[])r.add(n);for(let i of Object.keys(this.nodes))if(!r.has(i))throw new yh([`Node \`${i}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
|
|
431
|
+
`),{lc_error_code:"UNREACHABLE_NODE"});for(let i of r)if(i!=="__end__"&&!(i in this.nodes))throw new Error(`Found edge ending at unknown node \`${i}\``);if(e){for(let i of e)if(!(i in this.nodes))throw new Error(`Interrupt node \`${i}\` is not present`)}this.compiled=!0}},lS=class extends lh{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new xn,this.nodes[e]=new bn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new ot([{channel:e,value:mr}],[lt])),this.streamChannels.push(e)}attachEdge(e,t){if(t==="__end__"){if(e==="__start__")throw new Error("Cannot have an edge from START to END");this.nodes[e].writers.push(new ot([{channel:Ye,value:mr}],[lt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Ze]=eM.subscribeTo(Ze,{tags:[lt]})),this.nodes[e].pipe(r.run(n=>new ot(n.map(a=>dt(a)?a:{channel:a==="__end__"?Ye:`branch:${e}:${t}:${a}`,value:mr}),[lt])));let i=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let n of i)if(n!=="__end__"){let a=`branch:${e}:${t}:${n}`;this.channels[a]=new xn,this.nodes[n].triggers.push(a),this.nodes[n].channels.push(a)}}async getGraphAsync(e){let t=e?.xray,r=new wo,i={[Ze]:r.addNode({schema:Kr.any()},Ze)},n={},a={};t&&(a=Object.fromEntries((await vn(this.getSubgraphsAsync())).filter(c=>rM(c[1]))));function o(c,u,l,d=!1){if(u==="__end__"&&n.__end__===void 0&&(n[Ye]=r.addNode({schema:Kr.any()},Ye)),i[c]!==void 0){if(n[u]===void 0)throw new Error(`End node ${u} not found!`);return r.addEdge(i[c],n[u],l!==u?l:void 0,d)}}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Zt(c),d=u.runnable,f=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?f.__interrupt="before,after":this.interruptBefore?.includes(c)?f.__interrupt="before":this.interruptAfter?.includes(c)&&(f.__interrupt="after"),t){let p=typeof t=="number"?t-1:t,m=a[c]!==void 0?await a[c].getGraphAsync({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let b=function(x){return x?x.lc_runnable:!1},w=function(x,k){if(x!==void 0&&!Uo(x))return x;if(b(k))try{let E=k.getName();return E=E.startsWith("Runnable")?E.slice(8):E,E}catch{return k.getName()}else return k.name??"UnknownSchema"},[g,y]=r.extend(m,l);if(g===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);y!==void 0&&(i[l]={name:w(y.id,y.data),...y}),n[l]={name:w(g.id,g.data),...g}}else{let g=r.addNode(d,l,f);i[l]=g,n[l]=g}}else{let p=r.addNode(d,l,f);i[l]=p,n[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Zt(c),Zt(u));for(let[c,u]of Object.entries(this.builder.branches)){let l={...Object.fromEntries(Object.keys(this.builder.nodes).filter(d=>d!==c).map(d=>[Zt(d),Zt(d)])),[Ye]:Ye};for(let d of Object.values(u)){let f;d.ends!==void 0?f=d.ends:f=l;for(let[p,m]of Object.entries(f))o(Zt(c),Zt(m),p,!0)}}for(let[c,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let l of u.ends)o(Zt(c),Zt(l),void 0,!0);return r}getGraph(e){let t=e?.xray,r=new wo,i={[Ze]:r.addNode({schema:Kr.any()},Ze)},n={},a={};t&&(a=Object.fromEntries(To(this.getSubgraphs()).filter(c=>rM(c[1]))));function o(c,u,l,d=!1){return u==="__end__"&&n.__end__===void 0&&(n[Ye]=r.addNode({schema:Kr.any()},Ye)),r.addEdge(i[c],n[u],l!==u?l:void 0,d)}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Zt(c),d=u.runnable,f=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?f.__interrupt="before,after":this.interruptBefore?.includes(c)?f.__interrupt="before":this.interruptAfter?.includes(c)&&(f.__interrupt="after"),t){let p=typeof t=="number"?t-1:t,m=a[c]!==void 0?a[c].getGraph({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let b=function(x){return x?x.lc_runnable:!1},w=function(x,k){if(x!==void 0&&!Uo(x))return x;if(b(k))try{let E=k.getName();return E=E.startsWith("Runnable")?E.slice(8):E,E}catch{return k.getName()}else return k.name??"UnknownSchema"},[g,y]=r.extend(m,l);if(g===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);y!==void 0&&(i[l]={name:w(y.id,y.data),...y}),n[l]={name:w(g.id,g.data),...g}}else{let g=r.addNode(d,l,f);i[l]=g,n[l]=g}}else{let p=r.addNode(d,l,f);i[l]=p,n[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Zt(c),Zt(u));for(let[c,u]of Object.entries(this.builder.branches)){let l={...Object.fromEntries(Object.keys(this.builder.nodes).filter(d=>d!==c).map(d=>[Zt(d),Zt(d)])),[Ye]:Ye};for(let d of Object.values(u)){let f;d.ends!==void 0?f=d.ends:f=l;for(let[p,m]of Object.entries(f))o(Zt(c),Zt(m),p,!0)}}return r}};function rM(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Zt(e){return e==="subgraph"?`"${e}"`:e}function Ei(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function dS(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function H9(e){return Ei(e)&&dS(e)}function pa(e){if(dS(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function ma(e){if(e!=null&&Ei(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let r=t;if(!r.issues){let i=r.value;return()=>i}}}catch{}}var fS=Symbol.for("langgraph.channel.missing"),dh=class nM extends kt{lc_graph_name="UntrackedValue";guard;_value=fS;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new nM({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new be("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=t[t.length-1],!0}get(){if(this._value===fS)throw new Ne;return this._value}checkpoint(){}isAvailable(){return this._value!==fS}};var ha=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),pS=class iM extends kt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new iM(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let i of t)if(this.names.has(i))this.seen.has(i)||(this.seen.add(i),r=!0);else throw new be(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!ha(this.names,this.seen))throw new Ne}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&ha(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&ha(this.names,this.seen)}},mS=class aM extends kt{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let r=new aM(this.names);if(typeof t<"u"){let[i,n]=t;r.seen=new Set(i),r.finished=n}return r}update(t){let r=!1;for(let i of t)if(this.names.has(i)&&!this.seen.has(i))this.seen.add(i),r=!0;else if(!this.names.has(i))throw new be(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!ha(this.names,this.seen))throw new Ne}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&ha(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&ha(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&ha(this.names,this.seen)}};var hS=Symbol.for("langgraph.state.reduced_value"),Ti=class{[hS]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.jsonSchemaExtra=t.jsonSchemaExtra,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&hS in e&&e[hS]===!0}};var oM=Symbol.for("langgraph.state.untracked_value"),Oo=class{[oM]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&oM in e}};var gS=Symbol.for("langgraph.state.state_schema"),Qn=class{[gS]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(Ti.isInstance(r)){let i=ma(r.valueSchema);e[t]=new xi(r.reducer,i)}else if(Oo.isInstance(r)){let i=r.schema?ma(r.schema):void 0;e[t]=new dh({guard:r.guard,initialValueFactory:i})}else if(Ei(r))e[t]=new yn(ma(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,i]of Object.entries(this.fields)){let n;if(Ti.isInstance(i)?(n=pa(i.valueSchema),i.jsonSchemaExtra&&(n={...n??{},...i.jsonSchemaExtra})):Oo.isInstance(i)?n=i.schema?pa(i.schema):void 0:Ei(i)&&(n=pa(i)),n){e[r]=n;let a=!1;Ti.isInstance(i)?a=ma(i.valueSchema)!==void 0:Oo.isInstance(i)?a=i.schema?ma(i.schema)!==void 0:!1:a=ma(i)!==void 0,a||t.push(r)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,r]of Object.entries(this.fields)){let i;Ti.isInstance(r)?(i=pa(r.inputSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):Oo.isInstance(r)?i=r.schema?pa(r.schema):void 0:Ei(r)&&(i=pa(r)),i&&(e[t]=i)}return{type:"object",properties:e}}getChannelKeys(){return Object.entries(this.fields).map(([e])=>e)}getAllKeys(){return Object.keys(this.fields)}async validateInput(e){if(e==null||typeof e!="object")return e;let t={};for(let[r,i]of Object.entries(e)){let n=this.fields[r];if(n===void 0){t[r]=i;continue}let a;if(Ti.isInstance(n)?a=n.inputSchema:Oo.isInstance(n)?a=n.schema:Ei(n)&&(a=n),a){let o=await a["~standard"].validate(i);if(o.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(o.issues)}`);t[r]=o.value}else t[r]=i}return t}static isInstance(e){return typeof e=="object"&&e!==null&&gS in e&&e[gS]===!0}};var G9="__remove_all__";function ga(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t],n=r.map(It),a=i.map(It);for(let l of n)(l.id===null||l.id===void 0)&&(l.id=Dl(),l.lc_kwargs.id=l.id);let o;for(let l=0;l<a.length;l+=1){let d=a[l];(d.id===null||d.id===void 0)&&(d.id=Dl(),d.lc_kwargs.id=d.id),an.isInstance(d)&&d.id==="__remove_all__"&&(o=l)}if(o!=null)return a.slice(o+1);let s=[...n],c=new Map(s.map((l,d)=>[l.id,d])),u=new Set;for(let l of a){let d=c.get(l.id);if(d!==void 0)an.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(an.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,s.length),s.push(l)}}return s.filter(l=>!u.has(l.id))}var J9=new Ti(Kr.custom().default(()=>[]),{inputSchema:Kr.custom(),reducer:ga,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var K9=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let r=this.get(e);this._map.set(e,t(r))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},r=no(e);for(let[i,n]of Object.entries(r)){let a=this.get(n);a?.reducer?t[i]=new xi(a.reducer.fn,a.default):t[i]=new yn(a?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,a])=>a===!0).sort(([a],[o])=>a.localeCompare(o)).map(([a,o])=>`${a}:${o}`).join("|"),i=this._extensionCache.get(r)??new Map;if(i.has(e))return i.get(e);let n=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let a=Object.entries(no(e)).map(([o,s])=>{let c=this.get(s),u=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=pi(u)??pi(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[o,u]});n=op(e,Object.fromEntries(a)),at(n)&&(n._def.unknownKeys="strip")}return t.asPartial&&(n=Ns(n)),i.set(e,n),this._extensionCache.set(r,i),n}},Sl=new K9;function sM(e,t){if(t.reducer&&!t.default){let r=sp(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Sl.extend(r,()=>t),r}else return Sl.extend(e,()=>t),e}function Po(e){return e==null?!1:!!(Qn.isInstance(e)||Yt(e)||typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.values(e).every(t=>typeof t=="function"||E0(t)))}function cM(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&Po(t.state),i="stateSchema"in t&&Po(t.stateSchema),n="input"in t&&Po(t.input);return!(!r&&!i&&!n||"input"in t&&t.input!=null&&!Po(t.input)||"output"in t&&t.output!=null&&!Po(t.output))}var Ai="__root__",fh=Symbol.for("langgraph.state.partial"),_S=class extends uS{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Sl;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),i=r.state??r.stateSchema??r.input;if(!i)throw new kc;let n=this._getChannelsFromSchema(i);this._schemaDefinition=n,Qn.isInstance(i)?this._schemaRuntimeDefinition=i:Yt(i)&&(this._schemaRuntimeDefinition=i),r.input?Qn.isInstance(r.input)?this._inputRuntimeDefinition=r.input:Yt(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=fh:this._inputRuntimeDefinition=fh,r.output?Qn.isInstance(r.output)?this._outputRuntimeDefinition=r.output:Yt(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let a=r.input?this._getChannelsFromSchema(r.input):n,o=r.output?this._getChannelsFromSchema(r.output):n;this._inputDefinition=a,this._outputDefinition=o,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&Yt(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}_normalizeToStateGraphInit(e,t){if(cM(e)){if(Yt(t)||Lm.isInstance(t))return{...e,context:t};let r=t;return{...e,input:e.input??r?.input,output:e.output??r?.output,context:e.context??r?.context,interrupt:e.interrupt??r?.interrupt,writer:e.writer??r?.writer,nodes:e.nodes??r?.nodes}}if(Po(e)){if(Yt(t)||Lm.isInstance(t))return{state:e,context:t};let r=t;return{state:e,input:r?.input,output:r?.output,context:r?.context,interrupt:r?.interrupt,writer:r?.writer,nodes:r?.nodes}}if(q9(e))return{state:W9(e.channels)};throw new kc}_getChannelsFromSchema(e){if(Qn.isInstance(e))return e.getChannels();if(Yt(e))return this._metaRegistry.getChannelsForSchema(e);if(typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot")return e.spec;if(typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e;throw new kc("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([e,t])=>e.map(r=>[r,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,r]of Object.entries(e)){let i;if(typeof r=="function"?i=r():i=r,this.channels[t]!==void 0){if(!this.channels[t].equals(i)&&i.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=i}}}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([i,n])=>[i,n]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){if(i in this.channels)throw new Error(`${i} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let l of["|",":"])if(i.includes(l))throw new Error(`"${l}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__"||i==="__start__")throw new Error(`Node \`${i}\` is reserved.`);let o=this._schemaDefinition;a?.input!==void 0&&(o=this._getChannelsFromSchema(a.input)),this._addSchema(o);let s;ae.isRunnable(n)?s=n:typeof n=="function"?s=new Vt({func:n,name:i,trace:!1}):s=tt(n);let c=a?.cachePolicy;typeof c=="boolean"&&(c=c?{}:void 0);let u={runnable:s,retryPolicy:a?.retryPolicy,cachePolicy:c,metadata:a?.metadata,input:o??this._schemaDefinition,subgraphs:yl(s)?[s]:a?.subgraphs,ends:a?.ends,defer:a?.defer};this.nodes[i]=u}return this}addEdge(e,t){if(typeof e=="string")return super.addEdge(e,t);this.compiled&&console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let r of e){if(r==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(i=>i===r))throw new Error(`Need to add a node named "${r}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(r=>r===t))throw new Error(`Need to add a node named "${t}" first`);return this.waitingEdges.add([e,t]),this}addSequence(e){let t=Array.isArray(e)?e:Object.entries(e);if(t.length===0)throw new Error("Sequence requires at least one node.");let r;for(let[i,n,a]of t){if(i in this.nodes)throw new Error(`Node names must be unique: node with the name "${i}" already exists.`);let o=i;this.addNode(o,n,a),r!=null&&this.addEdge(r,o),r=o}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:a,description:o,transformers:s}={}){this.validate([...Array.isArray(i)?i:[],...Array.isArray(n)?n:[]]);let c=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),u=c.length===1&&c[0]===Ai?Ai:c,l=Object.keys(this.channels),d=l.length===1&&l[0]===Ai?Ai:l,f=this._interrupt,p=new lM({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:i,autoValidate:!1,nodes:{},channels:{...this.channels,[Ze]:new xn},inputChannels:Ze,outputChannels:u,streamChannels:d,streamMode:"updates",store:t,cache:r,name:a,description:o,userInterrupt:f,streamTransformers:s});p.attachNode(Ze);for(let[m,g]of Object.entries(this.nodes))p.attachNode(m,g);p.attachBranch(Ze,mh,uM(),{withReader:!1});for(let[m]of Object.entries(this.nodes))p.attachBranch(m,mh,uM(),{withReader:!1});for(let[m,g]of this.edges)p.attachEdge(m,g);for(let[m,g]of this.waitingEdges)p.attachEdge(m,g);for(let[m,g]of Object.entries(this.branches))for(let[y,b]of Object.entries(g))p.attachBranch(m,y,b);return p.validate()}};function W9(e){let t={};for(let[r,i]of Object.entries(e))r===Ai?t[r]=Fm(i):t[r]=Fm(i);return t}var lM=class extends lS{description;_metaRegistry=Sl;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let r;e==="__start__"?r=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([s])=>s):r=Object.keys(this.builder.channels);function i(s){if(ht(s))return s.graph===nr.PARENT?null:s._updateAsTuples();if(Array.isArray(s)&&s.length>0&&s.some(c=>ht(c))){let c=[];for(let u of s)if(ht(u)){if(u.graph===nr.PARENT)continue;c.push(...u._updateAsTuples())}else c.push([Ai,u]);return c}else if(s!=null)return[[Ai,s]];return null}let n=e;function a(s){if(s){if(ht(s))return s.graph===nr.PARENT?null:s._updateAsTuples().filter(([c])=>r.includes(c));if(Array.isArray(s)&&s.length>0&&s.some(ht)){let c=[];for(let u of s)if(ht(u)){if(u.graph===nr.PARENT)continue;c.push(...u._updateAsTuples().filter(([l])=>r.includes(l)))}else{let l=a(u);l&&c.push(...l??[])}return c}else{if(typeof s=="object"&&!Array.isArray(s))return Object.entries(s).filter(([c])=>r.includes(c));{let c=Array.isArray(s)?"array":typeof s;throw new be(`Expected node "${n.toString()}" to return an object or an array containing at least one Command object, received ${c}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let o=[{value:mr,mapper:new Vt({func:r.length&&r[0]===Ai?i:a,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new bn({tags:[lt],triggers:[Ze],channels:[Ze],writers:[new ot(o,[lt])]});else{let s=t?.input??this.builder._schemaDefinition,c=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(s)).map(d=>[d,d])),u=Object.keys(c).length===1&&Ai in c,l=`branch:to:${e}`;this.channels[l]=t?.defer?new T0:new xn(!1),this.nodes[e]=new bn({triggers:[l],channels:u?Object.keys(c):c,writers:[new ot(o,[lt])],mapper:u?void 0:d=>Object.fromEntries(Object.entries(d).filter(([f])=>f in c)),bound:t?.runnable,metadata:t?.metadata,retryPolicy:t?.retryPolicy,cachePolicy:t?.cachePolicy,subgraphs:t?.subgraphs,ends:t?.ends})}}attachEdge(e,t){if(t!=="__end__"){if(typeof e=="string")this.nodes[e].writers.push(new ot([{channel:`branch:to:${t}`,value:null}],[lt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new mS(new Set(e)):new pS(new Set(e)),this.nodes[t].triggers.push(r);for(let i of e)this.nodes[i].writers.push(new ot([{channel:r,value:i}],[lt]))}}}attachBranch(e,t,r,i={withReader:!0}){let n=async(a,o)=>{let s=a.filter(u=>u!==Ye);if(!s.length)return;let c=s.map(u=>dt(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await ot.doWrite({...o,tags:(o.tags??[]).concat([lt])},c)};this.nodes[e].writers.push(r.run(n,i.withReader?a=>wR.doRead(a,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,r=this.builder._schemaRuntimeDefinition;if(Qn.isInstance(t)){if(ht(e)){let n=e;return e.update&&(n.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await t.validateInput(e)}if(t===fh&&Qn.isInstance(r)){if(ht(e)){let n=e;return e.update&&(n.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await r.validateInput(e)}let i=(()=>{let n=a=>{if(a!=null)return this._metaRegistry.getExtendedChannelSchemas(a,{withReducerSchema:!0})};if(Yt(t))return n(t);if(t===fh)return Yt(r)?Ns(n(r)):void 0})();if(ht(e)){let n=e;return e.update&&i!=null&&(n.update=Os(i,e.update)),n}return i!=null?Os(i,e):e}isInterrupted(e){return Sa(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return Yt(t)&&Os(t,e),e}};function q9(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function X9(e){if(dt(e))return[e];let t=[];ht(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(ht));let r=[];for(let i of t){if(i.graph===nr.PARENT)throw new Pl(i);dt(i.goto)||typeof i.goto=="string"?r.push(i.goto):Array.isArray(i.goto)&&r.push(...i.goto)}return r}function uM(){return new cS({path:new Vt({func:X9,tags:[lt],trace:!1,recurse:!1,name:"<control_branch>"})})}var Y9=class extends _S{constructor(){super({channels:{__root__:{reducer:ga,default:()=>[]}}})}};function Q9(e,t){let{stateKey:r,...i}=t??{},n=lc(i),a=r??"messages";r===null&&(a=void 0);let o=It(e);if(!o.id)throw new Error("Message ID is required.");let s=(Array.isArray(n.callbacks)?n.callbacks:typeof n.callbacks<"u"?n.callbacks.handlers:[]).find(c=>"name"in c&&c.name==="StreamMessagesHandler");if(s){let c=n.metadata??{},u=(c.langgraph_checkpoint_ns??"").split("|");s._emit([u,c],o,void 0,!1)}return a&&n.configurable?.__pregel_send?.([[a,o]]),o}function eV(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0}:e,{name:i,retry:n}=r;if(G0(t)||J0(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let a=r.cachePolicy??("cache"in r?r.cache:void 0),o;return typeof a=="boolean"?o=a?{}:void 0:o=a,(...s)=>OR({func:t,name:i,retry:n,cache:o},...s)}var dM=function(t,r){let{name:i,checkpointer:n,store:a,cache:o}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t;if(G0(r)||J0(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let s="updates",c=CR(i,r);function u(p){return typeof p=="object"&&p!==null&&"__lg_type"in p&&p.__lg_type==="__pregel_final"}let l=new Vt({name:"pluckReturnValue",func:p=>u(p)?p.value:p}),d=new Vt({name:"pluckSaveValue",func:p=>u(p)?p.save:p}),f=new bn({bound:c,triggers:[Ze],channels:[Ze],writers:[new ot([{channel:Ye,value:mr,mapper:l},{channel:xa,value:mr,mapper:d}],[lt])]});return new lh({name:i,checkpointer:n,nodes:{[i]:f},channels:{[Ze]:new xn,[Ye]:new yn,[xa]:new yn},inputChannels:Ze,outputChannels:Ye,streamChannels:Ye,streamMode:s,store:a,cache:o})};dM.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function tV(){return Te.getRunnableConfig().configurable?.[wa]}var rV=ml.Root({messages:ml({reducer:ga,default:()=>[]})}),fM={reducer:{fn:ga},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},nV=St.object({messages:sM(St.custom(),fM)});function iV(e){let t=Te.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");return r.writer?.(e)}export{Ze as a,Ye as b,Ue as c,ph as d,SS as e,ba as f,hM as g,Sa as h,nr as i,ht as j,en as k,hh as l,gh as m,ka as n,ti as o,Ol as p,Pl as q,_h as r,$a as s,ri as t,Nl as u,Ne as v,be as w,gM as x,yh as y,_M as z,kc as A,yM as B,HS as C,Ht as D,KM as E,An as F,tk as G,Tc as H,rk as I,_t as J,Ho as K,Ee as L,Ko as M,Qe as N,nn as O,Ta as P,Ca as Q,Oa as R,oi as S,Jk as T,jt as U,Vi as V,Ha as W,Wi as X,Ef as Y,to as Z,Be as _,at as $,ur as aa,pi as ba,sp as ca,D as da,St as ea,yt as fa,Dt as ga,Ep as ha,G6 as ia,Au as ja,Mp as ka,Ew as la,UO as ma,LO as na,X6 as oa,Y6 as pa,Aw as qa,sa as ra,ca as sa,Hw as ta,Xs as ua,Ju as va,Kr as wa,iB as xa,fB as ya,sc as za,gn as Aa,jm as Ba,XN as Ca,uc as Da,Dm as Ea,eR as Fa,kt as Ga,xi as Ha,ml as Ia,VB as Ja,ZB as Ka,A0 as La,HB as Ma,Wr as Na,P0 as Oa,N0 as Pa,Hm as Qa,M0 as Ra,hl as Sa,gl as Ta,j0 as Ua,z0 as Va,Gm as Wa,L0 as Xa,dR as Ya,F0 as Za,H0 as _a,uS as $a,Ei as ab,H9 as bb,pa as cb,ma as db,dh as eb,Ti as fb,Oo as gb,Qn as hb,G9 as ib,ga as jb,J9 as kb,Sl as lb,sM as mb,_S as nb,lM as ob,Y9 as pb,Q9 as qb,eV as rb,dM as sb,tV as tb,rV as ub,fM as vb,nV as wb,iV as xb};
|