@arcgis/ai-components 5.1.0-next.73 → 5.1.0-next.74

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.
@@ -0,0 +1,305 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{a as ie,b as On,c as ji}from"./CFDTXKJ6.js";var MS=ie((_5,jS)=>{"use strict";jS.exports=function(e,t){if(typeof e!="string")throw new TypeError("Expected a string");return t=typeof t>"u"?"_":t,e.replace(/([a-z\d])([A-Z])/g,"$1"+t+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+t+"$2").toLowerCase()}});var VS=ie((y5,Rh)=>{"use strict";var qM=/[\p{Lu}]/u,JM=/[\p{Ll}]/u,zS=/^[\p{Lu}](?![\p{Lu}])/gu,US=/([\p{Alpha}\p{N}_]|$)/u,FS=/[_.\- ]+/,KM=new RegExp("^"+FS.source),DS=new RegExp(FS.source+US.source,"gu"),LS=new RegExp("\\d+"+US.source,"gu"),WM=(e,t,r)=>{let i=!1,n=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];i&&qM.test(s)?(e=e.slice(0,o)+"-"+e.slice(o),i=!1,a=n,n=!0,o++):n&&a&&JM.test(s)?(e=e.slice(0,o-1)+"-"+e.slice(o-1),a=n,n=!1,i=!0):(i=t(s)===s&&r(s)!==s,a=n,n=r(s)===s&&t(s)!==s)}return e},XM=(e,t)=>(zS.lastIndex=0,e.replace(zS,r=>t(r))),YM=(e,t)=>(DS.lastIndex=0,LS.lastIndex=0,e.replace(DS,(r,i)=>t(i)).replace(LS,r=>t(r))),BS=(e,t)=>{if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(a=>a.trim()).filter(a=>a.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),i=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return e.length===1?t.pascalCase?i(e):r(e):(e!==r(e)&&(e=WM(e,r,i)),e=e.replace(KM,""),t.preserveConsecutiveUppercase?e=XM(e,r):e=r(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),YM(e,i))};Rh.exports=BS;Rh.exports.default=BS});var vE=ie((Yq,$g)=>{"use strict";var Pz=Object.prototype.hasOwnProperty,Jt="~";function zc(){}Object.create&&(zc.prototype=Object.create(null),new zc().__proto__||(Jt=!1));function Rz(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function yE(e,t,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new Rz(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 yd(e,t){--e._eventsCount===0?e._events=new zc:delete e._events[t]}function Pt(){this._events=new zc,this._eventsCount=0}Pt.prototype.eventNames=function(){var t=[],r,i;if(this._eventsCount===0)return t;for(i in r=this._events)Pz.call(r,i)&&t.push(Jt?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Pt.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};Pt.prototype.listenerCount=function(t){var r=Jt?Jt+t:t,i=this._events[r];return i?i.fn?1:i.length:0};Pt.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 p=c.length,f;for(d=0;d<p;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(f=1,l=new Array(u-1);f<u;f++)l[f-1]=arguments[f];c[d].fn.apply(c[d].context,l)}}return!0};Pt.prototype.on=function(t,r,i){return yE(this,t,r,i,!1)};Pt.prototype.once=function(t,r,i){return yE(this,t,r,i,!0)};Pt.prototype.removeListener=function(t,r,i,n){var a=Jt?Jt+t:t;if(!this._events[a])return this;if(!r)return yd(this,a),this;var o=this._events[a];if(o.fn)o.fn===r&&(!n||o.once)&&(!i||o.context===i)&&yd(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:yd(this,a)}return this};Pt.prototype.removeAllListeners=function(t){var r;return t?(r=Jt?Jt+t:t,this._events[r]&&yd(this,r)):(this._events=new zc,this._eventsCount=0),this};Pt.prototype.off=Pt.prototype.removeListener;Pt.prototype.addListener=Pt.prototype.on;Pt.prefixed=Jt;Pt.EventEmitter=Pt;typeof $g<"u"&&($g.exports=Pt)});var wE=ie((Qq,bE)=>{"use strict";bE.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 SE=ie((eJ,bd)=>{"use strict";var jz=wE(),vd=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},xE=(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 vd(o);typeof e.cancel=="function"&&e.cancel(),n(s)},t);jz(e.then(i,n),()=>{clearTimeout(a)})});bd.exports=xE;bd.exports.default=xE;bd.exports.TimeoutError=vd});var kE=ie(Eg=>{"use strict";Object.defineProperty(Eg,"__esModule",{value:!0});function Mz(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}Eg.default=Mz});var $E=ie(Tg=>{"use strict";Object.defineProperty(Tg,"__esModule",{value:!0});var zz=kE(),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=zz.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}};Tg.default=Ig});var xd=ie(Cg=>{"use strict";Object.defineProperty(Cg,"__esModule",{value:!0});var Dz=vE(),EE=SE(),Lz=$E(),wd=()=>{},Uz=new EE.TimeoutError,Og=class extends Dz{constructor(t){var r,i,n,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=wd,this._resolveIdle=wd,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Lz.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=wd,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=wd,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():EE.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(Uz)});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}};Cg.default=Og});var Lc=ie((uJ,TE)=>{"use strict";var Bz="2.0.0",Vz=Number.MAX_SAFE_INTEGER||9007199254740991,Zz=16,Gz=250,Hz=["major","premajor","minor","preminor","patch","prepatch","prerelease"];TE.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Zz,MAX_SAFE_BUILD_LENGTH:Gz,MAX_SAFE_INTEGER:Vz,RELEASE_TYPES:Hz,SEMVER_SPEC_VERSION:Bz,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Uc=ie((lJ,OE)=>{"use strict";var qz=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};OE.exports=qz});var rs=ie((Ln,CE)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Pg,MAX_SAFE_BUILD_LENGTH:Jz,MAX_LENGTH:Kz}=Lc(),Wz=Uc();Ln=CE.exports={};var Xz=Ln.re=[],Yz=Ln.safeRe=[],W=Ln.src=[],Qz=Ln.safeSrc=[],X=Ln.t={},eD=0,Rg="[a-zA-Z0-9-]",tD=[["\\s",1],["\\d",Kz],[Rg,Jz]],rD=e=>{for(let[t,r]of tD)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},me=(e,t,r)=>{let i=rD(t),n=eD++;Wz(e,n,t),X[e]=n,W[n]=t,Qz[n]=i,Xz[n]=new RegExp(t,r?"g":void 0),Yz[n]=new RegExp(i,r?"g":void 0)};me("NUMERICIDENTIFIER","0|[1-9]\\d*");me("NUMERICIDENTIFIERLOOSE","\\d+");me("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Rg}*`);me("MAINVERSION",`(${W[X.NUMERICIDENTIFIER]})\\.(${W[X.NUMERICIDENTIFIER]})\\.(${W[X.NUMERICIDENTIFIER]})`);me("MAINVERSIONLOOSE",`(${W[X.NUMERICIDENTIFIERLOOSE]})\\.(${W[X.NUMERICIDENTIFIERLOOSE]})\\.(${W[X.NUMERICIDENTIFIERLOOSE]})`);me("PRERELEASEIDENTIFIER",`(?:${W[X.NONNUMERICIDENTIFIER]}|${W[X.NUMERICIDENTIFIER]})`);me("PRERELEASEIDENTIFIERLOOSE",`(?:${W[X.NONNUMERICIDENTIFIER]}|${W[X.NUMERICIDENTIFIERLOOSE]})`);me("PRERELEASE",`(?:-(${W[X.PRERELEASEIDENTIFIER]}(?:\\.${W[X.PRERELEASEIDENTIFIER]})*))`);me("PRERELEASELOOSE",`(?:-?(${W[X.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${W[X.PRERELEASEIDENTIFIERLOOSE]})*))`);me("BUILDIDENTIFIER",`${Rg}+`);me("BUILD",`(?:\\+(${W[X.BUILDIDENTIFIER]}(?:\\.${W[X.BUILDIDENTIFIER]})*))`);me("FULLPLAIN",`v?${W[X.MAINVERSION]}${W[X.PRERELEASE]}?${W[X.BUILD]}?`);me("FULL",`^${W[X.FULLPLAIN]}$`);me("LOOSEPLAIN",`[v=\\s]*${W[X.MAINVERSIONLOOSE]}${W[X.PRERELEASELOOSE]}?${W[X.BUILD]}?`);me("LOOSE",`^${W[X.LOOSEPLAIN]}$`);me("GTLT","((?:<|>)?=?)");me("XRANGEIDENTIFIERLOOSE",`${W[X.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);me("XRANGEIDENTIFIER",`${W[X.NUMERICIDENTIFIER]}|x|X|\\*`);me("XRANGEPLAIN",`[v=\\s]*(${W[X.XRANGEIDENTIFIER]})(?:\\.(${W[X.XRANGEIDENTIFIER]})(?:\\.(${W[X.XRANGEIDENTIFIER]})(?:${W[X.PRERELEASE]})?${W[X.BUILD]}?)?)?`);me("XRANGEPLAINLOOSE",`[v=\\s]*(${W[X.XRANGEIDENTIFIERLOOSE]})(?:\\.(${W[X.XRANGEIDENTIFIERLOOSE]})(?:\\.(${W[X.XRANGEIDENTIFIERLOOSE]})(?:${W[X.PRERELEASELOOSE]})?${W[X.BUILD]}?)?)?`);me("XRANGE",`^${W[X.GTLT]}\\s*${W[X.XRANGEPLAIN]}$`);me("XRANGELOOSE",`^${W[X.GTLT]}\\s*${W[X.XRANGEPLAINLOOSE]}$`);me("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Pg}})(?:\\.(\\d{1,${Pg}}))?(?:\\.(\\d{1,${Pg}}))?`);me("COERCE",`${W[X.COERCEPLAIN]}(?:$|[^\\d])`);me("COERCEFULL",W[X.COERCEPLAIN]+`(?:${W[X.PRERELEASE]})?(?:${W[X.BUILD]})?(?:$|[^\\d])`);me("COERCERTL",W[X.COERCE],!0);me("COERCERTLFULL",W[X.COERCEFULL],!0);me("LONETILDE","(?:~>?)");me("TILDETRIM",`(\\s*)${W[X.LONETILDE]}\\s+`,!0);Ln.tildeTrimReplace="$1~";me("TILDE",`^${W[X.LONETILDE]}${W[X.XRANGEPLAIN]}$`);me("TILDELOOSE",`^${W[X.LONETILDE]}${W[X.XRANGEPLAINLOOSE]}$`);me("LONECARET","(?:\\^)");me("CARETTRIM",`(\\s*)${W[X.LONECARET]}\\s+`,!0);Ln.caretTrimReplace="$1^";me("CARET",`^${W[X.LONECARET]}${W[X.XRANGEPLAIN]}$`);me("CARETLOOSE",`^${W[X.LONECARET]}${W[X.XRANGEPLAINLOOSE]}$`);me("COMPARATORLOOSE",`^${W[X.GTLT]}\\s*(${W[X.LOOSEPLAIN]})$|^$`);me("COMPARATOR",`^${W[X.GTLT]}\\s*(${W[X.FULLPLAIN]})$|^$`);me("COMPARATORTRIM",`(\\s*)${W[X.GTLT]}\\s*(${W[X.LOOSEPLAIN]}|${W[X.XRANGEPLAIN]})`,!0);Ln.comparatorTrimReplace="$1$2$3";me("HYPHENRANGE",`^\\s*(${W[X.XRANGEPLAIN]})\\s+-\\s+(${W[X.XRANGEPLAIN]})\\s*$`);me("HYPHENRANGELOOSE",`^\\s*(${W[X.XRANGEPLAINLOOSE]})\\s+-\\s+(${W[X.XRANGEPLAINLOOSE]})\\s*$`);me("STAR","(<|>)?=?\\s*\\*");me("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");me("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var kd=ie((dJ,AE)=>{"use strict";var nD=Object.freeze({loose:!0}),iD=Object.freeze({}),aD=e=>e?typeof e!="object"?nD:e:iD;AE.exports=aD});var jg=ie((pJ,RE)=>{"use strict";var NE=/^[0-9]+$/,PE=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;let r=NE.test(e),i=NE.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1},oD=(e,t)=>PE(t,e);RE.exports={compareIdentifiers:PE,rcompareIdentifiers:oD}});var Rt=ie((fJ,ME)=>{"use strict";var $d=Uc(),{MAX_LENGTH:jE,MAX_SAFE_INTEGER:Ed}=Lc(),{safeRe:Id,t:Td}=rs(),sD=kd(),{compareIdentifiers:Mg}=jg(),zg=class e{constructor(t,r){if(r=sD(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>jE)throw new TypeError(`version is longer than ${jE} characters`);$d("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let i=t.trim().match(r.loose?Id[Td.LOOSE]:Id[Td.FULL]);if(!i)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>Ed||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Ed||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Ed||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let a=+n;if(a>=0&&a<Ed)return a}return n}):this.prerelease=[],this.build=i[5]?i[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if($d("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let i=this.prerelease[r],n=t.prerelease[r];if($d("prerelease compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return Mg(i,n)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let i=this.build[r],n=t.build[r];if($d("build compare",r,i,n),i===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(i===void 0)return-1;if(i===n)continue;return Mg(i,n)}while(++r)}inc(t,r,i){if(t.startsWith("pre")){if(!r&&i===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?Id[Td.PRERELEASELOOSE]:Id[Td.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,i);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,i);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,i),this.inc("pre",r,i);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,i),this.inc("pre",r,i);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(i)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let a=this.prerelease.length;for(;--a>=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(r===this.prerelease.join(".")&&i===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let a=[r,n];i===!1&&(a=[r]),Mg(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};ME.exports=zg});var La=ie((mJ,DE)=>{"use strict";var zE=Rt(),cD=(e,t,r=!1)=>{if(e instanceof zE)return e;try{return new zE(e,t)}catch(i){if(!r)return null;throw i}};DE.exports=cD});var UE=ie((hJ,LE)=>{"use strict";var uD=La(),lD=(e,t)=>{let r=uD(e,t);return r?r.version:null};LE.exports=lD});var BE=ie((gJ,FE)=>{"use strict";var dD=La(),pD=(e,t)=>{let r=dD(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};FE.exports=pD});var GE=ie((_J,ZE)=>{"use strict";var VE=Rt(),fD=(e,t,r,i,n)=>{typeof r=="string"&&(n=i,i=r,r=void 0);try{return new VE(e instanceof VE?e.version:e,r).inc(t,i,n).version}catch{return null}};ZE.exports=fD});var JE=ie((yJ,qE)=>{"use strict";var HE=La(),mD=(e,t)=>{let r=HE(e,null,!0),i=HE(t,null,!0),n=r.compare(i);if(n===0)return null;let a=n>0,o=a?r:i,s=a?i:r,c=!!o.prerelease.length;if(!!s.prerelease.length&&!c){if(!s.patch&&!s.minor)return"major";if(s.compareMain(o)===0)return s.minor&&!s.patch?"minor":"patch"}let l=c?"pre":"";return r.major!==i.major?l+"major":r.minor!==i.minor?l+"minor":r.patch!==i.patch?l+"patch":"prerelease"};qE.exports=mD});var WE=ie((vJ,KE)=>{"use strict";var hD=Rt(),gD=(e,t)=>new hD(e,t).major;KE.exports=gD});var YE=ie((bJ,XE)=>{"use strict";var _D=Rt(),yD=(e,t)=>new _D(e,t).minor;XE.exports=yD});var eI=ie((wJ,QE)=>{"use strict";var vD=Rt(),bD=(e,t)=>new vD(e,t).patch;QE.exports=bD});var rI=ie((xJ,tI)=>{"use strict";var wD=La(),xD=(e,t)=>{let r=wD(e,t);return r&&r.prerelease.length?r.prerelease:null};tI.exports=xD});var Lr=ie((SJ,iI)=>{"use strict";var nI=Rt(),SD=(e,t,r)=>new nI(e,r).compare(new nI(t,r));iI.exports=SD});var oI=ie((kJ,aI)=>{"use strict";var kD=Lr(),$D=(e,t,r)=>kD(t,e,r);aI.exports=$D});var cI=ie(($J,sI)=>{"use strict";var ED=Lr(),ID=(e,t)=>ED(e,t,!0);sI.exports=ID});var Od=ie((EJ,lI)=>{"use strict";var uI=Rt(),TD=(e,t,r)=>{let i=new uI(e,r),n=new uI(t,r);return i.compare(n)||i.compareBuild(n)};lI.exports=TD});var pI=ie((IJ,dI)=>{"use strict";var OD=Od(),CD=(e,t)=>e.sort((r,i)=>OD(r,i,t));dI.exports=CD});var mI=ie((TJ,fI)=>{"use strict";var AD=Od(),ND=(e,t)=>e.sort((r,i)=>AD(i,r,t));fI.exports=ND});var Fc=ie((OJ,hI)=>{"use strict";var PD=Lr(),RD=(e,t,r)=>PD(e,t,r)>0;hI.exports=RD});var Cd=ie((CJ,gI)=>{"use strict";var jD=Lr(),MD=(e,t,r)=>jD(e,t,r)<0;gI.exports=MD});var Dg=ie((AJ,_I)=>{"use strict";var zD=Lr(),DD=(e,t,r)=>zD(e,t,r)===0;_I.exports=DD});var Lg=ie((NJ,yI)=>{"use strict";var LD=Lr(),UD=(e,t,r)=>LD(e,t,r)!==0;yI.exports=UD});var Ad=ie((PJ,vI)=>{"use strict";var FD=Lr(),BD=(e,t,r)=>FD(e,t,r)>=0;vI.exports=BD});var Nd=ie((RJ,bI)=>{"use strict";var VD=Lr(),ZD=(e,t,r)=>VD(e,t,r)<=0;bI.exports=ZD});var Ug=ie((jJ,wI)=>{"use strict";var GD=Dg(),HD=Lg(),qD=Fc(),JD=Ad(),KD=Cd(),WD=Nd(),XD=(e,t,r,i)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return GD(e,r,i);case"!=":return HD(e,r,i);case">":return qD(e,r,i);case">=":return JD(e,r,i);case"<":return KD(e,r,i);case"<=":return WD(e,r,i);default:throw new TypeError(`Invalid operator: ${t}`)}};wI.exports=XD});var SI=ie((MJ,xI)=>{"use strict";var YD=Rt(),QD=La(),{safeRe:Pd,t:Rd}=rs(),eL=(e,t)=>{if(e instanceof YD)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Pd[Rd.COERCEFULL]:Pd[Rd.COERCE]);else{let c=t.includePrerelease?Pd[Rd.COERCERTLFULL]:Pd[Rd.COERCERTL],u;for(;(u=c.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||u.index+u[0].length!==r.index+r[0].length)&&(r=u),c.lastIndex=u.index+u[1].length+u[2].length;c.lastIndex=-1}if(r===null)return null;let i=r[2],n=r[3]||"0",a=r[4]||"0",o=t.includePrerelease&&r[5]?`-${r[5]}`:"",s=t.includePrerelease&&r[6]?`+${r[6]}`:"";return QD(`${i}.${n}.${a}${o}${s}`,t)};xI.exports=eL});var $I=ie((zJ,kI)=>{"use strict";var Fg=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(t,r)}return this}};kI.exports=Fg});var Ur=ie((DJ,OI)=>{"use strict";var tL=/\s+/g,Bg=class e{constructor(t,r){if(r=nL(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof Vg)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(tL," "),this.set=this.raw.split("||").map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let i=this.set[0];if(this.set=this.set.filter(n=>!II(n[0])),this.set.length===0)this.set=[i];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&lL(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let i=0;i<r.length;i++)i>0&&(this.formatted+=" "),this.formatted+=r[i].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let i=((this.options.includePrerelease&&cL)|(this.options.loose&&uL))+":"+t,n=EI.get(i);if(n)return n;let a=this.options.loose,o=a?Kt[jt.HYPHENRANGELOOSE]:Kt[jt.HYPHENRANGE];t=t.replace(o,bL(this.options.includePrerelease)),Je("hyphen replace",t),t=t.replace(Kt[jt.COMPARATORTRIM],aL),Je("comparator trim",t),t=t.replace(Kt[jt.TILDETRIM],oL),Je("tilde trim",t),t=t.replace(Kt[jt.CARETTRIM],sL),Je("caret trim",t);let s=t.split(" ").map(d=>dL(d,this.options)).join(" ").split(/\s+/).map(d=>vL(d,this.options));a&&(s=s.filter(d=>(Je("loose invalid filter",d,this.options),!!d.match(Kt[jt.COMPARATORLOOSE])))),Je("range list",s);let c=new Map,u=s.map(d=>new Vg(d,this.options));for(let d of u){if(II(d))return[d];c.set(d.value,d)}c.size>1&&c.has("")&&c.delete("");let l=[...c.values()];return EI.set(i,l),l}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(i=>TI(i,r)&&t.set.some(n=>TI(n,r)&&i.every(a=>n.every(o=>a.intersects(o,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new iL(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(wL(this.set[r],t,this.options))return!0;return!1}};OI.exports=Bg;var rL=$I(),EI=new rL,nL=kd(),Vg=Bc(),Je=Uc(),iL=Rt(),{safeRe:Kt,t:jt,comparatorTrimReplace:aL,tildeTrimReplace:oL,caretTrimReplace:sL}=rs(),{FLAG_INCLUDE_PRERELEASE:cL,FLAG_LOOSE:uL}=Lc(),II=e=>e.value==="<0.0.0-0",lL=e=>e.value==="",TI=(e,t)=>{let r=!0,i=e.slice(),n=i.pop();for(;r&&i.length;)r=i.every(a=>n.intersects(a,t)),n=i.pop();return r},dL=(e,t)=>(e=e.replace(Kt[jt.BUILD],""),Je("comp",e,t),e=mL(e,t),Je("caret",e),e=pL(e,t),Je("tildes",e),e=gL(e,t),Je("xrange",e),e=yL(e,t),Je("stars",e),e),Wt=e=>!e||e.toLowerCase()==="x"||e==="*",pL=(e,t)=>e.trim().split(/\s+/).map(r=>fL(r,t)).join(" "),fL=(e,t)=>{let r=t.loose?Kt[jt.TILDELOOSE]:Kt[jt.TILDE];return e.replace(r,(i,n,a,o,s)=>{Je("tilde",e,i,n,a,o,s);let c;return Wt(n)?c="":Wt(a)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:Wt(o)?c=`>=${n}.${a}.0 <${n}.${+a+1}.0-0`:s?(Je("replaceTilde pr",s),c=`>=${n}.${a}.${o}-${s} <${n}.${+a+1}.0-0`):c=`>=${n}.${a}.${o} <${n}.${+a+1}.0-0`,Je("tilde return",c),c})},mL=(e,t)=>e.trim().split(/\s+/).map(r=>hL(r,t)).join(" "),hL=(e,t)=>{Je("caret",e,t);let r=t.loose?Kt[jt.CARETLOOSE]:Kt[jt.CARET],i=t.includePrerelease?"-0":"";return e.replace(r,(n,a,o,s,c)=>{Je("caret",e,n,a,o,s,c);let u;return Wt(a)?u="":Wt(o)?u=`>=${a}.0.0${i} <${+a+1}.0.0-0`:Wt(s)?a==="0"?u=`>=${a}.${o}.0${i} <${a}.${+o+1}.0-0`:u=`>=${a}.${o}.0${i} <${+a+1}.0.0-0`:c?(Je("replaceCaret pr",c),a==="0"?o==="0"?u=`>=${a}.${o}.${s}-${c} <${a}.${o}.${+s+1}-0`:u=`>=${a}.${o}.${s}-${c} <${a}.${+o+1}.0-0`:u=`>=${a}.${o}.${s}-${c} <${+a+1}.0.0-0`):(Je("no pr"),a==="0"?o==="0"?u=`>=${a}.${o}.${s}${i} <${a}.${o}.${+s+1}-0`:u=`>=${a}.${o}.${s}${i} <${a}.${+o+1}.0-0`:u=`>=${a}.${o}.${s} <${+a+1}.0.0-0`),Je("caret return",u),u})},gL=(e,t)=>(Je("replaceXRanges",e,t),e.split(/\s+/).map(r=>_L(r,t)).join(" ")),_L=(e,t)=>{e=e.trim();let r=t.loose?Kt[jt.XRANGELOOSE]:Kt[jt.XRANGE];return e.replace(r,(i,n,a,o,s,c)=>{Je("xRange",e,i,n,a,o,s,c);let u=Wt(a),l=u||Wt(o),d=l||Wt(s),p=d;return n==="="&&p&&(n=""),c=t.includePrerelease?"-0":"",u?n===">"||n==="<"?i="<0.0.0-0":i="*":n&&p?(l&&(o=0),s=0,n===">"?(n=">=",l?(a=+a+1,o=0,s=0):(o=+o+1,s=0)):n==="<="&&(n="<",l?a=+a+1:o=+o+1),n==="<"&&(c="-0"),i=`${n+a}.${o}.${s}${c}`):l?i=`>=${a}.0.0${c} <${+a+1}.0.0-0`:d&&(i=`>=${a}.${o}.0${c} <${a}.${+o+1}.0-0`),Je("xRange return",i),i})},yL=(e,t)=>(Je("replaceStars",e,t),e.trim().replace(Kt[jt.STAR],"")),vL=(e,t)=>(Je("replaceGTE0",e,t),e.trim().replace(Kt[t.includePrerelease?jt.GTE0PRE:jt.GTE0],"")),bL=e=>(t,r,i,n,a,o,s,c,u,l,d,p)=>(Wt(i)?r="":Wt(n)?r=`>=${i}.0.0${e?"-0":""}`:Wt(a)?r=`>=${i}.${n}.0${e?"-0":""}`:o?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,Wt(u)?c="":Wt(l)?c=`<${+u+1}.0.0-0`:Wt(d)?c=`<${u}.${+l+1}.0-0`:p?c=`<=${u}.${l}.${d}-${p}`:e?c=`<${u}.${l}.${+d+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),wL=(e,t,r)=>{for(let i=0;i<e.length;i++)if(!e[i].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let i=0;i<e.length;i++)if(Je(e[i].semver),e[i].semver!==Vg.ANY&&e[i].semver.prerelease.length>0){let n=e[i].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}});var Bc=ie((LJ,jI)=>{"use strict";var Vc=Symbol("SemVer ANY"),Hg=class e{static get ANY(){return Vc}constructor(t,r){if(r=CI(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),Gg("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===Vc?this.value="":this.value=this.operator+this.semver.version,Gg("comp",this)}parse(t){let r=this.options.loose?AI[NI.COMPARATORLOOSE]:AI[NI.COMPARATOR],i=t.match(r);if(!i)throw new TypeError(`Invalid comparator: ${t}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new PI(i[2],this.options.loose):this.semver=Vc}toString(){return this.value}test(t){if(Gg("Comparator.test",t,this.options.loose),this.semver===Vc||t===Vc)return!0;if(typeof t=="string")try{t=new PI(t,this.options)}catch{return!1}return Zg(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new RI(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new RI(this.value,r).test(t.semver):(r=CI(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||Zg(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||Zg(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};jI.exports=Hg;var CI=kd(),{safeRe:AI,t:NI}=rs(),Zg=Ug(),Gg=Uc(),PI=Rt(),RI=Ur()});var Zc=ie((UJ,MI)=>{"use strict";var xL=Ur(),SL=(e,t,r)=>{try{t=new xL(t,r)}catch{return!1}return t.test(e)};MI.exports=SL});var DI=ie((FJ,zI)=>{"use strict";var kL=Ur(),$L=(e,t)=>new kL(e,t).set.map(r=>r.map(i=>i.value).join(" ").trim().split(" "));zI.exports=$L});var UI=ie((BJ,LI)=>{"use strict";var EL=Rt(),IL=Ur(),TL=(e,t,r)=>{let i=null,n=null,a=null;try{a=new IL(t,r)}catch{return null}return e.forEach(o=>{a.test(o)&&(!i||n.compare(o)===-1)&&(i=o,n=new EL(i,r))}),i};LI.exports=TL});var BI=ie((VJ,FI)=>{"use strict";var OL=Rt(),CL=Ur(),AL=(e,t,r)=>{let i=null,n=null,a=null;try{a=new CL(t,r)}catch{return null}return e.forEach(o=>{a.test(o)&&(!i||n.compare(o)===1)&&(i=o,n=new OL(i,r))}),i};FI.exports=AL});var GI=ie((ZJ,ZI)=>{"use strict";var qg=Rt(),NL=Ur(),VI=Fc(),PL=(e,t)=>{e=new NL(e,t);let r=new qg("0.0.0");if(e.test(r)||(r=new qg("0.0.0-0"),e.test(r)))return r;r=null;for(let i=0;i<e.set.length;++i){let n=e.set[i],a=null;n.forEach(o=>{let s=new qg(o.semver.version);switch(o.operator){case">":s.prerelease.length===0?s.patch++:s.prerelease.push(0),s.raw=s.format();case"":case">=":(!a||VI(s,a))&&(a=s);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),a&&(!r||VI(r,a))&&(r=a)}return r&&e.test(r)?r:null};ZI.exports=PL});var qI=ie((GJ,HI)=>{"use strict";var RL=Ur(),jL=(e,t)=>{try{return new RL(e,t).range||"*"}catch{return null}};HI.exports=jL});var jd=ie((HJ,XI)=>{"use strict";var ML=Rt(),WI=Bc(),{ANY:zL}=WI,DL=Ur(),LL=Zc(),JI=Fc(),KI=Cd(),UL=Nd(),FL=Ad(),BL=(e,t,r,i)=>{e=new ML(e,i),t=new DL(t,i);let n,a,o,s,c;switch(r){case">":n=JI,a=UL,o=KI,s=">",c=">=";break;case"<":n=KI,a=FL,o=JI,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(LL(e,t,i))return!1;for(let u=0;u<t.set.length;++u){let l=t.set[u],d=null,p=null;if(l.forEach(f=>{f.semver===zL&&(f=new WI(">=0.0.0")),d=d||f,p=p||f,n(f.semver,d.semver,i)?d=f:o(f.semver,p.semver,i)&&(p=f)}),d.operator===s||d.operator===c||(!p.operator||p.operator===s)&&a(e,p.semver))return!1;if(p.operator===c&&o(e,p.semver))return!1}return!0};XI.exports=BL});var QI=ie((qJ,YI)=>{"use strict";var VL=jd(),ZL=(e,t,r)=>VL(e,t,">",r);YI.exports=ZL});var tT=ie((JJ,eT)=>{"use strict";var GL=jd(),HL=(e,t,r)=>GL(e,t,"<",r);eT.exports=HL});var iT=ie((KJ,nT)=>{"use strict";var rT=Ur(),qL=(e,t,r)=>(e=new rT(e,r),t=new rT(t,r),e.intersects(t,r));nT.exports=qL});var oT=ie((WJ,aT)=>{"use strict";var JL=Zc(),KL=Lr();aT.exports=(e,t,r)=>{let i=[],n=null,a=null,o=e.sort((l,d)=>KL(l,d,r));for(let l of o)JL(l,t,r)?(a=l,n||(n=l)):(a&&i.push([n,a]),a=null,n=null);n&&i.push([n,null]);let s=[];for(let[l,d]of i)l===d?s.push(l):!d&&l===o[0]?s.push("*"):d?l===o[0]?s.push(`<=${d}`):s.push(`${l} - ${d}`):s.push(`>=${l}`);let c=s.join(" || "),u=typeof t.raw=="string"?t.raw:String(t);return c.length<u.length?c:t}});var pT=ie((XJ,dT)=>{"use strict";var sT=Ur(),Kg=Bc(),{ANY:Jg}=Kg,Gc=Zc(),Wg=Lr(),WL=(e,t,r={})=>{if(e===t)return!0;e=new sT(e,r),t=new sT(t,r);let i=!1;e:for(let n of e.set){for(let a of t.set){let o=YL(n,a,r);if(i=i||o!==null,o)continue e}if(i)return!1}return!0},XL=[new Kg(">=0.0.0-0")],cT=[new Kg(">=0.0.0")],YL=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===Jg){if(t.length===1&&t[0].semver===Jg)return!0;r.includePrerelease?e=XL:e=cT}if(t.length===1&&t[0].semver===Jg){if(r.includePrerelease)return!0;t=cT}let i=new Set,n,a;for(let f of e)f.operator===">"||f.operator===">="?n=uT(n,f,r):f.operator==="<"||f.operator==="<="?a=lT(a,f,r):i.add(f.semver);if(i.size>1)return null;let o;if(n&&a){if(o=Wg(n.semver,a.semver,r),o>0)return null;if(o===0&&(n.operator!==">="||a.operator!=="<="))return null}for(let f of i){if(n&&!Gc(f,String(n),r)||a&&!Gc(f,String(a),r))return null;for(let m of t)if(!Gc(f,String(m),r))return!1;return!0}let s,c,u,l,d=a&&!r.includePrerelease&&a.semver.prerelease.length?a.semver:!1,p=n&&!r.includePrerelease&&n.semver.prerelease.length?n.semver:!1;d&&d.prerelease.length===1&&a.operator==="<"&&d.prerelease[0]===0&&(d=!1);for(let f of t){if(l=l||f.operator===">"||f.operator===">=",u=u||f.operator==="<"||f.operator==="<=",n){if(p&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===p.major&&f.semver.minor===p.minor&&f.semver.patch===p.patch&&(p=!1),f.operator===">"||f.operator===">="){if(s=uT(n,f,r),s===f&&s!==n)return!1}else if(n.operator===">="&&!Gc(n.semver,String(f),r))return!1}if(a){if(d&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===d.major&&f.semver.minor===d.minor&&f.semver.patch===d.patch&&(d=!1),f.operator==="<"||f.operator==="<="){if(c=lT(a,f,r),c===f&&c!==a)return!1}else if(a.operator==="<="&&!Gc(a.semver,String(f),r))return!1}if(!f.operator&&(a||n)&&o!==0)return!1}return!(n&&u&&!a&&o!==0||a&&l&&!n&&o!==0||p||d)},uT=(e,t,r)=>{if(!e)return t;let i=Wg(e.semver,t.semver,r);return i>0?e:i<0||t.operator===">"&&e.operator===">="?t:e},lT=(e,t,r)=>{if(!e)return t;let i=Wg(e.semver,t.semver,r);return i<0?e:i>0||t.operator==="<"&&e.operator==="<="?t:e};dT.exports=WL});var gT=ie((YJ,hT)=>{"use strict";var Xg=rs(),fT=Lc(),QL=Rt(),mT=jg(),eU=La(),tU=UE(),rU=BE(),nU=GE(),iU=JE(),aU=WE(),oU=YE(),sU=eI(),cU=rI(),uU=Lr(),lU=oI(),dU=cI(),pU=Od(),fU=pI(),mU=mI(),hU=Fc(),gU=Cd(),_U=Dg(),yU=Lg(),vU=Ad(),bU=Nd(),wU=Ug(),xU=SI(),SU=Bc(),kU=Ur(),$U=Zc(),EU=DI(),IU=UI(),TU=BI(),OU=GI(),CU=qI(),AU=jd(),NU=QI(),PU=tT(),RU=iT(),jU=oT(),MU=pT();hT.exports={parse:eU,valid:tU,clean:rU,inc:nU,diff:iU,major:aU,minor:oU,patch:sU,prerelease:cU,compare:uU,rcompare:lU,compareLoose:dU,compareBuild:pU,sort:fU,rsort:mU,gt:hU,lt:gU,eq:_U,neq:yU,gte:vU,lte:bU,cmp:wU,coerce:xU,Comparator:SU,Range:kU,satisfies:$U,toComparators:EU,maxSatisfying:IU,minSatisfying:TU,minVersion:OU,validRange:CU,outside:AU,gtr:NU,ltr:PU,intersects:RU,simplifyRange:jU,subset:MU,SemVer:QL,re:Xg.re,src:Xg.src,tokens:Xg.t,SEMVER_SPEC_VERSION:fT.SEMVER_SPEC_VERSION,RELEASE_TYPES:fT.RELEASE_TYPES,compareIdentifiers:mT.compareIdentifiers,rcompareIdentifiers:mT.rcompareIdentifiers}});var DT=ie((VK,zT)=>{"use strict";var jT=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,MT=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`;function o2(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,i]of Object.entries(t)){for(let[n,a]of Object.entries(i))t[n]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},i[n]=t[n],e.set(a[0],a[1]);Object.defineProperty(t,r,{value:i,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi256=jT(),t.color.ansi16m=MT(),t.bgColor.ansi256=jT(10),t.bgColor.ansi16m=MT(10),Object.defineProperties(t,{rgbToAnsi256:{value:(r,i,n)=>r===i&&i===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let i=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!i)return[0,0,0];let{colorString:n}=i.groups;n.length===3&&(n=n.split("").map(o=>o+o).join(""));let a=Number.parseInt(n,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1}}),t}Object.defineProperty(zT,"exports",{enumerable:!0,get:o2})});var qN=ie(jf=>{"use strict";jf.byteLength=lV;jf.toByteArray=pV;jf.fromByteArray=hV;var Xn=[],Kr=[],uV=typeof Uint8Array<"u"?Uint8Array:Array,zw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(xo=0,GN=zw.length;xo<GN;++xo)Xn[xo]=zw[xo],Kr[zw.charCodeAt(xo)]=xo;var xo,GN;Kr[45]=62;Kr[95]=63;function HN(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 lV(e){var t=HN(e),r=t[0],i=t[1];return(r+i)*3/4-i}function dV(e,t,r){return(t+r)*3/4-r}function pV(e){var t,r=HN(e),i=r[0],n=r[1],a=new uV(dV(e,i,n)),o=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)t=Kr[e.charCodeAt(c)]<<18|Kr[e.charCodeAt(c+1)]<<12|Kr[e.charCodeAt(c+2)]<<6|Kr[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return n===2&&(t=Kr[e.charCodeAt(c)]<<2|Kr[e.charCodeAt(c+1)]>>4,a[o++]=t&255),n===1&&(t=Kr[e.charCodeAt(c)]<<10|Kr[e.charCodeAt(c+1)]<<4|Kr[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function fV(e){return Xn[e>>18&63]+Xn[e>>12&63]+Xn[e>>6&63]+Xn[e&63]}function mV(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(fV(i));return n.join("")}function hV(e){for(var t,r=e.length,i=r%3,n=[],a=16383,o=0,s=r-i;o<s;o+=a)n.push(mV(e,o,o+a>s?s:o+a));return i===1?(t=e[r-1],n.push(Xn[t>>2]+Xn[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(Xn[t>>10]+Xn[t>>4&63]+Xn[t<<2&63]+"=")),n.join("")}});var Ge="__start__",Qe="__end__",Cn="__input__";var Mo="__error__",kl="__pregel_ns_writes",Pr="__pregel_send",zo="__pregel_call",en="__pregel_read",tn="__pregel_checkpointer",Do="__pregel_resuming",yc="__pregel_task_id",vc="__pregel_stream",bM="__pregel_resume_value",Lo="__pregel_resume_map",or="__pregel_scratchpad",$a="__pregel_previous",wM="__pregel_durability",$l="checkpoint_id",Rr="checkpoint_ns",wS="__pregel_node_finished",jr="checkpoint_map",xS="__pregel_abort_signals",He="__interrupt__",vr="__resume__",bc="__no_writes__",Mi="__return__",Ea="__previous__",pt="langsmith:hidden";var _h="__self__",An="__pregel_tasks",Mr="__pregel_push",El="__pregel_pull",br="00000000-0000-0000-0000-000000000000",SS=[pt,Cn,He,vr,Mo,bc,Pr,en,tn,wM,vc,Do,yc,zo,bM,or,$a,jr,Rr,$l],gh=Symbol.for("langgraph.command"),kS=class{[gh];constructor(e){this[gh]=e}};function Il(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var ka=class{lg_name="Send";node;args;constructor(e,t){this.node=e,this.args=_c(t)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function ft(e){return e instanceof ka}var jo="__overwrite__",xM=class{lg_name="Overwrite";[jo];constructor(e){this[jo]=e}get value(){return this[jo]}toJSON(){return{[jo]:this[jo]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function Tl(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[jo]]:[!1,void 0]}function $S(e){return Tl(e)[0]}function wc(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[He])}var ar=class extends kS{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)?_c(e.goto):[_c(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:ft(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 _t(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function _c(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]=_c(i,t)});else if(_t(e)&&!(e instanceof ar))r=new ar(e),t.set(e,r);else if(Il(e)&&!(e instanceof ka))r=new ka(e.node,e.args),t.set(e,r);else if(_t(e)||ft(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]=_c(n,t)}return r}return e}var rn=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}},yh=class extends rn{get is_bubble_up(){return!0}},vh=class extends rn{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},Ia=class extends rn{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},oi=class extends yh{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 oi{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},Cl=class extends yh{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function bh(e){return e!==void 0&&e.name===Cl.unminifiable_name}function Ta(e){return e!==void 0&&e.is_bubble_up===!0}function si(e){return e!==void 0&&[oi.unminifiable_name,Ol.unminifiable_name].includes(e.name)}var Al=class extends rn{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Pe=class extends rn{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},xe=class extends rn{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},SM=class extends rn{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},wh=class extends rn{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},kM=class extends rn{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},xc=class extends rn{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"}},$M=()=>(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 ES=/^(?:[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 EM(e){return typeof e=="string"&&ES.test(e)}var Uo=EM;function IM(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 Nl=IM;var Et=[];for(Pl=0;Pl<256;++Pl)Et.push((Pl+256).toString(16).slice(1));var Pl;function zr(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()}var Rl,TM=new Uint8Array(16);function Oa(){if(!Rl&&(Rl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Rl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Rl(TM)}var xh,jl,Sh=0,kh=0;function OM(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=xh),o==null&&(o=jl)),a==null||o==null){var s=e.random||(e.rng||Oa)();a==null&&(a=[s[0],s[1],s[2],s[3],s[4],s[5]],!xh&&!e._v6&&(a[0]|=1,xh=a)),o==null&&(o=(s[6]<<8|s[7])&16383,jl===void 0&&!e._v6&&(jl=o))}var c=e.msecs!==void 0?e.msecs:Date.now(),u=e.nsecs!==void 0?e.nsecs:kh+1,l=c-Sh+(u-kh)/1e4;if(l<0&&e.clockseq===void 0&&(o=o+1&16383),(l<0||c>Sh)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Sh=c,kh=u,jl=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 p=c/4294967296*1e4&268435455;n[i++]=p>>>8&255,n[i++]=p&255,n[i++]=p>>>24&15|16,n[i++]=p>>>16&255,n[i++]=o>>>8|128,n[i++]=o&255;for(var f=0;f<6;++f)n[i+f]=a[f];return t||zr(n)}var IS=OM;function $h(e){var t=typeof e=="string"?Nl(e):e,r=CM(t);return typeof e=="string"?zr(r):r}function CM(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 AM(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var NM="6ba7b810-9dad-11d1-80b4-00c04fd430c8",PM="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Eh(e,t,r){function i(n,a,o,s){var c;if(typeof n=="string"&&(n=AM(n)),typeof a=="string"&&(a=Nl(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 zr(u)}try{i.name=e}catch{}return i.DNS=NM,i.URL=PM,i}var RM=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ih={randomUUID:RM};function jM(e,t,r){if(Ih.randomUUID&&!t&&!e)return Ih.randomUUID();e=e||{};var i=e.random||(e.rng||Oa)();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 zr(i)}var Nn=jM;function MM(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 Th(e,t){return e<<t|e>>>32-t}function zM(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 p=new Uint32Array(80),f=0;f<16;++f)p[f]=s[d][f];for(var m=16;m<80;++m)p[m]=Th(p[m-3]^p[m-8]^p[m-14]^p[m-16],1);for(var _=r[0],v=r[1],k=r[2],w=r[3],x=r[4],$=0;$<80;++$){var T=Math.floor($/20),B=Th(_,5)+MM(T,v,k,w)+x+t[T]+p[$]>>>0;x=w,w=k,k=Th(v,30)>>>0,v=_,_=B}r[0]=r[0]+_>>>0,r[1]=r[1]+v>>>0,r[2]=r[2]+k>>>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 TS=zM;var DM=Eh("v5",80,TS),Sc=DM;function OS(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 CS(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?OS(Object(r),!0).forEach(function(i){LM(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):OS(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function LM(e,t,r){return(t=UM(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function UM(e){var t=FM(e,"string");return typeof t=="symbol"?t:t+""}function FM(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 Ml(e={},t,r=0){var i=IS(CS(CS({},e),{},{_v6:!0}),new Uint8Array(16));if(i=$h(i),t){for(var n=0;n<16;n++)t[r+n]=i[n];return t}return zr(i)}var AS=null,NS=null,nn=0;function BM(e,t,r){e=e||{};var i=t&&r||0,n=t||new Uint8Array(16),a=e.random||(e.rng||Oa)(),o=e.msecs!==void 0?e.msecs:Date.now(),s=e.seq!==void 0?e.seq:null,c=NS,u=AS;return o>nn&&e.msecs===void 0&&(nn=o,s!==null&&(c=null,u=null)),s!==null&&(s>2147483647&&(s=2147483647),c=s>>>19&4095,u=s&524287),(c===null||u===null)&&(c=a[6]&127,c=c<<8|a[7],u=a[8]&63,u=u<<8|a[9],u=u<<5|a[10]>>>3),o+1e4>nn&&s===null?++u>524287&&(u=0,++c>4095&&(c=0,nn++)):nn=o,NS=c,AS=u,n[i++]=nn/1099511627776&255,n[i++]=nn/4294967296&255,n[i++]=nn/16777216&255,n[i++]=nn/65536&255,n[i++]=nn/256&255,n[i++]=nn&255,n[i++]=c>>>4&15|112,n[i++]=c&255,n[i++]=u>>>13&63|128,n[i++]=u>>>5&255,n[i++]=u<<3&255|a[10]&7,n[i++]=a[11],n[i++]=a[12],n[i++]=a[13],n[i++]=a[14],n[i++]=a[15],t||zr(n)}var kc=BM;function $c(e){return Ml({clockseq:e})}function ci(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(i=>parseInt(i,16));return Sc(e,new Uint8Array(r))}var Ec="__pregel_tasks",Oh="__error__",Ca="__scheduled__",Ch="__interrupt__",Ah="__resume__";var PS="[...]",ZM="[Circular]",zl=[],Fo=[];function GM(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function RS(e,t,r,i){typeof i>"u"&&(i=GM()),Ph(e,"",0,[],void 0,0,i);var n;try{Fo.length===0?n=JSON.stringify(e,t,r):n=JSON.stringify(e,HM(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;zl.length!==0;){var a=zl.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return n}function Nh(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),zl.push([i,r,t,n])):Fo.push([t,r,e]):(i[r]=e,zl.push([i,r,t]))}function Ph(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){Nh(ZM,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Nh(PS,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Nh(PS,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Ph(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];Ph(e[u],u,s,i,e,a,o)}}i.pop()}}function HM(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Fo.length>0)for(var i=0;i<Fo.length;i++){var n=Fo[i];if(n[1]===t&&n[0]===r){r=n[2],Fo.splice(i,1);break}}return e.call(this,t,r)}}var ZS=ji(MS(),1),GS=ji(VS(),1);function HS(e,t){return t?.[e]||(0,ZS.default)(e)}function qS(e,t){return t?.[e]||(0,GS.default)(e)}function Dl(e,t,r){let i={};for(let n in e)Object.hasOwn(e,n)&&(i[t(n,r)]=e[n]);return i}var JS="__lc_escaped__";function QM(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function e4(e){return{[JS]:e}}function jh(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function t4(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function r4(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 Ll(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return r4(e);if(t4(e))return e;t.add(e);let r=e;if(QM(r))return t.delete(e),e4(r);let i={};for(let[n,a]of Object.entries(r))i[n]=Ll(a,t);return t.delete(e),i}return Array.isArray(e)?e.map(r=>Ll(r,t)):e}function Ul(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(jh(t))return t[JS];let r={};for(let[i,n]of Object.entries(t))r[i]=Ul(n);return r}return Array.isArray(e)?e.map(t=>Ul(t)):e}var KS=Object.defineProperty,I=(e,t)=>{let r={};for(var i in e)KS(r,i,{get:e[i],enumerable:!0});return t||KS(r,Symbol.toStringTag,{value:"Module"}),r};var XS=I({Serializable:()=>lt,get_lc_unique_name:()=>Bo});function WS(e){return Array.isArray(e)?[...e]:{...e}}function n4(e,t){let r=WS(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]=WS(s[c]),s=s[c]}s[a]!==void 0&&(s[a]={lc:1,type:"secret",id:[n]})}return r}function Bo(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 lt=class YS{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Bo(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 YS||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 p of d.reverse()){if(!(p in c)||c[p]===void 0)return;(!(p in u)||u[p]===void 0)&&(typeof c[p]=="object"&&c[p]!=null?u[p]={}:Array.isArray(c[p])&&(u[p]=[])),c=c[p],u=u[p]}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]=Ll(c,a);let o=Dl(Object.keys(r).length?n4(n,r):n,HS,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var QS=I({getEnv:()=>ik,getEnvironmentVariable:()=>Zt,getRuntimeEnvironment:()=>zh,isBrowser:()=>ek,isDeno:()=>Fl,isJsDom:()=>rk,isNode:()=>nk,isWebWorker:()=>tk}),ek=()=>typeof window<"u"&&typeof window.document<"u",tk=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",rk=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),Fl=()=>typeof Deno<"u",nk=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!Fl(),ik=()=>{let e;return ek()?e="browser":nk()?e="node":tk()?e="webworker":rk()?e="jsdom":Fl()?e="deno":e="other",e},Mh;function zh(){return Mh===void 0&&(Mh={library:"langchain-js",runtime:ik()}),Mh}function Zt(e){try{return typeof process<"u"?process.env?.[e]:Fl()?Deno?.env.get(e):void 0}catch{return}}var ak=[];var ok=I({});var sk=I({});var Q="0123456789abcdef".split(""),i4=[-2147483648,8388608,32768,128],an=[24,16,8,0],Bl=[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],wt=[];function on(e,t){t?(wt[0]=wt[16]=wt[1]=wt[2]=wt[3]=wt[4]=wt[5]=wt[6]=wt[7]=wt[8]=wt[9]=wt[10]=wt[11]=wt[12]=wt[13]=wt[14]=wt[15]=0,this.blocks=wt):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}on.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]<<an[a++&3];else for(a=this.start;n<o&&a<64;++n)i=e.charCodeAt(n),i<128?s[a>>>2]|=i<<an[a++&3]:i<2048?(s[a>>>2]|=(192|i>>>6)<<an[a++&3],s[a>>>2]|=(128|i&63)<<an[a++&3]):i<55296||i>=57344?(s[a>>>2]|=(224|i>>>12)<<an[a++&3],s[a>>>2]|=(128|i>>>6&63)<<an[a++&3],s[a>>>2]|=(128|i&63)<<an[a++&3]):(i=65536+((i&1023)<<10|e.charCodeAt(++n)&1023),s[a>>>2]|=(240|i>>>18)<<an[a++&3],s[a>>>2]|=(128|i>>>12&63)<<an[a++&3],s[a>>>2]|=(128|i>>>6&63)<<an[a++&3],s[a>>>2]|=(128|i&63)<<an[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}};on.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=i4[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()}};on.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,p,f,m,_,v,k,w,x;for(u=16;u<64;++u)f=c[u-15],l=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,f=c[u-2],d=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(x=t&r,u=0;u<64;u+=4)this.first?(this.is224?(v=300032,f=c[0]-1413257819,s=f-150054599<<0,i=f+24177077<<0):(v=704751109,f=c[0]-210244248,s=f-1521486534<<0,i=f+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),v=e&t,p=v^e&r^x,_=n&a^~n&o,f=s+d+_+Bl[u]+c[u],m=l+p,s=i+f<<0,i=f+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),k=i&e,p=k^i&t^v,_=o&s^~o&n,f=a+d+_+Bl[u+1]+c[u+1],m=l+p,o=r+f<<0,r=f+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,p=w^r&e^k,_=a&o^~a&s,f=n+d+_+Bl[u+2]+c[u+2],m=l+p,a=t+f<<0,t=f+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,p=x^t&i^w,_=a&o^~a&s,f=n+d+_+Bl[u+3]+c[u+3],m=l+p,n=e+f<<0,e=f+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+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};on.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=Q[e>>>28&15]+Q[e>>>24&15]+Q[e>>>20&15]+Q[e>>>16&15]+Q[e>>>12&15]+Q[e>>>8&15]+Q[e>>>4&15]+Q[e&15]+Q[t>>>28&15]+Q[t>>>24&15]+Q[t>>>20&15]+Q[t>>>16&15]+Q[t>>>12&15]+Q[t>>>8&15]+Q[t>>>4&15]+Q[t&15]+Q[r>>>28&15]+Q[r>>>24&15]+Q[r>>>20&15]+Q[r>>>16&15]+Q[r>>>12&15]+Q[r>>>8&15]+Q[r>>>4&15]+Q[r&15]+Q[i>>>28&15]+Q[i>>>24&15]+Q[i>>>20&15]+Q[i>>>16&15]+Q[i>>>12&15]+Q[i>>>8&15]+Q[i>>>4&15]+Q[i&15]+Q[n>>>28&15]+Q[n>>>24&15]+Q[n>>>20&15]+Q[n>>>16&15]+Q[n>>>12&15]+Q[n>>>8&15]+Q[n>>>4&15]+Q[n&15]+Q[a>>>28&15]+Q[a>>>24&15]+Q[a>>>20&15]+Q[a>>>16&15]+Q[a>>>12&15]+Q[a>>>8&15]+Q[a>>>4&15]+Q[a&15]+Q[o>>>28&15]+Q[o>>>24&15]+Q[o>>>20&15]+Q[o>>>16&15]+Q[o>>>12&15]+Q[o>>>8&15]+Q[o>>>4&15]+Q[o&15];return this.is224||(c+=Q[s>>>28&15]+Q[s>>>24&15]+Q[s>>>20&15]+Q[s>>>16&15]+Q[s>>>12&15]+Q[s>>>8&15]+Q[s>>>4&15]+Q[s&15]),c};on.prototype.toString=on.prototype.hex;on.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};on.prototype.array=on.prototype.digest;on.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 Vo=(...e)=>new on(!1,!0).update(e.join("")).hex();var ck=I({sha256:()=>Vo});function uk(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 uk(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var lk=uk("langchain");var dk=I({ContextOverflowError:()=>a4,LangChainError:()=>Dh,ModelAbortError:()=>Zl,addLangChainErrorFields:()=>ui,ns:()=>Vl});function ui(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 Vl=lk.sub("error"),Dh=class extends Vl.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Zl=class extends Vl.brand(Dh,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},a4=class pk extends Vl.brand(Dh,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new pk(t.message);return r.cause=t,r}};function Pn(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 Zo(e){return Pn(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Go(e){return Pn(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function fk(e){return Pn(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function Gl(e){return Pn(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function Hl(e){if(Pn(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 mk(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 Ic({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 hk(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 H(e,t){return te(e)&&e.type===t}function te(e){return typeof e=="object"&&e!==null}function yt(e){return Array.isArray(e)}function N(e){return typeof e=="string"}function wr(e){return typeof e=="number"}function ql(e){return e instanceof Uint8Array}function Lh(e){try{return JSON.parse(e)}catch{return}}var xr=e=>e();function o4(e){if(e.type==="char_location"&&N(e.document_title)&&wr(e.start_char_index)&&wr(e.end_char_index)&&N(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"&&N(e.document_title)&&wr(e.start_page_number)&&wr(e.end_page_number)&&N(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"&&N(e.document_title)&&wr(e.start_block_index)&&wr(e.end_block_index)&&N(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"&&N(e.url)&&N(e.title)&&N(e.encrypted_index)&&N(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"&&N(e.source)&&N(e.title)&&wr(e.start_block_index)&&wr(e.end_block_index)&&N(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 _k(e){if(H(e,"document")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&N(e.source.media_type)&&N(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&N(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&N(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&N(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(H(e,"image")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&N(e.source.media_type)&&N(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&N(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&N(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function yk(e){function*t(){for(let r of e){let i=_k(r);i?yield i:yield r}}return Array.from(t())}function gk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"text")&&N(i.text)){let{text:n,citations:a,...o}=i;if(yt(a)&&a.length){let s=a.reduce((c,u)=>{let l=o4(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(H(i,"thinking")&&N(i.thinking)){let{thinking:n,signature:a,...o}=i;yield{...o,type:"reasoning",reasoning:n,signature:a};continue}else if(H(i,"redacted_thinking")){yield{type:"non_standard",value:i};continue}else if(H(i,"tool_use")&&N(i.name)&&N(i.id)){yield{type:"tool_call",id:i.id,name:i.name,args:i.input};continue}else if(H(i,"input_json_delta")){if(s4(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(H(i,"server_tool_use")&&N(i.name)&&N(i.id)){let{name:n,id:a}=i;if(n==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:xr(()=>{if(typeof i.input=="string")return i.input;if(te(i.input)&&N(i.input.query))return i.input.query;if(N(i.partial_json)){let o=Lh(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:xr(()=>{if(typeof i.input=="string")return i.input;if(te(i.input)&&N(i.input.code))return i.input.code;if(N(i.partial_json)){let o=Lh(i.partial_json);if(o?.code)return o.code}return""})}};continue}}else if(H(i,"web_search_tool_result")&&N(i.tool_use_id)&&yt(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)=>H(s,"web_search_result")?[...o,s.url]:o,[])}};continue}else if(H(i,"code_execution_tool_result")&&N(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(H(i,"mcp_tool_use")){yield{id:i.id,type:"server_tool_call",name:"mcp_tool_use",args:i.input};continue}else if(H(i,"mcp_tool_result")&&N(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(H(i,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:i.input};continue}else if(H(i,"search_result")){yield{id:i.id,type:"non_standard",value:i};continue}else if(H(i,"tool_result")){yield{id:i.id,type:"non_standard",value:i};continue}else{let n=_k(i);if(n){yield n;continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var vk={translateContent:gk,translateContentChunk:gk};function s4(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function c4(e){return Zo(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Go(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:Gl(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function bk(e){return e.map(c4)}function wk(e){return!!(H(e,"image_url")&&te(e.image_url)||H(e,"input_audio")&&te(e.input_audio)||H(e,"file")&&te(e.file))}function xk(e){if(H(e,"image_url")&&te(e.image_url)&&N(e.image_url.url)){let t=Ic({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(H(e,"input_audio")&&te(e.input_audio)&&N(e.input_audio.data)&&N(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(H(e,"file")&&te(e.file)&&N(e.file.data)){let t=Ic({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(N(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function u4(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Jl(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 l4(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Jl(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 Jl(e){let t=[];for(let r of e)wk(r)?t.push(xk(r)):t.push(r);return t}function d4(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 Sk(e){function*t(){te(e.additional_kwargs?.reasoning)&&yt(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((i,n)=>te(n)&&N(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(H(i,"text")){let{text:n,annotations:a,phase:o,extras:s,...c}=i,u=te(s)?{...s}:{};N(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(d4)}: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)&&yt(e.additional_kwargs.tool_outputs))for(let i of e.additional_kwargs.tool_outputs){if(H(i,"web_search_call")){let n={};if(te(i.action)&&N(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:N(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:a}}continue}else if(H(i,"file_search_call")){yield{id:i.id,type:"server_tool_call",name:"file_search",args:{queries:yt(i.queries)?i.queries:[]}},(i.status==="completed"||i.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:N(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:yt(i.results)?{results:i.results}:{}});continue}else if(H(i,"computer_call")){yield{type:"non_standard",value:i};continue}else if(H(i,"code_interpreter_call")){if(N(i.code)&&(yield{id:i.id,type:"server_tool_call",name:"code_interpreter",args:{code:i.code}}),yt(i.outputs)){let n=xr(()=>{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(H(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(H(i,"mcp_call")){yield{id:i.id,type:"server_tool_call",name:"mcp_call",args:i.input};continue}else if(H(i,"mcp_list_tools")){yield{id:i.id,type:"server_tool_call",name:"mcp_list_tools",args:i.input};continue}else if(H(i,"mcp_approval_request")){yield{type:"non_standard",value:i};continue}else if(H(i,"tool_search_call")){let n={};te(i.arguments)&&Object.assign(n,i.arguments);let a={};N(i.execution)&&(a.execution=i.execution),N(i.status)&&(a.status=i.status),N(i.call_id)&&(a.call_id=i.call_id),yield{id:N(i.id)?i.id:"",type:"server_tool_call",name:"tool_search",args:n,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(H(i,"tool_search_output")){let n={name:"tool_search"};N(i.execution)&&(n.execution=i.execution),yield{type:"server_tool_call_result",toolCallId:N(i.id)?i.id:"",status:i.status==="completed"?"success":i.status==="failed"?"error":"success",output:{tools:yt(i.tools)?i.tools:[]},extras:n};continue}else if(H(i,"image_generation_call")){N(i.result)&&(yield{type:"image",mimeType:"image/png",data:i.result,id:N(i.id)?i.id:void 0,metadata:{status:N(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 p4(e){function*t(){yield*Sk(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 kk={translateContent:e=>typeof e.content=="string"?u4(e):Sk(e),translateContentChunk:e=>typeof e.content=="string"?l4(e):p4(e)};function Kl(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function $k(e,t="pretty"){return t==="pretty"?f4(e):JSON.stringify(e)}function f4(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 Uh=Symbol.for("langchain.message");function Ek(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Nt(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=>Pn(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=Ek(e);return zi(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>Pn(r))?[...e,{type:"file",source_type:"text",text:t}]:[...Ek(e),{type:"text",text:t}]}function Wl(e,t){return e==="error"||t==="error"?"error":"success"}function m4(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 Ue=class extends lt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[Uh]=!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[bk,Jl,yk].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&&Uh in e&&e[Uh]===!0&&Kl(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=m4(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return $k(this,e)}};function Ok(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var Fh=["index","created","timestamp"];function We(e,t,r){let i=r?.ignoreKeys??Fh;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]=We(n[a],o,r);else if(Array.isArray(n[a]))n[a]=zi(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 h4(e){return typeof e=="number"||typeof e=="string"}function Ik(e){return typeof e!="object"||e===null||!("index"in e)?!1:h4(e.index)}function Tk(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function g4(e,t){let r=Ik(t),i=Tk(t);return!r&&!i?-1:e.findIndex(n=>{let a=Ik(n),o=Tk(n);return r&&a?n.index!==t.index?!1:o&&i?n.id===t.id:!0:!r&&!a&&i&&o?n.id===t.id:!1})}function zi(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=g4(i,n);if(a!==-1)i[a]=We(i[a],n,r);else{if(typeof n=="object"&&n!==null&&"text"in n&&n.text==="")continue;i.push(n)}}return i}}}function Xl(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 zi(e,t,r);if(typeof e=="object"&&typeof t=="object")return We(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 Gt=class Ck extends Ue{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===Ck.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function Yl(e){return typeof e.role=="string"}function Xe(e){return typeof e?._getType=="function"}function li(e){return Gt.isInstance(e)}var Ak=I({ToolMessage:()=>Ht,ToolMessageChunk:()=>Ho,defaultToolCallParser:()=>Oc,isDirectToolOutput:()=>Tc,isToolMessage:()=>Cc,isToolMessageChunk:()=>Bh});function Tc(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var Ht=class extends Ue{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 Gt{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:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:We(this.response_metadata,e.response_metadata),artifact:Xl(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:Wl(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Oc(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 Cc(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function Bh(e){return e._getType()==="tool"}function Di(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function Nk(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 qo=class extends Error{output;constructor(e,t){super(e),this.output=t}};function Aa(e,t=Rn){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 _4(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 p=t[r];if(d){if(p==="n")l+=`
16
+ `;else if(p==="t")l+=" ";else if(p==="r")l+="\r";else if(p==="\\")l+="\\";else if(p==='"')l+='"';else if(p==="b")l+="\b";else if(p==="f")l+="\f";else if(p==="/")l+="/";else if(p==="u"){let f=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(f))f.length===4?l+=String.fromCharCode(Number.parseInt(f,16)):l+=`u${f}`,r+=f.length;else throw new Error(`Invalid unicode escape sequence '\\u${f}' at position ${r}`)}else throw new Error(`Invalid escape sequence '\\${p}' at position ${r}`);d=!1}else if(p==="\\")d=!0;else{if(p==='"')return r+=1,l;l+=p}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 p=Number.parseFloat(d);if(Number.isNaN(p))throw r=l,new Error(`Invalid number '${d}' at position ${l}`);return p}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 Rn(e){try{return typeof e>"u"?null:_4(e)}catch{return null}}function Vh(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 y4(e){if(te(e.document)&&te(e.document.source)){let t=Vh(te(e.document)&&N(e.document.format)?e.document.format:"");if(te(e.document.source)){if(te(e.document.source.s3Location)&&N(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(N(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(yt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,i)=>te(i)&&N(i.text)?r+i.text:r,"")}}}return{type:"non_standard",value:e}}function v4(e){if(H(e,"image")&&te(e.image)){let t=Vh(te(e.image)&&N(e.image.format)?e.image.format:"");if(te(e.image.source)){if(te(e.image.source.s3Location)&&N(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 b4(e){if(H(e,"video")&&te(e.video)){let t=Vh(te(e.video)&&N(e.video.format)?e.video.format:"");if(te(e.video.source)){if(te(e.video.source.s3Location)&&N(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 Pk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"cache_point")){yield{type:"non_standard",value:i};continue}else if(H(i,"citations_content")&&te(i.citationsContent)){yield{type:"text",text:yt(i.citationsContent.content)?i.citationsContent.content.reduce((n,a)=>te(a)&&N(a.text)?n+a.text:n,""):"",annotations:yt(i.citationsContent.citations)?i.citationsContent.citations.reduce((n,a)=>{if(te(a)){let o=yt(a.sourceContent)?a.sourceContent.reduce((c,u)=>te(u)&&N(u.text)?c+u.text:c,""):"",s=xr(()=>{if(te(a.location)){let c=a.location.documentChar||a.location.documentPage||a.location.documentChunk;if(te(c))return{source:wr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:wr(c.start)?c.start:void 0,endIndex:wr(c.end)?c.end:void 0}}return{}});n.push({type:"citation",citedText:o,...s})}return n},[]):[]};continue}else if(H(i,"document")&&te(i.document)){yield y4(i);continue}else if(H(i,"guard_content")){yield{type:"non_standard",value:i};continue}else if(H(i,"image")&&te(i.image)){yield v4(i);continue}else if(H(i,"reasoning_content")&&N(i.reasoningText)){yield{type:"reasoning",reasoning:i.reasoningText};continue}else if(H(i,"text")&&N(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"tool_result")){yield{type:"non_standard",value:i};continue}else{if(H(i,"tool_call"))continue;if(H(i,"video")&&te(i.video)){yield b4(i);continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var Rk={translateContent:Pk,translateContentChunk:Pk};function jk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(N(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&&N(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 Mk={translateContent:jk,translateContentChunk:jk};function zk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"text")&&N(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"thinking")&&N(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(H(i,"inlineData")&&te(i.inlineData)&&N(i.inlineData.mimeType)&&N(i.inlineData.data)){yield{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data};continue}else if(H(i,"functionCall")&&te(i.functionCall)&&N(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(H(i,"functionResponse")){yield{type:"non_standard",value:i};continue}else if(H(i,"fileData")&&te(i.fileData)&&N(i.fileData.mimeType)&&N(i.fileData.fileUri)){yield{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri};continue}else if(H(i,"executableCode")){yield{type:"non_standard",value:i};continue}else if(H(i,"codeExecutionResult")){yield{type:"non_standard",value:i};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Dk={translateContent:zk,translateContentChunk:zk};function Lk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"reasoning")&&N(i.reasoning)){let n=xr(()=>{let a=r.indexOf(i);if(yt(e.additional_kwargs?.signatures)&&a>=0)return e.additional_kwargs.signatures.at(a)});N(n)?yield{type:"reasoning",reasoning:i.reasoning,signature:n}:yield{type:"reasoning",reasoning:i.reasoning};continue}else if(H(i,"thinking")&&N(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(H(i,"text")&&N(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"image_url")){if(N(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(H(i,"media")&&N(i.mimeType)&&N(i.data)){yield{type:"file",mimeType:i.mimeType,data:i.data};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Uk={translateContent:Lk,translateContentChunk:Lk};function Fk(e){let t=[],r=e.additional_kwargs?.reasoning;if(N(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&&N(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 Bk={translateContent:Fk,translateContentChunk:Fk};function Vk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(N(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&&N(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 Zk={translateContent:Vk,translateContentChunk:Vk};function Gk(e){let t=[];if(te(e.additional_kwargs?.reasoning)){let i=e.additional_kwargs.reasoning;if(yt(i.summary)){let n=i.summary.reduce((a,o)=>te(o)&&N(o.text)?`${a}${o.text}`:a,"");n.length>0&&t.push({type:"reasoning",reasoning:n})}}let r=e.additional_kwargs?.reasoning_content;if(N(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&&N(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 Hk={translateContent:Gk,translateContentChunk:Gk};function qk(e){function*t(){let r=xr(()=>{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=xr(()=>H(i,"text")&&N(i.text)?{type:"text",text:i.text}:H(i,"inlineData")&&te(i.inlineData)&&N(i.inlineData.mimeType)&&N(i.inlineData.data)?{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data}:H(i,"functionCall")&&te(i.functionCall)&&N(i.functionCall.name)&&te(i.functionCall.args)?{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args}:H(i,"functionResponse")?{type:"non_standard",value:i}:H(i,"fileData")&&te(i.fileData)&&N(i.fileData.mimeType)&&N(i.fileData.fileUri)?{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri}:H(i,"executableCode")?{type:"non_standard",value:i}:H(i,"codeExecutionResult")?{type:"non_standard",value:i}:{type:"non_standard",value:i}),a=xr(()=>"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:qk,translateContentChunk:qk};globalThis.lc_block_translators_registry??=new Map([["anthropic",vk],["bedrock-converse",Rk],["deepseek",Mk],["google",Jk],["google-genai",Dk],["google-vertexai",Uk],["groq",Bk],["ollama",Zk],["openai",kk],["xai",Hk]]);function Zh(e){return globalThis.lc_block_translators_registry.get(e)}function Ql(e,t){return We(e,t)??{}}function Kk(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 w4(e,t){let r={...Kk(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 x4(e,t){let r={...Kk(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:w4(e?.input_token_details,t?.input_token_details),output_token_details:x4(e?.output_token_details,t?.output_token_details)}}var Ae=class extends Ue{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]=Oc(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){t.tool_calls&&t.contentBlocks.push(...t.tool_calls.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.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=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=Zh(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 Ac(e){return e._getType()==="ai"}var vt=class extends Gt{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=ed(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=Zh(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:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:Ql(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=zi(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=zi(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 sn=class Wk extends Ue{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return Wk}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}}},Na=class extends Gt{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:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:We(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 Xk(e){return e._getType()==="generic"}function Yk(e){return e._getType()==="generic"}var Pa=class extends Ue{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Ra=class extends Gt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:We(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function Qk(e){return e._getType()==="function"}function e$(e){return e._getType()==="function"}var nt=class extends Ue{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},ja=class extends Gt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:We(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function t$(e){return e.getType()==="human"}function r$(e){return e.getType()==="human"}var cn=class extends Ue{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 qt=class td extends Ue{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new td({content:Nt(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(td.isInstance(t))return new td({content:Nt(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"}},di=class extends Gt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Nt(this.content,e.content),additional_kwargs:We(this.additional_kwargs,e.additional_kwargs),response_metadata:We(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function n$(e){return e._getType()==="system"}function i$(e){return e._getType()==="system"}var a$=e=>e();function S4(e){return Di(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 k4(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function Gh(e){let t,r;if(k4(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 nt(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Ae(r);let a=i.map(S4);return new Ae({...n,tool_calls:a})}else{if(t==="system")return new qt(r);if(t==="developer")return new qt({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new Ht({...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 cn({...r,id:r.id});throw ui(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 nt(e);if(Xe(e))return e;if(Array.isArray(e)){let[t,r]=e;return Gh({type:t,content:r})}else if(Yl(e)){let{role:t,...r}=e;return Gh({...r,type:t})}else return Gh(e)}function $4(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($4).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 E4(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=E4(e);switch(t.type){case"human":return new nt(t.data);case"ai":return new Ae(t.data);case"system":return new qt(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new Pa(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 Ht(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new sn(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function o$(e){return e.map(Nc)}function s$(e){return e.map(t=>t.toDict())}function Ma(e){let t=e._getType();if(t==="human")return new ja({...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 vt({...r})}else{if(t==="system")return new di({...e});if(t==="function")return new Ra({...e});if(sn.isInstance(e))return new Na({...e});throw new Error("Unknown message type.")}}function ed(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=Rn(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 c$=I({BaseCache:()=>l$,InMemoryCache:()=>Hh,defaultHashKeyEncoder:()=>u$,deserializeStoredGeneration:()=>I4,serializeGeneration:()=>T4}),u$=(...e)=>Vo(e.join("_"));function I4(e){return e.message!==void 0?{text:e.text,message:Nc(e.message)}:{text:e.text}}function T4(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var l$=class{keyEncoder=u$;makeDefaultKeyEncoder(e){this.keyEncoder=e}},O4=new Map,Hh=class d$ extends l${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 d$(O4)}};var p$=/^(?:[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 C4(e){return typeof e=="string"&&p$.test(e)}var Li=C4;function A4(e){if(!Li(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 qh=A4;var Tt=[];for(let e=0;e<256;++e)Tt.push((e+256).toString(16).slice(1));function Xo(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 Jh,N4=new Uint8Array(16);function Yo(){if(!Jh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Jh=crypto.getRandomValues.bind(crypto)}return Jh(N4)}function P4(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 f$="6ba7b810-9dad-11d1-80b4-00c04fd430c8",m$="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Kh(e,t,r,i,n,a){let o=typeof r=="string"?P4(r):r,s=typeof i=="string"?qh(i):i;if(typeof i=="string"&&(i=qh(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){a=a||0;for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Xo(c)}var R4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Wh={randomUUID:R4};function j4(e,t,r){if(Wh.randomUUID&&!t&&!e)return Wh.randomUUID();e=e||{};let i=e.random??e.rng?.()??Yo();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 Xo(i)}var Xh=j4;function M4(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 Yh(e,t){return e<<t|e>>>32-t}function z4(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/Math.pow(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]=Yh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],p=r[3],f=r[4];for(let m=0;m<80;++m){let _=Math.floor(m/20),v=Yh(u,5)+M4(_,l,d,p)+f+t[_]+c[m]>>>0;f=p,p=d,d=Yh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+p>>>0,r[4]=r[4]+f>>>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 h$=z4;function Qh(e,t,r,i){return Kh(80,h$,e,t,r,i)}Qh.DNS=f$;Qh.URL=m$;var rd=Qh;var eg={};function D4(e,t,r){let i;if(e)i=g$(e.random??e.rng?.()??Yo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Yo();L4(eg,n,a),i=g$(a,eg.msecs,eg.seq,t,r)}return t??Xo(i)}function L4(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 g$(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 Dr=D4;var _$=I({BaseCallbackHandler:()=>un,callbackHandlerPrefersStreaming:()=>Pc,isBaseCallbackHandler:()=>tg}),F4=class{};function Pc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}var un=class extends F4{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,Bo(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Zt("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 lt.prototype.toJSON.call(this)}toJSONNotImplemented(){return lt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends un{name=Dr();constructor(){super(),Object.assign(this,e)}}return new t}},tg=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var y$="gen_ai.operation.name",v$="gen_ai.system",rg="gen_ai.request.model",b$="gen_ai.response.model",ng="gen_ai.usage.input_tokens",ig="gen_ai.usage.output_tokens",ag="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",E$="gen_ai.response.finish_reasons",I$="gen_ai.prompt",T$="gen_ai.completion",O$="gen_ai.request.extra_query",C$="gen_ai.request.extra_body",A$="gen_ai.serialized.name",N$="gen_ai.serialized.signature",P$="gen_ai.serialized.doc",R$="gen_ai.response.id",j$="gen_ai.response.service_tier",M$="gen_ai.response.system_fingerprint",z$="gen_ai.usage.input_token_details",D$="gen_ai.usage.output_token_details",L$="langsmith.trace.session_id",U$="langsmith.trace.session_name",F$="langsmith.span.kind",B$="langsmith.trace.name",V$="langsmith.metadata",og="langsmith.span.tags";var Z$="langsmith.request.streaming",G$="langsmith.request.headers";var V4=(...e)=>fetch(...e),Z4,H$=Symbol.for("ls:fetch_implementation");var q$=()=>globalThis[H$]===void 0?!0:Z4??!1,J$=e=>async(...t)=>{if(e||et("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[H$]??V4)(...t);return(e||et("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Rc=()=>et("PROJECT")??Sr("LANGCHAIN_SESSION")??"default";var K$={};function za(e){K$[e]||(console.warn(e),K$[e]=!0)}var P=e=>BigInt(e),Q$=P("0x9E3779B1"),eE=P("0x85EBCA77"),G4=P("0xC2B2AE3D"),Ui=P("0x9E3779B185EBCA87"),Da=P("0xC2B2AE3D27D4EB4F"),tE=P("0x165667B19E3779F9"),lg=P("0x85EBCA77C2B2AE63"),H4=P("0x27D4EB2F165667C5"),q4=P("0x165667919E3779F9"),J4=P("0x9FB21C651E98DF25");function K4(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 jn=K4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),es=(P(1)<<P(128))-P(1),ye=(P(1)<<P(64))-P(1),od=(P(1)<<P(32))-P(1),pi=64,rE=pi/8,W4=8,nd=4;function Fe(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function qe(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 X4=e=>(e&P(255))<<P(56)|(e&P(65280))<<P(40)|(e&P(16711680))<<P(24)|(e&P(4278190080))<<P(8)|(e&P(0xff00000000))>>P(8)|(e&P(0xff0000000000))>>P(24)|(e&P(0xff000000000000))>>P(40)|(e&P(0xff00000000000000))>>P(56),Y4=e=>(e=(e&P(65535))<<P(16)|(e&P(4294901760))>>P(16),e=(e&P(16711935))<<P(8)|(e&P(4278255360))>>P(8),e),Q4=(e,t)=>(e&od)*(t&od)&ye,ts=e=>{if(!e)throw new Error("Assert failed")};function ez(e,t){return(e<<t|e>>P(32)-t)&od}function nE(e,t,r){for(let i=0;i<rE;i++){let n=qe(t,i*8),a=n^qe(r,i*8);e[i^1]+=n,e[i]+=Q4(a,a>>P(32))}return e}function W$(e,t,r,i){for(let n=0;n<i;n++)nE(e,Fe(t,n*pi),Fe(r,n*8));return e}function tz(e,t){for(let r=0;r<rE;r++){let i=qe(t,r*8),n=e[r];n=cg(n,P(47)),n^=i,n*=Q$,e[r]=n&ye}return e}function id(e,t){return iE(e[0]^qe(t,0),e[1]^qe(t,W4))}function X$(e,t,r){let i=r;return i+=id(e.slice(0),Fe(t,0*nd)),i+=id(e.slice(2),Fe(t,4*nd)),i+=id(e.slice(4),Fe(t,8*nd)),i+=id(e.slice(6),Fe(t,12*nd)),Mn(i&ye)}function rz(e,t,r,i,n){let a=Math.floor((r.byteLength-pi)/8),o=pi*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=W$(e,Fe(t,c*o),r,a),e=n(e,Fe(r,r.byteLength-pi));{let c=Math.floor((t.byteLength-1-o*s)/pi);e=W$(e,Fe(t,s*o),r,c),e=i(e,Fe(t,t.byteLength-pi),Fe(r,r.byteLength-pi-7))}return e}function nz(e,t,r){let i=new BigUint64Array([G4,Ui,Da,tE,lg,eE,H4,Q$]);ts(e.length>128),i=rz(i,e,t,nE,tz),ts(i.length*8==64);{let n=X$(i,Fe(t,11),P(e.byteLength)*Ui&ye);return X$(i,Fe(t,t.byteLength-pi-11),~(P(e.byteLength)*Da)&ye)<<P(64)|n}}function iE(e,t){let r=e*t&es;return r&ye^r>>P(64)}function Y$(e,t,r){return iE((qe(e,0)^qe(t,0)+r)&ye,(qe(e,8)^qe(t,8)-r)&ye)}function ad(e,t,r,i,n){let a=e&ye,o=e>>P(64)&ye;return a+=Y$(t,i,n),a^=qe(r,0)+qe(r,8),a&=ye,o+=Y$(r,Fe(i,16),n),o^=qe(t,0)+qe(t,8),o&=ye,o<<P(64)|a}function Mn(e){return e^=e>>P(37),e*=q4,e&=ye,e^=e>>P(32),e}function sd(e){return e^=e>>P(33),e*=Da,e&=ye,e^=e>>P(29),e*=tE,e&=ye,e^=e>>P(32),e}function iz(e,t,r){let i=e.byteLength;ts(i>0&&i<=3);let n=P(sg(e,i-1))|P(i<<8)|P(sg(e,0)<<16)|P(sg(e,i>>1)<<24),a=(P(Qo(t,0))^P(Qo(t,4)))+r,o=(n^a)&ye,s=(P(Qo(t,8))^P(Qo(t,12)))-r,c=(ez(Y4(n),P(13))^s)&ye;return(sd(c)&ye)<<P(64)|sd(o)}function cg(e,t){return e^e>>t}function az(e,t,r){let i=e.byteLength;ts(i>=4&&i<=8);{let n=Qo(e,0),a=Qo(e,i-4),o=P(n)|P(a)<<P(32),s=(qe(t,16)^qe(t,24))+r&ye,u=(o^s)*(Ui+(P(i)<<P(2)))&es;return u+=(u&ye)<<P(65),u&=es,u^=u>>P(67),cg(cg(u&ye,P(35))*J4&ye,P(28))|Mn(u>>P(64))<<P(64)}}function oz(e,t,r){let i=e.byteLength;ts(i>=9&&i<=16);{let n=(qe(t,32)^qe(t,40))+r&ye,a=(qe(t,48)^qe(t,56))-r&ye,o=qe(e),s=qe(e,i-8),c=(o^s^n)*Ui,u=(c&ye)+(P(i-1)<<P(54));c=c&(es^ye)|u,s^=a,c+=s+(s&od)*(eE-P(1))<<P(64),c&=es,c^=X4(c>>P(64));let l=(c&ye)*Da;return l+=(c>>P(64))*Da<<P(64),l&=es,Mn(l&ye)|Mn(l>>P(64))<<P(64)}}function sz(e,t){let r=e.byteLength;return ts(r<=16),r>8?oz(e,jn,t):r>=4?az(e,jn,t):r>0?iz(e,jn,t):sd(t^qe(jn,64)^qe(jn,72))|sd(t^qe(jn,80)^qe(jn,88))<<P(64)}function ug(e){return~e+P(1)&ye}function cz(e,t,r){let i=P(e.byteLength)*Ui&ye,n=P(e.byteLength-1)/P(32);for(;n>=0;){let s=Number(n);i=ad(i,Fe(e,16*s),Fe(e,e.byteLength-16*(s+1)),Fe(t,32*s),r),n--}let a=i+(i>>P(64))&ye;a=Mn(a);let o=(i&ye)*Ui+(i>>P(64))*lg+(P(e.byteLength)-r&ye)*Da;return o&=ye,o=ug(Mn(o)),a|o<<P(64)}function uz(e,t,r){let i=P(e.byteLength)*Ui&ye;for(let o=32;o<160;o+=32)i=ad(i,Fe(e,o-32),Fe(e,o-16),Fe(t,o-32),r);i=Mn(i&ye)|Mn(i>>P(64))<<P(64);for(let o=160;o<=e.byteLength;o+=32)i=ad(i,Fe(e,o-32),Fe(e,o-16),Fe(t,3+o-160),r);i=ad(i,Fe(e,e.byteLength-16),Fe(e,e.byteLength-32),Fe(t,103),ug(r));let n=i+(i>>P(64))&ye;n=Mn(n);let a=(i&ye)*Ui+(i>>P(64))*lg+(P(e.byteLength)-r&ye)*Da;return a&=ye,a=ug(Mn(a)),n|a<<P(64)}function aE(e,t=P(0)){let r=e.byteLength;return r<=16?sz(e,t):r<=128?cz(e,jn,t):r<=240?uz(e,jn,t):nz(e,jn,t)}function oE(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&ye,n=e>>P(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var sE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function fe(e,t){if(!sE.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function cd(e){let t=typeof e=="string"?Date.parse(e):e;return kc({msecs:t,seq:0})}function lz(e){if(!sE.test(e))return null;let t=e[14];return parseInt(t,16)}function dz(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 pz(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 fz=new TextEncoder;function mz(e){let t=fz.encode(e),r=aE(t);return oE(r)}function jc(e,t){let r=`${e}:${t}`,i=mz(r),n=new Uint8Array(16);if(lz(e)===7){let o=dz(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),pz(n)}var Mc={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function cE(e){}async function uE(e,t){}async function lE(e){return[]}async function dE(e){return{size:0}}function ud(e){return!1}function pE(e){return""}function gz(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var ld=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=Mc.dirname(t);ud(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw ud(n)&&void 0,a}}load(t){if(!ud(t))return 0;let r;try{let a=pE(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())gz(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}},dd=new ld;var pd="0.5.12";var Dn,_z=()=>typeof window<"u"&&typeof window.document<"u",yz=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",vz=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),fE=()=>typeof Deno<"u",bz=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!fE(),fg=()=>Dn||(typeof Bun<"u"?Dn="bun":_z()?Dn="browser":bz()?Dn="node":yz()?Dn="webworker":vz()?Dn="jsdom":fE()?Dn="deno":Dn="other",Dn),dg;function fd(){if(dg===void 0){let e=fg(),t=xz();dg={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:pd,...t}}return dg}function mg(){let e=wz(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","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 wz(){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 Sr(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function et(e){return Sr(`LANGSMITH_${e}`)||Sr(`LANGCHAIN_${e}`)}var pg;function xz(){if(pg!==void 0)return pg;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=Sr(r);i!==void 0&&(t[r]=i)}return pg=t,t}function md(){return Sr("OTEL_ENABLED")==="true"||et("OTEL_ENABLED")==="true"}var _g=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&md()&&(console.warn('You have enabled OTEL export via the `OTEL_ENABLED` or `LANGSMITH_OTEL_ENABLED` environment variable, but have not initialized the required OTEL instances. 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()}},yg=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new _g})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},vg=class{active(){return{}}with(t,r){return r()}},hg=Symbol.for("ls:otel_trace"),gg=Symbol.for("ls:otel_context"),mE=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),Sz=new yg,kz=new vg,bg=class{getTraceInstance(){return globalThis[hg]??Sz}getContextInstance(){return globalThis[gg]??kz}initializeGlobalInstances(t){globalThis[hg]===void 0&&(globalThis[hg]=t.trace),globalThis[gg]===void 0&&(globalThis[gg]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[mE]=t}getDefaultOTLPTracerComponents(){return globalThis[mE]??void 0}},wg=new bg;function hd(){return wg.getTraceInstance()}function hE(){return wg.getContextInstance()}function gE(){return wg.getDefaultOTLPTracerComponents()}var $z={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function Ez(e){return $z[e]||e}var gd=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&&hd().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=Ez(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(L$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(U$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(rg,n),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(ng,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(ig,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(ag,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}`,String(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(og,o.join(", ")):o&&t.setAttribute(og,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(A$,String(s.name)),s.signature&&t.setAttribute(N$,String(s.signature)),s.doc&&t.setAttribute(P$,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(rg,i.model),i.stream!==void 0&&t.setAttribute(Z$,i.stream),i.extra_headers&&t.setAttribute(G$,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(O$,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(C$,JSON.stringify(i.extra_body))),t.setAttribute(I$,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(ng,n[0]),t.setAttribute(ig,n[1]),t.setAttribute(ag,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(E$,a.join(", "))}if(i.service_tier&&t.setAttribute(j$,i.service_tier),i.system_fingerprint&&t.setAttribute(M$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;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 Iz=Object.prototype.toString,Tz=e=>Iz.call(e)==="[object Error]",Oz=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 xg(e){if(!(e&&Tz(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:Oz.has(r)}function Cz(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 _d(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 Sg=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 Az(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 _E(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function Nz({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 Sg)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),_E(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=_E(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!xg(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=Az(r,n),p=Math.min(d,l);return p>0&&await new Promise((f,m)=>{let _=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",_),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",_),f()},p);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",_,{once:!0})}),n.signal?.throwIfAborted(),!0}async function kg(e,t={}){if(t={...t},Cz(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,_d("factor",t.factor,{min:0,allowInfinity:!1}),_d("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),_d("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),_d("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 Nz({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Sd=ji(xd(),1),IE="default"in Sd.default?Sd.default.default:Sd.default;var Fz=[408,425,429,500,502,503,504],Dc=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 IE({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(()=>kg(()=>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")&&!Fz.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 Ag(e){return typeof e?._getType=="function"}function Ng(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}var zU=ji(gT(),1);function zd(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 Yg=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}},Qg=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 e_(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}async function ee(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 Qg(n);if(e.status===409)throw new Yg(n);let a=new Error(n);throw a.status=e.status,a}var _T="ERR_CONFLICTING_ENDPOINTS",Md=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:_T}),this.name="ConflictingEndpointsError"}};function yT(e){return typeof e=="object"&&e!==null&&e.code===_T}function Un(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(zd(e));let[t,r]=e.split(":"),i=r||"latest";if(t.includes("/")){let[n,a]=t.split("/",2);if(!n||!a)throw new Error(zd(e));return[n,a,i]}else{if(!t)throw new Error(zd(e));return["-",t,i]}}var vT="[...]",DU={result:"[Circular]"},Ld=[],ns=[],LU=new TextEncoder;function UU(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Dd(e){return LU.encode(e)}function bT(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 FU(e){return function(t,r){if(e){let i=e.call(this,t,r);if(i!==void 0)return i}return bT(r)}}function sr(e,t,r,i,n){try{let a=JSON.stringify(e,FU(r),i);return Dd(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
26
+ Context: ${t}`:""}`),Dd("[Unserializable]");et("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
27
+ Context: ${t}`:""}`),typeof n>"u"&&(n=UU()),r_(e,"",0,[],void 0,0,n);let o;try{ns.length===0?o=JSON.stringify(e,r,i):o=JSON.stringify(e,BU(r),i)}catch{return Dd("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ld.length!==0;){let s=Ld.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return Dd(o)}}function t_(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),Ld.push([i,r,t,n])):ns.push([t,r,e]):(i[r]=e,Ld.push([i,r,t]))}function r_(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){t_(DU,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){t_(vT,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){t_(vT,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)r_(e[s],s,s,i,e,a,o);else{e=bT(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];r_(e[u],u,s,i,e,a,o)}}i.pop()}}function BU(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)}}function wT(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function Hc(e){return{...e,start_time:wT(e.start_time),end_time:wT(e.end_time)}}function xT(e,t,r){if(r)return e;let i=fd(),n=t??mg(),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 VU=e=>{let t=e?.toString()??et("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},ZU=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function GU(e){let t=[];for await(let r of e)t.push(r);return t}function Ud(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var HU=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 ST(e){return typeof e=="number"?Number(e.toFixed(4)):e}var qU=24*1024*1024,ET=1024*1024*1024,JU=1e4,KU=100,kT="https://api.smith.langchain.com",n_=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??ET}peek(){return this.items[0]}push(t){let r,i=new Promise(a=>{r=a}),n=sr(t.item,`Serializing run with id: ${t.item.id}`).length;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())]}},zn=class e{get _fetch(){return this.fetchImplementation||J$(this.debug)}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,"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:Sr("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,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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,"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:et("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,"debug",{enumerable:!0,configurable:!0,writable:!0,value:Sr("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();if(this.tracingSampleRate=VU(t.tracingSamplingRate),this.apiUrl=Ud(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1)),this.apiKey=Ud(t.apiKey??r.apiKey),this.webUrl=Ud(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=Ud(t.workspaceId??et("WORKSPACE_ID")),this.timeout_ms=t.timeout_ms??9e4,this.caller=new Dc({...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=et("FAILED_TRACES_DIR")||void 0;let i=et("FAILED_TRACES_MAX_MB");if(i){let a=parseInt(i,10);Number.isFinite(a)&&a>0&&(this.failedTracesMaxBytes=a*1024*1024)}let n=t.maxIngestMemoryBytes??ET;this.batchIngestCaller=new Dc({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:n,...t.callerOptions??{},onFailedResponseHook:HU,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new n_(n),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,md()&&(this.langSmithToOTELTranslator=new gd),this.cachedLSEnvVarsForMetadata=mg(),t.cache!==void 0&&t.disablePromptCache&&za("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?(za("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=dd:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=dd)}static getDefaultClientConfig(){let t=et("API_KEY"),r=et("ENDPOINT")??kT,i=et("HIDE_INPUTS")==="true",n=et("HIDE_OUTPUTS")==="true";return{apiUrl:r,apiKey:t,webUrl:void 0,hideInputs:i,hideOutputs:n}}getHostUrl(){return this.webUrl?this.webUrl:ZU(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("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get headers(){let t={"User-Agent":`langsmith-js/${pd}`};return this.apiKey&&(t["x-api-key"]=`${this.apiKey}`),this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),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 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}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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(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??qU}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??KU}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,p=l.apiKey??this.apiKey,m=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl?"default":`${d}|${p}`;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()}_${Nn().slice(0,8)}.json`,u=Mc.join(t,c);if(e._fallbackDirsCreated.has(t)||(await cE(t),e._fallbackDirsCreated.add(t)),a!==void 0&&a>0)try{let d=(await lE(t)).filter(f=>f.startsWith("trace_")&&f.endsWith(".json")),p=0;for(let f of d){let{size:m}=await dE(Mc.join(t,f));p+=m}if(p>=a){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${p} bytes >= ${a} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await uE(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(e_(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=xT(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.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n}),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,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:{Accept:"application/json"},signal:AbortSignal.timeout(JU),...this.fetchOptions});return await ee(i,"get server info"),i})).json();return this.debug&&console.log(`
28
+ === LangSmith Server Configuration ===
29
+ `+JSON.stringify(r,null,2)+`
30
+ `),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=hd(),r=hE();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.headers,"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=xT(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=sr(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 ee(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(sr(s,`Ingesting runs with ids: ${c}`),i)}}async _postBatchIngestRuns(t,r){let i={...this.headers,"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 ee(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 p=await this.prepareRunCreateOrUpdateInputs(d);p.id!==void 0&&p.attachments!==void 0&&(n[p.id]=p.attachments),delete p.attachments,a.push(p)}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((f,m)=>(m.id&&(f[m.id]=m),f),{}),p=[];for(let f of o)f.id!==void 0&&d[f.id]?d[f.id]={...d[f.id],...f}:p.push(f);a=Object.values(d),o=p}if(a.length===0&&o.length===0)return;let u=[],l=[];for(let[d,p]of[["post",a],["patch",o]])for(let f of p){let{inputs:m,outputs:_,events:v,extra:k,error:w,serialized:x,attachments:$,...T}=f,B={inputs:m,outputs:_,events:v,extra:k,error:w,serialized:x},O=sr(T,`Serializing for multipart ingestion of run with id: ${T.id}`);l.push({name:`${d}.${T.id}`,payload:new Blob([O],{type:`application/json; length=${O.length}`})});for(let[y,K]of Object.entries(B)){if(K===void 0)continue;let A=sr(K,`Serializing ${y} for multipart ingestion of run with id: ${T.id}`);l.push({name:`${d}.${T.id}.${y}`,payload:new Blob([A],{type:`application/json; length=${A.length}`})})}if(T.id!==void 0){let y=n[T.id];if(y){delete n[T.id];for(let[K,A]of Object.entries(y)){let F,he;if(Array.isArray(A)?[F,he]=A:(F=A.mimeType,he=A.data),K.includes(".")){console.warn(`Skipping attachment '${K}' for run ${T.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${T.id}.${K}`,payload:new Blob([he],{type:`${F}; length=${he.byteLength}`})})}}}u.push(`trace=${T.trace_id},id=${T.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
31
+ `])),i.push(new Blob([`Content-Disposition: form-data; name="${o.name}"\r
32
+ `,`Content-Type: ${o.payload.type}\r
33
+ \r
34
+ `])),i.push(o.payload),i.push(new Blob([`\r
35
+ `]));return i.push(new Blob([`--${r}--\r
36
+ `])),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
37
+ `),await o(`Content-Disposition: form-data; name="${s.name}"\r
38
+ `),await o(`Content-Type: ${s.payload.type}\r
39
+ \r
40
+ `);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
41
+ `)}await o(`--${r}--\r
42
+ `),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.headers,"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 p=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 ee(p,"Failed to send multipart request",!0),p});try{let c,u=!1;q$()&&!this.multipartStreamingDisabled&&fg()!=="bun"?(u=!0,c=await s(o)):c=await s(a),(!this.multipartStreamingDisabled||u)&&c.status===422&&(i?.apiUrl??this.apiUrl)!==kT&&(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(e_(c))throw c;if(console.warn(`${c.message.trim()}
43
+
44
+ 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){fe(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs));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.headers,"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=sr(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 ee(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){fe(t);let i=Hc(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:et("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 GU(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:p,query:f,filter:m,traceFilter:_,treeFilter:v,limit:k,select:w,order:x}=t,$=[];if(r&&($=Array.isArray(r)?r:[r]),i){let y=Array.isArray(i)?i:[i],K=await Promise.all(y.map(A=>this.readProject({projectName:A}).then(F=>F.id)));$.push(...K)}let T=["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"],B={session:$.length?$:null,run_type:l,reference_example:o,query:f,filter:m,trace_filter:_,tree_filter:v,execution_order:c,parent_run:n,start_time:s?s.toISOString():null,error:d,id:p,limit:k,trace:a,select:w||T,is_root:u,order:x};B.select.includes("child_run_ids")&&za("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let O=0;for await(let y of this._getCursorPaginatedList("/runs/query",B)){let K=y.map(Hc);if(k){if(O>=k)break;if(K.length+O>k){yield*K.slice(0,k-O);break}O+=K.length,yield*K}else yield*K}}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},p=Number(u)||0,f="/runs/group",m=`${this.apiUrl}${f}`;for(;;){let _={...d,offset:p},v=Object.fromEntries(Object.entries(_).filter(([B,O])=>O!==void 0)),k=JSON.stringify(v),x=await(await this.caller.call(async()=>{let B=await this._fetch(m,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:k});return await ee(B,`Failed to fetch ${f}`),B})).json(),{groups:$,total:T}=x;if($.length===0)break;for(let B of $)yield B;if(p+=$.length,p>=T)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),p={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&&(p.filter=o);let f=new Map;for await(let k of this._getCursorPaginatedList("/runs/query",p))for(let w of k){let x=Hc(w),$=x.thread_id;if($){let T=f.get($)??[];T.push(x),f.set($,T)}}let m=[];for(let[k,w]of f.entries()){w.sort((O,y)=>{let K=O,A=y,F=K.start_time??"",he=A.start_time??"";if(F!==he)return F.localeCompare(he);let Ze=K.dotted_order??"",Vt=A.dotted_order??"";return Ze.localeCompare(Vt)});let $=[...w.map(O=>O.start_time).filter(Boolean)].sort(),T=$.length?$[0]:"",B=$.length?$[$.length-1]:"";m.push({thread_id:k,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:T,max_start_time:B,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((k,w)=>{let x=k.max_start_time??"";return(w.max_start_time??"").localeCompare(x)});let _=a>0?m.slice(a):m;return n!==void 0?_.slice(0,n):_}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:p,traceFilter:f,treeFilter:m,isRoot:_,dataSourceType:v}){let k=o||[];a&&(k=[...o||[],...await Promise.all(a.map(O=>this.readProject({projectName:O}).then(y=>y.id)))]);let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:i,run_type:n,session:k,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:p,trace_filter:f,tree_filter:m,is_root:_,data_source_type:v}).filter(([O,y])=>y!==void 0)),$=JSON.stringify(x);return await(await this.caller.call(async()=>{let O=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:$});return await ee(O,"get run stats"),O})).json()}async shareRun(t,{shareId:r}={}){let i={run_id:t,share_token:r||Nn()};fe(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await ee(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){fe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(r,"unshare run",!0),r})}async readRunSharedLink(t){fe(t);let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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 fe(t),(await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/runs${i}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(o,"list shared runs"),o})).json()).map(Hc)}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),fe(t);let n=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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};fe(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await ee(s,"share dataset"),s})).json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(t){fe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(r,"unshare dataset",!0),r})}async readSharedDataset(t){return fe(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(s,"list shared examples"),s}),o=await a.json();if(!a.ok)throw"detail"in o?new Error(`Failed to list shared examples.
45
+ Status: ${a.status}
46
+ Message: ${Array.isArray(o.detail)?o.detail.join(`
47
+ `):"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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await ee(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 p=await this._fetch(s,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ee(p,"update project"),p})).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)fe(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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)fe(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,fe(i),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/sessions/${i}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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(f=>{u.append("input_keys",f)}),n.forEach(f=>{u.append("output_keys",f)}),a&&u.append("description",a),o&&u.append("data_type",o),s&&u.append("name",s),await(await this.caller.call(async()=>{let f=await this._fetch(c,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ee(f,"upload CSV"),f})).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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ee(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)fe(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(`
48
+ `).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;fe(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(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;fe(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await ee(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)fe(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(a,`delete ${i}`,!0),a})}async indexDataset({datasetId:t,datasetName:r,tag:i}){let n=t;if(!n&&!r)throw new Error("Must provide either datasetName or datasetId");if(n&&r)throw new Error("Must provide either datasetName or datasetId, not both");n||(n=(await this.readDataset({datasetName:r})).id),fe(n);let o=JSON.stringify({tag:i});await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${n}/index`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(c,"index dataset"),c})).json()}async similarExamples(t,r,i,{filter:n}={}){let a={limit:i,inputs:t};n!==void 0&&(a.filter=n),fe(r);let o=JSON.stringify(a);return(await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${r}/search`,{headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,method:"POST",body:o});return await ee(u,"fetch similar examples"),u})).json()).examples}async createExample(t,r,i){if($T(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;$T(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]??Nn())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,x=w[0].dataset_id,$=w[0].dataset_name;if(x===void 0&&$===void 0)throw new Error("Must provide either datasetName or datasetId");if(x!==void 0&&$!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");x===void 0&&(x=(await this.readDataset({datasetName:$})).id);let T=await this._uploadExamplesMultipart(x,w);return await Promise.all(T.example_ids.map(O=>this.readExample(O)))}let{inputs:r,outputs:i,metadata:n,splits:a,sourceRunIds:o,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:u,exampleIds:l,datasetId:d,datasetName:p}=t;if(r===void 0)throw new Error("Must provide inputs when using legacy parameters");let f=d,m=p;if(f===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(f!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");f===void 0&&(f=(await this.readDataset({datasetName:m})).id);let _=r.map((w,x)=>({dataset_id:f,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]})),v=await this._uploadExamplesMultipart(f,_);return await Promise.all(v.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=>Ag(o)?Ng(o):o),a=Ag(r)?Ng(r):r;return this.createExample({input:n},{output:a},i)}async readExample(t){fe(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 p;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)p=t;else if(r!==void 0)p=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide a datasetName or datasetId");let f=new URLSearchParams({dataset:p}),m=n?typeof n=="string"?n:n?.toISOString():void 0;m&&f.append("as_of",m);let _=o??!0;if(f.append("inline_s3_urls",_.toString()),i!==void 0)for(let k of i)f.append("id",k);if(a!==void 0)for(let k of a)f.append("splits",k);if(s!==void 0){let k=JSON.stringify(s);f.append("metadata",k)}c!==void 0&&f.append("limit",c.toString()),u!==void 0&&f.append("offset",u.toString()),l!==void 0&&f.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(k=>f.append("select",k));let v=0;for await(let k of this._getPaginated("/examples",f)){for(let w of k){let{attachment_urls:x,...$}=w,T=$;x&&(T.attachments=Object.entries(x).reduce((B,[O,y])=>(B[O.slice(11)]={presigned_url:y.presigned_url,mime_type:y.mime_type||void 0},B),{})),yield T,v++}if(c!==void 0&&v>=c)break}}async deleteExample(t){fe(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(i,`delete ${r}`,!0),i})}async deleteExamples(t,r){if(t.forEach(i=>fe(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.headers,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(n,"delete examples",!0),n})}}async updateExample(t,r){let i;r?i=t:i=t.id,fe(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,fe(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.headers},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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,fe(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,fe(o);let s={split_name:i,examples:n.map(u=>(fe(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ee(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:p,comparativeExperimentId:f,sessionId:m,startTime:_}){if(!t&&!p)throw new Error("One of runId or projectId must be provided");if(t&&p)throw new Error("Only one of runId or projectId can be provided");let v={type:c??"api",metadata:s??{}};u!==void 0&&v?.metadata!==void 0&&!v.metadata.__run&&(v.metadata.__run={run_id:u}),v?.metadata!==void 0&&v.metadata.__run?.run_id!==void 0&&fe(v.metadata.__run.run_id);let k={id:l??kc(),run_id:t,key:r,score:ST(i),value:n,correction:a,comment:o,feedback_source:v,comparative_experiment_id:f,feedbackConfig:d,session_id:m??p,start_time:_},w=JSON.stringify(k),x=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let $=await this._fetch(x,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await ee($,"create feedback",!0),$}),k}async updateFeedback(t,{score:r,value:i,correction:n,comment:a}){let o={};r!=null&&(o.score=ST(r)),i!=null&&(o.value=i),n!=null&&(o.correction=n),a!=null&&(o.comment=a),fe(t);let s=JSON.stringify(o);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await ee(c,"update feedback",!0),c})}async readFeedback(t){fe(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){fe(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(i,`delete ${r}`,!0),i})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:i}={}){let n=new URLSearchParams;if(t)for(let a of t)fe(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ee(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){fe(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await ee(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await ee(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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)=>{fe(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||Nn(),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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ee(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${fe(t,"queueId")}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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/${fe(t,"queueId")}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ee(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${fe(t,"queueId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let i=JSON.stringify(r.map((n,a)=>fe(n,`runIds[${a}]`).toString()));await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${fe(t,"queueId")}/runs`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await ee(n,"add runs to annotation queue",!0),n})}async getRunFromAnnotationQueue(t,r){let i=`/annotation-queues/${fe(t,"queueId")}/run`,a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}/${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(o,"get run from annotation queue"),o})).json();return Hc(a)}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${fe(t,"queueId")}/runs/${fe(r,"queueRunId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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/${fe(t,"queueId")}/size`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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.
49
+
50
+ Current tenant: ${i.tenant_handle}
51
+
52
+ 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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(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]=Un(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,i,n]=Un(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]=Un(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]=Un(t),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await ee(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
53
+
54
+ creating a LangChain Hub handle.
55
+ You can add a handle by creating a public prompt at:
56
+
57
+ https://smith.langchain.com/prompts`);let[n,a,o]=Un(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ee(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]=Un(t),s=i?.parentCommitHash==="latest"||!i?.parentCommitHash?await this._getLatestCommitHash(`${n}/${a}`):i?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let p=await this._fetch(`${this.apiUrl}/commits/${n}/${a}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ee(p,"create commit"),p})).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=sr(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(i.append(s,l),o.inputs){let d=sr(o.inputs,`Serializing inputs for example with id: ${s}`),p=new Blob([d],{type:"application/json"});i.append(`${s}.inputs`,p)}if(o.outputs){let d=sr(o.outputs,`Serializing outputs whle updating example with id: ${s}`),p=new Blob([d],{type:"application/json"});i.append(`${s}.outputs`,p)}if(o.attachments)for(let[d,p]of Object.entries(o.attachments)){let f,m;Array.isArray(p)?[f,m]=p:(f=p.mimeType,m=p.data);let _=new Blob([m],{type:`${f}; length=${m.byteLength}`});i.append(`${s}.attachment.${d}`,_)}if(o.attachments_operations){let d=sr(o.attachments_operations,`Serializing attachments while updating example with id: ${s}`),p=new Blob([d],{type:"application/json"});i.append(`${s}.attachments_operations`,p)}}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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await ee(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??Nn()).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=sr(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=sr(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=sr(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 p,f;Array.isArray(d)?[p,f]=d:(p=d.mimeType,f=d.data);let m=new Blob([f],{type:`${p}; length=${f.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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await ee(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]=Un(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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await ee(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]=Un(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(o,"delete prompt"),o})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[i,n,a]=Un(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.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ee(c,"pull prompt commit"),c})).json();return{owner:i,repo:n,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples}}async pullPromptCommit(t,r){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});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}):await this._getPromptUrl(t)}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(p=>p.inputs),outputs:l.flatMap(p=>p.outputs?[p.outputs]:[]),datasetId:d.id})}catch(p){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),p}}parseTokenOrUrl(t,r,i=2,n="dataset"){try{return fe(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();await new Promise(t=>setTimeout(t,1)),await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await gE()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}};Object.defineProperty(zn,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function $T(e){return"dataset_id"in e||"dataset_name"in e}var IT=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>et(r)==="true");var Fn=Symbol.for("lc:context_variables");var Fd=Symbol.for("langsmith:replica_trace_roots");function i_(e,t){if(Fn in e)return e[Fn][t]}function TT(e,t,r){let i=Fn in e?e[Fn]:{};i[t]=r,e[Fn]=i}var qc=36,WU="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function OT(e){let r=Object.keys(e).sort().map(i=>`${i}:${e[i]??""}`).join("|");return Sc(r,WU)}function XU(e){return e.replace(/[-:.]/g,"")}function AT(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 a_(e,t,r=1){let i=AT(e,r);return{dottedOrder:XU(i)+t,microsecondPrecisionDatestring:i}}var YU=new Set(["projectName","updates","reroot"]);function QU(e){let t={};for(let r of Object.keys(e))YU.has(r)&&(t[r]=e[r]);return t}var Bd=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(p=>Array.isArray(p)?p:QU(p)))}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(",")}},ln=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}),NT(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=AT(this.start_time,this.execution_order)),this.id||(this.id=cd(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=n2(this.replicas),!this.dotted_order){let{dottedOrder:s}=a_(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:Rc(),child_runs:[],api_url:Sr("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:Sr("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new zn),e.sharedClient}createChild(t){let r=this.child_execution_order+1,i=this.replicas?.map(p=>{let{reroot:f,...m}=p;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}}),Fn in this&&(a[Fn]=this[Fn]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(t2(u)){let p={...u},f=e2(p.callbacks)?p.callbacks.copy?.():void 0;f&&(Object.assign(f,{_parentRunId:a.id}),f.handlers?.find(PT)?.updateFromRunTree?.(a),p.callbacks=f),a.extra[c]=p}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(-qc)===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(-qc):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let i=i_(this,Fd)??{};i[t]=r,TT(this,Fd,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 k=OT({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});this._setReplicaTraceRoot(k,l.id)}let d;if(!a){let k=i_(this,Fd)??{},w=OT({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});if(d=k[w],d&&(l.trace_id=d,l.dotted_order)){let x=l.dotted_order.split("."),$=null;for(let T=0;T<x.length;T++)if(x[T].slice(-qc)===d){$=T;break}if($!==null){let T=x.slice($);l.dotted_order=T.join(".")}}}let p=l.id,f=jc(p,r),m;l.trace_id?m=jc(l.trace_id,r):m=f;let _;l.parent_run_id&&(_=jc(l.parent_run_id,r));let v;return l.dotted_order&&(v=l.dotted_order.split(".").map(x=>{let $=x.slice(-qc),T=jc($,r);return x.slice(0,-qc)+T}).join(".")),{...l,id:f,trace_id:m,parent_run_id:_,dotted_order:v,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=fd();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,apiKey:n,apiUrl:a,workspaceId:o,reroot:s}of this.replicas){let c=this._remapForProject({projectName:i??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:n,workspaceId:o});await this.client.createRun(c,{apiKey:n,apiUrl:a,workspaceId:o})}else{let i=this._convertToCreate(this,r,t);await this.client.createRun(i)}if(!t){za("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}of this.replicas){let c=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:i,workspaceId:a}),u={id:c.id,name:c.name,run_type:c.run_type,start_time:c.start_time,outputs:c.outputs,error:c.error,parent_run_id:c.parent_run_id,session_name:c.session_name,reference_example_id:c.reference_example_id,end_time:c.end_time,dotted_order:c.dotted_order,trace_id:c.trace_id,events:c.events,tags:c.tags,extra:c.extra,attachments:this.attachments,...o};t?.excludeInputs||(u.inputs=c.inputs),await this.client.updateRun(c.id,u,{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=IT();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,p]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:p}}),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=Bd.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 Bd(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(ln,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function NT(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function PT(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function CT(e){return Array.isArray(e)&&e.some(t=>PT(t))}function e2(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function t2(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(CT(t?.handlers)||CT(t))}function r2(){let e=Sr("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){i2(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(yT(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 n2(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):r2()}function i2(e){if(Object.keys(e).length>0&&et("ENDPOINT"))throw new Md}var RT=I({BaseTracer:()=>Ot,isBaseTracer:()=>Ua}),a2=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function s_(e,t){if(e)return new ln({...e,start_time:e._serialized_start_time??e.start_time,parent_run:s_(t),child_runs:e.child_runs.map(r=>s_(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:zh()},tracingEnabled:!1})}function o_(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Ua(e){return typeof e._addRunToRunMap=="function"}var Ot=class extends un{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?a2(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
58
+
59
+ ${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=a_(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=s_(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=o_(e,"output"),a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=o_(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=o_(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 c_=ji(DT(),1),UT=I({ConsoleCallbackHandler:()=>Vd});function Xt(e,t){return`${e.open}${t}${e.close}`}function Fr(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function LT(e){return typeof e=="string"?e.trim():e==null?e:Fr(e,e.toString())}function Fi(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:cr}=c_.default,Vd=class extends Ot{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?Xt(c_.default.bold,a):a}).join(" > ");return Xt(cr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Fr(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.cyan,"[chain/end]")} [${t}] [${Fi(e)}] Exiting Chain run with output: ${Fr(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.red,"[chain/error]")} [${t}] [${Fi(e)}] Chain run errored with error: ${Fr(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(`${Xt(cr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Fr(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.cyan,"[llm/end]")} [${t}] [${Fi(e)}] Exiting LLM run with output: ${Fr(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.red,"[llm/error]")} [${t}] [${Fi(e)}] LLM run errored with error: ${Fr(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${LT(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.cyan,"[tool/end]")} [${t}] [${Fi(e)}] Exiting Tool run with output: "${LT(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.red,"[tool/error]")} [${t}] [${Fi(e)}] Tool run errored with error: ${Fr(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Fr(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.cyan,"[retriever/end]")} [${t}] [${Fi(e)}] Exiting Retriever run with output: ${Fr(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${Xt(cr.red,"[retriever/error]")} [${t}] [${Fi(e)}] Retriever run errored with error: ${Fr(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${Xt(cr.blue,"[agent/action]")} [${r}] Agent selected action: ${Fr(t.actions[t.actions.length-1],"[action]")}`)}};var u_,Zd=()=>(u_===void 0&&(u_=new zn(Zt("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),u_);var d_=class{getStore(){}run(t,r){return r()}},l_=Symbol.for("ls:tracing_async_local_storage"),s2=new d_,p_=class{getInstance(){return globalThis[l_]??s2}initializeGlobalInstance(t){globalThis[l_]===void 0&&(globalThis[l_]=t)}},c2=new p_;function FT(e=!1){let t=c2.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
60
+
61
+ Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Gd(e){return typeof e=="function"&&"langsmith:traceable"in e}var BT=I({LangChainTracer:()=>Hd});function u2(e){let t;for(let r of e)for(let i of r)Ae.isInstance(i.message)&&i.message.usage_metadata!==void 0&&(t=Jo(t,i.message.usage_metadata));return t}var Hd=class VT extends Ot{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;constructor(t={}){super(t);let{exampleId:r,projectName:i,client:n,replicas:a}=t;this.projectName=i??Rc(),this.replicas=a,this.exampleId=r,this.client=n??Zd();let o=VT.getTraceableRunTree();o&&this.updateFromRunTree(o)}async persistRun(t){}async onRunCreate(t){t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(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=u2(r.generations);if(i!==void 0){t.extra=t.extra??{};let n=t.extra.metadata??{};n.usage_metadata=i,t.extra.metadata=n}}}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}getRunTreeWithTracingConfig(t){let r=this.runTreeMap.get(t);if(r)return new ln({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return FT(!0)}catch{return}}};var ZT=Symbol.for("ls:tracing_async_local_storage"),Bi=Symbol.for("lc:context_variables"),GT=e=>{globalThis[ZT]=e},Vi=()=>globalThis[ZT];var qd=ji(xd(),1),Fa;function l2(){return new("default"in qd.default?qd.default.default:qd.default)({autoStart:!0,concurrency:1})}function d2(){return typeof Fa>"u"&&(Fa=l2()),Fa}async function tt(e,t){if(t===!0){let r=Vi();r!==void 0?await r.run(void 0,async()=>e()):await e()}else Fa=d2(),Fa.add(async()=>{let r=Vi();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function HT(){let e=Zd();await Promise.allSettled([typeof Fa<"u"?Fa.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var qT=I({awaitAllCallbacks:()=>HT,consumeCallback:()=>tt});var JT=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Zt(t)==="true");function f_(e){let t=Vi();if(t!==void 0)return t.getStore()?.[Bi]?.[e]}var p2=Symbol("lc:configure_hooks"),KT=()=>f_(p2)||[];var WT=I({BaseCallbackManager:()=>XT,BaseRunManager:()=>Kc,CallbackManager:()=>dt,CallbackManagerForChainRun:()=>QT,CallbackManagerForLLMRun:()=>m_,CallbackManagerForRetrieverRun:()=>YT,CallbackManagerForToolRun:()=>eO,ensureHandler:()=>is,parseCallbackConfigArg:()=>Ba});function Ba(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var XT=class{setHandler(e){return this.setHandlers([e])}},Kc=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=>tt(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=>tt(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)))}},YT=class extends Kc{getChild(e){let t=new dt(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=>tt(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=>tt(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)))}},m_=class extends Kc{async handleLLMNewToken(e,t,r,i,n,a){await Promise.all(this.handlers.map(o=>tt(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 handleLLMError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>tt(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=>tt(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)))}},QT=class extends Kc{getChild(e){let t=new dt(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=>tt(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=>tt(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=>tt(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=>tt(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)))}},eO=class extends Kc{getChild(e){let t=new dt(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=>tt(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=>tt(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=>tt(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)))}},dt=class Jc extends XT{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:Dr();return await Promise.all(this.handlers.map(p=>{if(!p.ignoreLLM)return Ua(p)&&p._createRunForLLMStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),tt(async()=>{try{await p.handleLLMStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c)}catch(f){if((p.raiseError?console.error:console.warn)(`Error in handler ${p.constructor.name}, handleLLMStart: ${f}`),p.raiseError)throw f}},p.awaitHandlers)})),new m_(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:Dr();return await Promise.all(this.handlers.map(p=>{if(!p.ignoreLLM)return Ua(p)&&p._createRunForChatModelStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),tt(async()=>{try{if(p.handleChatModelStart)await p.handleChatModelStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c);else if(p.handleLLMStart){let f=Wo(u);await p.handleLLMStart?.(t,[f],d,this._parentRunId,a,this.tags,this.metadata,c)}}catch(f){if((p.raiseError?console.error:console.warn)(`Error in handler ${p.constructor.name}, handleLLMStart: ${f}`),p.raiseError)throw f}},p.awaitHandlers)})),new m_(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,i=Dr(),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),tt(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 QT(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,i=Dr(),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),tt(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 eO(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,i=Dr(),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),tt(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 YT(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=>tt(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 Jc(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 un{name=Dr();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 Jc,c.setHandlers(t?.map(is)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(is):r?.handlers,!1));let u=Zt("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=Hd.getTraceableRunTree(),d=l?.tracingEnabled??JT();if(l?.tracingEnabled===!1&&c){let f=c.handlers.filter(m=>m.name==="langchain_tracer");for(let m of f)c.removeHandler(m)}let p=d||(Zt("LANGCHAIN_TRACING")??!1);if(u||p){if(c||(c=new Jc),u&&!c.handlers.some(f=>f.name===Vd.prototype.name)){let f=new Vd;c.addHandler(f,!0)}if(p&&!c.handlers.some(f=>f.name==="langchain_tracer")&&d){let f=new Hd;c.addHandler(f,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(f=>f.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:f,inheritable:m=!0,handlerClass:_,envVar:v}of KT()){let k=v&&Zt(v)==="true"&&_,w,x=f!==void 0?f_(f):void 0;x&&tg(x)?w=x:k&&(w=new _({})),w!==void 0&&(c||(c=new Jc),c.handlers.some($=>$.name===w.name)||c.addHandler(w,m))}return(i||n)&&c&&(c.addTags(i??[]),c.addTags(n??[],!1)),(a||o)&&c&&(c.addMetadata(a??{}),c.addMetadata(o??{},!1)),c}};function is(e){return"name"in e?e:un.fromMethods(e)}var h_=class{getStore(){}run(e,t){return t()}enterWith(e){}},f2=new h_,tO=Symbol.for("lc:child_config"),m2=class{getInstance(){return Vi()??f2}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[tO]}runWithConfig(e,t,r){let i=dt._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 ln({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[tO]:e}),a!==void 0&&a[Bi]!==void 0&&(c===void 0&&(c={}),c[Bi]=a[Bi]),n.run(c,t)}initializeGlobalInstance(e){Vi()===void 0&&GT(e)}},Oe=new m2;var rO=I({AsyncLocalStorageProviderSingleton:()=>Oe,MockAsyncLocalStorage:()=>h_,_CONTEXT_VARIABLES_KEY:()=>Bi});async function xt(e){return dt._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function St(...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(is(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(is(s),!0);t.callbacks=o}else t.callbacks=new dt(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}var h2=new Set(["string","number","boolean"]);function Se(e){let t=Oe.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)for(let i of Object.keys(r.configurable))h2.has(typeof r.configurable[i])&&!r.metadata?.[i]&&(r.metadata||(r.metadata={}),r.metadata[i]=r.configurable[i]);if(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 Ie(e={},{callbacks:t,maxConcurrency:r,recursionLimit:i,runName:n,configurable:a,runId:o}={}){let s=Se(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 ur(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(Zi(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&n(Zi(t))})]).finally(()=>t.removeEventListener("abort",r))}function Zi(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var nO=I({AsyncGeneratorWithSetup:()=>Gi,IterableReadableStream:()=>mt,atee:()=>Jd,concat:()=>$r,pipeGeneratorWithSetup:()=>__}),mt=class g_ 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 g_({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 g_({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 Jd(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 Gi=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)=>{Oe.runWithConfig(ur(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?Oe.runWithConfig(ur(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,t,r,i,...n){let a=new Gi({generator:t,startSetup:r,signal:i}),o=await a.setup;return{output:e(a,o,...n),setup:o}}var g2=Object.prototype.hasOwnProperty;function Wd(e,t){return g2.call(e,t)}function Xd(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)Wd(e,r)&&t.push(r);return t}function Er(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Yd(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 Va(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function aO(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Kd(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,i=e.length;r<i;r++)if(Kd(e[r]))return!0}else if(typeof e=="object"){let r=Xd(e),i=r.length;for(var t=0;t<i;t++)if(Kd(e[r[t]]))return!0}}return!1}function iO(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(`
62
+ `)}var oO=class extends Error{constructor(e,t,r,i,n){super(iO(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=iO(e,{name:t,index:r,operation:i,tree:n})}};var sO=I({JsonPatchError:()=>it,_areEquals:()=>Wc,applyOperation:()=>Za,applyPatch:()=>Hi,applyReducer:()=>v2,deepClone:()=>_2,getValueByPointer:()=>Qd,validate:()=>cO,validator:()=>ep}),it=oO,_2=Er,as={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=Qd(r,this.path);i&&(i=Er(i));let n=Za(r,{op:"remove",path:this.from}).removed;return Za(r,{op:"add",path:this.path,value:n}),{newDocument:r,removed:i}},copy:function(e,t,r){let i=Qd(r,this.from);return Za(r,{op:"add",path:this.path,value:Er(i)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Wc(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},y2={add:function(e,t,r){return Yd(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:as.move,copy:as.copy,test:as.test,_get:as._get};function Qd(e,t){if(t=="")return e;var r={op:"_get",path:t};return Za(e,r),r.value}function Za(e,t,r=!1,i=!0,n=!0,a=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):ep(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=Qd(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=Wc(e,t.value),o.test===!1)throw new it("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 it("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else{i||(e=Er(e));let o=(t.path||"").split("/"),s=e,c=1,u=o.length,l,d,p;for(typeof r=="function"?p=r:p=ep;;){if(d=o[c],d&&d.indexOf("~")!=-1&&(d=aO(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&&p(t,0,e,l)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!Yd(d))throw new it("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);Yd(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new it("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);let f=y2[t.op].call(t,s,d,e);if(f.test===!1)throw new it("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return f}}else if(c>=u){let f=as[t.op].call(t,s,d,e);if(f.test===!1)throw new it("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return f}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new it("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function Hi(e,t,r,i=!0,n=!0){if(r&&!Array.isArray(t))throw new it("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");i||(e=Er(e));let a=new Array(t.length);for(let o=0,s=t.length;o<s;o++)a[o]=Za(e,t[o],r,!0,n,o),e=a[o].newDocument;return a.newDocument=e,a}function v2(e,t,r){let i=Za(e,t);if(i.test===!1)throw new it("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return i.newDocument}function ep(e,t,r,i){if(typeof e!="object"||e===null||Array.isArray(e))throw new it("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(as[e.op]){if(typeof e.path!="string")throw new it("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new it('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 it("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 it("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")&&Kd(e.value))throw new it("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 it("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 it("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=cO([{op:"_get",path:e.from,value:void 0}],r);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new it("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new it("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function cO(e,t,r){try{if(!Array.isArray(e))throw new it("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Hi(Er(t),Er(e),r||!0);else{r=r||ep;for(var i=0;i<e.length;i++)r(e[i],i,t,void 0)}}catch(n){if(n instanceof it)return n;throw n}}function Wc(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(!Wc(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],!Wc(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function uO(e,t,r,i,n){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=Xd(t),o=Xd(e),s=!1,c=o.length-1;c>=0;c--){var u=o[c],l=e[u];if(Wd(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)?uO(l,d,r,i+"/"+Va(u),n):l!==d&&(n&&r.push({op:"test",path:i+"/"+Va(u),value:Er(l)}),r.push({op:"replace",path:i+"/"+Va(u),value:Er(d)}))}else Array.isArray(e)===Array.isArray(t)?(n&&r.push({op:"test",path:i+"/"+Va(u),value:Er(l)}),r.push({op:"remove",path:i+"/"+Va(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];!Wd(e,u)&&t[u]!==void 0&&r.push({op:"add",path:i+"/"+Va(u),value:Er(t[u])})}}}function qi(e,t,r=!1){var i=[];return uO(e,t,i,"",r),i}({...sO});var pO=I({LogStreamCallbackHandler:()=>rp,RunLog:()=>tp,RunLogPatch:()=>Bn,isLogStreamHandler:()=>v_}),Bn=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=Hi({},t);return new tp({ops:t,state:r[r.length-1].newDocument})}},tp=class y_ extends Bn{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),i=Hi(this.state,t.ops);return new y_({ops:r,state:i[i.length-1].newDocument})}static fromRunLogPatch(t){let r=Hi({},t.ops);return new y_({ops:t.ops,state:r[r.length-1].newDocument})}},v_=e=>e.name==="log_stream_tracer";async function lO(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 dO(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 b2(e){return e!==void 0&&e.message!==void 0}var rp=class extends Ot{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=mt.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 Bn({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 Bn({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 lO(e,this._schemaFormat)),await this.writer.write(new Bn({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 lO(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await dO(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 Bn({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){let t=new Bn({ops:[{op:"replace",path:"/final_output",value:await dO(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?b2(r?.chunk)?a=r?.chunk:a=new vt({id:`run-${e.id}`,content:t}):a=t;let o=new Bn({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 fO=I({ChatGenerationChunk:()=>Ji,GenerationChunk:()=>fi,RUN_KEY:()=>Ga}),Ga="__run",fi=class mO{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new mO({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},Ji=class hO extends fi{message;constructor(t){super(t),this.message=t.message}concat(t){return new hO({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var w2=Object.prototype.toString,x2=e=>w2.call(e)==="[object Error]",S2=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 gO(e){if(!(e&&x2(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:S2.has(t)}function k2(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 np(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 $2=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 E2(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 _O(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function I2({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 $2)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),_O(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=_O(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!gO(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=E2(r,n),p=Math.min(d,l);return p>0&&await new Promise((f,m)=>{let _=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",_),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",_),f()},p);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",_,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Xc(e,t={}){if(t={...t},k2(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,np("factor",t.factor,{min:0,allowInfinity:!1}),np("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),np("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),np("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 I2({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var ip=ji(xd(),1),yO=I({AsyncCaller:()=>mi}),T2=[400,401,402,403,404,405,406,407,409],O2=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&&T2.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}},mi=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??O2,this.queue=new("default"in ip.default?ip.default.default:ip.default)({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>Xc(()=>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(Zi(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 vO=I({isSerializableSchema:()=>Ha,isStandardJsonSchema:()=>ap,isStandardSchema:()=>bO});function bO(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 ap(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 bO(e)&&ap(e)}var _i={};On(_i,{$ZodAny:()=>ov,$ZodArray:()=>uv,$ZodAsyncError:()=>dn,$ZodBase64:()=>Wy,$ZodBase64URL:()=>Xy,$ZodBigInt:()=>Ip,$ZodBigIntFormat:()=>rv,$ZodBoolean:()=>du,$ZodCIDRv4:()=>qy,$ZodCIDRv6:()=>Jy,$ZodCUID:()=>jy,$ZodCUID2:()=>My,$ZodCatch:()=>Iv,$ZodCheck:()=>Le,$ZodCheckBigIntFormat:()=>dy,$ZodCheckEndsWith:()=>Sy,$ZodCheckGreaterThan:()=>bp,$ZodCheckIncludes:()=>wy,$ZodCheckLengthEquals:()=>_y,$ZodCheckLessThan:()=>vp,$ZodCheckLowerCase:()=>vy,$ZodCheckMaxLength:()=>hy,$ZodCheckMaxSize:()=>py,$ZodCheckMimeType:()=>$y,$ZodCheckMinLength:()=>gy,$ZodCheckMinSize:()=>fy,$ZodCheckMultipleOf:()=>uy,$ZodCheckNumberFormat:()=>ly,$ZodCheckOverwrite:()=>Ey,$ZodCheckProperty:()=>ky,$ZodCheckRegex:()=>yy,$ZodCheckSizeEquals:()=>my,$ZodCheckStartsWith:()=>xy,$ZodCheckStringFormat:()=>fs,$ZodCheckUpperCase:()=>by,$ZodCodec:()=>hu,$ZodCustom:()=>jv,$ZodCustomStringFormat:()=>ev,$ZodDate:()=>cv,$ZodDefault:()=>Sv,$ZodDiscriminatedUnion:()=>pv,$ZodE164:()=>Yy,$ZodEmail:()=>Ay,$ZodEmoji:()=>Py,$ZodEncodeError:()=>Ki,$ZodEnum:()=>_v,$ZodError:()=>au,$ZodExactOptional:()=>wv,$ZodFile:()=>vv,$ZodFunction:()=>Nv,$ZodGUID:()=>Oy,$ZodIPv4:()=>Zy,$ZodIPv6:()=>Gy,$ZodISODate:()=>Fy,$ZodISODateTime:()=>Uy,$ZodISODuration:()=>Vy,$ZodISOTime:()=>By,$ZodIntersection:()=>fv,$ZodJWT:()=>Qy,$ZodKSUID:()=>Ly,$ZodLazy:()=>Rv,$ZodLiteral:()=>yv,$ZodMAC:()=>Hy,$ZodMap:()=>hv,$ZodNaN:()=>Tv,$ZodNanoID:()=>Ry,$ZodNever:()=>fu,$ZodNonOptional:()=>$v,$ZodNull:()=>av,$ZodNullable:()=>xv,$ZodNumber:()=>Ep,$ZodNumberFormat:()=>tv,$ZodObject:()=>qO,$ZodObjectJIT:()=>lv,$ZodOptional:()=>Xa,$ZodPipe:()=>Ov,$ZodPrefault:()=>kv,$ZodPromise:()=>Pv,$ZodReadonly:()=>Cv,$ZodRealError:()=>dr,$ZodRecord:()=>mv,$ZodRegistry:()=>Np,$ZodSet:()=>gv,$ZodString:()=>Wa,$ZodStringFormat:()=>Me,$ZodSuccess:()=>Ev,$ZodSymbol:()=>nv,$ZodTemplateLiteral:()=>Av,$ZodTransform:()=>bv,$ZodTuple:()=>Tp,$ZodType:()=>de,$ZodULID:()=>zy,$ZodURL:()=>Ny,$ZodUUID:()=>Cy,$ZodUndefined:()=>iv,$ZodUnion:()=>mu,$ZodUnknown:()=>pu,$ZodVoid:()=>sv,$ZodXID:()=>Dy,$ZodXor:()=>dv,$brand:()=>op,$constructor:()=>b,$input:()=>zv,$output:()=>Mv,Doc:()=>lu,JSONSchema:()=>HC,JSONSchemaGenerator:()=>uf,NEVER:()=>b_,TimePrecision:()=>Fv,_any:()=>cb,_array:()=>fb,_base64:()=>Wp,_base64url:()=>Xp,_bigint:()=>tb,_boolean:()=>Qv,_catch:()=>KF,_check:()=>GC,_cidrv4:()=>Jp,_cidrv6:()=>Kp,_coercedBigint:()=>rb,_coercedBoolean:()=>eb,_coercedDate:()=>db,_coercedNumber:()=>qv,_coercedString:()=>Lv,_cuid:()=>Fp,_cuid2:()=>Bp,_custom:()=>hb,_date:()=>lb,_decode:()=>lp,_decodeAsync:()=>pp,_default:()=>HF,_discriminatedUnion:()=>RF,_e164:()=>Yp,_email:()=>Rp,_emoji:()=>Lp,_encode:()=>up,_encodeAsync:()=>dp,_endsWith:()=>bs,_enum:()=>UF,_file:()=>mb,_float32:()=>Kv,_float64:()=>Wv,_gt:()=>Zn,_gte:()=>Yt,_guid:()=>yu,_includes:()=>ys,_int:()=>Jv,_int32:()=>Xv,_int64:()=>nb,_intersection:()=>jF,_ipv4:()=>Hp,_ipv6:()=>qp,_isoDate:()=>Vv,_isoDateTime:()=>Bv,_isoDuration:()=>Gv,_isoTime:()=>Zv,_jwt:()=>Qp,_ksuid:()=>Gp,_lazy:()=>QF,_length:()=>eo,_literal:()=>BF,_lowercase:()=>gs,_lt:()=>Vn,_lte:()=>Tr,_mac:()=>Uv,_map:()=>DF,_max:()=>Tr,_maxLength:()=>Qa,_maxSize:()=>ra,_mime:()=>ws,_min:()=>Yt,_minLength:()=>gi,_minSize:()=>Gn,_multipleOf:()=>ta,_nan:()=>pb,_nanoid:()=>Up,_nativeEnum:()=>FF,_negative:()=>tf,_never:()=>wu,_nonnegative:()=>nf,_nonoptional:()=>qF,_nonpositive:()=>rf,_normalize:()=>xs,_null:()=>sb,_nullable:()=>GF,_number:()=>Hv,_optional:()=>ZF,_overwrite:()=>pn,_parse:()=>us,_parseAsync:()=>ls,_pipe:()=>WF,_positive:()=>ef,_promise:()=>eB,_property:()=>af,_readonly:()=>XF,_record:()=>zF,_refine:()=>gb,_regex:()=>hs,_safeDecode:()=>mp,_safeDecodeAsync:()=>gp,_safeEncode:()=>fp,_safeEncodeAsync:()=>hp,_safeParse:()=>ds,_safeParseAsync:()=>ps,_set:()=>LF,_size:()=>Ya,_slugify:()=>Es,_startsWith:()=>vs,_string:()=>Dv,_stringFormat:()=>Is,_stringbool:()=>bb,_success:()=>JF,_superRefine:()=>_b,_symbol:()=>ab,_templateLiteral:()=>YF,_toLowerCase:()=>ks,_toUpperCase:()=>$s,_transform:()=>VF,_trim:()=>Ss,_tuple:()=>MF,_uint32:()=>Yv,_uint64:()=>ib,_ulid:()=>Vp,_undefined:()=>ob,_union:()=>NF,_unknown:()=>bu,_uppercase:()=>_s,_url:()=>vu,_uuid:()=>jp,_uuidv4:()=>Mp,_uuidv6:()=>zp,_uuidv7:()=>Dp,_void:()=>ub,_xid:()=>Zp,_xor:()=>PF,clone:()=>Ke,config:()=>at,createStandardJSONSchemaMethod:()=>Ts,createToJSONSchemaMethod:()=>wb,decode:()=>n6,decodeAsync:()=>a6,describe:()=>yb,encode:()=>r6,encodeAsync:()=>i6,extractDefs:()=>ia,finalize:()=>aa,flattenError:()=>ou,formatError:()=>su,globalConfig:()=>Yc,globalRegistry:()=>Ne,initializeContext:()=>na,isValidBase64:()=>Ky,isValidBase64URL:()=>VO,isValidJWT:()=>ZO,locales:()=>_u,meta:()=>vb,parse:()=>ea,parseAsync:()=>Ja,prettifyError:()=>N_,process:()=>Re,regexes:()=>Vr,registry:()=>Pp,safeDecode:()=>s6,safeDecodeAsync:()=>u6,safeEncode:()=>o6,safeEncodeAsync:()=>c6,safeParse:()=>P_,safeParseAsync:()=>R_,toDotPath:()=>$O,toJSONSchema:()=>to,treeifyError:()=>A_,util:()=>j,version:()=>Iy});var b_=Object.freeze({status:"aborted"});function b(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 p=l[d];p in s||(s[p]=u[p].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 op=Symbol("zod_brand"),dn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ki=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Yc={};function at(e){return e&&Object.assign(Yc,e),Yc}var j={};On(j,{BIGINT_FORMAT_RANGES:()=>C_,Class:()=>x_,NUMBER_FORMAT_RANGES:()=>O_,aborted:()=>Qi,allowsEval:()=>$_,assert:()=>R2,assertEqual:()=>C2,assertIs:()=>N2,assertNever:()=>P2,assertNotEqual:()=>A2,assignProp:()=>Xi,base64ToUint8Array:()=>xO,base64urlToUint8Array:()=>X2,cached:()=>ss,captureStackTrace:()=>cp,cleanEnum:()=>W2,cleanRegex:()=>tu,clone:()=>Ke,cloneDef:()=>M2,createTransparentProxy:()=>B2,defineLazy:()=>ve,esc:()=>sp,escapeRegex:()=>Br,extend:()=>G2,finalizeIssue:()=>lr,floatSafeRemainder:()=>S_,getElementAtPath:()=>z2,getEnumValues:()=>eu,getLengthableOrigin:()=>iu,getParsedType:()=>F2,getSizableOrigin:()=>nu,hexToUint8Array:()=>Q2,isObject:()=>qa,isPlainObject:()=>Yi,issue:()=>cs,joinValues:()=>E,jsonStringifyReplacer:()=>os,merge:()=>q2,mergeDefs:()=>hi,normalizeParams:()=>L,nullish:()=>Wi,numKeys:()=>U2,objectClone:()=>j2,omit:()=>Z2,optionalKeys:()=>T_,parsedType:()=>z,partial:()=>J2,pick:()=>V2,prefixIssues:()=>Ir,primitiveTypes:()=>I_,promiseAllObject:()=>D2,propertyKeyTypes:()=>ru,randomString:()=>L2,required:()=>K2,safeExtend:()=>H2,shallowClone:()=>E_,slugify:()=>k_,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>SO,uint8ArrayToBase64url:()=>Y2,uint8ArrayToHex:()=>e6,unwrapMessage:()=>Qc});function C2(e){return e}function A2(e){return e}function N2(e){}function P2(e){throw new Error("Unexpected value in exhaustive check")}function R2(e){}function eu(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 E(e,t="|"){return e.map(r=>R(r)).join(t)}function os(e,t){return typeof t=="bigint"?t.toString():t}function ss(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Wi(e){return e==null}function tu(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.toString().split(".")[1]||"").length,i=t.toString(),n=(i.split(".")[1]||"").length;if(n===0&&/\d?e-\d?/.test(i)){let c=i.match(/\d?e-(\d?)/);c?.[1]&&(n=Number.parseInt(c[1]))}let a=r>n?r:n,o=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return o%s/10**a}var wO=Symbol("evaluating");function ve(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==wO)return i===void 0&&(i=wO,i=r()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function j2(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Xi(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function hi(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function M2(e){return hi(e._zod.def)}function z2(e,t){return t?t.reduce((r,i)=>r?.[i],e):e}function D2(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 L2(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return r}function sp(e){return JSON.stringify(e)}function k_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var cp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var $_=ss(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Yi(e){if(qa(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(qa(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function E_(e){return Yi(e)?{...e}:Array.isArray(e)?[...e]:e}function U2(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var F2=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}`)}},ru=new Set(["string","number","symbol"]),I_=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Br(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function L(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 B2(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 T_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var O_={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]},C_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function V2(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=hi(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 Xi(this,"shape",o),o},checks:[]});return Ke(e,a)}function Z2(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=hi(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 Xi(this,"shape",o),o},checks:[]});return Ke(e,a)}function G2(e,t){if(!Yi(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=hi(e._zod.def,{get shape(){let a={...e._zod.def.shape,...t};return Xi(this,"shape",a),a}});return Ke(e,n)}function H2(e,t){if(!Yi(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=hi(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Xi(this,"shape",i),i}});return Ke(e,r)}function q2(e,t){let r=hi(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return Xi(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return Ke(e,r)}function J2(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=hi(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 Xi(this,"shape",c),c},checks:[]});return Ke(t,o)}function K2(e,t,r){let i=hi(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 Xi(this,"shape",a),a}});return Ke(t,i)}function Qi(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 Ir(e,t){return t.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Qc(e){return typeof e=="string"?e:e?.message}function lr(e,t,r){let i={...e,path:e.path??[]};if(!e.message){let n=Qc(e.inst?._zod.def?.error?.(e))??Qc(t?.error?.(e))??Qc(r.customError?.(e))??Qc(r.localeError?.(e))??"Invalid input";i.message=n}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function nu(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function iu(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function z(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 cs(...e){let[t,r,i]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:i}:{...t}}function W2(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function xO(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 SO(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function X2(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return xO(t+r)}function Y2(e){return SO(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Q2(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 e6(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var x_=class{constructor(...t){}};var kO=(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,os,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},au=b("$ZodError",kO),dr=b("$ZodError",kO,{Parent:Error});function ou(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 su(e,t=r=>r.message){let r={_errors:[]},i=n=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(o=>i({issues:o}));else if(a.code==="invalid_key")i({issues:a.issues});else if(a.code==="invalid_element")i({issues:a.issues});else if(a.path.length===0)r._errors.push(t(a));else{let o=r,s=0;for(;s<a.path.length;){let c=a.path[s];s===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(a))):o[c]=o[c]||{_errors:[]},o=o[c],s++}}};return i(e),r}function A_(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},c.path));else if(c.code==="invalid_key")i({issues:c.issues},c.path);else if(c.code==="invalid_element")i({issues:c.issues},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 p=u[d],f=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),(o=l.properties)[p]??(o[p]={errors:[]}),l=l.properties[p]):(l.items??(l.items=[]),(s=l.items)[p]??(s[p]={errors:[]}),l=l.items[p]),f&&l.errors.push(t(c)),d++}}};return i(e),r}function $O(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 N_(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 ${$O(i.path)}`);return t.join(`
63
+ `)}var us=e=>(t,r,i,n)=>{let a=i?Object.assign(i,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new dn;if(o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>lr(c,a,at())));throw cp(s,n?.callee),s}return o.value},ea=us(dr),ls=e=>async(t,r,i,n)=>{let a=i?Object.assign(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=>lr(c,a,at())));throw cp(s,n?.callee),s}return o.value},Ja=ls(dr),ds=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 dn;return a.issues.length?{success:!1,error:new(e??au)(a.issues.map(o=>lr(o,n,at())))}:{success:!0,data:a.value}},P_=ds(dr),ps=e=>async(t,r,i)=>{let n=i?Object.assign(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=>lr(o,n,at())))}:{success:!0,data:a.value}},R_=ps(dr),up=e=>(t,r,i)=>{let n=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return us(e)(t,r,n)},r6=up(dr),lp=e=>(t,r,i)=>us(e)(t,r,i),n6=lp(dr),dp=e=>async(t,r,i)=>{let n=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ls(e)(t,r,n)},i6=dp(dr),pp=e=>async(t,r,i)=>ls(e)(t,r,i),a6=pp(dr),fp=e=>(t,r,i)=>{let n=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ds(e)(t,r,n)},o6=fp(dr),mp=e=>(t,r,i)=>ds(e)(t,r,i),s6=mp(dr),hp=e=>async(t,r,i)=>{let n=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ps(e)(t,r,n)},c6=hp(dr),gp=e=>async(t,r,i)=>ps(e)(t,r,i),u6=gp(dr);var Vr={};On(Vr,{base64:()=>W_,base64url:()=>_p,bigint:()=>ry,boolean:()=>iy,browserEmail:()=>_6,cidrv4:()=>J_,cidrv6:()=>K_,cuid:()=>j_,cuid2:()=>M_,date:()=>Y_,datetime:()=>ey,domain:()=>b6,duration:()=>F_,e164:()=>X_,email:()=>V_,emoji:()=>Z_,extendedDuration:()=>l6,guid:()=>B_,hex:()=>w6,hostname:()=>v6,html5Email:()=>m6,idnEmail:()=>g6,integer:()=>ny,ipv4:()=>G_,ipv6:()=>H_,ksuid:()=>L_,lowercase:()=>sy,mac:()=>q_,md5_base64:()=>S6,md5_base64url:()=>k6,md5_hex:()=>x6,nanoid:()=>U_,null:()=>ay,number:()=>yp,rfc5322Email:()=>h6,sha1_base64:()=>E6,sha1_base64url:()=>I6,sha1_hex:()=>$6,sha256_base64:()=>O6,sha256_base64url:()=>C6,sha256_hex:()=>T6,sha384_base64:()=>N6,sha384_base64url:()=>P6,sha384_hex:()=>A6,sha512_base64:()=>j6,sha512_base64url:()=>M6,sha512_hex:()=>R6,string:()=>ty,time:()=>Q_,ulid:()=>z_,undefined:()=>oy,unicodeEmail:()=>EO,uppercase:()=>cy,uuid:()=>Ka,uuid4:()=>d6,uuid6:()=>p6,uuid7:()=>f6,xid:()=>D_});var j_=/^[cC][^\s-]{8,}$/,M_=/^[0-9a-z]+$/,z_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,D_=/^[0-9a-vA-V]{20}$/,L_=/^[A-Za-z0-9]{27}$/,U_=/^[a-zA-Z0-9_-]{21}$/,F_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,l6=/^[-+]?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)?)??$/,B_=/^([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})$/,Ka=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)$/,d6=Ka(4),p6=Ka(6),f6=Ka(7),V_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,m6=/^[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])?)*$/,h6=/^(([^<>()\[\]\\.,;:\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,}))$/,EO=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,g6=EO,_6=/^[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])?)*$/,y6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Z_(){return new RegExp(y6,"u")}var G_=/^(?:(?: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])$/,H_=/^(([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}|:))$/,q_=e=>{let t=Br(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},J_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,K_=/^(([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])$/,W_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_p=/^[A-Za-z0-9_-]*$/,v6=/^(?=.{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])?)*\.?$/,b6=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,X_=/^\+[1-9]\d{6,14}$/,IO="(?:(?:\\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])))",Y_=new RegExp(`^${IO}$`);function TO(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 Q_(e){return new RegExp(`^${TO(e)}$`)}function ey(e){let t=TO({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(`^${IO}T(?:${i})$`)}var ty=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ry=/^-?\d+n?$/,ny=/^-?\d+$/,yp=/^-?\d+(?:\.\d+)?$/,iy=/^(?:true|false)$/i,ay=/^null$/i;var oy=/^undefined$/i;var sy=/^[^A-Z]*$/,cy=/^[^a-z]*$/,w6=/^[0-9a-fA-F]*$/;function cu(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function uu(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var x6=/^[0-9a-fA-F]{32}$/,S6=cu(22,"=="),k6=uu(22),$6=/^[0-9a-fA-F]{40}$/,E6=cu(27,"="),I6=uu(27),T6=/^[0-9a-fA-F]{64}$/,O6=cu(43,"="),C6=uu(43),A6=/^[0-9a-fA-F]{96}$/,N6=cu(64,""),P6=uu(64),R6=/^[0-9a-fA-F]{128}$/,j6=cu(86,"=="),M6=uu(86);var Le=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),CO={number:"number",bigint:"bigint",object:"date"},vp=b("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=CO[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})}}),bp=b("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=CO[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})}}),uy=b("$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})}}),ly=b("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=O_[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=ny)}),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})}}),dy=b("$ZodCheckBigIntFormat",(e,t)=>{Le.init(e,t);let[r,i]=C_[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})}}),py=b("$ZodCheckMaxSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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:nu(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),fy=b("$ZodCheckMinSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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:nu(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),my=b("$ZodCheckSizeEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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:nu(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})}}),hy=b("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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=iu(n);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),gy=b("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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=iu(n);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),_y=b("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Wi(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=iu(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})}}),fs=b("$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=()=>{})}),yy=b("$ZodCheckRegex",(e,t)=>{fs.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})}}),vy=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sy),fs.init(e,t)}),by=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cy),fs.init(e,t)}),wy=b("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=Br(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})}}),xy=b("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${Br(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})}}),Sy=b("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${Br(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 OO(e,t,r){e.issues.length&&t.issues.push(...Ir(r,e.issues))}var ky=b("$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=>OO(n,r,t.property));OO(i,r,t.property)}}),$y=b("$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})}}),Ey=b("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var lu=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(`
64
+ `).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(`
65
+ `))}};var Iy={major:4,minor:3,patch:6};var de=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Iy;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=Qi(o),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(o))continue}else if(u)continue;let p=o.issues.length,f=d._zod.check(o);if(f instanceof Promise&&c?.async===!1)throw new dn;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,o.issues.length!==p&&(u||(u=Qi(o,p)))});else{if(o.issues.length===p)continue;u||(u=Qi(o,p))}}return l?l.then(()=>o):o},a=(o,s,c)=>{if(Qi(o))return o.aborted=!0,o;let u=n(s,i,c);if(u instanceof Promise){if(c.async===!1)throw new dn;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 dn;return c.then(u=>n(u,i,s))}return n(c,i,s)}}ve(e,"~standard",()=>({validate:n=>{try{let a=P_(e,n);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return R_(e,n).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),Wa=b("$ZodString",(e,t)=>{de.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ty(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}}),Me=b("$ZodStringFormat",(e,t)=>{fs.init(e,t),Wa.init(e,t)}),Oy=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=B_),Me.init(e,t)}),Cy=b("$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=Ka(i))}else t.pattern??(t.pattern=Ka());Me.init(e,t)}),Ay=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=V_),Me.init(e,t)}),Ny=b("$ZodURL",(e,t)=>{Me.init(e,t),e._zod.check=r=>{try{let i=r.value.trim(),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})}}}),Py=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Z_()),Me.init(e,t)}),Ry=b("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=U_),Me.init(e,t)}),jy=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=j_),Me.init(e,t)}),My=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=M_),Me.init(e,t)}),zy=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=z_),Me.init(e,t)}),Dy=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=D_),Me.init(e,t)}),Ly=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=L_),Me.init(e,t)}),Uy=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ey(t)),Me.init(e,t)}),Fy=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Y_),Me.init(e,t)}),By=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Q_(t)),Me.init(e,t)}),Vy=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=F_),Me.init(e,t)}),Zy=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=G_),Me.init(e,t),e._zod.bag.format="ipv4"}),Gy=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=H_),Me.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})}}}),Hy=b("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=q_(t.delimiter)),Me.init(e,t),e._zod.bag.format="mac"}),qy=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=J_),Me.init(e,t)}),Jy=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=K_),Me.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 Ky(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Wy=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=W_),Me.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Ky(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function VO(e){if(!_p.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ky(r)}var Xy=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=_p),Me.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{VO(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Yy=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=X_),Me.init(e,t)});function ZO(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 Qy=b("$ZodJWT",(e,t)=>{Me.init(e,t),e._zod.check=r=>{ZO(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ev=b("$ZodCustomStringFormat",(e,t)=>{Me.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})}}),Ep=b("$ZodNumber",(e,t)=>{de.init(e,t),e._zod.pattern=e._zod.bag.pattern??yp,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}}),tv=b("$ZodNumberFormat",(e,t)=>{ly.init(e,t),Ep.init(e,t)}),du=b("$ZodBoolean",(e,t)=>{de.init(e,t),e._zod.pattern=iy,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}}),Ip=b("$ZodBigInt",(e,t)=>{de.init(e,t),e._zod.pattern=ry,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}}),rv=b("$ZodBigIntFormat",(e,t)=>{dy.init(e,t),Ip.init(e,t)}),nv=b("$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}}),iv=b("$ZodUndefined",(e,t)=>{de.init(e,t),e._zod.pattern=oy,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",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}}),av=b("$ZodNull",(e,t)=>{de.init(e,t),e._zod.pattern=ay,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}}),ov=b("$ZodAny",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),pu=b("$ZodUnknown",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),fu=b("$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)}),sv=b("$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}}),cv=b("$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 NO(e,t,r){e.issues.length&&t.issues.push(...Ir(r,e.issues)),t.value[r]=e.value}var uv=b("$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=>NO(u,r,o))):NO(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function $p(e,t,r,i,n){if(e.issues.length){if(n&&!(r in i))return;t.issues.push(...Ir(r,e.issues))}e.value===void 0?r in i&&(t.value[r]=void 0):t.value[r]=e.value}function GO(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=T_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function HO(e,t,r,i,n,a){let o=[],s=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in t){if(s.has(d))continue;if(u==="never"){o.push(d);continue}let p=c.run({value:t[d],issues:[]},i);p instanceof Promise?e.push(p.then(f=>$p(f,r,d,t,l))):$p(p,r,d,t,l)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var qO=b("$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=ss(()=>GO(t));ve(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=qa,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 p of o.keys){let f=d[p],m=f._zod.optout==="optional",_=f._zod.run({value:u[p],issues:[]},c);_ instanceof Promise?l.push(_.then(v=>$p(v,s,p,u,m))):$p(_,s,p,u,m)}return a?HO(l,u,s,c,i.value,e):l.length?Promise.all(l).then(()=>s):s}}),lv=b("$ZodObjectJIT",(e,t)=>{qO.init(e,t);let r=e._zod.parse,i=ss(()=>GO(t)),n=p=>{let f=new lu(["shape","payload","ctx"]),m=i.value,_=x=>{let $=sp(x);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};f.write("const input = payload.value;");let v=Object.create(null),k=0;for(let x of m.keys)v[x]=`key_${k++}`;f.write("const newResult = {};");for(let x of m.keys){let $=v[x],T=sp(x),O=p[x]?._zod?.optout==="optional";f.write(`const ${$} = ${_(x)};`),O?f.write(`
66
+ if (${$}.issues.length) {
67
+ if (${T} in input) {
68
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
69
+ ...iss,
70
+ path: iss.path ? [${T}, ...iss.path] : [${T}]
71
+ })));
72
+ }
73
+ }
74
+
75
+ if (${$}.value === undefined) {
76
+ if (${T} in input) {
77
+ newResult[${T}] = undefined;
78
+ }
79
+ } else {
80
+ newResult[${T}] = ${$}.value;
81
+ }
82
+
83
+ `):f.write(`
84
+ if (${$}.issues.length) {
85
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
86
+ ...iss,
87
+ path: iss.path ? [${T}, ...iss.path] : [${T}]
88
+ })));
89
+ }
90
+
91
+ if (${$}.value === undefined) {
92
+ if (${T} in input) {
93
+ newResult[${T}] = undefined;
94
+ }
95
+ } else {
96
+ newResult[${T}] = ${$}.value;
97
+ }
98
+
99
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");let w=f.compile();return(x,$)=>w(p,x,$)},a,o=qa,s=!Yc.jitless,u=s&&$_.value,l=t.catchall,d;e._zod.parse=(p,f)=>{d??(d=i.value);let m=p.value;return o(m)?s&&u&&f?.async===!1&&f.jitless!==!0?(a||(a=n(t.shape)),p=a(p,f),l?HO([],m,p,f,d,e):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function PO(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=>!Qi(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=>lr(o,i,at())))}),t)}var mu=b("$ZodUnion",(e,t)=>{de.init(e,t),ve(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),ve(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ve(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),ve(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>tu(a.source)).join("|")})$`)}});let r=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(n,a)=>{if(r)return i(n,a);let o=!1,s=[];for(let c of t.options){let u=c._zod.run({value:n.value,issues:[]},a);if(u instanceof Promise)s.push(u),o=!0;else{if(u.issues.length===0)return u;s.push(u)}}return o?Promise.all(s).then(c=>PO(c,n,e,a)):PO(s,n,e,a)}});function RO(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=>lr(o,i,at())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var dv=b("$ZodXor",(e,t)=>{mu.init(e,t),t.inclusive=!1;let r=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(n,a)=>{if(r)return i(n,a);let o=!1,s=[];for(let c of t.options){let u=c._zod.run({value:n.value,issues:[]},a);u instanceof Promise?(s.push(u),o=!0):s.push(u)}return o?Promise.all(s).then(c=>RO(c,n,e,a)):RO(s,n,e,a)}}),pv=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,mu.init(e,t);let r=e._zod.parse;ve(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=ss(()=>{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(!qa(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?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),n)}}),fv=b("$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])=>jO(r,c,u)):jO(r,a,o)}});function Ty(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(Yi(e)&&Yi(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=Ty(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=Ty(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 jO(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}),Qi(e))return e;let o=Ty(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 Tp=b("$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=[...r].reverse().findIndex(l=>l._zod.optin!=="optional"),c=s===-1?0:r.length-s;if(!t.rest){let l=a.length>r.length,d=a.length<c-1;if(l||d)return i.issues.push({...l?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:a,inst:e,origin:"array"}),i}let u=-1;for(let l of r){if(u++,u>=a.length&&u>=c)continue;let d=l._zod.run({value:a[u],issues:[]},n);d instanceof Promise?o.push(d.then(p=>wp(p,i,u))):wp(d,i,u)}if(t.rest){let l=a.slice(r.length);for(let d of l){u++;let p=t.rest._zod.run({value:d,issues:[]},n);p instanceof Promise?o.push(p.then(f=>wp(f,i,u))):wp(p,i,u)}}return o.length?Promise.all(o).then(()=>i):i}});function wp(e,t,r){e.issues.length&&t.issues.push(...Ir(r,e.issues)),t.value[r]=e.value}var mv=b("$ZodRecord",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Yi(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.valueType._zod.run({value:n[u],issues:[]},i);l instanceof Promise?a.push(l.then(d=>{d.issues.length&&r.issues.push(...Ir(u,d.issues)),r.value[u]=d.value})):(l.issues.length&&r.issues.push(...Ir(u,l.issues)),r.value[u]=l.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__")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"&&yp.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=>lr(d,i,at())),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(...Ir(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Ir(s,l.issues)),r.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>r):r}}),hv=b("$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])=>{MO(l,d,r,o,n,e,i)})):MO(c,u,r,o,n,e,i)}return a.length?Promise.all(a).then(()=>r):r}});function MO(e,t,r,i,n,a,o){e.issues.length&&(ru.has(typeof i)?r.issues.push(...Ir(i,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:a,issues:e.issues.map(s=>lr(s,o,at()))})),t.issues.length&&(ru.has(typeof i)?r.issues.push(...Ir(i,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:a,key:i,issues:t.issues.map(s=>lr(s,o,at()))})),r.value.set(e.value,t.value)}var gv=b("$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=>zO(c,r))):zO(s,r)}return a.length?Promise.all(a).then(()=>r):r}});function zO(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var _v=b("$ZodEnum",(e,t)=>{de.init(e,t);let r=eu(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=new RegExp(`^(${r.filter(n=>ru.has(typeof n)).map(n=>typeof n=="string"?Br(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}}),yv=b("$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"?Br(i):i?Br(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}}),vv=b("$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}}),bv=b("$ZodTransform",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Ki(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));if(n instanceof Promise)throw new dn;return r.value=n,r}});function DO(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Xa=b("$ZodOptional",(e,t)=>{de.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ve(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tu(r.source)})?$`):void 0}),e._zod.parse=(r,i)=>{if(t.innerType._zod.optin==="optional"){let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>DO(a,r.value)):DO(n,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,i)}}),wv=b("$ZodExactOptional",(e,t)=>{Xa.init(e,t),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,i)=>t.innerType._zod.run(r,i)}),xv=b("$ZodNullable",(e,t)=>{de.init(e,t),ve(e._zod,"optin",()=>t.innerType._zod.optin),ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tu(r.source)}|null)$`):void 0}),ve(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)}),Sv=b("$ZodDefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",ve(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=>LO(a,t)):LO(n,t)}});function LO(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var kv=b("$ZodPrefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",ve(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))}),$v=b("$ZodNonOptional",(e,t)=>{de.init(e,t),ve(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=>UO(a,e)):UO(n,e)}});function UO(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 Ev=b("$ZodSuccess",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Ki("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)}}),Iv=b("$ZodCatch",(e,t)=>{de.init(e,t),ve(e._zod,"optin",()=>t.innerType._zod.optin),ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(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=>lr(o,i,at()))},input:r.value}),r.issues=[]),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(a=>lr(a,i,at()))},input:r.value}),r.issues=[]),r)}}),Tv=b("$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)}),Ov=b("$ZodPipe",(e,t)=>{de.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(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=>xp(o,t.in,i)):xp(a,t.in,i)}let n=t.in._zod.run(r,i);return n instanceof Promise?n.then(a=>xp(a,t.out,i)):xp(n,t.out,i)}});function xp(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var hu=b("$ZodCodec",(e,t)=>{de.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(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=>Sp(o,t,i)):Sp(a,t,i)}else{let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>Sp(o,t,i)):Sp(a,t,i)}}});function Sp(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=>kp(e,a,t.out,r)):kp(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(a=>kp(e,a,t.in,r)):kp(e,n,t.in,r)}}function kp(e,t,r,i){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},i)}var Cv=b("$ZodReadonly",(e,t)=>{de.init(e,t),ve(e._zod,"propValues",()=>t.innerType._zod.propValues),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"optin",()=>t.innerType?._zod?.optin),ve(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(FO):FO(n)}});function FO(e){return e.value=Object.freeze(e.value),e}var Av=b("$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||I_.has(typeof i))r.push(Br(`${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)}),Nv=b("$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?ea(e._def.input,i):i,a=Reflect.apply(r,this,n);return e._def.output?ea(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 Ja(e._def.input,i):i,a=await Reflect.apply(r,this,n);return e._def.output?await Ja(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 Tp({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)),Pv=b("$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))}),Rv=b("$ZodLazy",(e,t)=>{de.init(e,t),ve(e._zod,"innerType",()=>t.getter()),ve(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ve(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ve(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ve(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,i)=>e._zod.innerType._zod.run(r,i)}),jv=b("$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=>BO(a,r,i,e));BO(n,r,i,e)}});function BO(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(cs(n))}}var _u={};On(_u,{ar:()=>JO,az:()=>KO,be:()=>XO,bg:()=>YO,ca:()=>QO,cs:()=>eC,da:()=>tC,de:()=>rC,en:()=>Op,eo:()=>nC,es:()=>iC,fa:()=>aC,fi:()=>oC,fr:()=>sC,frCA:()=>cC,he:()=>uC,hu:()=>lC,hy:()=>pC,id:()=>fC,is:()=>mC,it:()=>hC,ja:()=>gC,ka:()=>_C,kh:()=>yC,km:()=>Cp,ko:()=>vC,lt:()=>wC,mk:()=>xC,ms:()=>SC,nl:()=>kC,no:()=>$C,ota:()=>EC,pl:()=>TC,ps:()=>IC,pt:()=>OC,ru:()=>AC,sl:()=>NC,sv:()=>PC,ta:()=>RC,th:()=>jC,tr:()=>MC,ua:()=>zC,uk:()=>Ap,ur:()=>DC,uz:()=>LC,vi:()=>UC,yo:()=>VC,zhCN:()=>FC,zhTW:()=>BC});var D6=()=>{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=z(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: ${E(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":""}: ${E(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 JO(){return{localeError:D6()}}var L6=()=>{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=z(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: ${E(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":""}: ${E(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 KO(){return{localeError:L6()}}function WO(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 U6=()=>{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=z(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 ${E(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=WO(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=WO(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"}: ${E(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 XO(){return{localeError:U6()}}var F6=()=>{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=z(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 ${E(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":""}: ${E(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 YO(){return{localeError:F6()}}var B6=()=>{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=z(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 ${E(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":""}: ${E(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 QO(){return{localeError:B6()}}var V6=()=>{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=z(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 ${E(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: ${E(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 eC(){return{localeError:V6()}}var Z6=()=>{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=z(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 ${E(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"}: ${E(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 tC(){return{localeError:Z6()}}var G6=()=>{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=z(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 ${E(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"}: ${E(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 rC(){return{localeError:G6()}}var H6=()=>{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=z(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 ${E(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":""}: ${E(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Op(){return{localeError:H6()}}var q6=()=>{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=z(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 ${E(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":""}: ${E(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 nC(){return{localeError:q6()}}var J6=()=>{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=z(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 ${E(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":""}: ${E(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 iC(){return{localeError:J6()}}var K6=()=>{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=z(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 ${E(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: ${E(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 aC(){return{localeError:K6()}}var W6=()=>{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=z(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: ${E(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"}: ${E(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 oC(){return{localeError:W6()}}var X6=()=>{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={nan:"NaN",number:"nombre",array:"tableau"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=z(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 ${E(n.values,"|")} attendue`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Trop grand : ${n.origin??"valeur"} doit ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n.origin??"valeur"} doit \xEAtre ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Trop petit : ${n.origin} doit ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : ${n.origin} 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":""} : ${E(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 sC(){return{localeError:X6()}}var Y6=()=>{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=z(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 ${E(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":""} : ${E(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 cC(){return{localeError:Y6()}}var Q6=()=>{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),p=z(u.input),f=c[p]??e[p]?.label??p;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${R(u.values[0])}`;let l=u.values.map(f=>R(f));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=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",_=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 ${_}`.trim()}let p=u.inclusive?"<=":"<",f=a(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.maximum.toString()}`}case"too_small":{let l=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 v=(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 ${v}`}let _=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 ${_}`.trim()}let p=u.inclusive?">=":">",f=a(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${l.pattern}`;let d=s[l.format],p=d?.label??l.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${E(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 uC(){return{localeError:Q6()}}var eF=()=>{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=z(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 ${E(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":""}: ${E(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 lC(){return{localeError:eF()}}function dC(e,t,r){return Math.abs(e)===1?t:r}function ms(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 tF=()=>{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=z(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 ${E(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=dC(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 ${ms(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 ${ms(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=dC(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 ${ms(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 ${ms(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":""}. ${E(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${ms(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 ${ms(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function pC(){return{localeError:tF()}}var rF=()=>{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=z(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 ${E(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":""}: ${E(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 fC(){return{localeError:rF()}}var nF=()=>{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=z(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 ${E(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"}: ${E(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 mC(){return{localeError:nF()}}var iF=()=>{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=z(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 ${E(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}`:`Invalid ${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"}: ${E(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 hC(){return{localeError:iF()}}var aF=()=>{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=z(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: ${E(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":""}: ${E(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 gC(){return{localeError:aF()}}var oF=()=>{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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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=z(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 ${E(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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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"}: ${E(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 _C(){return{localeError:oF()}}var sF=()=>{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=z(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 ${E(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 ${E(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 Cp(){return{localeError:sF()}}function yC(){return Cp()}var cF=()=>{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=z(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: ${E(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: ${E(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 vC(){return{localeError:cF()}}var gu=e=>e.charAt(0).toUpperCase()+e.slice(1);function bC(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 uF=()=>{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=z(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 ${E(n.values,"|")} pasirinkim\u0173`;case"too_big":{let a=i[n.origin]??n.origin,o=t(n.origin,bC(Number(n.maximum)),n.inclusive??!1,"smaller");if(o?.verb)return`${gu(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`${gu(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,bC(Number(n.minimum)),n.inclusive??!1,"bigger");if(o?.verb)return`${gu(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`${gu(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"}: ${E(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`${gu(a??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function wC(){return{localeError:uF()}}var lF=()=>{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=z(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 ${E(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"}: ${E(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 xC(){return{localeError:lF()}}var dF=()=>{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=z(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 ${E(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: ${E(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 SC(){return{localeError:dF()}}var pF=()=>{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=z(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 ${E(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":""}: ${E(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 kC(){return{localeError:pF()}}var fF=()=>{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=z(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 ${E(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"}: ${E(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 $C(){return{localeError:fF()}}var mF=()=>{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=z(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 ${E(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":""}: ${E(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 EC(){return{localeError:mF()}}var hF=()=>{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=z(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 ${E(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"}: ${E(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 IC(){return{localeError:hF()}}var gF=()=>{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=z(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 ${E(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":""}: ${E(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 TC(){return{localeError:gF()}}var _F=()=>{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=z(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 ${E(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":""}: ${E(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 OC(){return{localeError:_F()}}function CC(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 yF=()=>{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=z(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 ${E(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=CC(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=CC(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":""}: ${E(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 AC(){return{localeError:yF()}}var vF=()=>{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=z(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 ${E(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"}: ${E(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 NC(){return{localeError:vF()}}var bF=()=>{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=z(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 ${E(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"}: ${E(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 PC(){return{localeError:bF()}}var wF=()=>{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=z(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 ${E(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":""}: ${E(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 RC(){return{localeError:wF()}}var xF=()=>{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=z(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 ${E(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: ${E(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 jC(){return{localeError:xF()}}var SF=()=>{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=z(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: ${E(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":""}: ${E(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 MC(){return{localeError:SF()}}var kF=()=>{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=z(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 ${E(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":""}: ${E(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 Ap(){return{localeError:kF()}}function zC(){return Ap()}var $F=()=>{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=z(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: ${E(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":""}: ${E(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 DC(){return{localeError:$F()}}var EF=()=>{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"}};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=z(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 ${E(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":""}: ${E(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 LC(){return{localeError:EF()}}var IF=()=>{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=z(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 ${E(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: ${E(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 UC(){return{localeError:IF()}}var TF=()=>{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=z(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 ${E(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): ${E(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 FC(){return{localeError:TF()}}var OF=()=>{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=z(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 ${E(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${E(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 BC(){return{localeError:OF()}}var CF=()=>{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=z(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 ${E(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: ${E(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 VC(){return{localeError:CF()}}var ZC,Mv=Symbol("ZodOutput"),zv=Symbol("ZodInput"),Np=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 Pp(){return new Np}(ZC=globalThis).__zod_globalRegistry??(ZC.__zod_globalRegistry=Pp());var Ne=globalThis.__zod_globalRegistry;function Dv(e,t){return new e({type:"string",...L(t)})}function Lv(e,t){return new e({type:"string",coerce:!0,...L(t)})}function Rp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...L(t)})}function yu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...L(t)})}function jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...L(t)})}function Mp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...L(t)})}function zp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...L(t)})}function Dp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...L(t)})}function vu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...L(t)})}function Lp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...L(t)})}function Up(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...L(t)})}function Fp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...L(t)})}function Bp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...L(t)})}function Vp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...L(t)})}function Zp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...L(t)})}function Gp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...L(t)})}function Hp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...L(t)})}function qp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...L(t)})}function Uv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...L(t)})}function Jp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...L(t)})}function Kp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...L(t)})}function Wp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...L(t)})}function Xp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...L(t)})}function Yp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...L(t)})}function Qp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...L(t)})}var Fv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Bv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...L(t)})}function Vv(e,t){return new e({type:"string",format:"date",check:"string_format",...L(t)})}function Zv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...L(t)})}function Gv(e,t){return new e({type:"string",format:"duration",check:"string_format",...L(t)})}function Hv(e,t){return new e({type:"number",checks:[],...L(t)})}function qv(e,t){return new e({type:"number",coerce:!0,checks:[],...L(t)})}function Jv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...L(t)})}function Kv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...L(t)})}function Wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...L(t)})}function Xv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...L(t)})}function Yv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...L(t)})}function Qv(e,t){return new e({type:"boolean",...L(t)})}function eb(e,t){return new e({type:"boolean",coerce:!0,...L(t)})}function tb(e,t){return new e({type:"bigint",...L(t)})}function rb(e,t){return new e({type:"bigint",coerce:!0,...L(t)})}function nb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...L(t)})}function ib(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...L(t)})}function ab(e,t){return new e({type:"symbol",...L(t)})}function ob(e,t){return new e({type:"undefined",...L(t)})}function sb(e,t){return new e({type:"null",...L(t)})}function cb(e){return new e({type:"any"})}function bu(e){return new e({type:"unknown"})}function wu(e,t){return new e({type:"never",...L(t)})}function ub(e,t){return new e({type:"void",...L(t)})}function lb(e,t){return new e({type:"date",...L(t)})}function db(e,t){return new e({type:"date",coerce:!0,...L(t)})}function pb(e,t){return new e({type:"nan",...L(t)})}function Vn(e,t){return new vp({check:"less_than",...L(t),value:e,inclusive:!1})}function Tr(e,t){return new vp({check:"less_than",...L(t),value:e,inclusive:!0})}function Zn(e,t){return new bp({check:"greater_than",...L(t),value:e,inclusive:!1})}function Yt(e,t){return new bp({check:"greater_than",...L(t),value:e,inclusive:!0})}function ef(e){return Zn(0,e)}function tf(e){return Vn(0,e)}function rf(e){return Tr(0,e)}function nf(e){return Yt(0,e)}function ta(e,t){return new uy({check:"multiple_of",...L(t),value:e})}function ra(e,t){return new py({check:"max_size",...L(t),maximum:e})}function Gn(e,t){return new fy({check:"min_size",...L(t),minimum:e})}function Ya(e,t){return new my({check:"size_equals",...L(t),size:e})}function Qa(e,t){return new hy({check:"max_length",...L(t),maximum:e})}function gi(e,t){return new gy({check:"min_length",...L(t),minimum:e})}function eo(e,t){return new _y({check:"length_equals",...L(t),length:e})}function hs(e,t){return new yy({check:"string_format",format:"regex",...L(t),pattern:e})}function gs(e){return new vy({check:"string_format",format:"lowercase",...L(e)})}function _s(e){return new by({check:"string_format",format:"uppercase",...L(e)})}function ys(e,t){return new wy({check:"string_format",format:"includes",...L(t),includes:e})}function vs(e,t){return new xy({check:"string_format",format:"starts_with",...L(t),prefix:e})}function bs(e,t){return new Sy({check:"string_format",format:"ends_with",...L(t),suffix:e})}function af(e,t,r){return new ky({check:"property",property:e,schema:t,...L(r)})}function ws(e,t){return new $y({check:"mime_type",mime:e,...L(t)})}function pn(e){return new Ey({check:"overwrite",tx:e})}function xs(e){return pn(t=>t.normalize(e))}function Ss(){return pn(e=>e.trim())}function ks(){return pn(e=>e.toLowerCase())}function $s(){return pn(e=>e.toUpperCase())}function Es(){return pn(e=>k_(e))}function fb(e,t,r){return new e({type:"array",element:t,...L(r)})}function NF(e,t,r){return new e({type:"union",options:t,...L(r)})}function PF(e,t,r){return new e({type:"union",options:t,inclusive:!1,...L(r)})}function RF(e,t,r,i){return new e({type:"union",options:r,discriminator:t,...L(i)})}function jF(e,t,r){return new e({type:"intersection",left:t,right:r})}function MF(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,...L(a)})}function zF(e,t,r,i){return new e({type:"record",keyType:t,valueType:r,...L(i)})}function DF(e,t,r,i){return new e({type:"map",keyType:t,valueType:r,...L(i)})}function LF(e,t,r){return new e({type:"set",valueType:t,...L(r)})}function UF(e,t,r){let i=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:i,...L(r)})}function FF(e,t,r){return new e({type:"enum",entries:t,...L(r)})}function BF(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...L(r)})}function mb(e,t){return new e({type:"file",...L(t)})}function VF(e,t){return new e({type:"transform",transform:t})}function ZF(e,t){return new e({type:"optional",innerType:t})}function GF(e,t){return new e({type:"nullable",innerType:t})}function HF(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():E_(r)}})}function qF(e,t,r){return new e({type:"nonoptional",innerType:t,...L(r)})}function JF(e,t){return new e({type:"success",innerType:t})}function KF(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function WF(e,t,r){return new e({type:"pipe",in:t,out:r})}function XF(e,t){return new e({type:"readonly",innerType:t})}function YF(e,t,r){return new e({type:"template_literal",parts:t,...L(r)})}function QF(e,t){return new e({type:"lazy",getter:t})}function eB(e,t){return new e({type:"promise",innerType:t})}function hb(e,t,r){let i=L(r);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function gb(e,t,r){return new e({type:"custom",check:"custom",fn:t,...L(r)})}function _b(e){let t=GC(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(cs(i,r.value,t._zod.def));else{let n=i;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(cs(n))}},e(r.value,r)));return t}function GC(e,t){let r=new Le({check:"custom",...L(t)});return r._zod.check=e,r}function yb(e){let t=new Le({check:"describe"});return t._zod.onattach=[r=>{let i=Ne.get(r)??{};Ne.add(r,{...i,description:e})}],t._zod.check=()=>{},t}function vb(e){let t=new Le({check:"meta"});return t._zod.onattach=[r=>{let i=Ne.get(r)??{};Ne.add(r,{...i,...e})}],t._zod.check=()=>{},t}function bb(e,t){let r=L(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(f=>typeof f=="string"?f.toLowerCase():f),n=n.map(f=>typeof f=="string"?f.toLowerCase():f));let a=new Set(i),o=new Set(n),s=e.Codec??hu,c=e.Boolean??du,u=e.String??Wa,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),p=new s({type:"pipe",in:l,out:d,transform:((f,m)=>{let _=f;return r.case!=="sensitive"&&(_=_.toLowerCase()),a.has(_)?!0:o.has(_)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...a,...o],input:m.value,inst:p,continue:!1}),{})}),reverseTransform:((f,m)=>f===!0?i[0]||"true":n[0]||"false"),error:r.error});return p}function Is(e,t,r,i={}){let n=L(i),a={...L(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 na(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??Ne,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 p=o.schema,f=t.processors[n.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);f(e,t,p,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"&&Qt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ia(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,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${p("__shared")}#/${s}/${f}`}}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>
100
+
101
+ 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 aa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=o=>{let s=e.seen.get(o);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){i(l);let p=e.seen.get(l),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),o._zod.parent===l)for(let _ in c)_==="$ref"||_==="allOf"||_ in u||delete c[_];if(f.$ref&&p.def)for(let _ in c)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(c[_])===JSON.stringify(p.def[_])&&delete c[_]}let d=o._zod.parent;if(d&&d!==l){i(d);let p=e.seen.get(d);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}e.override({zodSchema:o,jsonSchema:c,path:s.path??[]})};for(let o of[...e.seen.entries()].reverse())i(o[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 o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(o)}Object.assign(n,r.def??r.schema);let a=e.external?.defs??{};for(let o of e.seen.entries()){let s=o[1];s.def&&s.defId&&(a[s.defId]=s.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let o=JSON.parse(JSON.stringify(n));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ts(t,"input",e.processors),output:Ts(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function Qt(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 Qt(i.element,r);if(i.type==="set")return Qt(i.valueType,r);if(i.type==="lazy")return Qt(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 Qt(i.innerType,r);if(i.type==="intersection")return Qt(i.left,r)||Qt(i.right,r);if(i.type==="record"||i.type==="map")return Qt(i.keyType,r)||Qt(i.valueType,r);if(i.type==="pipe")return Qt(i.in,r)||Qt(i.out,r);if(i.type==="object"){for(let n in i.shape)if(Qt(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(Qt(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(Qt(n,r))return!0;return!!(i.rest&&Qt(i.rest,r))}return!1}var wb=(e,t={})=>r=>{let i=na({...r,processors:t});return Re(e,i),ia(i,e),aa(i,e)},Ts=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=na({...n??{},target:a,io:t,processors:r});return Re(e,o),ia(o,e),aa(o,e)};var tB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xb=(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=tB[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}))])}},Sb=(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",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l),typeof a=="number"&&(n.minimum=a,typeof l=="number"&&t.target!=="draft-04"&&(l>=a?delete n.minimum:delete n.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u),typeof o=="number"&&(n.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete n.maximum:delete n.exclusiveMaximum)),typeof c=="number"&&(n.multipleOf=c)},kb=(e,t,r,i)=>{r.type="boolean"},$b=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Eb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Ib=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Tb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Ob=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Cb=(e,t,r,i)=>{r.not={}},Ab=(e,t,r,i)=>{},Nb=(e,t,r,i)=>{},Pb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Rb=(e,t,r,i)=>{let n=e._zod.def,a=eu(n.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},jb=(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},Mb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},zb=(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},Db=(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)},Lb=(e,t,r,i)=>{r.type="boolean"},Ub=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Fb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Bb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Vb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Zb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Gb=(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"]})},Hb=(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)},sf=(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},qb=(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},Jb=(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((p,f)=>Re(p,t,{...i,path:[...i.path,o,f]})),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)},Kb=(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)}},Wb=(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"}]},Xb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Yb=(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))},Qb=(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)))},ew=(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},tw=(e,t,r,i)=>{let n=e._zod.def,a=t.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;Re(a,t,i);let o=t.seen.get(e);o.ref=a},rw=(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},nw=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},cf=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},iw=(e,t,r,i)=>{let n=e._zod.innerType;Re(n,t,i);let a=t.seen.get(e);a.ref=n},of={string:xb,number:Sb,boolean:kb,bigint:$b,symbol:Eb,null:Ib,undefined:Tb,void:Ob,never:Cb,any:Ab,unknown:Nb,date:Pb,enum:Rb,literal:jb,nan:Mb,template_literal:zb,file:Db,success:Lb,custom:Ub,function:Fb,transform:Bb,map:Vb,set:Zb,array:Gb,object:Hb,union:sf,intersection:qb,tuple:Jb,record:Kb,nullable:Wb,nonoptional:Xb,default:Yb,prefault:Qb,catch:ew,pipe:tw,readonly:rw,promise:nw,optional:cf,lazy:iw};function to(e,t){if("_idmap"in e){let i=e,n=na({...t,processors:of}),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;ia(n,l),o[u]=aa(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=na({...t,processors:of});return Re(e,r),ia(r,e),aa(r,e)}var uf=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=na({processors:of,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)),ia(this.ctx,t);let i=aa(this.ctx,t),{"~standard":n,...a}=i;return a}};var HC={};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 ot(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 qC(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."),ot(e)}function pr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(Be(e)||ot(e))}function aw(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 ow(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 JC(e){return!!(aw(e)||ow(e))}async function df(e,t){if(Be(e))try{return{success:!0,data:await Ja(e,t)}}catch(r){return{success:!1,error:r}}if(ot(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function oa(e,t){if(Be(e))return await Ja(e,t);if(ot(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function KC(e,t){if(Be(e))try{return{success:!0,data:ea(e,t)}}catch(r){return{success:!1,error:r}}if(ot(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Cs(e,t){if(Be(e))return ea(e,t);if(ot(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function yi(e){if(Be(e))return Ne.get(e)?.description;if(ot(e)||"description"in e&&typeof e.description=="string")return e.description}function WC(e){if(!pr(e))return!1;if(ot(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 As(e){return pr(e)?ot(e)?e._def.typeName==="ZodString":Be(e)?e._zod.def.type==="string":!1:!1}function xu(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 Zr(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 Su(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 sw(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 cw(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 er(e){return!!(xu(e)||Zr(e))}function no(e){if(ot(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 pf(e,t){if(ot(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(ot(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 Os(e,t=!1){if(xu(e))return e.strict();if(Zr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Zr(o))r[a]=Os(o,t);else if(Su(o)){let c=o._zod.def.element;Zr(c)&&(c=Os(c,t)),r[a]=Ke(o,{...o._zod.def,element:c})}else r[a]=o;let s=Ne.get(o);s&&Ne.add(r[a],s)}let i=Ke(e,{...e._zod.def,shape:r,catchall:wu(fu)}),n=Ne.get(e);return n&&Ne.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function lf(e,t=!1){if(xu(e))return e.passthrough();if(Zr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Zr(o))r[a]=lf(o,t);else if(Su(o)){let c=o._zod.def.element;Zr(c)&&(c=lf(c,t)),r[a]=Ke(o,{...o._zod.def,element:c})}else r[a]=o;let s=Ne.get(o);s&&Ne.add(r[a],s)}let i=Ke(e,{...e._zod.def,shape:r,catchall:bu(pu)}),n=Ne.get(e);return n&&Ne.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function ff(e){if(ot(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(Be(e))try{let t=ea(e,void 0);return()=>t}catch{return}}function nB(e){return ot(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function iB(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(ot(e))return nB(e)?ro(e._def.schema,t,r):e;if(Be(e)){let n=e;if(iB(e)&&(n=ro(e._zod.def.in,t,r)),t){if(Zr(n)){let o={};for(let[s,c]of Object.entries(n._zod.def.shape))o[s]=ro(c,t,r);n=Ke(n,{...n._zod.def,shape:o})}else if(Su(n)){let o=ro(n._zod.def.element,t,r);n=Ke(n,{...n._zod.def,element:o})}else if(sw(n)){let o=ro(n._zod.def.innerType,t,r);n=Ke(n,{...n._zod.def,innerType:o})}else if(cw(n)){let o=ro(n._zod.def.innerType,t,r);n=Ke(n,{...n._zod.def,innerType:o})}}let a=Ne.get(e);return a&&Ne.add(n,a),r.set(e,n),n}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function mf(e,t=!1){return ro(e,t,new WeakMap)}function XC(e,t){if(ot(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=Ke(e,{...e._zod.def,shape:i}),a=Ne.get(e);return a&&Ne.add(n,a),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function hf(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var QC=Symbol("Let zodToJsonSchema decide on which parser to use"),YC={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"},eA=e=>typeof e=="string"?{...YC,name:e}:{...YC,...e};var tA=e=>{let t=eA(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 gf=(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 Ye(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?gf(t,e.currentPath):t.join("/")}}function uw(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ce(e,t,r,i,n){e[t]=r,uw(e,t,i,n)}var kt={};On(kt,{BRAND:()=>CB,DIRTY:()=>io,EMPTY_PATH:()=>cB,INVALID:()=>oe,NEVER:()=>m9,OK:()=>Mt,ParseStatus:()=>Ct,Schema:()=>be,ZodAny:()=>ua,ZodArray:()=>xi,ZodBigInt:()=>oo,ZodBoolean:()=>so,ZodBranded:()=>$u,ZodCatch:()=>vo,ZodDate:()=>co,ZodDefault:()=>yo,ZodDiscriminatedUnion:()=>vf,ZodEffects:()=>qr,ZodEnum:()=>go,ZodError:()=>fr,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>wf,ZodIntersection:()=>fo,ZodIssueCode:()=>M,ZodLazy:()=>mo,ZodLiteral:()=>ho,ZodMap:()=>Ds,ZodNaN:()=>Us,ZodNativeEnum:()=>_o,ZodNever:()=>fn,ZodNull:()=>lo,ZodNullable:()=>Jn,ZodNumber:()=>ao,ZodObject:()=>mr,ZodOptional:()=>Gr,ZodParsedType:()=>J,ZodPipeline:()=>Eu,ZodPromise:()=>la,ZodReadonly:()=>bo,ZodRecord:()=>bf,ZodSchema:()=>be,ZodSet:()=>Ls,ZodString:()=>ca,ZodSymbol:()=>Ms,ZodTransformer:()=>qr,ZodTuple:()=>qn,ZodType:()=>be,ZodUndefined:()=>uo,ZodUnion:()=>po,ZodUnknown:()=>wi,ZodVoid:()=>zs,addIssueToContext:()=>V,any:()=>LB,array:()=>VB,bigint:()=>RB,boolean:()=>pA,coerce:()=>f9,custom:()=>uA,date:()=>jB,datetimeRegex:()=>sA,defaultErrorMap:()=>vi,discriminatedUnion:()=>qB,effect:()=>a9,enum:()=>r9,function:()=>QB,getErrorMap:()=>Ps,getParsedType:()=>Hn,instanceof:()=>NB,intersection:()=>JB,isAborted:()=>_f,isAsync:()=>Rs,isDirty:()=>yf,isValid:()=>sa,late:()=>AB,lazy:()=>e9,literal:()=>t9,makeIssue:()=>ku,map:()=>XB,nan:()=>PB,nativeEnum:()=>n9,never:()=>FB,null:()=>DB,nullable:()=>s9,number:()=>dA,object:()=>ZB,objectUtil:()=>lw,oboolean:()=>p9,onumber:()=>d9,optional:()=>o9,ostring:()=>l9,pipeline:()=>u9,preprocess:()=>c9,promise:()=>i9,quotelessJson:()=>aB,record:()=>WB,set:()=>YB,setErrorMap:()=>sB,strictObject:()=>GB,string:()=>lA,symbol:()=>MB,transformer:()=>a9,tuple:()=>KB,undefined:()=>zB,union:()=>HB,unknown:()=>UB,util:()=>Te,void:()=>BB});var Te;(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})(Te||(Te={}));var lw;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(lw||(lw={}));var J=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Hn=e=>{switch(typeof e){case"undefined":return J.undefined;case"string":return J.string;case"number":return Number.isNaN(e)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(e)?J.array:e===null?J.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?J.promise:typeof Map<"u"&&e instanceof Map?J.map:typeof Set<"u"&&e instanceof Set?J.set:typeof Date<"u"&&e instanceof Date?J.date:J.object;default:return J.unknown}};var M=Te.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),aB=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),fr=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,Te.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()}};fr.create=e=>new fr(e);var oB=(e,t)=>{let r;switch(e.code){case M.invalid_type:e.received===J.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case M.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Te.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:r=`Unrecognized key(s) in object: ${Te.joinValues(e.keys,", ")}`;break;case M.invalid_union:r="Invalid input";break;case M.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Te.joinValues(e.options)}`;break;case M.invalid_enum_value:r=`Invalid enum value. Expected ${Te.joinValues(e.options)}, received '${e.received}'`;break;case M.invalid_arguments:r="Invalid function arguments";break;case M.invalid_return_type:r="Invalid function return type";break;case M.invalid_date:r="Invalid date";break;case M.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}"`:Te.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case M.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 M.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 M.custom:r="Invalid input";break;case M.invalid_intersection_types:r="Intersection results could not be merged";break;case M.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case M.not_finite:r="Number must be finite";break;default:r=t.defaultError,Te.assertNever(e)}return{message:r}},vi=oB;var rA=vi;function sB(e){rA=e}function Ps(){return rA}var ku=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}},cB=[];function V(e,t){let r=Ps(),i=ku({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===vi?void 0:vi].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}),Mt=e=>({status:"valid",value:e}),_f=e=>e.status==="aborted",yf=e=>e.status==="dirty",sa=e=>e.status==="valid",Rs=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 Hr=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}},nA=(e,t)=>{if(sa(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 fr(e.common.issues);return this._error=r,this._error}}};function ge(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 be=class{get description(){return this._def.description}_getType(t){return Hn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Hn(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:Hn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Rs(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:Hn(t)},n=this._parseSync({data:t,path:i.path,parent:i});return nA(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Hn(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return sa(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=>sa(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:Hn(t)},n=this._parse({data:t,path:i.path,parent:i}),a=await(Rs(n)?n:Promise.resolve(n));return nA(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:M.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 qr({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 Gr.create(this,this._def)}nullable(){return Jn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xi.create(this)}promise(){return la.create(this,this._def)}or(t){return po.create([this,t],this._def)}and(t){return fo.create(this,t,this._def)}transform(t){return new qr({...ge(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new yo({...ge(this._def),innerType:this,defaultValue:r,typeName:D.ZodDefault})}brand(){return new $u({typeName:D.ZodBranded,type:this,...ge(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new vo({...ge(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 Eu.create(this,t)}readonly(){return bo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},uB=/^c[^\s-]{8,}$/i,lB=/^[0-9a-z]+$/,dB=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pB=/^[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,fB=/^[a-z0-9_-]{21}$/i,mB=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hB=/^[-+]?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)?)??$/,gB=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_B="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dw,yB=/^(?:(?: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])$/,vB=/^(?:(?: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])$/,bB=/^(([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]))$/,wB=/^(([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])$/,xB=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,SB=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aA="((\\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])))",kB=new RegExp(`^${aA}$`);function oA(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 $B(e){return new RegExp(`^${oA(e)}$`)}function sA(e){let t=`${aA}T${oA(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 EB(e,t){return!!((t==="v4"||!t)&&yB.test(e)||(t==="v6"||!t)&&bB.test(e))}function IB(e,t){if(!mB.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 TB(e,t){return!!((t==="v4"||!t)&&vB.test(e)||(t==="v6"||!t)&&wB.test(e))}var ca=class e extends be{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==J.string){let a=this._getOrReturnCtx(t);return V(a,{code:M.invalid_type,expected:J.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),V(n,{code:M.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),V(n,{code:M.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?V(n,{code:M.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&V(n,{code:M.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),i.dirty())}else if(a.kind==="email")gB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"email",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="emoji")dw||(dw=new RegExp(_B,"u")),dw.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"emoji",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="uuid")pB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"uuid",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="nanoid")fB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"nanoid",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid")uB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"cuid",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid2")lB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"cuid2",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="ulid")dB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"ulid",code:M.invalid_string,message:a.message}),i.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),V(n,{validation:"url",code:M.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),V(n,{validation:"regex",code:M.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),V(n,{code:M.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),V(n,{code:M.invalid_string,validation:{startsWith:a.value},message:a.message}),i.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),V(n,{code:M.invalid_string,validation:{endsWith:a.value},message:a.message}),i.dirty()):a.kind==="datetime"?sA(a).test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{code:M.invalid_string,validation:"datetime",message:a.message}),i.dirty()):a.kind==="date"?kB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{code:M.invalid_string,validation:"date",message:a.message}),i.dirty()):a.kind==="time"?$B(a).test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{code:M.invalid_string,validation:"time",message:a.message}),i.dirty()):a.kind==="duration"?hB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"duration",code:M.invalid_string,message:a.message}),i.dirty()):a.kind==="ip"?EB(t.data,a.version)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"ip",code:M.invalid_string,message:a.message}),i.dirty()):a.kind==="jwt"?IB(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"jwt",code:M.invalid_string,message:a.message}),i.dirty()):a.kind==="cidr"?TB(t.data,a.version)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"cidr",code:M.invalid_string,message:a.message}),i.dirty()):a.kind==="base64"?xB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"base64",code:M.invalid_string,message:a.message}),i.dirty()):a.kind==="base64url"?SB.test(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{validation:"base64url",code:M.invalid_string,message:a.message}),i.dirty()):Te.assertNever(a);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:M.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}};ca.create=e=>new ca({checks:[],typeName:D.ZodString,coerce:e?.coerce??!1,...ge(e)});function OB(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 be{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)!==J.number){let a=this._getOrReturnCtx(t);return V(a,{code:M.invalid_type,expected:J.number,received:a.parsedType}),oe}let i,n=new Ct;for(let a of this._def.checks)a.kind==="int"?Te.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{code:M.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),V(i,{code:M.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),V(i,{code:M.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?OB(t.data,a.value)!==0&&(i=this._getOrReturnCtx(t,i),V(i,{code:M.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{code:M.not_finite,message:a.message}),n.dirty()):Te.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"&&Te.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,...ge(e)});var oo=class e extends be{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)!==J.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),V(i,{code:M.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),V(i,{code:M.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),V(i,{code:M.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Te.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return V(r,{code:M.invalid_type,expected:J.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,...ge(e)});var so=class extends be{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==J.boolean){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.boolean,received:i.parsedType}),oe}return Mt(t.data)}};so.create=e=>new so({typeName:D.ZodBoolean,coerce:e?.coerce||!1,...ge(e)});var co=class e extends be{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==J.date){let a=this._getOrReturnCtx(t);return V(a,{code:M.invalid_type,expected:J.date,received:a.parsedType}),oe}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return V(a,{code:M.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),V(n,{code:M.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),V(n,{code:M.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),i.dirty()):Te.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,...ge(e)});var Ms=class extends be{_parse(t){if(this._getType(t)!==J.symbol){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.symbol,received:i.parsedType}),oe}return Mt(t.data)}};Ms.create=e=>new Ms({typeName:D.ZodSymbol,...ge(e)});var uo=class extends be{_parse(t){if(this._getType(t)!==J.undefined){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.undefined,received:i.parsedType}),oe}return Mt(t.data)}};uo.create=e=>new uo({typeName:D.ZodUndefined,...ge(e)});var lo=class extends be{_parse(t){if(this._getType(t)!==J.null){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.null,received:i.parsedType}),oe}return Mt(t.data)}};lo.create=e=>new lo({typeName:D.ZodNull,...ge(e)});var ua=class extends be{constructor(){super(...arguments),this._any=!0}_parse(t){return Mt(t.data)}};ua.create=e=>new ua({typeName:D.ZodAny,...ge(e)});var wi=class extends be{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Mt(t.data)}};wi.create=e=>new wi({typeName:D.ZodUnknown,...ge(e)});var fn=class extends be{_parse(t){let r=this._getOrReturnCtx(t);return V(r,{code:M.invalid_type,expected:J.never,received:r.parsedType}),oe}};fn.create=e=>new fn({typeName:D.ZodNever,...ge(e)});var zs=class extends be{_parse(t){if(this._getType(t)!==J.undefined){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.void,received:i.parsedType}),oe}return Mt(t.data)}};zs.create=e=>new zs({typeName:D.ZodVoid,...ge(e)});var xi=class e extends be{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==J.array)return V(r,{code:M.invalid_type,expected:J.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)&&(V(r,{code:o?M.too_big:M.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&&(V(r,{code:M.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&&(V(r,{code:M.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 Hr(r,o,r.path,s)))).then(o=>Ct.mergeArray(i,o));let a=[...r.data].map((o,s)=>n.type._parseSync(new Hr(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)}};xi.create=(e,t)=>new xi({type:e,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...ge(t)});function js(e){if(e instanceof mr){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=Gr.create(js(i))}return new mr({...e._def,shape:()=>t})}else return e instanceof xi?new xi({...e._def,type:js(e.element)}):e instanceof Gr?Gr.create(js(e.unwrap())):e instanceof Jn?Jn.create(js(e.unwrap())):e instanceof qn?qn.create(e.items.map(t=>js(t))):e}var mr=class e extends be{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=Te.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==J.object){let u=this._getOrReturnCtx(t);return V(u,{code:M.invalid_type,expected:J.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 fn&&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 Hr(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof fn){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&&(V(n,{code:M.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 Hr(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,p=await l.value;u.push({key:d,value:p,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 Te.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 Te.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 Te.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 Te.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let a=this.shape[i];for(;a instanceof Gr;)a=a._def.innerType;r[i]=a}return new e({...this._def,shape:()=>r})}keyof(){return cA(Te.objectKeys(this.shape))}};mr.create=(e,t)=>new mr({shape:()=>e,unknownKeys:"strip",catchall:fn.create(),typeName:D.ZodObject,...ge(t)});mr.strictCreate=(e,t)=>new mr({shape:()=>e,unknownKeys:"strict",catchall:fn.create(),typeName:D.ZodObject,...ge(t)});mr.lazycreate=(e,t)=>new mr({shape:e,unknownKeys:"strip",catchall:fn.create(),typeName:D.ZodObject,...ge(t)});var po=class extends be{_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 fr(s.ctx.common.issues));return V(r,{code:M.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 fr(c));return V(r,{code:M.invalid_union,unionErrors:s}),oe}}get options(){return this._def.options}};po.create=(e,t)=>new po({options:e,typeName:D.ZodUnion,...ge(t)});var bi=e=>e instanceof mo?bi(e.schema):e instanceof qr?bi(e.innerType()):e instanceof ho?[e.value]:e instanceof go?e.options:e instanceof _o?Te.objectValues(e.enum):e instanceof yo?bi(e._def.innerType):e instanceof uo?[void 0]:e instanceof lo?[null]:e instanceof Gr?[void 0,...bi(e.unwrap())]:e instanceof Jn?[null,...bi(e.unwrap())]:e instanceof $u||e instanceof bo?bi(e.unwrap()):e instanceof vo?bi(e._def.innerType):[],vf=class e extends be{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.object)return V(r,{code:M.invalid_type,expected:J.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}):(V(r,{code:M.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=bi(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,...ge(i)})}};function pw(e,t){let r=Hn(e),i=Hn(t);if(e===t)return{valid:!0,data:e};if(r===J.object&&i===J.object){let n=Te.objectKeys(t),a=Te.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=pw(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(r===J.array&&i===J.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=pw(o,s);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===J.date&&i===J.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var fo=class extends be{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(a,o)=>{if(_f(a)||_f(o))return oe;let s=pw(a.value,o.value);return s.valid?((yf(a)||yf(o))&&r.dirty(),{status:r.value,value:s.data}):(V(i,{code:M.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}))}};fo.create=(e,t,r)=>new fo({left:e,right:t,typeName:D.ZodIntersection,...ge(r)});var qn=class e extends be{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.array)return V(i,{code:M.invalid_type,expected:J.array,received:i.parsedType}),oe;if(i.data.length<this._def.items.length)return V(i,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&i.data.length>this._def.items.length&&(V(i,{code:M.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 Hr(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})}};qn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new qn({items:e,typeName:D.ZodTuple,rest:null,...ge(t)})};var bf=class e extends be{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!==J.object)return V(i,{code:M.invalid_type,expected:J.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 Hr(i,s,i.path,s)),value:o._parse(new Hr(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 be?new e({keyType:t,valueType:r,typeName:D.ZodRecord,...ge(i)}):new e({keyType:ca.create(),valueType:t,typeName:D.ZodRecord,...ge(r)})}},Ds=class extends be{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!==J.map)return V(i,{code:M.invalid_type,expected:J.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 Hr(i,s,i.path,[u,"key"])),value:a._parse(new Hr(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}}}};Ds.create=(e,t,r)=>new Ds({valueType:t,keyType:e,typeName:D.ZodMap,...ge(r)});var Ls=class e extends be{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.set)return V(i,{code:M.invalid_type,expected:J.set,received:i.parsedType}),oe;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(V(i,{code:M.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&&(V(i,{code:M.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 Hr(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,...ge(t)});var wf=class e extends be{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.function)return V(r,{code:M.invalid_type,expected:J.function,received:r.parsedType}),oe;function i(s,c){return ku({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ps(),vi].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function n(s,c){return ku({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ps(),vi].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof la){let s=this;return Mt(async function(...c){let u=new fr([]),l=await s._def.args.parseAsync(c,a).catch(f=>{throw u.addIssue(i(c,f)),u}),d=await Reflect.apply(o,this,l);return await s._def.returns._def.type.parseAsync(d,a).catch(f=>{throw u.addIssue(n(d,f)),u})})}else{let s=this;return Mt(function(...c){let u=s._def.args.safeParse(c,a);if(!u.success)throw new fr([i(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=s._def.returns.safeParse(l,a);if(!d.success)throw new fr([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:qn.create(t).rest(wi.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||qn.create([]).rest(wi.create()),returns:r||wi.create(),typeName:D.ZodFunction,...ge(i)})}},mo=class extends be{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,...ge(t)});var ho=class extends be{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return V(r,{received:r.data,code:M.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,...ge(t)});function cA(e,t){return new go({values:e,typeName:D.ZodEnum,...ge(t)})}var go=class e extends be{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return V(r,{expected:Te.joinValues(i),received:r.parsedType,code:M.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 V(r,{received:r.data,code:M.invalid_enum_value,options:i}),oe}return Mt(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=cA;var _o=class extends be{_parse(t){let r=Te.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==J.string&&i.parsedType!==J.number){let n=Te.objectValues(r);return V(i,{expected:Te.joinValues(n),received:i.parsedType,code:M.invalid_type}),oe}if(this._cache||(this._cache=new Set(Te.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=Te.objectValues(r);return V(i,{received:i.data,code:M.invalid_enum_value,options:n}),oe}return Mt(t.data)}get enum(){return this._def.values}};_o.create=(e,t)=>new _o({values:e,typeName:D.ZodNativeEnum,...ge(t)});var la=class extends be{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.promise&&r.common.async===!1)return V(r,{code:M.invalid_type,expected:J.promise,received:r.parsedType}),oe;let i=r.parsedType===J.promise?r.data:Promise.resolve(r.data);return Mt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};la.create=(e,t)=>new la({type:e,typeName:D.ZodPromise,...ge(t)});var qr=class extends be{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=>{V(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(!sa(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=>sa(o)?Promise.resolve(n.transform(o.value,a)).then(s=>({status:r.value,value:s})):oe);Te.assertNever(n)}};qr.create=(e,t,r)=>new qr({schema:e,typeName:D.ZodEffects,effect:t,...ge(r)});qr.createWithPreprocess=(e,t,r)=>new qr({schema:t,effect:{type:"preprocess",transform:e},typeName:D.ZodEffects,...ge(r)});var Gr=class extends be{_parse(t){return this._getType(t)===J.undefined?Mt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Gr.create=(e,t)=>new Gr({innerType:e,typeName:D.ZodOptional,...ge(t)});var Jn=class extends be{_parse(t){return this._getType(t)===J.null?Mt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Jn.create=(e,t)=>new Jn({innerType:e,typeName:D.ZodNullable,...ge(t)});var yo=class extends be{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===J.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,...ge(t)});var vo=class extends be{_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 Rs(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new fr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new fr(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,...ge(t)});var Us=class extends be{_parse(t){if(this._getType(t)!==J.nan){let i=this._getOrReturnCtx(t);return V(i,{code:M.invalid_type,expected:J.nan,received:i.parsedType}),oe}return{status:"valid",value:t.data}}};Us.create=e=>new Us({typeName:D.ZodNaN,...ge(e)});var CB=Symbol("zod_brand"),$u=class extends be{_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}},Eu=class e extends be{_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 be{_parse(t){let r=this._def.innerType._parse(t),i=n=>(sa(n)&&(n.value=Object.freeze(n.value)),n);return Rs(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};bo.create=(e,t)=>new bo({innerType:e,typeName:D.ZodReadonly,...ge(t)});function iA(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function uA(e,t={},r){return e?ua.create().superRefine((i,n)=>{let a=e(i);if(a instanceof Promise)return a.then(o=>{if(!o){let s=iA(t,i),c=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=iA(t,i),s=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:s})}}):ua.create()}var AB={object:mr.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 NB=(e,t={message:`Input not instance of ${e.name}`})=>uA(r=>r instanceof e,t),lA=ca.create,dA=ao.create,PB=Us.create,RB=oo.create,pA=so.create,jB=co.create,MB=Ms.create,zB=uo.create,DB=lo.create,LB=ua.create,UB=wi.create,FB=fn.create,BB=zs.create,VB=xi.create,ZB=mr.create,GB=mr.strictCreate,HB=po.create,qB=vf.create,JB=fo.create,KB=qn.create,WB=bf.create,XB=Ds.create,YB=Ls.create,QB=wf.create,e9=mo.create,t9=ho.create,r9=go.create,n9=_o.create,i9=la.create,a9=qr.create,o9=Gr.create,s9=Jn.create,c9=qr.createWithPreprocess,u9=Eu.create,l9=()=>lA().optional(),d9=()=>dA().optional(),p9=()=>pA().optional(),f9={string:(e=>ca.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 m9=oe;function fA(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&&Ce(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ce(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ce(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ce(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function mA(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?Ce(r,"minimum",i.value,i.message,t):Ce(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ce(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ce(r,"maximum",i.value,i.message,t):Ce(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ce(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ce(r,"multipleOf",i.value,i.message,t);break}return r}function hA(){return{type:"boolean"}}function xf(e,t){return se(e.type._def,t)}var gA=(e,t)=>se(e.innerType._def,t);function fw(e,t,r){let i=r??t.dateStrategy;if(Array.isArray(i))return{anyOf:i.map(n=>fw(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 h9(e,t)}}var h9=(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":Ce(r,"minimum",i.value,i.message,t);break;case"max":Ce(r,"maximum",i.value,i.message,t);break}return r};function _A(e,t){return{...se(e.innerType._def,t),default:e.defaultValue()}}function yA(e,t){return t.effectStrategy==="input"?se(e.schema._def,t):Ye(t)}function vA(e){return{type:"string",enum:Array.from(e.values)}}var g9=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function bA(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(g9(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 wA(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 mw,mn={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:()=>(mw===void 0&&(mw=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),mw),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 Sf(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Ce(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":hn(r,"email",i.message,t);break;case"format:idn-email":hn(r,"idn-email",i.message,t);break;case"pattern:zod":tr(r,mn.email,i.message,t);break}break;case"url":hn(r,"uri",i.message,t);break;case"uuid":hn(r,"uuid",i.message,t);break;case"regex":tr(r,i.regex,i.message,t);break;case"cuid":tr(r,mn.cuid,i.message,t);break;case"cuid2":tr(r,mn.cuid2,i.message,t);break;case"startsWith":tr(r,RegExp(`^${hw(i.value,t)}`),i.message,t);break;case"endsWith":tr(r,RegExp(`${hw(i.value,t)}$`),i.message,t);break;case"datetime":hn(r,"date-time",i.message,t);break;case"date":hn(r,"date",i.message,t);break;case"time":hn(r,"time",i.message,t);break;case"duration":hn(r,"duration",i.message,t);break;case"length":Ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Ce(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":tr(r,RegExp(hw(i.value,t)),i.message,t);break;case"ip":i.version!=="v6"&&hn(r,"ipv4",i.message,t),i.version!=="v4"&&hn(r,"ipv6",i.message,t);break;case"base64url":tr(r,mn.base64url,i.message,t);break;case"jwt":tr(r,mn.jwt,i.message,t);break;case"cidr":i.version!=="v6"&&tr(r,mn.ipv4Cidr,i.message,t),i.version!=="v4"&&tr(r,mn.ipv6Cidr,i.message,t);break;case"emoji":tr(r,mn.emoji(),i.message,t);break;case"ulid":tr(r,mn.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":hn(r,"binary",i.message,t);break;case"contentEncoding:base64":Ce(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":tr(r,mn.base64,i.message,t);break}break;case"nanoid":tr(r,mn.nanoid,i.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function hw(e,t){return t.patternStrategy==="escape"?y9(e):e}var _9=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function y9(e){let t="";for(let r=0;r<e.length;r++)_9.has(e[r])||(t+="\\"),t+=e[r];return t}function hn(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}}})):Ce(e,"format",t,r,i)}function tr(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:xA(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Ce(e,"pattern",xA(t,i),r,i)}function xA(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
102
+ ]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
103
+ ]))`;continue}}if(r.s&&i[c]==="."){n+=o?`${i[c]}\r
104
+ `:`[${i[c]}\r
105
+ ]`;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 kf(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]})??Ye(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}=Sf(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}=xf(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function SA(e,t){return t.mapStrategy==="record"?kf(e,t):{type:"array",maxItems:125,items:{type:"array",items:[se(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ye(t),se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ye(t)],minItems:2,maxItems:2}}}function kA(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 $A(e){return e.target==="openAi"?void 0:{not:Ye({...e,currentPath:[...e.currentPath,"not"]})}}function EA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Iu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function TA(e,t){if(t.target==="openApi3")return IA(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(i=>i._def.typeName in Iu&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,a)=>{let o=Iu[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 IA(e,t)}var IA=(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 OA(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:Iu[e.innerType._def.typeName],nullable:!0}:{type:[Iu[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 CA(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",uw(r,"type",i.message,t);break;case"min":t.target==="jsonSchema7"?i.inclusive?Ce(r,"minimum",i.value,i.message,t):Ce(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ce(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ce(r,"maximum",i.value,i.message,t):Ce(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ce(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ce(r,"multipleOf",i.value,i.message,t);break}return r}function AA(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=b9(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=v9(e,t);return o!==void 0&&(i.additionalProperties=o),i}function v9(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 b9(e){try{return e.isOptional()}catch{return!0}}var NA=(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:Ye(t)},r]}:Ye(t)};var PA=(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 RA(e,t){return se(e.type._def,t)}function jA(e,t){let r={type:"array",uniqueItems:!0,items:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ce(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ce(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function MA(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 zA(e){return{not:Ye(e)}}function DA(e){return Ye(e)}var LA=(e,t)=>se(e.innerType._def,t);var UA=(e,t,r)=>{switch(t){case D.ZodString:return Sf(e,r);case D.ZodNumber:return CA(e,r);case D.ZodObject:return AA(e,r);case D.ZodBigInt:return mA(e,r);case D.ZodBoolean:return hA();case D.ZodDate:return fw(e,r);case D.ZodUndefined:return zA(r);case D.ZodNull:return EA(r);case D.ZodArray:return fA(e,r);case D.ZodUnion:case D.ZodDiscriminatedUnion:return TA(e,r);case D.ZodIntersection:return bA(e,r);case D.ZodTuple:return MA(e,r);case D.ZodRecord:return kf(e,r);case D.ZodLiteral:return wA(e,r);case D.ZodEnum:return vA(e);case D.ZodNativeEnum:return kA(e);case D.ZodNullable:return OA(e,r);case D.ZodOptional:return NA(e,r);case D.ZodMap:return SA(e,r);case D.ZodSet:return jA(e,r);case D.ZodLazy:return()=>e.getter()._def;case D.ZodPromise:return RA(e,r);case D.ZodNaN:case D.ZodNever:return $A(r);case D.ZodEffects:return yA(e,r);case D.ZodAny:return Ye(r);case D.ZodUnknown:return DA(r);case D.ZodDefault:return _A(e,r);case D.ZodBranded:return xf(e,r);case D.ZodReadonly:return LA(e,r);case D.ZodCatch:return gA(e,r);case D.ZodPipeline:return PA(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!==QC)return s}if(i&&!r){let s=w9(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=UA(e,e.typeName,t),o=typeof a=="function"?se(a(),t):a;if(o&&x9(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var w9=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:gf(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`),Ye(t)):t.$refStrategy==="seen"?Ye(t):void 0}},x9=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var FA=(e,t)=>{let r=tA(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)??Ye(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)??Ye(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 Kn(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(!Kn(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(!Kn(e[o],t[o]))return!1;return!0}return e===t}function Or(e){return encodeURI(S9(e))}function S9(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var k9={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},$9={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},E9={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},I9=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 gn(e,t=Object.create(null),r=I9,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:gn(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(E9[a])continue;let o=`${i}/${Or(a)}`,s=e[a];if(Array.isArray(s)){if(k9[a]){let c=s.length;for(let u=0;u<c;u++)gn(s[u],t,r,`${o}/${u}`)}}else if($9[a])for(let c in s)gn(s[c],t,r,`${o}/${Or(c)}`);else gn(s,t,r,o)}return t}var T9=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,O9=[0,31,28,31,30,31,30,31,31,30,31,30,31],C9=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,A9=/^(?=.{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,N9=/^(?:[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,P9=/^(?:(?:[^\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,R9=/^(?:(?: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,j9=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,M9=/^(?:\/(?:[^~/]|~0|~1)*)*$/,z9=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,D9=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,L9=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))},U9=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,F9=/^((([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,B9=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 Wn(e){return e.test.bind(e)}var gw={date:BA,time:VA.bind(void 0,!1),"date-time":G9,duration:B9,uri:J9,"uri-reference":Wn(N9),"uri-template":Wn(P9),url:Wn(R9),email:L9,hostname:Wn(A9),ipv4:Wn(U9),ipv6:Wn(F9),regex:W9,uuid:Wn(j9),"json-pointer":Wn(M9),"json-pointer-uri-fragment":Wn(z9),"relative-json-pointer":Wn(D9)};function V9(e){return e%4===0&&(e%100!==0||e%400===0)}function BA(e){let t=e.match(T9);if(!t)return!1;let r=+t[1],i=+t[2],n=+t[3];return i>=1&&i<=12&&n>=1&&n<=(i==2&&V9(r)?29:O9[i])}function VA(e,t){let r=t.match(C9);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 Z9=/t|\s/i;function G9(e){let t=e.split(Z9);return t.length==2&&BA(t[0])&&VA(!0,t[1])}var H9=/\/|:/,q9=/^(?:[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 J9(e){return H9.test(e)&&q9.test(e)}var K9=/[^\\]\\Z/;function W9(e){if(K9.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var ZA;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(ZA||(ZA={}));function GA(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=gn(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:p,$recursiveAnchor:f,type:m,const:_,enum:v,required:k,not:w,anyOf:x,allOf:$,oneOf:T,if:B,then:O,else:y,format:K,properties:A,patternProperties:F,additionalProperties:he,unevaluatedProperties:Ze,minProperties:Vt,maxProperties:In,propertyNames:$e,dependentRequired:wa,dependentSchemas:ii,dependencies:xa,prefixItems:Yr,items:ai,additionalItems:mc,unevaluatedItems:hc,contains:gc,minContains:Qr,maxContains:g,minItems:h,maxItems:C,uniqueItems:S,minimum:Ee,maximum:je,exclusiveMinimum:gt,exclusiveMaximum:ct,multipleOf:At,minLength:Nr,maxLength:ut,pattern:Tn,__absolute_ref__:Ro,__absolute_recursive_ref__:Sl}=t,q=[];if(f===!0&&a===null&&(a=t),p==="#"){let ce=a===null?i[Sl]:a,ne=`${s}/$recursiveRef`,pe=Ve(e,a===null?t:a,r,i,n,ce,o,ne,c);pe.valid||q.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:ne,error:"A subschema had errors."},...pe.errors)}if(d!==void 0){let ne=i[Ro||d];if(ne===void 0){let G=`Unresolved $ref "${d}".`;throw Ro&&Ro!==d&&(G+=` Absolute URI "${Ro}".`),G+=`
106
+ Known schemas:
107
+ - ${Object.keys(i).join(`
108
+ - `)}`,new Error(G)}let pe=`${s}/$ref`,Y=Ve(e,ne,r,i,n,a,o,pe,c);if(Y.valid||q.push({instanceLocation:o,keyword:"$ref",keywordLocation:pe,error:"A subschema had errors."},...Y.errors),r==="4"||r==="7")return{valid:q.length===0,errors:q}}if(Array.isArray(m)){let ce=m.length,ne=!1;for(let pe=0;pe<ce;pe++)if(l===m[pe]||m[pe]==="integer"&&l==="number"&&e%1===0&&e===e){ne=!0;break}ne||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(_!==void 0&&(l==="object"||l==="array"?Kn(e,_)||q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(_)}.`}):e!==_&&q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(_)}.`})),v!==void 0&&(l==="object"||l==="array"?v.some(ce=>Kn(e,ce))||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(ce=>e===ce)||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),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 Sa=[];if(x!==void 0){let ce=`${s}/anyOf`,ne=q.length,pe=!1;for(let Y=0;Y<x.length;Y++){let G=x[Y],le=Object.create(c),ue=Ve(e,G,r,i,n,f===!0?a:null,o,`${ce}/${Y}`,le);q.push(...ue.errors),pe=pe||ue.valid,ue.valid&&Sa.push(le)}pe?q.length=ne:q.splice(ne,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:ce,error:"Instance does not match any subschemas."})}if($!==void 0){let ce=`${s}/allOf`,ne=q.length,pe=!0;for(let Y=0;Y<$.length;Y++){let G=$[Y],le=Object.create(c),ue=Ve(e,G,r,i,n,f===!0?a:null,o,`${ce}/${Y}`,le);q.push(...ue.errors),pe=pe&&ue.valid,ue.valid&&Sa.push(le)}pe?q.length=ne:q.splice(ne,0,{instanceLocation:o,keyword:"allOf",keywordLocation:ce,error:"Instance does not match every subschema."})}if(T!==void 0){let ce=`${s}/oneOf`,ne=q.length,pe=T.filter((Y,G)=>{let le=Object.create(c),ue=Ve(e,Y,r,i,n,f===!0?a:null,o,`${ce}/${G}`,le);return q.push(...ue.errors),ue.valid&&Sa.push(le),ue.valid}).length;pe===1?q.length=ne:q.splice(ne,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:ce,error:`Instance does not match exactly one subschema (${pe} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...Sa),B!==void 0){let ce=`${s}/if`;if(Ve(e,B,r,i,n,a,o,ce,c).valid){if(O!==void 0){let pe=Ve(e,O,r,i,n,a,o,`${s}/then`,c);pe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "then" schema.'},...pe.errors)}}else if(y!==void 0){let pe=Ve(e,y,r,i,n,a,o,`${s}/else`,c);pe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "else" schema.'},...pe.errors)}}if(l==="object"){if(k!==void 0)for(let Y of k)Y in e||q.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${Y}".`});let ce=Object.keys(e);if(Vt!==void 0&&ce.length<Vt&&q.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${Vt} properties.`}),In!==void 0&&ce.length>In&&q.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${In} properties.`}),$e!==void 0){let Y=`${s}/propertyNames`;for(let G in e){let le=`${o}/${Or(G)}`,ue=Ve(G,$e,r,i,n,a,le,Y);ue.valid||q.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:Y,error:`Property name "${G}" does not match schema.`},...ue.errors)}}if(wa!==void 0){let Y=`${s}/dependantRequired`;for(let G in wa)if(G in e){let le=wa[G];for(let ue of le)ue in e||q.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:Y,error:`Instance has "${G}" but does not have "${ue}".`})}}if(ii!==void 0)for(let Y in ii){let G=`${s}/dependentSchemas`;if(Y in e){let le=Ve(e,ii[Y],r,i,n,a,o,`${G}/${Or(Y)}`,c);le.valid||q.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:G,error:`Instance has "${Y}" but does not match dependant schema.`},...le.errors)}}if(xa!==void 0){let Y=`${s}/dependencies`;for(let G in xa)if(G in e){let le=xa[G];if(Array.isArray(le))for(let ue of le)ue in e||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Y,error:`Instance has "${G}" but does not have "${ue}".`});else{let ue=Ve(e,le,r,i,n,a,o,`${Y}/${Or(G)}`);ue.valid||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Y,error:`Instance has "${G}" but does not match dependant schema.`},...ue.errors)}}}let ne=Object.create(null),pe=!1;if(A!==void 0){let Y=`${s}/properties`;for(let G in A){if(!(G in e))continue;let le=`${o}/${Or(G)}`,ue=Ve(e[G],A[G],r,i,n,a,le,`${Y}/${Or(G)}`);if(ue.valid)c[G]=ne[G]=!0;else if(pe=n,q.push({instanceLocation:o,keyword:"properties",keywordLocation:Y,error:`Property "${G}" does not match schema.`},...ue.errors),pe)break}}if(!pe&&F!==void 0){let Y=`${s}/patternProperties`;for(let G in F){let le=new RegExp(G,"u"),ue=F[G];for(let ir in e){if(!le.test(ir))continue;let vS=`${o}/${Or(ir)}`,bS=Ve(e[ir],ue,r,i,n,a,vS,`${Y}/${Or(G)}`);bS.valid?c[ir]=ne[ir]=!0:(pe=n,q.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:Y,error:`Property "${ir}" matches pattern "${G}" but does not match associated schema.`},...bS.errors))}}}if(!pe&&he!==void 0){let Y=`${s}/additionalProperties`;for(let G in e){if(ne[G])continue;let le=`${o}/${Or(G)}`,ue=Ve(e[G],he,r,i,n,a,le,Y);ue.valid?c[G]=!0:(pe=n,q.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:Y,error:`Property "${G}" does not match additional properties schema.`},...ue.errors))}}else if(!pe&&Ze!==void 0){let Y=`${s}/unevaluatedProperties`;for(let G in e)if(!c[G]){let le=`${o}/${Or(G)}`,ue=Ve(e[G],Ze,r,i,n,a,le,Y);ue.valid?c[G]=!0:q.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:Y,error:`Property "${G}" does not match unevaluated properties schema.`},...ue.errors)}}}else if(l==="array"){C!==void 0&&e.length>C&&q.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${C}).`}),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,ne=0,pe=!1;if(Yr!==void 0){let Y=`${s}/prefixItems`,G=Math.min(Yr.length,ce);for(;ne<G;ne++){let le=Ve(e[ne],Yr[ne],r,i,n,a,`${o}/${ne}`,`${Y}/${ne}`);if(c[ne]=!0,!le.valid&&(pe=n,q.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:Y,error:"Items did not match schema."},...le.errors),pe))break}}if(ai!==void 0){let Y=`${s}/items`;if(Array.isArray(ai)){let G=Math.min(ai.length,ce);for(;ne<G;ne++){let le=Ve(e[ne],ai[ne],r,i,n,a,`${o}/${ne}`,`${Y}/${ne}`);if(c[ne]=!0,!le.valid&&(pe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:Y,error:"Items did not match schema."},...le.errors),pe))break}}else for(;ne<ce;ne++){let G=Ve(e[ne],ai,r,i,n,a,`${o}/${ne}`,Y);if(c[ne]=!0,!G.valid&&(pe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:Y,error:"Items did not match schema."},...G.errors),pe))break}if(!pe&&mc!==void 0){let G=`${s}/additionalItems`;for(;ne<ce;ne++){let le=Ve(e[ne],mc,r,i,n,a,`${o}/${ne}`,G);c[ne]=!0,le.valid||(pe=n,q.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:G,error:"Items did not match additional items schema."},...le.errors))}}}if(gc!==void 0)if(ce===0&&Qr===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(Qr!==void 0&&ce<Qr)q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${ce}) than minContains (${Qr}).`});else{let Y=`${s}/contains`,G=q.length,le=0;for(let ue=0;ue<ce;ue++){let ir=Ve(e[ue],gc,r,i,n,a,`${o}/${ue}`,Y);ir.valid?(c[ue]=!0,le++):q.push(...ir.errors)}le>=(Qr||0)&&(q.length=G),Qr===void 0&&g===void 0&&le===0?q.splice(G,0,{instanceLocation:o,keyword:"contains",keywordLocation:Y,error:"Array does not contain item matching schema."}):Qr!==void 0&&le<Qr?q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Qr} items matching schema. Only ${le} items were found.`}):g!==void 0&&le>g&&q.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${g} items matching schema. ${le} items were found.`})}if(!pe&&hc!==void 0){let Y=`${s}/unevaluatedItems`;for(ne;ne<ce;ne++){if(c[ne])continue;let G=Ve(e[ne],hc,r,i,n,a,`${o}/${ne}`,Y);c[ne]=!0,G.valid||q.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:Y,error:"Items did not match unevaluated items schema."},...G.errors)}}if(S)for(let Y=0;Y<ce;Y++){let G=e[Y],le=typeof G=="object"&&G!==null;for(let ue=0;ue<ce;ue++){if(Y===ue)continue;let ir=e[ue];(G===ir||le&&(typeof ir=="object"&&ir!==null)&&Kn(G,ir))&&(q.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${Y} and ${ue}.`}),Y=Number.MAX_SAFE_INTEGER,ue=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(Ee!==void 0&&(gt===!0&&e<=Ee||e<Ee)&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${gt?"or equal to ":""} ${Ee}.`}),je!==void 0&&(ct===!0&&e>=je||e>je)&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${ct?"or equal to ":""} ${je}.`})):(Ee!==void 0&&e<Ee&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${Ee}.`}),je!==void 0&&e>je&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${je}.`}),gt!==void 0&&e<=gt&&q.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${gt}.`}),ct!==void 0&&e>=ct&&q.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${ct}.`})),At!==void 0){let ce=e%At;Math.abs(0-ce)>=11920929e-14&&Math.abs(At-ce)>=11920929e-14&&q.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${At}.`})}}else if(l==="string"){let ce=Nr===void 0&&ut===void 0?0:GA(e);Nr!==void 0&&ce<Nr&&q.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${ce} < ${Nr}).`}),ut!==void 0&&ce>ut&&q.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${ce} > ${ut}).`}),Tn!==void 0&&!new RegExp(Tn,"u").test(e)&&q.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),K!==void 0&&gw[K]&&!gw[K](e)&&q.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${K}".`})}return{valid:q.length===0,errors:q}}var $f=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=gn(t)}validate(t){return Ve(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),gn(t,this.lookup)}};var qA=I({Validator:()=>$f,deepCompareStrict:()=>Kn,toJsonSchema:()=>bt,validatesOnlyStrings:()=>Fs}),HA=new WeakMap;function bt(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let n=HA.get(e);if(n)return n}let i;if(ap(e)&&!Be(e))i=e["~standard"].jsonSchema.input({target:"draft-07"});else if(Be(e)){let n=mf(e,!0);Zr(n)?i=to(Os(n,!0),t):i=to(e,t)}else ot(e)?i=FA(e):i=e;return r&&i!=null&&typeof i=="object"&&HA.set(e,i),i}function Fs(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=>Fs(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=>Fs(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=gn(e);return r[t]?Fs(r[t]):!1}return!1}function Tu(e){return e?e.lc_runnable:!1}var JA=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}},KA=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function _w(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var X9=["*","_","`"];function Y9(e){let t="";for(let[r,i]of Object.entries(e))t+=` classDef ${r} ${i};
109
+ `;return t}function WA(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}'}}}%%
110
+ graph TD;
111
+ `:`graph TD;
112
+ `;if(o){let m="default",_={[m]:"{0}({1})"};i!==void 0&&(_[i]="{0}([{1}]):::first"),n!==void 0&&(_[n]="{0}([{1}]):::last");for(let[v,k]of Object.entries(e)){let w=k.name.split(":").pop()??"",x=X9.some(T=>w.startsWith(T)&&w.endsWith(T))?`<p>${w}</p>`:w;Object.keys(k.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(k.metadata??{}).map(([T,B])=>`${T} = ${B}`).join(`
113
+ `)}</em></small>`);let $=(_[v]??_[m]).replace("{0}",_w(v)).replace("{1}",x);u+=` ${$}
114
+ `}}let l={};for(let m of t){let _=m.source.split(":"),v=m.target.split(":"),k=_.filter((w,x)=>w===v[x]).join(":");l[k]||(l[k]=[]),l[k].push(m)}let d=new Set;function p(m){return[...m].sort((_,v)=>_.split(":").length-v.split(":").length)}function f(m,_){let v=m.length===1&&m[0].source===m[0].target;if(_&&!v){let w=_.split(":").pop();if(d.has(_))throw new Error(`Found duplicate subgraph '${w}' at '${_} -- 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(_),u+=` subgraph ${w}
115
+ `}let k=p(Object.keys(l).filter(w=>w.startsWith(`${_}:`)&&w!==_&&w.split(":").length===_.split(":").length+1));for(let w of k)f(l[w],w);for(let w of m){let{source:x,target:$,data:T,conditional:B}=w,O="";if(T!==void 0){let y=T,K=y.split(" ");K.length>c&&(y=Array.from({length:Math.ceil(K.length/c)},(A,F)=>K.slice(F*c,(F+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),O=B?` -. &nbsp;${y}&nbsp; .-> `:` -- &nbsp;${y}&nbsp; --> `}else O=B?" -.-> ":" --> ";u+=` ${_w(x)}${O}${_w($)};
116
+ `}_&&!v&&(u+=` end
117
+ `)}f(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&f(l[m],m);return o&&(u+=Y9(a??{})),u}async function XA(e,t){let r=t?.backgroundColor??"white",i=t?.imageType??"png",n=KA(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(`
118
+ `));return await o.blob()}var eN=I({Graph:()=>wo});function Q9(e,t){if(e!==void 0&&!Li(e))return e;if(Tu(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 eV(e){return Tu(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...bt(e.data.schema),title:e.data.name}}}var wo=class tN{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]=Li(r.id)?i:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...eV(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??Xh(),a={id:n,data:t,name:Q9(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 YA(this)}lastNode(){return QA(this)}extend(t,r=""){let i=r;Object.values(t.nodes).map(c=>c.id).every(Li)&&(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&&YA(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&QA(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 Li(n)&&r.get(a)===1?a:n};return new tN({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 WA(o.nodes,o.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:i,nodeColors:n,wrapLabelNWords:a})}async drawMermaidPng(t){return XA(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function YA(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 QA(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 Ef({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 rN=e=>e.name==="event_stream_tracer",nN=class extends Ot{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=mt.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 fi({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=Ef(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 vt({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 fi({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=Ef(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=Ef(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=Ef(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 yw=class extends Ot{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 iN(e){let t=new TextEncoder,r=new ReadableStream({async start(i){for await(let n of e)i.enqueue(t.encode(`event: data
119
+ data: ${JSON.stringify(n)}
120
+
121
+ `));i.enqueue(t.encode(`event: end
122
+
123
+ `)),i.close()}});return mt.fromReadableStream(r)}function vw(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var aN=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function If(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function bw(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function oN(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*ww(e,t){for(;;){let{value:r,done:i}=Oe.runWithConfig(ur(e),t.next.bind(t),!0);if(i)break;yield r}}async function*Tf(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:i,done:n}=await Oe.runWithConfig(ur(e),r.next.bind(t),!0);if(n)break;yield i}}function ht(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var ae=class extends lt{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 Cf({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Jr({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new xw({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(Se);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)=>Se(n===0?e:r))}return Array.from({length:t},()=>Se(e))}async batch(e,t,r){let i=this._getOptionsList(t??{},e.length),n=new mi({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=Se(t),i=new Gi({generator:this._streamIterator(e,r),config:r});return await i.setup,mt.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Se(e):t=Se({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=Se(r),n=await(await xt(i))?.handleChainStart(this.toJSON(),ht(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(ht(a,"output")),a}async _batchWithConfig(e,t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(xt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),ht(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(ht(s,"output")))),s}_concatOutputChunks(e,t){return $r(e,t)}async*_transformStreamWithConfig(e,t,r){let i,n=!0,a,o=!0,s=Se(r),c=await xt(s),u=this;async function*l(){for await(let p of e){if(n)if(i===void 0)i=p;else try{i=u._concatOutputChunks(i,p)}catch{i=void 0,n=!1}yield p}}let d;try{let p=await __(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=p.setup;let f=d?.handlers.find(rN),m=p.output;f!==void 0&&d!==void 0&&(m=f.tapOutputIterable(d.runId,m));let _=d?.handlers.find(v_);_!==void 0&&d!==void 0&&(m=_.tapOutputIterable(d.runId,m));for await(let v of m)if(yield v,o)if(a===void 0)a=v;else try{a=this._concatOutputChunks(a,v)}catch{a=void 0,o=!1}}catch(p){throw await d?.handleChainError(p,void 0,void 0,void 0,{inputs:ht(i,"input")}),p}await d?.handleChainEnd(a??{},void 0,void 0,void 0,{inputs:ht(i,"input")})}getGraph(e){let t=new wo,r=t.addNode({name:`${this.getName()}Input`,schema:kt.any()}),i=t.addNode(this),n=t.addNode({name:`${this.getName()}Output`,schema:kt.any()});return t.addEdge(r,i),t.addEdge(i,n),t}pipe(e){return new Cr({first:this,last:rt(e)})}pick(e){return this.pipe(new Sw(e))}assign(e){return this.pipe(new Cu(new da({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,Se(t))}async*streamLog(e,t,r){let i=new rp({...r,autoClose:!1,_schemaFormat:"original"}),n=Se(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 Bn({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"?iN(i):mt.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){let i=new nN({...r,autoClose:!1}),n=Se(t),a=n.runId??Dr();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 f=o.copy();f.addHandler(i,!0),n.callbacks=f}let s=new AbortController,c=this;async function u(){let f;try{if(n.signal)if("any"in AbortSignal)f=AbortSignal.any([s.signal,n.signal]);else{let v=new AbortController;n.signal.addEventListener("abort",()=>v.abort(),{once:!0}),s.signal.addEventListener("abort",()=>v.abort(),{once:!0}),f=v.signal}else f=s.signal;let m=await c.stream(e,{...n,signal:f}),_=i.tapOutputIterable(a,m);for await(let v of _)if(s.signal.aborted)break}finally{await i.finish()}}let l=u(),d=!1,p;try{for await(let f of i){if(!d){f.data.input=e,d=!0,p=f.run_id,yield f;continue}f.run_id===p&&f.event.endsWith("_end")&&f.data?.input&&delete f.data.input,yield f}}finally{s.abort(),await l}}async*_streamEventsV1(e,t,r){let i,n=!1,a=Se(t),o=a.tags??[],s=a.metadata??{},c=a.runName??this.getName(),u=new rp({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new JA({...r}),d=this._streamLog(e,u,a);for await(let f of d){if(i?i=i.concat(f):i=tp.fromRunLogPatch(f),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!n){n=!0;let k={...i.state},w={run_id:k.id,event:`on_${k.type}_start`,name:c,tags:o,metadata:s,data:{input:e}};l.includeEvent(w,k.type)&&(yield w)}let m=f.ops.filter(k=>k.path.startsWith("/logs/")).map(k=>k.path.split("/")[2]),_=[...new Set(m)];for(let k of _){let w,x={},$=i.state.logs[k];if($.end_time===void 0?$.streamed_output.length>0?w="stream":w="start":w="end",w==="start")$.inputs!==void 0&&(x.input=$.inputs);else if(w==="end")$.inputs!==void 0&&(x.input=$.inputs),x.output=$.final_output;else if(w==="stream"){let T=$.streamed_output.length;if(T!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${T} instead. Encountered in: "${$.name}"`);x={chunk:$.streamed_output[0]},$.streamed_output=[]}yield{event:`on_${$.type}_${w}`,name:$.name,run_id:$.id,tags:$.tags,metadata:$.metadata,data:x}}let{state:v}=i;if(v.streamed_output.length>0){let k=v.streamed_output.length;if(k!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${k} instead. Encountered in: "${v.name}"`);let w={chunk:v.streamed_output[0]};v.streamed_output=[];let x={event:`on_${v.type}_stream`,run_id:v.id,tags:o,metadata:s,name:c,data:w};l.includeEvent(x,v.type)&&(yield x)}}let p=i?.state;if(p!==void 0){let f={event:`on_${p.type}_end`,name:c,run_id:p.id,tags:o,metadata:s,data:{output:p.final_output}};l.includeEvent(f,p.type)&&(yield f)}}static isRunnable(e){return Tu(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Jr({bound:this,config:{},configFactories:[i=>({callbacks:[new yw({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return nV(this,e)}},Jr=class sN 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=St(this.config,...t);return St(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 Cf({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(Se(a),this.kwargs))):await this._mergeConfig(Se(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(Se(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(Se(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(Se(r),this.kwargs))}streamEvents(t,r,i){let n=this,a=async function*(){yield*n.bound.streamEvents(t,{...await n._mergeConfig(Se(r),n.kwargs),version:r.version},i)};return mt.fromAsyncGenerator(a())}static isRunnableBinding(t){return t.bound&&ae.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:i}){return new sN({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new yw({config:n,onStart:t,onEnd:r,onError:i})]})]})}},cN=class uN 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,Ie(r,{callbacks:i?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:i}){return new uN({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:i})})}},Cf=class extends Jr{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 Ie(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return Xc(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 Xc(async a=>{let o=e.map((d,p)=>p).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 p=u[d],f=o[d];p instanceof Error&&l===void 0&&(l=p,l.input=s[d]),n[f.toString()]=p}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 Ou 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=Se(r),n=await(await xt(i))?.handleChainStart(this.toJSON(),ht(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,Ie(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),i.signal);if(i.signal?.aborted)throw Zi(i.signal);o=await this.last.invoke(a,Ie(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(ht(o,"output")),o}async batch(t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(xt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),ht(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 Ie(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(ht(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let i=await xt(r),{runId:n,...a}=r??{},o=await i?.handleChainStart(this.toJSON(),ht(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(),Ie(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let p=1;p<s.length;p+=1)d=await s[p].transform(d,Ie(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${p+1}`)}));for await(let p of d)if(r?.signal?.throwIfAborted(),yield p,c)if(u===void 0)u=p;else try{u=this._concatOutputChunks(u,p)}catch{u=void 0,c=!1}}catch(d){throw await o?.handleChainError(d),d}await o?.handleChainEnd(ht(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 Ou.isRunnableSequence(t)?new Ou({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Ou({first:this.first,middle:[...this.middle,this.last],last:rt(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 Ou({...n,first:rt(t),middle:r.slice(0,-1).map(rt),last:rt(r[r.length-1])})}},da=class lN 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]=rt(i)}static from(t){return new lN({steps:t})}async invoke(t,r){let i=Se(r),n=await(await xt(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,Ie(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=Jd(t,Object.keys(n).length),o=new Map(Object.entries(n).map(([s,c],u)=>{let l=c.transform(a[u],Ie(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=Se(r),a=new Gi({generator:this.transform(i(),n),config:n});return await a.setup,mt.fromAsyncGenerator(a)}},tV=class dN extends ae{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Gd(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 xt(i);return kr(this.func(Ie(i,{callbacks:n}),t),i?.signal)}async*_streamIterator(t,r){let[i]=this._getOptionsList(r??{},1),n=await this.invoke(t,r);if(If(n)){for await(let a of n)i?.signal?.throwIfAborted(),yield a;return}if(aN(n)){for(;;){i?.signal?.throwIfAborted();let a=n.next();if(a.done)break;yield a.value}return}yield n}static from(t){return new dN({func:t})}};function rV(e){if(Gd(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var zt=class pN extends ae{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Gd(t.func))return tV.from(t.func);super(t),rV(t.func),this.func=t.func}static from(t){return new pN({func:t})}async _invoke(t,r,i){return new Promise((n,a)=>{let o=Ie(r,{callbacks:i?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Oe.runWithConfig(ur(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(If(s)){let c;for await(let u of Tf(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(vw(s)){let c;for(let u of ww(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=Ie(i,{callbacks:r?.getChild(),recursionLimit:(i?.recursionLimit??25)-1}),o=await new Promise((s,c)=>{Oe.runWithConfig(ur(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(If(o))for await(let s of Tf(a,o))i?.signal?.throwIfAborted(),yield s;else if(vw(o))for(let s of ww(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=Se(r),a=new Gi({generator:this.transform(i(),n),config:n});return await a.setup,mt.fromAsyncGenerator(a)}},fN=class extends da{},xw=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=Se(t),i=await xt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),ht(e,"input"),n,void 0,void 0,void 0,a?.runName),s=Ie(a,{callbacks:o?.getChild()});return await Oe.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(ht(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=Se(t),i=await xt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),ht(e,"input"),n,void 0,void 0,void 0,a?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=Ie(a,{callbacks:o?.getChild()});try{c=Tf(d,await l.stream(e,d));break}catch(p){s===void 0&&(s=p)}}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(ht(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=>xt(s))),a=await Promise.all(n.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),ht(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)=>Ie(i[l],{callbacks:u?.getChild()})),r);return await Promise.all(a.map((u,l)=>u?.handleChainEnd(ht(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 rt(e){if(typeof e=="function")return new zt({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]=rt(i);return new da({steps:t})}else throw new Error(`Expected a Runnable, function or object.
124
+ Instead got an unsupported type.`)}var Cu=class extends ae{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof da&&(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]=Jd(e),o=this.mapper.transform(a,Ie(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=Se(t),n=new Gi({generator:this.transform(r(),i),config:i});return await n.setup,mt.fromAsyncGenerator(n)}},Sw=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=Se(t),n=new Gi({generator:this.transform(r(),i),config:i});return await n.setup,mt.fromAsyncGenerator(n)}},Of=class extends Jr{name;description;schema;constructor(e){let t=Cr.from([zt.from(async r=>{let i;if(Di(r))try{i=await oa(this.schema,r.args)}catch{throw new qo("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 nV(e,t){let r=t.name??e.getName(),i=t.description??yi(t.schema);return As(t.schema)?new Of({name:r,description:i,schema:kt.object({input:kt.string()}).transform(n=>n.input),bound:e}):new Of({name:r,description:i,schema:t.schema,bound:e})}var Af=(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 yN(e,t){return Array.isArray(e)?mN(e,t):zt.from(r=>mN(r,e))}function mN(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&&Af(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&&Af(u,n)||o&&u.id&&o.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function vN(e){return Array.isArray(e)?hN(e):zt.from(hN)}function hN(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=Ma(n),o=Ma(i),s=a.concat(o);typeof a.content=="string"&&typeof o.content=="string"&&(s.content=`${a.content}
125
+ ${o.content}`),t.push(aV(s))}}return t}function bN(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return gN(r,t)}else{let r=e;return zt.from(i=>gN(i,r)).withConfig({runName:"trim_messages"})}}async function gN(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 p=>(await Promise.all(p.map(f=>i.getNumTokens(f.content)))).reduce((f,m)=>f+m,0):l=async p=>i(p);let d=$w;if(u&&("splitText"in u?d=u.splitText:d=async p=>u(p)),n==="first")return wN(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:a?"first":void 0,endOn:o});if(n==="last")return iV(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 wN(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,p=a==="last"?[...l.content].reverse():l.content;for(let f=1;f<=d;f+=1){let m=a==="first"?p.slice(0,f):p.slice(-f),_=Object.fromEntries(Object.entries(l).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),v=kw(l.getType(),{..._,content:m}),k=[...s.slice(0,c),v];if(await i(k)<=r)s=k,c+=1,u=!0;else break}u&&a==="last"&&(l.content=[...p].reverse())}if(!u){let l=s[c],d;if(Array.isArray(l.content)&&l.content.some(p=>typeof p=="string"||p.type==="text")?d=l.content.find(p=>p.type==="text"&&p.text)?.text:typeof l.content=="string"&&(d=l.content),d){let p=await n(d),f=p.length;a==="last"&&p.reverse();for(let m=0;m<f-1;m+=1)if(p.pop(),l.content=p.join(""),await i([...s.slice(0,c),l])<=r){a==="last"&&(l.content=[...p].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(o){let u=Array.isArray(o)?o:[o];for(;c>0&&!Af(s[c-1],u);)c-=1}return s.slice(0,c)}async function iV(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(([p])=>p!=="type"&&!p.startsWith("lc_")));return kw(l.getType(),d,li(l))});if(n){let l=Array.isArray(n)?n:[n];for(;s.length>0&&!Af(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 wN(u,{...o,partialStrategy:r?"last":void 0,endOn:a}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var _N={human:{message:nt,messageChunk:ja},ai:{message:Ae,messageChunk:vt},system:{message:qt,messageChunk:di},developer:{message:qt,messageChunk:di},tool:{message:Ht,messageChunk:Ho},function:{message:Pa,messageChunk:Ra},generic:{message:sn,messageChunk:Na},remove:{message:cn,messageChunk:cn}};function kw(e,t,r){let i,n;switch(e){case"human":r?i=new ja(t):n=new nt(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 vt(a)}else n=new Ae(t);break;case"system":r?i=new di(t):n=new qt(t);break;case"developer":r?i=new di({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):n=new qt({...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 Ht(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 Ra(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new Pa(t)}break;case"generic":if("role"in t)r?i=new Na(t):n=new sn(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 aV(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 _N&&(r=kw(t,i)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(_N)}`);return r}function $w(e){let t=e.split(`
126
+ `);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
127
+ `),t[t.length-1]])}var xN=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var SN=["image","video","audio","text-plain","file"];var kN=["text","reasoning",...xN,...SN];var $N=I({AIMessage:()=>Ae,AIMessageChunk:()=>vt,BaseMessage:()=>Ue,BaseMessageChunk:()=>Gt,ChatMessage:()=>sn,ChatMessageChunk:()=>Na,DEFAULT_MERGE_IGNORE_KEYS:()=>Fh,FunctionMessage:()=>Pa,FunctionMessageChunk:()=>Ra,HumanMessage:()=>nt,HumanMessageChunk:()=>ja,KNOWN_BLOCK_TYPES:()=>kN,RemoveMessage:()=>cn,SystemMessage:()=>qt,SystemMessageChunk:()=>di,ToolMessage:()=>Ht,ToolMessageChunk:()=>Ho,_isMessageFieldWithRole:()=>Yl,_mergeDicts:()=>We,_mergeLists:()=>zi,_mergeObj:()=>Xl,_mergeStatus:()=>Wl,coerceMessageLikeToMessage:()=>It,collapseToolCallChunks:()=>ed,convertToChunk:()=>Ma,convertToOpenAIImageBlock:()=>Hl,convertToProviderContentBlock:()=>hk,defaultTextSplitter:()=>$w,defaultToolCallParser:()=>Oc,filterMessages:()=>yN,getBufferString:()=>Wo,iife:()=>a$,isAIMessage:()=>Ko,isAIMessageChunk:()=>Ac,isBase64ContentBlock:()=>Go,isBaseMessage:()=>Xe,isBaseMessageChunk:()=>li,isChatMessage:()=>Xk,isChatMessageChunk:()=>Yk,isDataContentBlock:()=>Pn,isDirectToolOutput:()=>Tc,isFunctionMessage:()=>Qk,isFunctionMessageChunk:()=>e$,isHumanMessage:()=>t$,isHumanMessageChunk:()=>r$,isIDContentBlock:()=>Gl,isMessage:()=>Kl,isOpenAIToolCallArray:()=>Ok,isPlainTextContentBlock:()=>fk,isSystemMessage:()=>n$,isSystemMessageChunk:()=>i$,isToolMessage:()=>Cc,isToolMessageChunk:()=>Bh,isURLContentBlock:()=>Zo,mapChatMessagesToStoredMessages:()=>s$,mapStoredMessageToChatMessage:()=>Nc,mapStoredMessagesToChatMessages:()=>o$,mergeContent:()=>Nt,mergeMessageRuns:()=>vN,mergeResponseMetadata:()=>Ql,mergeUsageMetadata:()=>Jo,parseBase64DataUrl:()=>Ic,parseMimeType:()=>mk,trimMessages:()=>bN});var EN=I({BaseChatMessageHistory:()=>Ew,BaseListChatMessageHistory:()=>Nf,InMemoryChatMessageHistory:()=>oV}),Ew=class extends lt{async addMessages(e){for(let t of e)await this.addMessage(t)}},Nf=class extends lt{addUserMessage(e){return this.addMessage(new nt(e))}addAIMessage(e){return this.addMessage(new Ae(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},oV=class extends Nf{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 Ar=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var Iw=class extends ae{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},IN=class extends Iw{async transformDocuments(e){let t=[];for(let r of e){let i=await this._transformDocument(r);t.push(i)}return t}};var TN=I({BaseDocumentTransformer:()=>Iw,Document:()=>Ar,MappingDocumentTransformer:()=>IN});var ON=I({BaseDocumentLoader:()=>Tw}),Tw=class{};var CN=I({LangSmithLoader:()=>sV}),sV=class extends Tw{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 zn(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??cV,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 cV(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var AN=I({Embeddings:()=>Pf}),Pf=class{caller;constructor(e){this.caller=new mi(e??{})}};var Bs=class extends lt{lc_namespace=["langchain_core","example_selectors","base"]};var Ow=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},NN=class extends Ow{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 PN(e){return e._modelType()==="base_llm"}function RN(e){return e._modelType()==="base_chat_model"}function jN(e){return e.split(/\n| /).length}var MN=class zN extends Bs{examples=[];examplePrompt;getTextLength=jN;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??jN}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 zN(r);return await Promise.all(t.map(n=>i.addExample(n))),i}};function Cw(e){return Object.keys(e).sort().map(t=>e[t])}var DN=class LN extends Bs{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=Cw((this.inputKeys??Object.keys(t)).reduce((i,n)=>({...i,[n]:t[n]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new Ar({pageContent:r,metadata:t})])}async selectExamples(t){let r=Cw((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=>Cw(a?a.reduce((c,u)=>({...c,[u]:s[u]}),{}):s).join(" "));return new LN({vectorStore:await i.fromTexts(o,t,r,n),k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}};var UN=I({BaseExampleSelector:()=>Bs,BasePromptSelector:()=>Ow,ConditionalPromptSelector:()=>NN,LengthBasedExampleSelector:()=>MN,SemanticSimilarityExampleSelector:()=>DN,isChatModel:()=>RN,isLLM:()=>PN});var Au="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",FN=class extends lt{lc_namespace=["langchain","recordmanagers"]};var Aw=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Vo;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 Ar({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 rd(this.keyEncoder(e),Au)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return rd(this.keyEncoder(t),Au)}};function Nw(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 Pw(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 Rw(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 jw=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function BN(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=jw(t)?await t.load():t,d=Rw(s??null),p=await r.getTime(),f=0,m=0,_=0,v=0,k=Nw(a??100,l);for(let w of k){let x=Pw(w.map(A=>Aw.fromDocument(A))),$=x.map(A=>d(A));o==="incremental"&&x.forEach((A,F)=>{if($[F]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let T=await r.exists(x.map(A=>A.uid)),B=[],O=[],y=[],K=new Set;if(x.forEach((A,F)=>{if(T[F])if(u)K.add(A.uid);else{y.push(A.uid);return}B.push(A.uid),O.push(A.toDocument())}),y.length>0&&(await r.update(y,{timeAtLeast:p}),v+=y.length),O.length>0&&(await i.addDocuments(O,{ids:B}),f+=O.length-K.size,_+=K.size),await r.update(x.map(A=>A.uid),{timeAtLeast:p,groupIds:$}),o==="incremental"){$.forEach(F=>{if(!F)throw new Error("Source id cannot be null")});let A=await r.listKeys({before:p,groupIds:$});A.length>0&&(await i.delete({ids:A}),await r.deleteKeys(A),m+=A.length)}}if(o==="full"){let w=await r.listKeys({before:p,limit:c});for(;w.length>0;)await i.delete({ids:w}),await r.deleteKeys(w),m+=w.length,w=await r.listKeys({before:p,limit:c})}return{numAdded:f,numDeleted:m,numUpdated:_,numSkipped:v}}var VN=I({RecordManager:()=>FN,UUIDV5_NAMESPACE:()=>Au,_HashedDocument:()=>Aw,_batch:()=>Nw,_deduplicateInOrder:()=>Pw,_getSourceIdAssigner:()=>Rw,_isBaseDocumentLoader:()=>jw,index:()=>BN});var ZN=I({BasePromptValue:()=>Rf,ChatPromptValue:()=>Pu,ImagePromptValue:()=>Mw,StringPromptValue:()=>Nu}),Rf=class extends lt{},Nu=class extends Rf{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 nt(this.value)]}},Pu=class extends Rf{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}},Mw=class extends Rf{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 nt({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var JN=ji(qN(),1),gV=Object.defineProperty,_V=(e,t,r)=>t in e?gV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yV=(e,t,r)=>(_V(e,typeof t!="symbol"?t+"":t,r),r);function vV(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 bV(e,t){return e.length===1?[t.get(e.join(","))]:vV(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function wV(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Dw=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(`
128
+ `).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=JN.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=Dw.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=Dw.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 f of e.substring(c,d).matchAll(i)){let m=this.textEncoder.encode(f[0]),_=this.rankMap.get(m.join(","));if(_!=null){a.push(_);continue}a.push(...bV(m,this.rankMap))}if(u==null)break;let p=this.specialTokens[u[0]];a.push(p),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)}},Mf=Dw;yV(Mf,"specialTokenRegex",e=>new RegExp(e.map(t=>wV(t)).join("|"),"g"));function Lw(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 KN=I({encodingForModel:()=>Df,getEncoding:()=>WN}),zf={},xV=new mi({});async function WN(e){return e in zf||(zf[e]=xV.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Mf(t)).catch(t=>{throw delete zf[e],t})),await zf[e]}async function Df(e){return WN(Lw(e))}var XN=I({BaseLangChain:()=>Uf,BaseLanguageModel:()=>Ru,calculateMaxTokens:()=>$V,getEmbeddingContextSize:()=>SV,getModelContextSize:()=>YN,getModelNameForTiktoken:()=>Lf,isOpenAITool:()=>kV}),Lf=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,SV=e=>e==="text-embedding-ada-002"?8191:2046,YN=e=>{switch(Lf(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 kV(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 $V=async({prompt:e,modelName:t})=>{let r;try{r=(await Df(Lf(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 YN(t)-r},EV=()=>!1,Uf=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??EV(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.39")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Ru=class extends Uf{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=Hh.global():this.cache=void 0,this.caller=new mi(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 Df("modelName"in this?Lf(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 Nu(e):Array.isArray(e)?new Pu(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{}}};var Si=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=Se(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){let r=Se(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 Cu(new da({steps:e}))}};var QN=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,Se(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((f,m)=>a[m].invoke(f,o[m])),p=await Promise.all(d);u.push(p)}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 e1=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])=>[rt(i),rt(n)]),r=rt(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,Ie(t,{callbacks:r?.getChild(`condition:${n+1}`)}))){i=await o.invoke(e,Ie(t,{callbacks:r?.getChild(`branch:${n+1}`)}));break}}return i||(i=await this.default.invoke(e,Ie(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 xt(t))?.handleChainStart(this.toJSON(),ht(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,Ie(t,{callbacks:r?.getChild(`condition:${o+1}`)}))){a=await c.stream(e,Ie(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,Ie(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 t1=class extends Jr{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=zt.from((a,o)=>this._enterHistory(a,o??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=Si.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)&&!Xe(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 nt(t)];if(Array.isArray(t))return t;if(Xe(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
129
+ Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!Xe(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 Ae(t)];if(Array.isArray(t))return t;if(Xe(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()
130
+ 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 r1=I({RouterRunnable:()=>QN,Runnable:()=>ae,RunnableAssign:()=>Cu,RunnableBinding:()=>Jr,RunnableBranch:()=>e1,RunnableEach:()=>cN,RunnableLambda:()=>zt,RunnableMap:()=>da,RunnableParallel:()=>fN,RunnablePassthrough:()=>Si,RunnablePick:()=>Sw,RunnableRetry:()=>Cf,RunnableSequence:()=>Cr,RunnableToolLike:()=>Of,RunnableWithFallbacks:()=>xw,RunnableWithMessageHistory:()=>t1,_coerceToRunnable:()=>rt,ensureConfig:()=>Se,getCallbackManagerForConfig:()=>xt,mergeConfigs:()=>St,patchConfig:()=>Ie,pickRunnableConfigKeys:()=>ur,raceWithSignal:()=>kr});var n1=I({applyPatch:()=>Hi,compare:()=>qi});var Vs=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"})}},_n=class extends Vs{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")}},Dt=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");ui(this,"OUTPUT_PARSING_FAILURE")}};var ki=class extends _n{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"})}},Yn=class extends ki{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(li(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Ji({message:i,text:i.content})}else if(Xe(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Ji({message:Ma(i),text:i.content})}else n=new fi({text:i});r===void 0?r=n:r=r.concat(n);let a=await this.parsePartialResult([r]);a!=null&&!Kn(a,t)&&(this.diff?yield this._diff(t,a):yield a,t=a)}}getFormatInstructions(){return""}};var i1=class extends ki{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 Zs=class extends ki{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]}},a1=class extends Zs{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 Dt(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},o1=class extends Zs{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 Dt(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===Dt.prototype?t:new Dt(`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\`)`}},s1=class extends Zs{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:
131
+
132
+ 1. foo
133
+
134
+ 2. bar
135
+
136
+ 3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},c1=class extends Zs{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:
137
+
138
+ 1. foo
139
+
140
+ 2. bar
141
+
142
+ 3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var u1=class extends ki{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 Ff=class extends Yn{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?qi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Aa(e[0].text)}async parse(e){return Aa(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var Bf=class extends _n{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=Aa(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 Dt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}getFormatInstructions(){return""}};var ju=class extends _n{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=kt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,kt.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.
143
+
144
+ "JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
145
+
146
+ For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
147
+ 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.
148
+ 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.
149
+
150
+ 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!
151
+
152
+ Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
153
+ \`\`\`json
154
+ ${JSON.stringify(bt(this.schema))}
155
+ \`\`\`
156
+ `}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 oa(this.schema,JSON.parse(r))}catch(t){throw new Dt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}},Uw=class extends ju{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:
157
+ \`\`\`json
158
+ ${this._schemaToInstruction(bt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
159
+ \`\`\``}_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`{
160
+ ${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(`
161
+ `)}
162
+ ${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
163
+ ${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
164
+ ${" ".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(`
165
+ ${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=kt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,kt.string().describe(i)])));return new this(t)}},l1=class extends _n{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new Uw(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new Dt(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var IV=function(){let e={};e.parser=function(g,h){return new r(g,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(g,h){if(!(this instanceof r))return new r(g,h);var C=this;n(C),C.q=C.c="",C.bufferCheckPosition=e.MAX_BUFFER_LENGTH,C.opt=h||{},C.opt.lowercase=C.opt.lowercase||C.opt.lowercasetags,C.looseCase=C.opt.lowercase?"toLowerCase":"toUpperCase",C.tags=[],C.closed=C.closedRoot=C.sawRoot=!1,C.tag=C.error=null,C.strict=!!g,C.noscript=!!(g||C.opt.noscript),C.state=y.BEGIN,C.strictEntities=C.opt.strictEntities,C.ENTITIES=C.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),C.attribList=[],C.opt.xmlns&&(C.ns=Object.create(m)),C.trackPosition=C.opt.position!==!1,C.trackPosition&&(C.position=C.line=C.column=0),A(C,"onready")}Object.create||(Object.create=function(g){function h(){}return h.prototype=g,new h}),Object.keys||(Object.keys=function(g){var h=[];for(var C in g)g.hasOwnProperty(C)&&h.push(C);return h});function i(g){for(var h=Math.max(e.MAX_BUFFER_LENGTH,10),C=0,S=0,Ee=t.length;S<Ee;S++){var je=g[t[S]].length;if(je>h)switch(t[S]){case"textNode":he(g);break;case"cdata":F(g,"oncdata",g.cdata),g.cdata="";break;case"script":F(g,"onscript",g.script),g.script="";break;default:Vt(g,"Max buffer length exceeded: "+t[S])}C=Math.max(C,je)}g.bufferCheckPosition=e.MAX_BUFFER_LENGTH-C+g.position}function n(g){for(var h=0,C=t.length;h<C;h++)g[t[h]]=""}function a(g){he(g),g.cdata!==""&&(F(g,"oncdata",g.cdata),g.cdata=""),g.script!==""&&(F(g,"onscript",g.script),g.script="")}r.prototype={end:function(){In(this)},write:Qr,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(g){return g!=="error"&&g!=="end"});function c(g,h){return new u(g,h)}function u(g,h){if(!(this instanceof u))return new u(g,h);o.apply(this),this._parser=new r(g,h),this.writable=!0,this.readable=!0;var C=this;this._parser.onend=function(){C.emit("end")},this._parser.onerror=function(S){C.emit("error",S),C._parser.error=null},this._decoder=null,s.forEach(function(S){Object.defineProperty(C,"on"+S,{get:function(){return C._parser["on"+S]},set:function(Ee){if(!Ee)return C.removeAllListeners(S),C._parser["on"+S]=Ee,Ee;C.on(S,Ee)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(o.prototype,{constructor:{value:u}}),u.prototype.write=function(g){return this._parser.write(g.toString()),this.emit("data",g),!0},u.prototype.end=function(g){return g&&g.length&&this.write(g),this._parser.end(),!0},u.prototype.on=function(g,h){var C=this;return!C._parser["on"+g]&&s.indexOf(g)!==-1&&(C._parser["on"+g]=function(){var S=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);S.splice(0,0,g),C.emit.apply(C,S)}),o.prototype.on.call(C,g,h)};var l="[CDATA[",d="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",f="http://www.w3.org/2000/xmlns/",m={xml:p,xmlns:f},_=/[:_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]/,v=/[:_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-]/,k=/[#:_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(g){return g===" "||g===`
166
+ `||g==="\r"||g===" "}function $(g){return g==='"'||g==="'"}function T(g){return g===">"||x(g)}function B(g,h){return g.test(h)}function O(g,h){return!B(g,h)}var y=0;e.STATE={BEGIN:y++,BEGIN_WHITESPACE:y++,TEXT:y++,TEXT_ENTITY:y++,OPEN_WAKA:y++,SGML_DECL:y++,SGML_DECL_QUOTED:y++,DOCTYPE:y++,DOCTYPE_QUOTED:y++,DOCTYPE_DTD:y++,DOCTYPE_DTD_QUOTED:y++,COMMENT_STARTING:y++,COMMENT:y++,COMMENT_ENDING:y++,COMMENT_ENDED:y++,CDATA:y++,CDATA_ENDING:y++,CDATA_ENDING_2:y++,PROC_INST:y++,PROC_INST_BODY:y++,PROC_INST_ENDING:y++,OPEN_TAG:y++,OPEN_TAG_SLASH:y++,ATTRIB:y++,ATTRIB_NAME:y++,ATTRIB_NAME_SAW_WHITE:y++,ATTRIB_VALUE:y++,ATTRIB_VALUE_QUOTED:y++,ATTRIB_VALUE_CLOSED:y++,ATTRIB_VALUE_UNQUOTED:y++,ATTRIB_VALUE_ENTITY_Q:y++,ATTRIB_VALUE_ENTITY_U:y++,CLOSE_TAG:y++,CLOSE_TAG_SAW_WHITE:y++,SCRIPT:y++,SCRIPT_ENDING:y++},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(g){var h=e.ENTITIES[g],C=typeof h=="number"?String.fromCharCode(h):h;e.ENTITIES[g]=C});for(var K in e.STATE)e.STATE[e.STATE[K]]=K;y=e.STATE;function A(g,h,C){g[h]&&g[h](C)}function F(g,h,C){g.textNode&&he(g),A(g,h,C)}function he(g){g.textNode=Ze(g.opt,g.textNode),g.textNode&&A(g,"ontext",g.textNode),g.textNode=""}function Ze(g,h){return g.trim&&(h=h.trim()),g.normalize&&(h=h.replace(/\s+/g," ")),h}function Vt(g,h){return he(g),g.trackPosition&&(h+=`
167
+ Line: `+g.line+`
168
+ Column: `+g.column+`
169
+ Char: `+g.c),h=new Error(h),g.error=h,A(g,"onerror",h),g}function In(g){return g.sawRoot&&!g.closedRoot&&$e(g,"Unclosed root tag"),g.state!==y.BEGIN&&g.state!==y.BEGIN_WHITESPACE&&g.state!==y.TEXT&&Vt(g,"Unexpected end"),he(g),g.c="",g.closed=!0,A(g,"onend"),r.call(g,g.strict,g.opt),g}function $e(g,h){if(typeof g!="object"||!(g instanceof r))throw new Error("bad call to strictFail");g.strict&&Vt(g,h)}function wa(g){g.strict||(g.tagName=g.tagName[g.looseCase]());var h=g.tags[g.tags.length-1]||g,C=g.tag={name:g.tagName,attributes:{}};g.opt.xmlns&&(C.ns=h.ns),g.attribList.length=0,F(g,"onopentagstart",C)}function ii(g,h){var C=g.indexOf(":")<0?["",g]:g.split(":"),S=C[0],Ee=C[1];return h&&g==="xmlns"&&(S="xmlns",Ee=""),{prefix:S,local:Ee}}function xa(g){if(g.strict||(g.attribName=g.attribName[g.looseCase]()),g.attribList.indexOf(g.attribName)!==-1||g.tag.attributes.hasOwnProperty(g.attribName)){g.attribName=g.attribValue="";return}if(g.opt.xmlns){var h=ii(g.attribName,!0),C=h.prefix,S=h.local;if(C==="xmlns")if(S==="xml"&&g.attribValue!==p)$e(g,"xml: prefix must be bound to "+p+`
170
+ Actual: `+g.attribValue);else if(S==="xmlns"&&g.attribValue!==f)$e(g,"xmlns: prefix must be bound to "+f+`
171
+ Actual: `+g.attribValue);else{var Ee=g.tag,je=g.tags[g.tags.length-1]||g;Ee.ns===je.ns&&(Ee.ns=Object.create(je.ns)),Ee.ns[S]=g.attribValue}g.attribList.push([g.attribName,g.attribValue])}else g.tag.attributes[g.attribName]=g.attribValue,F(g,"onattribute",{name:g.attribName,value:g.attribValue});g.attribName=g.attribValue=""}function Yr(g,h){if(g.opt.xmlns){var C=g.tag,S=ii(g.tagName);C.prefix=S.prefix,C.local=S.local,C.uri=C.ns[S.prefix]||"",C.prefix&&!C.uri&&($e(g,"Unbound namespace prefix: "+JSON.stringify(g.tagName)),C.uri=S.prefix);var Ee=g.tags[g.tags.length-1]||g;C.ns&&Ee.ns!==C.ns&&Object.keys(C.ns).forEach(function(Sa){F(g,"onopennamespace",{prefix:Sa,uri:C.ns[Sa]})});for(var je=0,gt=g.attribList.length;je<gt;je++){var ct=g.attribList[je],At=ct[0],Nr=ct[1],ut=ii(At,!0),Tn=ut.prefix,Ro=ut.local,Sl=Tn===""?"":C.ns[Tn]||"",q={name:At,value:Nr,prefix:Tn,local:Ro,uri:Sl};Tn&&Tn!=="xmlns"&&!Sl&&($e(g,"Unbound namespace prefix: "+JSON.stringify(Tn)),q.uri=Tn),g.tag.attributes[At]=q,F(g,"onattribute",q)}g.attribList.length=0}g.tag.isSelfClosing=!!h,g.sawRoot=!0,g.tags.push(g.tag),F(g,"onopentag",g.tag),h||(!g.noscript&&g.tagName.toLowerCase()==="script"?g.state=y.SCRIPT:g.state=y.TEXT,g.tag=null,g.tagName=""),g.attribName=g.attribValue="",g.attribList.length=0}function ai(g){if(!g.tagName){$e(g,"Weird empty close tag."),g.textNode+="</>",g.state=y.TEXT;return}if(g.script){if(g.tagName!=="script"){g.script+="</"+g.tagName+">",g.tagName="",g.state=y.SCRIPT;return}F(g,"onscript",g.script),g.script=""}var h=g.tags.length,C=g.tagName;g.strict||(C=C[g.looseCase]());for(var S=C;h--&&g.tags[h].name!==S;)$e(g,"Unexpected close tag");if(h<0){$e(g,"Unmatched closing tag: "+g.tagName),g.textNode+="</"+g.tagName+">",g.state=y.TEXT;return}g.tagName=C;for(var Ee=g.tags.length;Ee-- >h;){var je=g.tag=g.tags.pop();g.tagName=g.tag.name,F(g,"onclosetag",g.tagName);var gt={};for(var ct in je.ns)gt[ct]=je.ns[ct];var At=g.tags[g.tags.length-1]||g;g.opt.xmlns&&je.ns!==At.ns&&Object.keys(je.ns).forEach(function(Nr){var ut=je.ns[Nr];F(g,"onclosenamespace",{prefix:Nr,uri:ut})})}h===0&&(g.closedRoot=!0),g.tagName=g.attribValue=g.attribName="",g.attribList.length=0,g.state=y.TEXT}function mc(g){var h=g.entity,C=h.toLowerCase(),S,Ee="";return g.ENTITIES[h]?g.ENTITIES[h]:g.ENTITIES[C]?g.ENTITIES[C]:(h=C,h.charAt(0)==="#"&&(h.charAt(1)==="x"?(h=h.slice(2),S=parseInt(h,16),Ee=S.toString(16)):(h=h.slice(1),S=parseInt(h,10),Ee=S.toString(10))),h=h.replace(/^0+/,""),isNaN(S)||Ee.toLowerCase()!==h?($e(g,"Invalid character entity"),"&"+g.entity+";"):String.fromCodePoint(S))}function hc(g,h){h==="<"?(g.state=y.OPEN_WAKA,g.startTagPosition=g.position):x(h)||($e(g,"Non-whitespace before first tag."),g.textNode=h,g.state=y.TEXT)}function gc(g,h){var C="";return h<g.length&&(C=g.charAt(h)),C}function Qr(g){var h=this;if(this.error)throw this.error;if(h.closed)return Vt(h,"Cannot write after close. Assign an onready handler.");if(g===null)return In(h);typeof g=="object"&&(g=g.toString());for(var C=0,S="";S=gc(g,C++),h.c=S,!!S;)switch(h.trackPosition&&(h.position++,S===`
172
+ `?(h.line++,h.column=0):h.column++),h.state){case y.BEGIN:if(h.state=y.BEGIN_WHITESPACE,S==="\uFEFF")continue;hc(h,S);continue;case y.BEGIN_WHITESPACE:hc(h,S);continue;case y.TEXT:if(h.sawRoot&&!h.closedRoot){for(var Ee=C-1;S&&S!=="<"&&S!=="&";)S=gc(g,C++),S&&h.trackPosition&&(h.position++,S===`
173
+ `?(h.line++,h.column=0):h.column++);h.textNode+=g.substring(Ee,C-1)}S==="<"&&!(h.sawRoot&&h.closedRoot&&!h.strict)?(h.state=y.OPEN_WAKA,h.startTagPosition=h.position):(!x(S)&&(!h.sawRoot||h.closedRoot)&&$e(h,"Text data outside of root node."),S==="&"?h.state=y.TEXT_ENTITY:h.textNode+=S);continue;case y.SCRIPT:S==="<"?h.state=y.SCRIPT_ENDING:h.script+=S;continue;case y.SCRIPT_ENDING:S==="/"?h.state=y.CLOSE_TAG:(h.script+="<"+S,h.state=y.SCRIPT);continue;case y.OPEN_WAKA:if(S==="!")h.state=y.SGML_DECL,h.sgmlDecl="";else if(!x(S))if(B(_,S))h.state=y.OPEN_TAG,h.tagName=S;else if(S==="/")h.state=y.CLOSE_TAG,h.tagName="";else if(S==="?")h.state=y.PROC_INST,h.procInstName=h.procInstBody="";else{if($e(h,"Unencoded <"),h.startTagPosition+1<h.position){var je=h.position-h.startTagPosition;S=new Array(je).join(" ")+S}h.textNode+="<"+S,h.state=y.TEXT}continue;case y.SGML_DECL:(h.sgmlDecl+S).toUpperCase()===l?(F(h,"onopencdata"),h.state=y.CDATA,h.sgmlDecl="",h.cdata=""):h.sgmlDecl+S==="--"?(h.state=y.COMMENT,h.comment="",h.sgmlDecl=""):(h.sgmlDecl+S).toUpperCase()===d?(h.state=y.DOCTYPE,(h.doctype||h.sawRoot)&&$e(h,"Inappropriately located doctype declaration"),h.doctype="",h.sgmlDecl=""):S===">"?(F(h,"onsgmldeclaration",h.sgmlDecl),h.sgmlDecl="",h.state=y.TEXT):($(S)&&(h.state=y.SGML_DECL_QUOTED),h.sgmlDecl+=S);continue;case y.SGML_DECL_QUOTED:S===h.q&&(h.state=y.SGML_DECL,h.q=""),h.sgmlDecl+=S;continue;case y.DOCTYPE:S===">"?(h.state=y.TEXT,F(h,"ondoctype",h.doctype),h.doctype=!0):(h.doctype+=S,S==="["?h.state=y.DOCTYPE_DTD:$(S)&&(h.state=y.DOCTYPE_QUOTED,h.q=S));continue;case y.DOCTYPE_QUOTED:h.doctype+=S,S===h.q&&(h.q="",h.state=y.DOCTYPE);continue;case y.DOCTYPE_DTD:h.doctype+=S,S==="]"?h.state=y.DOCTYPE:$(S)&&(h.state=y.DOCTYPE_DTD_QUOTED,h.q=S);continue;case y.DOCTYPE_DTD_QUOTED:h.doctype+=S,S===h.q&&(h.state=y.DOCTYPE_DTD,h.q="");continue;case y.COMMENT:S==="-"?h.state=y.COMMENT_ENDING:h.comment+=S;continue;case y.COMMENT_ENDING:S==="-"?(h.state=y.COMMENT_ENDED,h.comment=Ze(h.opt,h.comment),h.comment&&F(h,"oncomment",h.comment),h.comment=""):(h.comment+="-"+S,h.state=y.COMMENT);continue;case y.COMMENT_ENDED:S!==">"?($e(h,"Malformed comment"),h.comment+="--"+S,h.state=y.COMMENT):h.state=y.TEXT;continue;case y.CDATA:S==="]"?h.state=y.CDATA_ENDING:h.cdata+=S;continue;case y.CDATA_ENDING:S==="]"?h.state=y.CDATA_ENDING_2:(h.cdata+="]"+S,h.state=y.CDATA);continue;case y.CDATA_ENDING_2:S===">"?(h.cdata&&F(h,"oncdata",h.cdata),F(h,"onclosecdata"),h.cdata="",h.state=y.TEXT):S==="]"?h.cdata+="]":(h.cdata+="]]"+S,h.state=y.CDATA);continue;case y.PROC_INST:S==="?"?h.state=y.PROC_INST_ENDING:x(S)?h.state=y.PROC_INST_BODY:h.procInstName+=S;continue;case y.PROC_INST_BODY:if(!h.procInstBody&&x(S))continue;S==="?"?h.state=y.PROC_INST_ENDING:h.procInstBody+=S;continue;case y.PROC_INST_ENDING:S===">"?(F(h,"onprocessinginstruction",{name:h.procInstName,body:h.procInstBody}),h.procInstName=h.procInstBody="",h.state=y.TEXT):(h.procInstBody+="?"+S,h.state=y.PROC_INST_BODY);continue;case y.OPEN_TAG:B(v,S)?h.tagName+=S:(wa(h),S===">"?Yr(h):S==="/"?h.state=y.OPEN_TAG_SLASH:(x(S)||$e(h,"Invalid character in tag name"),h.state=y.ATTRIB));continue;case y.OPEN_TAG_SLASH:S===">"?(Yr(h,!0),ai(h)):($e(h,"Forward-slash in opening tag not followed by >"),h.state=y.ATTRIB);continue;case y.ATTRIB:if(x(S))continue;S===">"?Yr(h):S==="/"?h.state=y.OPEN_TAG_SLASH:B(_,S)?(h.attribName=S,h.attribValue="",h.state=y.ATTRIB_NAME):$e(h,"Invalid attribute name");continue;case y.ATTRIB_NAME:S==="="?h.state=y.ATTRIB_VALUE:S===">"?($e(h,"Attribute without value"),h.attribValue=h.attribName,xa(h),Yr(h)):x(S)?h.state=y.ATTRIB_NAME_SAW_WHITE:B(v,S)?h.attribName+=S:$e(h,"Invalid attribute name");continue;case y.ATTRIB_NAME_SAW_WHITE:if(S==="=")h.state=y.ATTRIB_VALUE;else{if(x(S))continue;$e(h,"Attribute without value"),h.tag.attributes[h.attribName]="",h.attribValue="",F(h,"onattribute",{name:h.attribName,value:""}),h.attribName="",S===">"?Yr(h):B(_,S)?(h.attribName=S,h.state=y.ATTRIB_NAME):($e(h,"Invalid attribute name"),h.state=y.ATTRIB)}continue;case y.ATTRIB_VALUE:if(x(S))continue;$(S)?(h.q=S,h.state=y.ATTRIB_VALUE_QUOTED):($e(h,"Unquoted attribute value"),h.state=y.ATTRIB_VALUE_UNQUOTED,h.attribValue=S);continue;case y.ATTRIB_VALUE_QUOTED:if(S!==h.q){S==="&"?h.state=y.ATTRIB_VALUE_ENTITY_Q:h.attribValue+=S;continue}xa(h),h.q="",h.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:x(S)?h.state=y.ATTRIB:S===">"?Yr(h):S==="/"?h.state=y.OPEN_TAG_SLASH:B(_,S)?($e(h,"No whitespace between attributes"),h.attribName=S,h.attribValue="",h.state=y.ATTRIB_NAME):$e(h,"Invalid attribute name");continue;case y.ATTRIB_VALUE_UNQUOTED:if(!T(S)){S==="&"?h.state=y.ATTRIB_VALUE_ENTITY_U:h.attribValue+=S;continue}xa(h),S===">"?Yr(h):h.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(h.tagName)S===">"?ai(h):B(v,S)?h.tagName+=S:h.script?(h.script+="</"+h.tagName,h.tagName="",h.state=y.SCRIPT):(x(S)||$e(h,"Invalid tagname in closing tag"),h.state=y.CLOSE_TAG_SAW_WHITE);else{if(x(S))continue;O(_,S)?h.script?(h.script+="</"+S,h.state=y.SCRIPT):$e(h,"Invalid tagname in closing tag."):h.tagName=S}continue;case y.CLOSE_TAG_SAW_WHITE:if(x(S))continue;S===">"?ai(h):$e(h,"Invalid characters in closing tag");continue;case y.TEXT_ENTITY:case y.ATTRIB_VALUE_ENTITY_Q:case y.ATTRIB_VALUE_ENTITY_U:var gt,ct;switch(h.state){case y.TEXT_ENTITY:gt=y.TEXT,ct="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:gt=y.ATTRIB_VALUE_QUOTED,ct="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:gt=y.ATTRIB_VALUE_UNQUOTED,ct="attribValue";break}if(S===";")if(h.opt.unparsedEntities){var At=mc(h);h.entity="",h.state=gt,h.write(At)}else h[ct]+=mc(h),h.entity="",h.state=gt;else B(h.entity.length?w:k,S)?h.entity+=S:($e(h,"Invalid character in entity name"),h[ct]+="&"+h.entity+S,h.entity="",h.state=gt);continue;default:throw new Error(h,"Unknown state: "+h.state)}return h.position>=h.bufferCheckPosition&&i(h),h}return String.fromCodePoint||(function(){var g=String.fromCharCode,h=Math.floor,C=function(){var S=16384,Ee=[],je,gt,ct=-1,At=arguments.length;if(!At)return"";for(var Nr="";++ct<At;){var ut=Number(arguments[ct]);if(!isFinite(ut)||ut<0||ut>1114111||h(ut)!==ut)throw RangeError("Invalid code point: "+ut);ut<=65535?Ee.push(ut):(ut-=65536,je=(ut>>10)+55296,gt=ut%1024+56320,Ee.push(je,gt)),(ct+1===At||Ee.length>S)&&(Nr+=g.apply(null,Ee),Ee.length=0)}return Nr};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:C,configurable:!0,writable:!0}):String.fromCodePoint=C})(),e},d1=IV();var Vf=`The output should be formatted as a XML file.
174
+ 1. Output should conform to the tags below.
175
+ 2. If tags are not given, make them on your own.
176
+ 3. Remember to always open and close all the tags.
177
+
178
+ As an example, for the tags ["foo", "bar", "baz"]:
179
+ 1. String "<foo>
180
+ <bar>
181
+ <baz></baz>
182
+ </bar>
183
+ </foo>" is a well-formatted instance of the schema.
184
+ 2. String "<foo>
185
+ <bar>
186
+ </foo>" is a badly-formatted instance.
187
+ 3. String "<foo>
188
+ <tag>
189
+ </tag>
190
+ </foo>" is a badly-formatted instance.
191
+
192
+ Here are the output tags:
193
+ \`\`\`
194
+ {tags}
195
+ \`\`\``,p1=class extends Yn{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?qi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Zf(e[0].text)}async parse(e){return Zf(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?Vf.replace("{tags}",this.tags?.join(", ")??""):Vf}},TV=e=>e.split(`
196
+ `).map(t=>t.replace(/^\s+/,"")).join(`
197
+ `).trim(),f1=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(f1),t):(t[e.name]=e.text??void 0,t)};function Zf(e){let t=TV(e),r=d1.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]),f1(i)}var m1=I({AsymmetricStructuredOutputParser:()=>l1,BaseCumulativeTransformOutputParser:()=>Yn,BaseLLMOutputParser:()=>Vs,BaseOutputParser:()=>_n,BaseTransformOutputParser:()=>ki,BytesOutputParser:()=>i1,CommaSeparatedListOutputParser:()=>a1,CustomListOutputParser:()=>o1,JsonMarkdownStructuredOutputParser:()=>Uw,JsonOutputParser:()=>Ff,ListOutputParser:()=>Zs,MarkdownListOutputParser:()=>c1,NumberedListOutputParser:()=>s1,OutputParserException:()=>Dt,StandardSchemaOutputParser:()=>Bf,StringOutputParser:()=>u1,StructuredOutputParser:()=>ju,XMLOutputParser:()=>p1,XML_FORMAT_INSTRUCTIONS:()=>Vf,parseJsonMarkdown:()=>Aa,parsePartialJson:()=>Rn,parseXMLMarkdown:()=>Zf});var h1=I({extendInteropZodObject:()=>pf,getInteropZodDefaultGetter:()=>ff,getInteropZodObjectShape:()=>no,getSchemaDescription:()=>yi,interopParse:()=>Cs,interopParseAsync:()=>oa,interopSafeParse:()=>KC,interopSafeParseAsync:()=>df,interopZodObjectMakeFieldsOptional:()=>XC,interopZodObjectPartial:()=>Ns,interopZodObjectPassthrough:()=>lf,interopZodObjectStrict:()=>Os,interopZodTransformInputSchema:()=>mf,isInteropZodError:()=>hf,isInteropZodLiteral:()=>JC,isInteropZodObject:()=>er,isInteropZodSchema:()=>pr,isShapelessZodSchema:()=>WC,isSimpleStringZodSchema:()=>As,isZodArrayV4:()=>Su,isZodLiteralV3:()=>aw,isZodLiteralV4:()=>ow,isZodNullableV4:()=>cw,isZodObjectV3:()=>xu,isZodObjectV4:()=>Zr,isZodOptionalV4:()=>sw,isZodSchema:()=>qC,isZodSchemaV3:()=>ot,isZodSchemaV4:()=>Be});function Fw(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=Rn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(n){throw new Dt([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${n.message}`].join(`
198
+ `))}let i={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(i.id=e.id),i}function g1(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 _1(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var Bw=class extends Yn{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=>Fw(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}},Gf=class extends Bw{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 Dt(`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 df(this.zodSchema,e);if(t.success)return t.data;throw new Dt(`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 y1=I({assembleStructuredOutputPipeline:()=>Vw,createContentParser:()=>OV,createFunctionCallingParser:()=>CV});function OV(e){return pr(e)?ju.fromZodSchema(e):Ha(e)?Bf.fromSerializableSchema(e):new Ff}function CV(e,t,r){let i=r??Gf;return pr(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 Vw(e,t,r,i){if(!r){let c=e.pipe(t);return i?c.withConfig({runName:i}):c}let n=Si.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),a=Si.assign({parsed:()=>null}),o=n.withFallbacks({fallbacks:[a]}),s=Cr.from([{raw:e},o]);return i?s.withConfig({runName:i}):s}var v1=e=>e();function Hf(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var b1=I({BaseChatModel:()=>pa,SimpleChatModel:()=>AV});function Zw(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];(Zo(a)||Go(a))&&i===r&&(i=new r.constructor({...i,content:[...r.content.slice(0,n),Hl(a),...r.content.slice(n+1)]}))}t.push(i)}return t}var pa=class So extends Ru{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=v1(()=>{let r=t.outputVersion??Zt("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=So._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*_streamIterator(t,r){if(this._streamResponseChunks===So.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let i=So._convertInputToPromptValue(t).toChatMessages(),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o={...n.metadata,...this.getLsParamsWithDefaults(a)},s=await dt.configure(n.callbacks,this.callbacks,n.tags,this.tags,o,this.metadata,{verbose:this.verbose}),c={options:a,invocation_params:this?.invocationParams(a),batch_size:1},u=a.outputVersion??this.outputVersion,l=await s?.handleChatModelStart(this.toJSON(),[Zw(i)],n.runId,void 0,c,void 0,void 0,n.runName),d,p;try{for await(let f of this._streamResponseChunks(i,a,l?.[0])){if(a.signal?.throwIfAborted(),f.message.id==null){let m=l?.at(0)?.runId;m!=null&&f.message._updateId(`run-${m}`)}f.message.response_metadata={...f.generationInfo,...f.message.response_metadata},u==="v1"?yield Hf(f.message):yield f.message,d?d=d.concat(f):d=f,Ac(f.message)&&f.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:f.message.usage_metadata.input_tokens,completionTokens:f.message.usage_metadata.output_tokens,totalTokens:f.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(f){throw await Promise.all((l??[]).map(m=>m?.handleLLMError(f))),f}await Promise.all((l??[]).map(f=>f?.handleLLMEnd({generations:[[d]],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(d=>d.map(It)),o;if(n!==void 0&&n.length===a.length)o=n;else{let d={...i.metadata,...this.getLsParamsWithDefaults(r)},p=await dt.configure(i.callbacks,this.callbacks,i.tags,this.tags,d,this.metadata,{verbose:this.verbose}),f={options:r,invocation_params:this?.invocationParams(r),batch_size:1};o=await p?.handleChatModelStart(this.toJSON(),a.map(Zw),i.runId,void 0,f,void 0,void 0,i.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[];if(o?.[0].handlers.find(Pc)&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==So.prototype._streamResponseChunks)try{let d=await this._streamResponseChunks(a[0],r,o?.[0]),p,f;for await(let m of d){if(r.signal?.aborted){let _=p?.message;throw new Zl("Model invocation was aborted.",_)}if(m.message.id==null){let _=o?.at(0)?.runId;_!=null&&m.message._updateId(`run-${_}`)}p===void 0?p=m:p=$r(p,m),Ac(m.message)&&m.message.usage_metadata!==void 0&&(f={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let m=p?.message;throw new Zl("Model invocation was aborted.",m)}if(p===void 0)throw new Error("Received empty response from chat model call.");c.push([p]),await o?.[0].handleLLMEnd({generations:c,llmOutput:f})}catch(d){throw await o?.[0].handleLLMError(d),d}else{let d=await Promise.allSettled(a.map(async(p,f)=>{let m=await this._generate(p,{...r,promptIndex:f},o?.[f]);if(s==="v1")for(let _ of m.generations)_.message=Hf(_.message);return m}));await Promise.all(d.map(async(p,f)=>{if(p.status==="fulfilled"){let m=p.value;for(let _ of m.generations){if(_.message.id==null){let v=o?.at(0)?.runId;v!=null&&_.message._updateId(`run-${v}`)}_.message.response_metadata={..._.generationInfo,..._.message.response_metadata}}return m.generations.length===1&&(m.generations[0].message.response_metadata={...m.llmOutput,...m.generations[0].message.response_metadata}),c[f]=m.generations,u[f]=m.llmOutput,o?.[f]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await o?.[f]?.handleLLMError(p.reason),Promise.reject(p.reason)}))}let l={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(l,Ga,{value:o?{runIds:o?.map(d=>d.runId)}:void 0,configurable:!0}),l}async _generateCached({messages:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a}){let o=t.map(v=>v.map(It)),s={...a.metadata,...this.getLsParamsWithDefaults(n)},c=await dt.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose}),u={options:n,invocation_params:this?.invocationParams(n),batch_size:1},l=await c?.handleChatModelStart(this.toJSON(),o.map(Zw),a.runId,void 0,u,void 0,void 0,a.runName),d=[],p=(await Promise.allSettled(o.map(async(v,k)=>{let w=So._convertInputToPromptValue(v).toString(),x=await r.lookup(w,i);return x==null&&d.push(k),x}))).map((v,k)=>({result:v,runManager:l?.[k]})).filter(({result:v})=>v.status==="fulfilled"&&v.value!=null||v.status==="rejected"),f=n.outputVersion??this.outputVersion,m=[];await Promise.all(p.map(async({result:v,runManager:k},w)=>{if(v.status==="fulfilled"){let x=v.value;return m[w]=x.map($=>("message"in $&&Xe($.message)&&Ko($.message)&&($.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},f==="v1"&&($.message=Hf($.message))),$.generationInfo={...$.generationInfo,tokenUsage:{}},$)),x.length&&await k?.handleLLMNewToken(x[0].text),k?.handleLLMEnd({generations:[x]},void 0,void 0,void 0,{cached:!0})}else return await k?.handleLLMError(v.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(v.reason)}));let _={generations:m,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(_,Ga,{value:l?{runIds:l?.map(v=>v.runId)}:void 0,configurable:!0}),_}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:p}=await this._generateCached({messages:a,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:o}),f={};if(d.length>0){let m=await this._generateUncached(d.map(_=>a[_]),s,o,p!==void 0?d.map(_=>p?.[_]):void 0);await Promise.all(m.generations.map(async(_,v)=>{let k=d[v];l[k]=_;let w=So._convertInputToPromptValue(a[k]).toString();return c.update(w,u,_)})),f=m.llmOutput??{}}return{generations:l,llmOutput:f}}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=yi(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";!pr(i)&&!Ha(i)&&"name"in i&&(c=i.name);let u=pr(i)||Ha(i)?bt(i):i,l=[{type:"function",function:{name:c,description:a,parameters:u}}];return Vw(this.bindTools(l),zt.from(d=>{if(!vt.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let p=d.tool_calls.find(f=>f.name===c);if(!p)throw new Error(`No tool call found with name ${c}.`);return p.args}),s,s?"StructuredOutputRunnable":"StructuredOutput")}},AV=class extends pa{async _generate(e,t,r){let i=new Ae(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 w1=I({BaseLLM:()=>x1,LLM:()=>qf}),x1=class Mu extends Ru{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let i=Mu._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===Mu.prototype._streamResponseChunks)yield this.invoke(t,r);else{let i=Mu._convertInputToPromptValue(t),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o=await dt.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose}),s={options:a,invocation_params:this?.invocationParams(a),batch_size:1},c=await o?.handleLLMStart(this.toJSON(),[i.toString()],n.runId,void 0,s,void 0,void 0,n.runName),u=new fi({text:""});try{for await(let l of this._streamResponseChunks(i.toString(),a,c?.[0]))u?u=u.concat(l):u=l,typeof l.text=="string"&&(yield l.text)}catch(l){throw await Promise.all((c??[]).map(d=>d?.handleLLMError(l))),l}await Promise.all((c??[]).map(l=>l?.handleLLMEnd({generations:[[u]]})))}}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=await dt.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose}),l={options:r,invocation_params:this?.invocationParams(r),batch_size:t.length};a=await u?.handleLLMStart(this.toJSON(),t,i.runId,void 0,l,void 0,void 0,i?.runName)}let o=!!a?.[0].handlers.find(Pc),s;if(o&&t.length===1&&this._streamResponseChunks!==Mu.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,Ga,{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=await dt.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),c={options:n,invocation_params:this?.invocationParams(n),batch_size:t.length},u=await s?.handleLLMStart(this.toJSON(),t,o,void 0,c,void 0,void 0,a?.runName),l=[],d=(await Promise.allSettled(t.map(async(m,_)=>{let v=await r.lookup(m,i);return v==null&&l.push(_),v}))).map((m,_)=>({result:m,runManager:u?.[_]})).filter(({result:m})=>m.status==="fulfilled"&&m.value!=null||m.status==="rejected"),p=[];await Promise.all(d.map(async({result:m,runManager:_},v)=>{if(m.status==="fulfilled"){let k=m.value;return p[v]=k.map(w=>(w.generationInfo={...w.generationInfo,tokenUsage:{}},w)),k.length&&await _?.handleLLMNewToken(k[0].text),_?.handleLLMEnd({generations:[k]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(m.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(m.reason)}));let f={generations:p,missingPromptIndices:l,startedRunManagers:u};return Object.defineProperty(f,Ga,{value:u?{runIds:u?.map(m=>m.runId)}:void 0,configurable:!0}),f}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}),p={};if(l.length>0){let f=await this._generateUncached(l.map(m=>t[m]),o,a,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(f.generations.map(async(m,_)=>{let v=l[_];return u[v]=m,s.update(t[v],c,m)})),p=f.llmOutput??{}}return{generations:u,llmOutput:p}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},qf=class extends x1{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 S1=I({});var k1=I({BaseMemory:()=>NV,getInputValue:()=>PV,getOutputValue:()=>RV,getPromptInputKey:()=>jV}),NV=class{},$1=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},PV=(e,t)=>{let r=$1(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},RV=(e,t)=>{let r=$1(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 jV(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 Gw=class extends Vs{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)}`)}},Hw=class extends Yn{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 Gw(e)}_diff(e,t){if(t)return qi(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?Rn(i.arguments):{...i,arguments:Rn(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""}},E1=class extends Vs{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new Hw;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 I1=I({JsonKeyOutputFunctionsParser:()=>E1,JsonOutputFunctionsParser:()=>Hw,OutputFunctionsParser:()=>Gw});var T1=I({JsonOutputKeyToolsParser:()=>Gf,JsonOutputToolsParser:()=>Bw,convertLangChainToolCallToOpenAI:()=>g1,makeInvalidToolCall:()=>_1,parseToolCall:()=>Fw});var Qn=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 $i=class extends Qn{async formatPromptValue(e){return new Nu(await this.format(e))}};var MV=Object.prototype.toString,Hs=Array.isArray||function(t){return MV.call(t)==="[object Array]"};function Jw(e){return typeof e=="function"}function zV(e){return Hs(e)?"array":typeof e}function qw(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function O1(e,t){return e!=null&&typeof e=="object"&&t in e}function DV(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var LV=RegExp.prototype.test;function UV(e,t){return LV.call(e,t)}var FV=/\S/;function BV(e){return!UV(FV,e)}var VV={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function ZV(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return VV[r]})}var GV=/\s*/,HV=/\s+/,C1=/\s*=/,qV=/\s*\}/,JV=/#|\^|\/|>|\{|&|=|!/;function KV(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,p,f;function m(y){if(typeof y=="string"&&(y=y.split(HV,2)),!Hs(y)||y.length!==2)throw new Error("Invalid tags: "+y);d=new RegExp(qw(y[0])+"\\s*"),p=new RegExp("\\s*"+qw(y[1])),f=new RegExp("\\s*"+qw("}"+y[1]))}m(t||Wr.tags);for(var _=new Du(e),v,k,w,x,$,T;!_.eos();){if(v=_.pos,w=_.scanUntil(d),w)for(var B=0,O=w.length;B<O;++B)x=w.charAt(B),BV(x)?(a.push(n.length),c+=x):(s=!0,r=!0,c+=" "),n.push(["text",x,v,v+1]),v+=1,x===`
199
+ `&&(l(),c="",u=0,r=!1);if(!_.scan(d))break;if(o=!0,k=_.scan(JV)||"name",_.scan(GV),k==="="?(w=_.scanUntil(C1),_.scan(C1),_.scanUntil(p)):k==="{"?(w=_.scanUntil(f),_.scan(qV),_.scanUntil(p),k="&"):w=_.scanUntil(p),!_.scan(p))throw new Error("Unclosed tag at "+_.pos);if(k==">"?$=[k,w,v,_.pos,c,u,r]:$=[k,w,v,_.pos],u++,n.push($),k==="#"||k==="^")i.push($);else if(k==="/"){if(T=i.pop(),!T)throw new Error('Unopened section "'+w+'" at '+v);if(T[1]!==w)throw new Error('Unclosed section "'+T[1]+'" at '+v)}else k==="name"||k==="{"||k==="&"?s=!0:k==="="&&m(w)}if(l(),T=i.pop(),T)throw new Error('Unclosed section "'+T[1]+'" at '+_.pos);return XV(WV(n))}function WV(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 XV(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 Du(e){this.string=e,this.tail=e,this.pos=0}Du.prototype.eos=function(){return this.tail===""};Du.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};Du.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 Gs(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Gs.prototype.push=function(t){return new Gs(t,this)};Gs.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=O1(a,o[s])||DV(a,o[s])),a=a[o[s++]];else a=n.view[t],c=O1(n.view,t);if(c){i=a;break}n=n.parent}r[t]=i}return Jw(i)&&(i=i.call(this.view)),i};function rr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}rr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};rr.prototype.parse=function(t,r){var i=this.templateCache,n=t+":"+(r||Wr.tags).join(":"),a=typeof i<"u",o=a?i.get(n):void 0;return o==null&&(o=KV(t,r),a&&i.set(n,o)),o};rr.prototype.render=function(t,r,i,n){var a=this.getConfigTags(n),o=this.parse(t,a),s=r instanceof Gs?r:new Gs(r,void 0);return this.renderTokens(o,s,i,t,n)};rr.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};rr.prototype.renderSection=function(t,r,i,n,a){var o=this,s="",c=r.lookup(t[1]);function u(p){return o.render(p,r,i,a)}if(c){if(Hs(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(Jw(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}};rr.prototype.renderInverted=function(t,r,i,n,a){var o=r.lookup(t[1]);if(!o||Hs(o)&&o.length===0)return this.renderTokens(t[4],r,i,n,a)};rr.prototype.indentPartial=function(t,r,i){for(var n=r.replace(/[^ \t]/g,""),a=t.split(`
200
+ `),o=0;o<a.length;o++)a[o].length&&(o>0||!i)&&(a[o]=n+a[o]);return a.join(`
201
+ `)};rr.prototype.renderPartial=function(t,r,i,n){if(i){var a=this.getConfigTags(n),o=Jw(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)}}};rr.prototype.unescapedValue=function(t,r){var i=r.lookup(t[1]);if(i!=null)return i};rr.prototype.escapedValue=function(t,r,i){var n=this.getConfigEscape(i)||Wr.escape,a=r.lookup(t[1]);if(a!=null)return typeof a=="number"&&n===Wr.escape?String(a):n(a)};rr.prototype.rawValue=function(t){return t[1]};rr.prototype.getConfigTags=function(t){return Hs(t)?t:t&&typeof t=="object"?t.tags:void 0};rr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Hs(t))return t.escape};var Wr={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){zu.templateCache=e},get templateCache(){return zu.templateCache}},zu=new rr;Wr.clearCache=function(){return zu.clearCache()};Wr.parse=function(t,r){return zu.parse(t,r)};Wr.render=function(t,r,i,n){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+zV(t)+'" was given as the first argument for mustache#render(template, view, partials)');return zu.render(t,r,i,n)};Wr.escape=ZV;Wr.Scanner=Du;Wr.Context=Gs;Wr.Writer=rr;var Jf=Wr;function A1(){Jf.escape=e=>e}var ko=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},N1=(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=N1(i[4],n);r.push(...a)}}else r.push({type:"literal",text:i[1]});return r},qs=e=>(A1(),N1(Jf.parse(e))),Kw=(e,t)=>ko(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},""),Ww=(e,t)=>(A1(),Jf.render(e,t)),Lu={"f-string":Kw,mustache:Ww},Xw={"f-string":ko,mustache:qs},Lt=(e,t,r)=>{try{return Lu[t](e,r)}catch(i){throw ui(i,"INVALID_PROMPT_INPUT")}},$o=(e,t)=>Xw[t](e),Ei=(e,t,r)=>{if(!(t in Lu))throw new Error(`Invalid template format. Got \`${t}\`;
202
+ should be one of ${Object.keys(Lu)}`);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 yn=class Uu extends $i{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))),Ei(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=`
203
+
204
+ `,a=""){return new Uu({inputVariables:i,template:[a,...t,r].join(n)})}static fromTemplate(t,r){let{templateFormat:i="f-string",...n}=r??{},a=new Set;return $o(t,i).forEach(o=>{o.type==="variable"&&a.add(o.name)}),new Uu({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 Uu({...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 Uu({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var Js=class P1 extends Qn{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))),Ei([{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 P1({...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 Mw(await this.format(t))}};var Fu=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=Yw(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return Qw(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function Yw(e,t){let r=[];for(let i of Object.values(e))if(typeof i=="string")$o(i,t).forEach(n=>{n.type==="variable"&&r.push(n.name)});else if(Array.isArray(i))for(let n of i)typeof n=="string"?$o(n,t).forEach(a=>{a.type==="variable"&&r.push(a.name)}):typeof n=="object"&&r.push(...Yw(n,t));else typeof i=="object"&&i!==null&&r.push(...Yw(i,t));return Array.from(new Set(r))}function Qw(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(Qw(s,t,r));i[n]=o}else typeof a=="object"&&a!==null?i[n]=Qw(a,t,r):i[n]=a;return i}var Bu=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"})}},Wf=class extends Bu{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(`
205
+
206
+ `));throw a.name="InputFormatError",a.lc_error_code=i.lc_error_code,a}return r}},ex=class extends Bu{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)]}},Vu=class extends Qn{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Pu(await this.formatMessages(e))}},tx=class extends ex{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 sn(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(yn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function YV(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function QV(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 rx=class extends Bu{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(yn.fromTemplate(e,t));let r=[];for(let i of e)if(typeof i=="string")r.push(yn.fromTemplate(i,t));else if(i!==null)if(YV(i)){let n="";typeof i.text=="string"&&(n=i.text??"");let a={...t,additionalContentFields:i};r.push(yn.fromTemplate(n,a))}else if(QV(i)){let n=i.image_url??"",a,o=[];if(typeof n=="string"){let s;t?.templateFormat==="mustache"?s=qs(n):s=ko(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.
207
+ Got: ${c}
208
+ From: ${n}`);o=[c[0]]}else o=[];n={url:n},a=new Js({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof n=="object"){if("url"in n){let s;t?.templateFormat==="mustache"?s=qs(n.url):s=ko(n.url),o=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else o=[];a=new Js({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 Fu({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof $i){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 $i){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 Js){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 Fu){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)]}},Xf=class extends rx{static _messageClass(){return nt}static lc_name(){return"HumanMessagePromptTemplate"}},nx=class extends rx{static _messageClass(){return Ae}static lc_name(){return"AIMessagePromptTemplate"}},ix=class extends rx{static _messageClass(){return qt}static lc_name(){return"SystemMessagePromptTemplate"}};function eZ(e){return typeof e.formatMessages=="function"}function tZ(e,t){if(eZ(e)||Xe(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 Wf({variableName:n.slice(2,-2),optional:!0});if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")return new Wf({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 Xf.fromTemplate(i,t);if(r._getType()==="ai")return nx.fromTemplate(i,t);if(r._getType()==="system")return ix.fromTemplate(i,t);if(sn.isInstance(r))return tx.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function rZ(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Ks=class Kf extends Vu{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 Ue))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 yn.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 Ue)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)&&!(rZ(n)&&n.optional))throw ui(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 Kf({...this,inputVariables:r,partialVariables:i})}static fromTemplate(t,r){let i=new Xf({prompt:yn.fromTemplate(t,r)});return this.fromMessages([i])}static fromMessages(t,r){let i=t.reduce((o,s)=>o.concat(s instanceof Kf?s.promptMessages:[tZ(s,r)]),[]),n=t.reduce((o,s)=>s instanceof Kf?Object.assign(o,s.partialVariables):o,Object.create(null)),a=new Set;for(let o of i)if(!(o instanceof Ue))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 R1=class ax extends $i{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
209
+
210
+ `;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))),Ei(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 ax({...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 yn.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 ax({inputVariables:t.input_variables,examplePrompt:i,examples:n,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},j1=class M1 extends Vu{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
211
+
212
+ `;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??`
213
+
214
+ `,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))),Ei(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 M1({...this,inputVariables:r,partialVariables:i})}};var z1=class Yf extends Qn{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=Yf.extractRequiredInputValues(r,n.inputVariables);n instanceof Ks?r[i]=await n.formatMessages(a):r[i]=await n.format(a)}return Yf.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 Yf(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function D1(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function nZ(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 L1=class U1 extends Ks{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(D1(t))return super.pipe(t.withStructuredOutput(this.schema));if(nZ(t)&&D1(t.bound))return super.pipe(new Jr({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 U1.fromMessages(t,{schema:r,method:i})}};var F1=I({AIMessagePromptTemplate:()=>nx,BaseChatPromptTemplate:()=>Vu,BaseMessagePromptTemplate:()=>Bu,BaseMessageStringPromptTemplate:()=>ex,BasePromptTemplate:()=>Qn,BaseStringPromptTemplate:()=>$i,ChatMessagePromptTemplate:()=>tx,ChatPromptTemplate:()=>Ks,DEFAULT_FORMATTER_MAPPING:()=>Lu,DEFAULT_PARSER_MAPPING:()=>Xw,DictPromptTemplate:()=>Fu,FewShotChatMessagePromptTemplate:()=>j1,FewShotPromptTemplate:()=>R1,HumanMessagePromptTemplate:()=>Xf,ImagePromptTemplate:()=>Js,MessagesPlaceholder:()=>Wf,PipelinePromptTemplate:()=>z1,PromptTemplate:()=>yn,StructuredPrompt:()=>L1,SystemMessagePromptTemplate:()=>ix,checkValidTemplate:()=>Ei,interpolateFString:()=>Kw,interpolateMustache:()=>Ww,parseFString:()=>ko,parseMustache:()=>qs,parseTemplate:()=>$o,renderTemplate:()=>Lt});var B1=I({BaseDocumentCompressor:()=>iZ}),iZ=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var V1=I({BaseRetriever:()=>Zu}),Zu=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=Se(Ba(t)),i=await(await dt.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 Z1=I({BaseStore:()=>G1,InMemoryStore:()=>aZ}),G1=class extends lt{},aZ=class extends G1{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 vn={and:"and",or:"or",not:"not"},ke={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},Qf=class{},em=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")}},tm=class extends em{},H1=class extends tm{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},q1=class extends tm{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},J1=class extends em{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function ox(e){return e&&typeof e=="object"&&!Array.isArray(e)}function hr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:ox(e)&&Object.keys(e).length===0:!0}function sx(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 cx(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 ux(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function lx(e){return typeof e=="boolean"}function Ws(e){let t;if(ux(e))t=e;else if(sx(e))t=parseInt(e,10);else if(cx(e))t=parseFloat(e);else if(lx(e))t=!!e;else throw new Error("Unsupported value type");return t}var Gu=class extends Qf{},K1=class extends Gu{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[vn.and,vn.or],this.allowedComparators=e?.allowedComparators??[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte]}formatFunction(e){if(e in ke){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 vn){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)]:Ws(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",i=!1){if(!(hr(e)&&hr(t))){if(hr(e)||r==="replace")return hr(t)?void 0:t;if(hr(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 W1=class extends Gu{allowedOperators=[vn.and,vn.or];allowedComparators=[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];case"number":return[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];case"boolean":return[ke.eq,ke.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case ke.eq:return(t,r)=>t===r;case ke.ne:return(t,r)=>t!==r;case ke.gt:return(t,r)=>t>r;case ke.gte:return(t,r)=>t>=r;case ke.lt:return(t,r)=>t<r;case ke.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case vn.and:return(t,r)=>t&&r;case vn.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=[ke.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,Ws(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(!(hr(e)&&hr(t))){if(hr(e)||r==="replace")return hr(t)?void 0:t;if(hr(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 X1=I({BaseTranslator:()=>Gu,BasicTranslator:()=>K1,Comparators:()=>ke,Comparison:()=>H1,Expression:()=>em,FilterDirective:()=>tm,FunctionalTranslator:()=>W1,Operation:()=>q1,Operators:()=>vn,StructuredQuery:()=>J1,Visitor:()=>Qf,castValue:()=>Ws,isBoolean:()=>lx,isFilterEmpty:()=>hr,isFloat:()=>cx,isInt:()=>sx,isObject:()=>ox,isString:()=>ux});function Hu(e){return Ue.isInstance(e)?e.constructor.name||e.type:typeof e}function rm(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)}
215
+
216
+ Expected: ${n?"not ":""}${e}
217
+ Received: ${Hu(r)}`,actual:Hu(r),expected:e};if(i===void 0)return{pass:!0,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
218
+
219
+ Expected: not ${e}
220
+ Received: ${e}`};let o=r;return typeof i=="string"?{pass:o.content===i,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
221
+
222
+ Expected: ${e} with content ${a.printExpected(i)}
223
+ 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)}
224
+
225
+ Expected: ${e} matching ${a.printExpected(i)}
226
+ 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 dx=rm("HumanMessage",nt.isInstance),px=rm("AIMessage",Ae.isInstance),fx=rm("SystemMessage",qt.isInstance),mx=rm("ToolMessage",Ht.isInstance);function hx(e,t){let{isNot:r,utils:i}=this;if(!Ae.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
227
+
228
+ Expected: AIMessage
229
+ Received: ${Hu(e)}`};let n=e.tool_calls??[];if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
230
+
231
+ 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")}
232
+
233
+ Could not find matching tool call(s) for:
234
+ ${i.printExpected(a)}
235
+ 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")}
236
+
237
+ Expected AIMessage not to have matching tool calls`}}function gx(e,t){let{isNot:r,utils:i}=this;if(!Ae.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCallCount")}
238
+
239
+ Expected: AIMessage
240
+ Received: ${Hu(e)}`};let n=e.tool_calls?.length??0;return{pass:n===t,message:()=>`${i.matcherHint("toHaveToolCallCount")}
241
+
242
+ Expected ${r?"not ":""}${t} tool call(s)
243
+ Received: ${n}`,actual:n,expected:t}}function _x(e,t){let{isNot:r,utils:i}=this;if(!Ae.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toContainToolCall")}
244
+
245
+ Expected: AIMessage
246
+ Received: ${Hu(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")}
247
+
248
+ Expected AIMessage ${r?"not ":""}to contain a tool call matching ${i.printExpected(t)}
249
+ 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 yx(e,t){let{isNot:r,utils:i}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
250
+
251
+ Expected an array of messages
252
+ Received: ${typeof e}`};let n=e.filter(Ht.isInstance);if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
253
+
254
+ 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")}
255
+
256
+ Tool message at index ${a} did not match:
257
+ Expected: ${i.printExpected(t[a])}
258
+ Received: ${i.printReceived(o)}`},actual:n[a],expected:t[a]};return{pass:!0,message:()=>`${i.matcherHint("toHaveToolMessages")}
259
+
260
+ Expected messages not to contain matching tool messages`}}function vx(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")}
261
+
262
+ Expected result ${r?"not ":""}to have been interrupted
263
+ Received __interrupt__: ${i.printReceived(n)}`};if(t===void 0)return{pass:!0,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
264
+
265
+ Expected result not to have been interrupted
266
+ Received ${n.length} interrupt(s)`};let a=n[0]?.value;return{pass:this.equals(a,t),message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
267
+
268
+ Expected interrupt value: ${i.printExpected(t)}
269
+ Received interrupt value: ${i.printReceived(a)}`,actual:a,expected:t}}function bx(e,t){let{isNot:r,utils:i}=this,n=e?.structuredResponse;return n===void 0?{pass:!1,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
270
+
271
+ Expected result ${r?"not ":""}to have a structured response
272
+ Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
273
+
274
+ Expected result not to have a structured response`}:{pass:Object.entries(t).every(([a,o])=>this.equals(n[a],o)),message:()=>`${i.matcherHint("toHaveStructuredResponse")}
275
+
276
+ Expected structured response: ${i.printExpected(t)}
277
+ Received structured response: ${i.printReceived(n)}`,actual:n,expected:t}}var Y1={toBeHumanMessage:dx,toBeAIMessage:px,toBeSystemMessage:fx,toBeToolMessage:mx,toHaveToolCalls:hx,toHaveToolCallCount:gx,toContainToolCall:_x,toHaveToolMessages:yx,toHaveBeenInterrupted:vx,toHaveStructuredResponse:bx};function oZ(e){return e.map(t=>t.text).filter(Boolean).join("-")}var Q1=0;function sZ(){return Q1+=1,`fake_tc_${Q1}`}var wx=class eP extends pa{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_callIndex=0;_calls=[];get calls(){return this._calls}get callCount(){return this._calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Ue.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??sZ(),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 eP;return i.queue=this.queue,i._alwaysThrowError=this._alwaysThrowError,i._structuredResponseValue=this._structuredResponseValue,i._tools=r,i._calls=this._calls,i._callIndex=this._callIndex,i.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:i}=this;return zt.from(async()=>i)}async _generate(t,r,i){this._calls.push({messages:[...t],options:r});let n=this._callIndex;if(this._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(!Ue.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(a.kind==="message")return{generations:[{text:"",message:a.message}]};let o=oZ(t);return{generations:[{text:o,message:new Ae({content:o,id:n.toString(),tool_calls:a.toolCalls.length>0?a.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function tP(){return new wx}var rP=I({FakeBuiltModel:()=>wx,fakeModel:()=>tP,langchainMatchers:()=>Y1,toBeAIMessage:()=>px,toBeHumanMessage:()=>dx,toBeSystemMessage:()=>fx,toBeToolMessage:()=>mx,toContainToolCall:()=>_x,toHaveBeenInterrupted:()=>vx,toHaveStructuredResponse:()=>bx,toHaveToolCallCount:()=>gx,toHaveToolCalls:()=>hx,toHaveToolMessages:()=>yx});function qu(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function Ju(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 Ku(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(pr(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 Wu(e){return Ku(e)||Ju(e)||qu(e)}var Xr={};On(Xr,{$brand:()=>op,$input:()=>zv,$output:()=>Mv,NEVER:()=>b_,TimePrecision:()=>Fv,ZodAny:()=>Gx,ZodArray:()=>Kx,ZodBase64:()=>Sm,ZodBase64URL:()=>km,ZodBigInt:()=>nc,ZodBigIntFormat:()=>Im,ZodBoolean:()=>rc,ZodCIDRv4:()=>wm,ZodCIDRv6:()=>xm,ZodCUID:()=>mm,ZodCUID2:()=>hm,ZodCatch:()=>_0,ZodCodec:()=>jm,ZodCustom:()=>cl,ZodCustomStringFormat:()=>ec,ZodDate:()=>nl,ZodDefault:()=>d0,ZodDiscriminatedUnion:()=>Xx,ZodE164:()=>$m,ZodEmail:()=>dm,ZodEmoji:()=>pm,ZodEnum:()=>Ys,ZodError:()=>cZ,ZodExactOptional:()=>c0,ZodFile:()=>o0,ZodFirstPartyTypeKind:()=>O0,ZodFunction:()=>E0,ZodGUID:()=>Yu,ZodIPv4:()=>vm,ZodIPv6:()=>bm,ZodISODate:()=>am,ZodISODateTime:()=>im,ZodISODuration:()=>sm,ZodISOTime:()=>om,ZodIntersection:()=>Yx,ZodIssueCode:()=>lZ,ZodJWT:()=>Em,ZodKSUID:()=>ym,ZodLazy:()=>S0,ZodLiteral:()=>a0,ZodMAC:()=>Dx,ZodMap:()=>n0,ZodNaN:()=>v0,ZodNanoID:()=>fm,ZodNever:()=>qx,ZodNonOptional:()=>Pm,ZodNull:()=>Vx,ZodNullable:()=>l0,ZodNumber:()=>tc,ZodNumberFormat:()=>Io,ZodObject:()=>al,ZodOptional:()=>Nm,ZodPipe:()=>Rm,ZodPrefault:()=>f0,ZodPromise:()=>$0,ZodReadonly:()=>b0,ZodRealError:()=>gr,ZodRecord:()=>sl,ZodSet:()=>i0,ZodString:()=>Qs,ZodStringFormat:()=>ze,ZodSuccess:()=>g0,ZodSymbol:()=>Fx,ZodTemplateLiteral:()=>x0,ZodTransform:()=>s0,ZodTuple:()=>e0,ZodType:()=>_e,ZodULID:()=>gm,ZodURL:()=>rl,ZodUUID:()=>ei,ZodUndefined:()=>Bx,ZodUnion:()=>ol,ZodUnknown:()=>Hx,ZodVoid:()=>Jx,ZodXID:()=>_m,ZodXor:()=>Wx,_ZodString:()=>lm,_default:()=>p0,_function:()=>uR,any:()=>FP,array:()=>il,base64:()=>kP,base64url:()=>$P,bigint:()=>MP,boolean:()=>Ux,catch:()=>y0,check:()=>lR,cidrv4:()=>xP,cidrv6:()=>SP,clone:()=>Ke,codec:()=>oR,coerce:()=>C0,config:()=>at,core:()=>_i,cuid:()=>mP,cuid2:()=>hP,custom:()=>dR,date:()=>VP,decode:()=>Ax,decodeAsync:()=>Px,describe:()=>pR,discriminatedUnion:()=>KP,e164:()=>EP,email:()=>iP,emoji:()=>pP,encode:()=>Cx,encodeAsync:()=>Nx,endsWith:()=>bs,enum:()=>Cm,exactOptional:()=>u0,file:()=>rR,flattenError:()=>ou,float32:()=>NP,float64:()=>PP,formatError:()=>su,fromJSONSchema:()=>vR,function:()=>uR,getErrorMap:()=>pZ,globalRegistry:()=>Ne,gt:()=>Zn,gte:()=>Yt,guid:()=>aP,hash:()=>AP,hex:()=>CP,hostname:()=>OP,httpUrl:()=>dP,includes:()=>ys,instanceof:()=>mR,int:()=>um,int32:()=>RP,int64:()=>zP,intersection:()=>Qx,ipv4:()=>vP,ipv6:()=>wP,iso:()=>Xs,json:()=>gR,jwt:()=>IP,keyof:()=>ZP,ksuid:()=>yP,lazy:()=>k0,length:()=>eo,literal:()=>tR,locales:()=>_u,looseObject:()=>qP,looseRecord:()=>XP,lowercase:()=>gs,lt:()=>Vn,lte:()=>Tr,mac:()=>bP,map:()=>YP,maxLength:()=>Qa,maxSize:()=>ra,meta:()=>fR,mime:()=>ws,minLength:()=>gi,minSize:()=>Gn,multipleOf:()=>ta,nan:()=>aR,nanoid:()=>fP,nativeEnum:()=>eR,negative:()=>tf,never:()=>Tm,nonnegative:()=>nf,nonoptional:()=>h0,nonpositive:()=>rf,normalize:()=>xs,null:()=>Zx,nullable:()=>el,nullish:()=>nR,number:()=>Lx,object:()=>GP,optional:()=>Qu,overwrite:()=>pn,parse:()=>Ex,parseAsync:()=>Ix,partialRecord:()=>WP,pipe:()=>tl,positive:()=>ef,prefault:()=>m0,preprocess:()=>_R,prettifyError:()=>N_,promise:()=>cR,property:()=>af,readonly:()=>w0,record:()=>r0,refine:()=>I0,regex:()=>hs,regexes:()=>Vr,registry:()=>Pp,safeDecode:()=>jx,safeDecodeAsync:()=>zx,safeEncode:()=>Rx,safeEncodeAsync:()=>Mx,safeParse:()=>Tx,safeParseAsync:()=>Ox,set:()=>QP,setErrorMap:()=>dZ,size:()=>Ya,slugify:()=>Es,startsWith:()=>vs,strictObject:()=>HP,string:()=>cm,stringFormat:()=>TP,stringbool:()=>hR,success:()=>iR,superRefine:()=>T0,symbol:()=>LP,templateLiteral:()=>sR,toJSONSchema:()=>to,toLowerCase:()=>ks,toUpperCase:()=>$s,transform:()=>Am,treeifyError:()=>A_,trim:()=>Ss,tuple:()=>t0,uint32:()=>jP,uint64:()=>DP,ulid:()=>gP,undefined:()=>UP,union:()=>Om,unknown:()=>Eo,uppercase:()=>_s,url:()=>lP,util:()=>j,uuid:()=>oP,uuidv4:()=>sP,uuidv6:()=>cP,uuidv7:()=>uP,void:()=>BP,xid:()=>_P,xor:()=>JP});var Xu={};On(Xu,{ZodAny:()=>Gx,ZodArray:()=>Kx,ZodBase64:()=>Sm,ZodBase64URL:()=>km,ZodBigInt:()=>nc,ZodBigIntFormat:()=>Im,ZodBoolean:()=>rc,ZodCIDRv4:()=>wm,ZodCIDRv6:()=>xm,ZodCUID:()=>mm,ZodCUID2:()=>hm,ZodCatch:()=>_0,ZodCodec:()=>jm,ZodCustom:()=>cl,ZodCustomStringFormat:()=>ec,ZodDate:()=>nl,ZodDefault:()=>d0,ZodDiscriminatedUnion:()=>Xx,ZodE164:()=>$m,ZodEmail:()=>dm,ZodEmoji:()=>pm,ZodEnum:()=>Ys,ZodExactOptional:()=>c0,ZodFile:()=>o0,ZodFunction:()=>E0,ZodGUID:()=>Yu,ZodIPv4:()=>vm,ZodIPv6:()=>bm,ZodIntersection:()=>Yx,ZodJWT:()=>Em,ZodKSUID:()=>ym,ZodLazy:()=>S0,ZodLiteral:()=>a0,ZodMAC:()=>Dx,ZodMap:()=>n0,ZodNaN:()=>v0,ZodNanoID:()=>fm,ZodNever:()=>qx,ZodNonOptional:()=>Pm,ZodNull:()=>Vx,ZodNullable:()=>l0,ZodNumber:()=>tc,ZodNumberFormat:()=>Io,ZodObject:()=>al,ZodOptional:()=>Nm,ZodPipe:()=>Rm,ZodPrefault:()=>f0,ZodPromise:()=>$0,ZodReadonly:()=>b0,ZodRecord:()=>sl,ZodSet:()=>i0,ZodString:()=>Qs,ZodStringFormat:()=>ze,ZodSuccess:()=>g0,ZodSymbol:()=>Fx,ZodTemplateLiteral:()=>x0,ZodTransform:()=>s0,ZodTuple:()=>e0,ZodType:()=>_e,ZodULID:()=>gm,ZodURL:()=>rl,ZodUUID:()=>ei,ZodUndefined:()=>Bx,ZodUnion:()=>ol,ZodUnknown:()=>Hx,ZodVoid:()=>Jx,ZodXID:()=>_m,ZodXor:()=>Wx,_ZodString:()=>lm,_default:()=>p0,_function:()=>uR,any:()=>FP,array:()=>il,base64:()=>kP,base64url:()=>$P,bigint:()=>MP,boolean:()=>Ux,catch:()=>y0,check:()=>lR,cidrv4:()=>xP,cidrv6:()=>SP,codec:()=>oR,cuid:()=>mP,cuid2:()=>hP,custom:()=>dR,date:()=>VP,describe:()=>pR,discriminatedUnion:()=>KP,e164:()=>EP,email:()=>iP,emoji:()=>pP,enum:()=>Cm,exactOptional:()=>u0,file:()=>rR,float32:()=>NP,float64:()=>PP,function:()=>uR,guid:()=>aP,hash:()=>AP,hex:()=>CP,hostname:()=>OP,httpUrl:()=>dP,instanceof:()=>mR,int:()=>um,int32:()=>RP,int64:()=>zP,intersection:()=>Qx,ipv4:()=>vP,ipv6:()=>wP,json:()=>gR,jwt:()=>IP,keyof:()=>ZP,ksuid:()=>yP,lazy:()=>k0,literal:()=>tR,looseObject:()=>qP,looseRecord:()=>XP,mac:()=>bP,map:()=>YP,meta:()=>fR,nan:()=>aR,nanoid:()=>fP,nativeEnum:()=>eR,never:()=>Tm,nonoptional:()=>h0,null:()=>Zx,nullable:()=>el,nullish:()=>nR,number:()=>Lx,object:()=>GP,optional:()=>Qu,partialRecord:()=>WP,pipe:()=>tl,prefault:()=>m0,preprocess:()=>_R,promise:()=>cR,readonly:()=>w0,record:()=>r0,refine:()=>I0,set:()=>QP,strictObject:()=>HP,string:()=>cm,stringFormat:()=>TP,stringbool:()=>hR,success:()=>iR,superRefine:()=>T0,symbol:()=>LP,templateLiteral:()=>sR,transform:()=>Am,tuple:()=>t0,uint32:()=>jP,uint64:()=>DP,ulid:()=>gP,undefined:()=>UP,union:()=>Om,unknown:()=>Eo,url:()=>lP,uuid:()=>oP,uuidv4:()=>sP,uuidv6:()=>cP,uuidv7:()=>uP,void:()=>BP,xid:()=>_P,xor:()=>JP});var nm={};On(nm,{endsWith:()=>bs,gt:()=>Zn,gte:()=>Yt,includes:()=>ys,length:()=>eo,lowercase:()=>gs,lt:()=>Vn,lte:()=>Tr,maxLength:()=>Qa,maxSize:()=>ra,mime:()=>ws,minLength:()=>gi,minSize:()=>Gn,multipleOf:()=>ta,negative:()=>tf,nonnegative:()=>nf,nonpositive:()=>rf,normalize:()=>xs,overwrite:()=>pn,positive:()=>ef,property:()=>af,regex:()=>hs,size:()=>Ya,slugify:()=>Es,startsWith:()=>vs,toLowerCase:()=>ks,toUpperCase:()=>$s,trim:()=>Ss,uppercase:()=>_s});var Xs={};On(Xs,{ZodISODate:()=>am,ZodISODateTime:()=>im,ZodISODuration:()=>sm,ZodISOTime:()=>om,date:()=>Sx,datetime:()=>xx,duration:()=>$x,time:()=>kx});var im=b("ZodISODateTime",(e,t)=>{Uy.init(e,t),ze.init(e,t)});function xx(e){return Bv(im,e)}var am=b("ZodISODate",(e,t)=>{Fy.init(e,t),ze.init(e,t)});function Sx(e){return Vv(am,e)}var om=b("ZodISOTime",(e,t)=>{By.init(e,t),ze.init(e,t)});function kx(e){return Zv(om,e)}var sm=b("ZodISODuration",(e,t)=>{Vy.init(e,t),ze.init(e,t)});function $x(e){return Gv(sm,e)}var nP=(e,t)=>{au.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>su(e,r)},flatten:{value:r=>ou(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,os,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,os,2)}},isEmpty:{get(){return e.issues.length===0}}})},cZ=b("ZodError",nP),gr=b("ZodError",nP,{Parent:Error});var Ex=us(gr),Ix=ls(gr),Tx=ds(gr),Ox=ps(gr),Cx=up(gr),Ax=lp(gr),Nx=dp(gr),Px=pp(gr),Rx=fp(gr),jx=mp(gr),Mx=hp(gr),zx=gp(gr);var _e=b("ZodType",(e,t)=>(de.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ts(e,"input"),output:Ts(e,"output")}}),e.toJSONSchema=wb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(j.mergeDefs(t,{checks:[...t.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(r,i)=>Ke(e,r,i),e.brand=()=>e,e.register=((r,i)=>(r.add(e,i),e)),e.parse=(r,i)=>Ex(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>Tx(e,r,i),e.parseAsync=async(r,i)=>Ix(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>Ox(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>Cx(e,r,i),e.decode=(r,i)=>Ax(e,r,i),e.encodeAsync=async(r,i)=>Nx(e,r,i),e.decodeAsync=async(r,i)=>Px(e,r,i),e.safeEncode=(r,i)=>Rx(e,r,i),e.safeDecode=(r,i)=>jx(e,r,i),e.safeEncodeAsync=async(r,i)=>Mx(e,r,i),e.safeDecodeAsync=async(r,i)=>zx(e,r,i),e.refine=(r,i)=>e.check(I0(r,i)),e.superRefine=r=>e.check(T0(r)),e.overwrite=r=>e.check(pn(r)),e.optional=()=>Qu(e),e.exactOptional=()=>u0(e),e.nullable=()=>el(e),e.nullish=()=>Qu(el(e)),e.nonoptional=r=>h0(e,r),e.array=()=>il(e),e.or=r=>Om([e,r]),e.and=r=>Qx(e,r),e.transform=r=>tl(e,Am(r)),e.default=r=>p0(e,r),e.prefault=r=>m0(e,r),e.catch=r=>y0(e,r),e.pipe=r=>tl(e,r),e.readonly=()=>w0(e),e.describe=r=>{let i=e.clone();return Ne.add(i,{description:r}),i},Object.defineProperty(e,"description",{get(){return Ne.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ne.get(e);let i=e.clone();return Ne.add(i,r[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),lm=b("_ZodString",(e,t)=>{Wa.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(i,n,a)=>xb(e,i,n,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...i)=>e.check(hs(...i)),e.includes=(...i)=>e.check(ys(...i)),e.startsWith=(...i)=>e.check(vs(...i)),e.endsWith=(...i)=>e.check(bs(...i)),e.min=(...i)=>e.check(gi(...i)),e.max=(...i)=>e.check(Qa(...i)),e.length=(...i)=>e.check(eo(...i)),e.nonempty=(...i)=>e.check(gi(1,...i)),e.lowercase=i=>e.check(gs(i)),e.uppercase=i=>e.check(_s(i)),e.trim=()=>e.check(Ss()),e.normalize=(...i)=>e.check(xs(...i)),e.toLowerCase=()=>e.check(ks()),e.toUpperCase=()=>e.check($s()),e.slugify=()=>e.check(Es())}),Qs=b("ZodString",(e,t)=>{Wa.init(e,t),lm.init(e,t),e.email=r=>e.check(Rp(dm,r)),e.url=r=>e.check(vu(rl,r)),e.jwt=r=>e.check(Qp(Em,r)),e.emoji=r=>e.check(Lp(pm,r)),e.guid=r=>e.check(yu(Yu,r)),e.uuid=r=>e.check(jp(ei,r)),e.uuidv4=r=>e.check(Mp(ei,r)),e.uuidv6=r=>e.check(zp(ei,r)),e.uuidv7=r=>e.check(Dp(ei,r)),e.nanoid=r=>e.check(Up(fm,r)),e.guid=r=>e.check(yu(Yu,r)),e.cuid=r=>e.check(Fp(mm,r)),e.cuid2=r=>e.check(Bp(hm,r)),e.ulid=r=>e.check(Vp(gm,r)),e.base64=r=>e.check(Wp(Sm,r)),e.base64url=r=>e.check(Xp(km,r)),e.xid=r=>e.check(Zp(_m,r)),e.ksuid=r=>e.check(Gp(ym,r)),e.ipv4=r=>e.check(Hp(vm,r)),e.ipv6=r=>e.check(qp(bm,r)),e.cidrv4=r=>e.check(Jp(wm,r)),e.cidrv6=r=>e.check(Kp(xm,r)),e.e164=r=>e.check(Yp($m,r)),e.datetime=r=>e.check(xx(r)),e.date=r=>e.check(Sx(r)),e.time=r=>e.check(kx(r)),e.duration=r=>e.check($x(r))});function cm(e){return Dv(Qs,e)}var ze=b("ZodStringFormat",(e,t)=>{Me.init(e,t),lm.init(e,t)}),dm=b("ZodEmail",(e,t)=>{Ay.init(e,t),ze.init(e,t)});function iP(e){return Rp(dm,e)}var Yu=b("ZodGUID",(e,t)=>{Oy.init(e,t),ze.init(e,t)});function aP(e){return yu(Yu,e)}var ei=b("ZodUUID",(e,t)=>{Cy.init(e,t),ze.init(e,t)});function oP(e){return jp(ei,e)}function sP(e){return Mp(ei,e)}function cP(e){return zp(ei,e)}function uP(e){return Dp(ei,e)}var rl=b("ZodURL",(e,t)=>{Ny.init(e,t),ze.init(e,t)});function lP(e){return vu(rl,e)}function dP(e){return vu(rl,{protocol:/^https?$/,hostname:Vr.domain,...j.normalizeParams(e)})}var pm=b("ZodEmoji",(e,t)=>{Py.init(e,t),ze.init(e,t)});function pP(e){return Lp(pm,e)}var fm=b("ZodNanoID",(e,t)=>{Ry.init(e,t),ze.init(e,t)});function fP(e){return Up(fm,e)}var mm=b("ZodCUID",(e,t)=>{jy.init(e,t),ze.init(e,t)});function mP(e){return Fp(mm,e)}var hm=b("ZodCUID2",(e,t)=>{My.init(e,t),ze.init(e,t)});function hP(e){return Bp(hm,e)}var gm=b("ZodULID",(e,t)=>{zy.init(e,t),ze.init(e,t)});function gP(e){return Vp(gm,e)}var _m=b("ZodXID",(e,t)=>{Dy.init(e,t),ze.init(e,t)});function _P(e){return Zp(_m,e)}var ym=b("ZodKSUID",(e,t)=>{Ly.init(e,t),ze.init(e,t)});function yP(e){return Gp(ym,e)}var vm=b("ZodIPv4",(e,t)=>{Zy.init(e,t),ze.init(e,t)});function vP(e){return Hp(vm,e)}var Dx=b("ZodMAC",(e,t)=>{Hy.init(e,t),ze.init(e,t)});function bP(e){return Uv(Dx,e)}var bm=b("ZodIPv6",(e,t)=>{Gy.init(e,t),ze.init(e,t)});function wP(e){return qp(bm,e)}var wm=b("ZodCIDRv4",(e,t)=>{qy.init(e,t),ze.init(e,t)});function xP(e){return Jp(wm,e)}var xm=b("ZodCIDRv6",(e,t)=>{Jy.init(e,t),ze.init(e,t)});function SP(e){return Kp(xm,e)}var Sm=b("ZodBase64",(e,t)=>{Wy.init(e,t),ze.init(e,t)});function kP(e){return Wp(Sm,e)}var km=b("ZodBase64URL",(e,t)=>{Xy.init(e,t),ze.init(e,t)});function $P(e){return Xp(km,e)}var $m=b("ZodE164",(e,t)=>{Yy.init(e,t),ze.init(e,t)});function EP(e){return Yp($m,e)}var Em=b("ZodJWT",(e,t)=>{Qy.init(e,t),ze.init(e,t)});function IP(e){return Qp(Em,e)}var ec=b("ZodCustomStringFormat",(e,t)=>{ev.init(e,t),ze.init(e,t)});function TP(e,t,r={}){return Is(ec,e,t,r)}function OP(e){return Is(ec,"hostname",Vr.hostname,e)}function CP(e){return Is(ec,"hex",Vr.hex,e)}function AP(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=Vr[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Is(ec,i,n,t)}var tc=b("ZodNumber",(e,t)=>{Ep.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Sb(e,i,n,a),e.gt=(i,n)=>e.check(Zn(i,n)),e.gte=(i,n)=>e.check(Yt(i,n)),e.min=(i,n)=>e.check(Yt(i,n)),e.lt=(i,n)=>e.check(Vn(i,n)),e.lte=(i,n)=>e.check(Tr(i,n)),e.max=(i,n)=>e.check(Tr(i,n)),e.int=i=>e.check(um(i)),e.safe=i=>e.check(um(i)),e.positive=i=>e.check(Zn(0,i)),e.nonnegative=i=>e.check(Yt(0,i)),e.negative=i=>e.check(Vn(0,i)),e.nonpositive=i=>e.check(Tr(0,i)),e.multipleOf=(i,n)=>e.check(ta(i,n)),e.step=(i,n)=>e.check(ta(i,n)),e.finite=()=>e;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 Lx(e){return Hv(tc,e)}var Io=b("ZodNumberFormat",(e,t)=>{tv.init(e,t),tc.init(e,t)});function um(e){return Jv(Io,e)}function NP(e){return Kv(Io,e)}function PP(e){return Wv(Io,e)}function RP(e){return Xv(Io,e)}function jP(e){return Yv(Io,e)}var rc=b("ZodBoolean",(e,t)=>{du.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>kb(e,r,i,n)});function Ux(e){return Qv(rc,e)}var nc=b("ZodBigInt",(e,t)=>{Ip.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(i,n,a)=>$b(e,i,n,a),e.gte=(i,n)=>e.check(Yt(i,n)),e.min=(i,n)=>e.check(Yt(i,n)),e.gt=(i,n)=>e.check(Zn(i,n)),e.gte=(i,n)=>e.check(Yt(i,n)),e.min=(i,n)=>e.check(Yt(i,n)),e.lt=(i,n)=>e.check(Vn(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(Zn(BigInt(0),i)),e.negative=i=>e.check(Vn(BigInt(0),i)),e.nonpositive=i=>e.check(Tr(BigInt(0),i)),e.nonnegative=i=>e.check(Yt(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(ta(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function MP(e){return tb(nc,e)}var Im=b("ZodBigIntFormat",(e,t)=>{rv.init(e,t),nc.init(e,t)});function zP(e){return nb(Im,e)}function DP(e){return ib(Im,e)}var Fx=b("ZodSymbol",(e,t)=>{nv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eb(e,r,i,n)});function LP(e){return ab(Fx,e)}var Bx=b("ZodUndefined",(e,t)=>{iv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tb(e,r,i,n)});function UP(e){return ob(Bx,e)}var Vx=b("ZodNull",(e,t)=>{av.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ib(e,r,i,n)});function Zx(e){return sb(Vx,e)}var Gx=b("ZodAny",(e,t)=>{ov.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ab(e,r,i,n)});function FP(){return cb(Gx)}var Hx=b("ZodUnknown",(e,t)=>{pu.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Nb(e,r,i,n)});function Eo(){return bu(Hx)}var qx=b("ZodNever",(e,t)=>{fu.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cb(e,r,i,n)});function Tm(e){return wu(qx,e)}var Jx=b("ZodVoid",(e,t)=>{sv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ob(e,r,i,n)});function BP(e){return ub(Jx,e)}var nl=b("ZodDate",(e,t)=>{cv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Pb(e,i,n,a),e.min=(i,n)=>e.check(Yt(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 VP(e){return lb(nl,e)}var Kx=b("ZodArray",(e,t)=>{uv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Gb(e,r,i,n),e.element=t.element,e.min=(r,i)=>e.check(gi(r,i)),e.nonempty=r=>e.check(gi(1,r)),e.max=(r,i)=>e.check(Qa(r,i)),e.length=(r,i)=>e.check(eo(r,i)),e.unwrap=()=>e.element});function il(e,t){return fb(Kx,e,t)}function ZP(e){let t=e._zod.def.shape;return Cm(Object.keys(t))}var al=b("ZodObject",(e,t)=>{lv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Hb(e,r,i,n),j.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Cm(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Eo()}),e.loose=()=>e.clone({...e._zod.def,catchall:Eo()}),e.strict=()=>e.clone({...e._zod.def,catchall:Tm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>j.extend(e,r),e.safeExtend=r=>j.safeExtend(e,r),e.merge=r=>j.merge(e,r),e.pick=r=>j.pick(e,r),e.omit=r=>j.omit(e,r),e.partial=(...r)=>j.partial(Nm,e,r[0]),e.required=(...r)=>j.required(Pm,e,r[0])});function GP(e,t){let r={type:"object",shape:e??{},...j.normalizeParams(t)};return new al(r)}function HP(e,t){return new al({type:"object",shape:e,catchall:Tm(),...j.normalizeParams(t)})}function qP(e,t){return new al({type:"object",shape:e,catchall:Eo(),...j.normalizeParams(t)})}var ol=b("ZodUnion",(e,t)=>{mu.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>sf(e,r,i,n),e.options=t.options});function Om(e,t){return new ol({type:"union",options:e,...j.normalizeParams(t)})}var Wx=b("ZodXor",(e,t)=>{ol.init(e,t),dv.init(e,t),e._zod.processJSONSchema=(r,i,n)=>sf(e,r,i,n),e.options=t.options});function JP(e,t){return new Wx({type:"union",options:e,inclusive:!1,...j.normalizeParams(t)})}var Xx=b("ZodDiscriminatedUnion",(e,t)=>{ol.init(e,t),pv.init(e,t)});function KP(e,t,r){return new Xx({type:"union",options:t,discriminator:e,...j.normalizeParams(r)})}var Yx=b("ZodIntersection",(e,t)=>{fv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>qb(e,r,i,n)});function Qx(e,t){return new Yx({type:"intersection",left:e,right:t})}var e0=b("ZodTuple",(e,t)=>{Tp.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Jb(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function t0(e,t,r){let i=t instanceof de,n=i?r:t,a=i?t:null;return new e0({type:"tuple",items:e,rest:a,...j.normalizeParams(n)})}var sl=b("ZodRecord",(e,t)=>{mv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Kb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function r0(e,t,r){return new sl({type:"record",keyType:e,valueType:t,...j.normalizeParams(r)})}function WP(e,t,r){let i=Ke(e);return i._zod.values=void 0,new sl({type:"record",keyType:i,valueType:t,...j.normalizeParams(r)})}function XP(e,t,r){return new sl({type:"record",keyType:e,valueType:t,mode:"loose",...j.normalizeParams(r)})}var n0=b("ZodMap",(e,t)=>{hv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Vb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Gn(...r)),e.nonempty=r=>e.check(Gn(1,r)),e.max=(...r)=>e.check(ra(...r)),e.size=(...r)=>e.check(Ya(...r))});function YP(e,t,r){return new n0({type:"map",keyType:e,valueType:t,...j.normalizeParams(r)})}var i0=b("ZodSet",(e,t)=>{gv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Zb(e,r,i,n),e.min=(...r)=>e.check(Gn(...r)),e.nonempty=r=>e.check(Gn(1,r)),e.max=(...r)=>e.check(ra(...r)),e.size=(...r)=>e.check(Ya(...r))});function QP(e,t){return new i0({type:"set",valueType:e,...j.normalizeParams(t)})}var Ys=b("ZodEnum",(e,t)=>{_v.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Rb(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 Ys({...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 Ys({...t,checks:[],...j.normalizeParams(n),entries:a})}});function Cm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Ys({type:"enum",entries:r,...j.normalizeParams(t)})}function eR(e,t){return new Ys({type:"enum",entries:e,...j.normalizeParams(t)})}var a0=b("ZodLiteral",(e,t)=>{yv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>jb(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 tR(e,t){return new a0({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}var o0=b("ZodFile",(e,t)=>{vv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Db(e,r,i,n),e.min=(r,i)=>e.check(Gn(r,i)),e.max=(r,i)=>e.check(ra(r,i)),e.mime=(r,i)=>e.check(ws(Array.isArray(r)?r:[r],i))});function rR(e){return mb(o0,e)}var s0=b("ZodTransform",(e,t)=>{bv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Bb(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Ki(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)):(r.value=n,r)}});function Am(e){return new s0({type:"transform",transform:e})}var Nm=b("ZodOptional",(e,t)=>{Xa.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cf(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Qu(e){return new Nm({type:"optional",innerType:e})}var c0=b("ZodExactOptional",(e,t)=>{wv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cf(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function u0(e){return new c0({type:"optional",innerType:e})}var l0=b("ZodNullable",(e,t)=>{xv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Wb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function el(e){return new l0({type:"nullable",innerType:e})}function nR(e){return Qu(el(e))}var d0=b("ZodDefault",(e,t)=>{Sv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Yb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function p0(e,t){return new d0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var f0=b("ZodPrefault",(e,t)=>{kv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Qb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function m0(e,t){return new f0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Pm=b("ZodNonOptional",(e,t)=>{$v.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Xb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function h0(e,t){return new Pm({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}var g0=b("ZodSuccess",(e,t)=>{Ev.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Lb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function iR(e){return new g0({type:"success",innerType:e})}var _0=b("ZodCatch",(e,t)=>{Iv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ew(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function y0(e,t){return new _0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var v0=b("ZodNaN",(e,t)=>{Tv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Mb(e,r,i,n)});function aR(e){return pb(v0,e)}var Rm=b("ZodPipe",(e,t)=>{Ov.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>tw(e,r,i,n),e.in=t.in,e.out=t.out});function tl(e,t){return new Rm({type:"pipe",in:e,out:t})}var jm=b("ZodCodec",(e,t)=>{Rm.init(e,t),hu.init(e,t)});function oR(e,t,r){return new jm({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var b0=b("ZodReadonly",(e,t)=>{Cv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>rw(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function w0(e){return new b0({type:"readonly",innerType:e})}var x0=b("ZodTemplateLiteral",(e,t)=>{Av.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>zb(e,r,i,n)});function sR(e,t){return new x0({type:"template_literal",parts:e,...j.normalizeParams(t)})}var S0=b("ZodLazy",(e,t)=>{Rv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>iw(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function k0(e){return new S0({type:"lazy",getter:e})}var $0=b("ZodPromise",(e,t)=>{Pv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>nw(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function cR(e){return new $0({type:"promise",innerType:e})}var E0=b("ZodFunction",(e,t)=>{Nv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Fb(e,r,i,n)});function uR(e){return new E0({type:"function",input:Array.isArray(e?.input)?t0(e?.input):e?.input??il(Eo()),output:e?.output??Eo()})}var cl=b("ZodCustom",(e,t)=>{jv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ub(e,r,i,n)});function lR(e){let t=new Le({check:"custom"});return t._zod.check=e,t}function dR(e,t){return hb(cl,e??(()=>!0),t)}function I0(e,t={}){return gb(cl,e,t)}function T0(e){return _b(e)}var pR=yb,fR=vb;function mR(e,t={}){let r=new cl({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 hR=(...e)=>bb({Codec:jm,Boolean:rc,String:Qs},...e);function gR(e){let t=k0(()=>Om([cm(e),Lx(),Ux(),Zx(),il(t),r0(cm(),t)]));return t}function _R(e,t){return tl(Am(e),t)}var lZ={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 dZ(e){at({customError:e})}function pZ(){return at().customError}var O0;O0||(O0={});var Z={...Xu,...nm,iso:Xs},fZ=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 mZ(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 hZ(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 yR(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return Z.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 Z.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=hZ(n,t),o=Ut(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 Z.null();if(n.length===0)return Z.never();if(n.length===1)return Z.literal(n[0]);if(n.every(o=>typeof o=="string"))return Z.enum(n);let a=n.map(o=>Z.literal(o));return a.length<2?a[0]:Z.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return Z.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(a=>{let o={...e,type:a};return yR(o,t)});return n.length===0?Z.never():n.length===1?n[0]:Z.union(n)}if(!r)return Z.any();let i;switch(r){case"string":{let n=Z.string();if(e.format){let a=e.format;a==="email"?n=n.check(Z.email()):a==="uri"||a==="uri-reference"?n=n.check(Z.url()):a==="uuid"||a==="guid"?n=n.check(Z.uuid()):a==="date-time"?n=n.check(Z.iso.datetime()):a==="date"?n=n.check(Z.iso.date()):a==="time"?n=n.check(Z.iso.time()):a==="duration"?n=n.check(Z.iso.duration()):a==="ipv4"?n=n.check(Z.ipv4()):a==="ipv6"?n=n.check(Z.ipv6()):a==="mac"?n=n.check(Z.mac()):a==="cidr"?n=n.check(Z.cidrv4()):a==="cidr-v6"?n=n.check(Z.cidrv6()):a==="base64"?n=n.check(Z.base64()):a==="base64url"?n=n.check(Z.base64url()):a==="e164"?n=n.check(Z.e164()):a==="jwt"?n=n.check(Z.jwt()):a==="emoji"?n=n.check(Z.emoji()):a==="nanoid"?n=n.check(Z.nanoid()):a==="cuid"?n=n.check(Z.cuid()):a==="cuid2"?n=n.check(Z.cuid2()):a==="ulid"?n=n.check(Z.ulid()):a==="xid"?n=n.check(Z.xid()):a==="ksuid"&&(n=n.check(Z.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"?Z.number().int():Z.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=Z.boolean();break}case"null":{i=Z.null();break}case"object":{let n={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(a)){let l=Ut(u,t);n[c]=o.has(c)?l:l.optional()}if(e.propertyNames){let c=Ut(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Ut(e.additionalProperties,t):Z.any();if(Object.keys(n).length===0){i=Z.record(c,u);break}let l=Z.object(n).passthrough(),d=Z.looseRecord(c,u);i=Z.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let f=Ut(c[p],t),m=Z.string().regex(new RegExp(p));l.push(Z.looseRecord(m,f))}let d=[];if(Object.keys(n).length>0&&d.push(Z.object(n).passthrough()),d.push(...l),d.length===0)i=Z.object({}).passthrough();else if(d.length===1)i=d[0];else{let p=Z.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=Z.intersection(p,d[f]);i=p}break}let s=Z.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(Ut(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=>Ut(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?Ut(a,t):void 0;s?i=Z.tuple(o).rest(s):i=Z.tuple(o),typeof e.minItems=="number"&&(i=i.check(Z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(Z.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>Ut(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Ut(e.additionalItems,t):void 0;s?i=Z.tuple(o).rest(s):i=Z.tuple(o),typeof e.minItems=="number"&&(i=i.check(Z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(Z.maxLength(e.maxItems)))}else if(a!==void 0){let o=Ut(a,t),s=Z.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=Z.array(Z.any());break}default:throw new Error(`Unsupported type: ${r}`)}return e.description&&(i=i.describe(e.description)),e.default!==void 0&&(i=i.default(e.default)),i}function Ut(e,t){if(typeof e=="boolean")return e?Z.any():Z.never();let r=yR(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=>Ut(u,t)),c=Z.union(s);r=i?Z.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>Ut(u,t)),c=Z.xor(s);r=i?Z.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:Z.any();else{let s=i?r:Ut(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=Z.intersection(s,Ut(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=Z.nullable(r)),e.readOnly===!0&&(r=Z.readonly(r));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))fZ.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),r}function vR(e,t){if(typeof e=="boolean")return e?Z.any():Z.never();let r=mZ(e,t?.defaultTarget),i=e.$defs||e.definitions||{},n={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??Ne};return Ut(e,n)}var C0={};On(C0,{bigint:()=>vZ,boolean:()=>yZ,date:()=>bZ,number:()=>_Z,string:()=>gZ});function gZ(e){return Lv(Qs,e)}function _Z(e){return qv(tc,e)}function yZ(e){return eb(rc,e)}function vZ(e){return rb(nc,e)}function bZ(e){return db(nl,e)}at(Op());var bR=I({BaseToolkit:()=>wZ,DynamicStructuredTool:()=>SR,DynamicTool:()=>xR,StructuredTool:()=>ul,Tool:()=>wR,ToolInputParsingException:()=>qo,isLangChainTool:()=>Wu,isRunnableToolLike:()=>Ju,isStructuredTool:()=>qu,isStructuredToolParams:()=>Ku,tool:()=>xZ}),ul=class extends Uf{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=Se(St(this.defaultConfig,t));return Di(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){let i=Di(e)?e.args:e,n;if(pr(this.schema))try{n=await oa(this.schema,i)}catch(f){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
278
+ Details: ${f.message}`),hf(f)&&(m=`${m}
279
+
280
+ ${Xr.prettifyError(f)}`),new qo(m,JSON.stringify(e))}else{let f=Ve(i,this.schema);if(!f.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
281
+ Details: ${f.errors.map(_=>`${_.keywordLocation}: ${_.error}`).join(`
282
+ `)}`),new qo(m,JSON.stringify(e))}n=i}let a=Ba(t),o=dt.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Di(e)&&(s=e.id),!s&&Nk(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 f=await this._call(n,c,a);u=bw(f)?await oN(f,async m=>{try{await c?.handleToolEvent(m)}catch(_){await c?.handleToolError(_)}}):f}catch(f){throw await c?.handleToolError(f),f}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
283
+ Result: ${JSON.stringify(u)}`);else l=u;let p=SZ({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(p),p}},wR=class extends ul{schema=kt.object({input:kt.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)}},xR=class extends wR{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=Ba(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},SR=class extends ul{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=Ba(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)}},wZ=class{getTools(){return this.tools}};function xZ(e,t){let r=As(t.schema),i=Fs(t.schema);if(!t.schema||r||i)return new xR({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(o,s,c)=>new Promise((u,l)=>{let d=Ie(c,{callbacks:s?.getChild()});Oe.runWithConfig(ur(d),async()=>{try{u(e(o,d))}catch(p){l(p)}})})});let n=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new SR({...t,description:a,schema:n,func:async(o,s,c)=>new Promise((u,l)=>{let d,p=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{p(),l(Zi(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let f=Ie(c,{callbacks:s?.getChild()});Oe.runWithConfig(ur(f),async()=>{try{let m=await e(o,f);if(bw(m)){u(m);return}if(c?.signal?.aborted){p();return}p(),u(m)}catch(m){p(),l(m)}})})})}function SZ(e){let{content:t,artifact:r,toolCallId:i,metadata:n}=e;return i&&!Tc(t)?typeof t=="string"||Array.isArray(t)&&t.every(a=>typeof a=="object")?new Ht({status:"success",content:t,artifact:r,tool_call_id:i,name:e.name,metadata:n}):new Ht({status:"success",content:kZ(t),artifact:r,tool_call_id:i,name:e.name,metadata:n}):t}function kZ(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var kR=I({RunCollectorCallbackHandler:()=>$Z}),$Z=class extends Ot{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 $R=I({});var ER=I({chunkArray:()=>EZ}),EZ=(e,t)=>e.reduce((r,i,n)=>{let a=Math.floor(n/t);return r[a]=(r[a]||[]).concat([i]),r},[]);var IR=I({context:()=>IZ});function IZ(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=TZ(t[n],i);i+=typeof o=="string"?o:JSON.stringify(o)}}return i=OZ(i),i=i.trim(),i=i.replace(/\\n/g,`
284
+ `),i}function TZ(e,t){if(typeof e!="string"||!e.includes(`
285
+ `))return e;let r=t.slice(t.lastIndexOf(`
286
+ `)+1).match(/^(\s+)/);if(r){let i=r[1];return e.replace(/\n/g,`
287
+ ${i}`)}return e}function OZ(e){let t=e.split(`
288
+ `),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(`
289
+ `)}var TR=I({EventStreamContentType:()=>CZ,convertEventStreamToIterableReadableDataStream:()=>NZ,getBytes:()=>OR,getLines:()=>CR,getMessages:()=>AR}),CZ="text/event-stream";async function OR(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(`
290
+ `))}}var ic=(function(e){return e[e.NewLine=10]="NewLine",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.Colon=58]="Colon",e})(ic||{});function CR(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=AZ(t,o);let c=t.length,u=0;for(;r<c;){n&&(t[r]===ic.NewLine&&(u=++r),n=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case ic.Colon:i===-1&&(i=r-u);break;case ic.CarriageReturn:n=!0;case ic.NewLine: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 AR(e,t,r){let i=A0(),n=new TextDecoder;return function(o,s,c){if(c){PZ(i)||(e?.(i),i=A0());return}if(o.length===0)e?.(i),i=A0();else if(s>0){let u=n.decode(o.subarray(0,s)),l=s+(o[s+1]===ic.Space?2:1),d=n.decode(o.subarray(l));switch(u){case"data":i.data=i.data?i.data+`
291
+ `+d:d;break;case"event":i.event=d;break;case"id":t?.(i.id=d);break;case"retry":{let p=parseInt(d,10);Number.isNaN(p)||r?.(i.retry=p);break}}}}}function AZ(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function A0(){return{data:"",event:"",id:"",retry:void 0}}function NZ(e,t){let r=new ReadableStream({async start(i){let n=AR(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 OR(e,CR((o,s,c)=>{n(o,s,c),c&&i.close()}))}});return mt.fromReadableStream(r)}function PZ(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var NR=I({});var PR=I({convertToOpenAIFunction:()=>RR,convertToOpenAITool:()=>RZ,isLangChainTool:()=>Wu,isRunnableToolLike:()=>Ju,isStructuredTool:()=>qu,isStructuredToolParams:()=>Ku});function RR(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:bt(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function RZ(e,t){let r=typeof t=="number"?void 0:t,i;return Wu(e)?i={type:"function",function:RR(e)}:i=e,r?.strict!==void 0&&(i.function.strict=r.strict),i}function Mm(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 jR(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}function jZ(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 MR(e,t){return Math.sqrt(jZ(e,t))}var zR=I({cosineSimilarity:()=>N0,euclideanDistance:()=>DZ,innerProduct:()=>zZ,matrixFunc:()=>zm,maximalMarginalRelevance:()=>LZ,normalize:()=>MZ});function zm(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 MZ(e,t=!1){let r=UZ(e);return e.map(i=>i.map(n=>t?1-n/r:n/r))}function N0(e,t){return zm(e,t,Mm)}function zZ(e,t){return zm(e,t,jR)}function DZ(e,t){return zm(e,t,MR)}function LZ(e,t,r=.5,i=4){if(Math.min(i,t.length)<=0)return[];let n=N0(Array.isArray(e[0])?e:[e],t)[0],a=DR(n).maxIndex,o=[t[a]],s=[a];for(;s.length<Math.min(i,t.length);){let c=-1/0,u=-1,l=N0(t,o);n.forEach((d,p)=>{if(s.includes(p))return;let f=Math.max(...l[p]),m=r*d-(1-r)*f;m>c&&(c=m,u=p)}),o.push(t[u]),s.push(u)}return s}function DR(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 UZ(e){return e.reduce((t,r)=>Math.max(t,DR(r).maxValue),0)}var LR=I({isCloudMetadata:()=>P0,isLocalhost:()=>R0,isPrivateIp:()=>ZR,isSafeUrl:()=>JZ,isSameOrigin:()=>KZ,validateSafeUrl:()=>GR}),FZ=["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"],BZ=["169.254.169.254","169.254.170.2","100.100.100.200"],VZ=["metadata.google.internal","metadata","instance-data"],ZZ=["localhost","localhost.localdomain"],GZ=/^(?:(?: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 UR(e){return GZ.test(e)}function Dm(e){return VR(e)!==null}function FR(e){return UR(e)||Dm(e)}function BR(e){if(UR(e))return e.split(".").map(t=>parseInt(t,10));if(Dm(e)){let t=VR(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 VR(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 HZ(e){let[t,r]=e.split("/");if(!t||!r)return null;let i=BR(t);if(!i)return null;let n=parseInt(r,10);if(isNaN(n))return null;let a=Dm(t);return a&&n>128||!a&&n>32?null:{addr:i,prefixLen:n,isIpv6:a}}function qZ(e,t){let r=BR(e);if(!r)return!1;let i=HZ(t);if(!i)return!1;let n=Dm(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 ZR(e){if(!FR(e))return!1;for(let t of FZ)if(qZ(e,t))return!0;return!1}function P0(e,t){if(BZ.includes(t||""))return!0;let r=e.toLowerCase();return!!VZ.includes(r)}function R0(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!!ZZ.includes(r)}function GR(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(P0(a))throw new Error(`URL points to cloud metadata endpoint: ${a}`);if(R0(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(FR(a)){let s=a;if(R0(a,s)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}if(P0(a,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${a})`);if(ZR(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 JZ(e,t){try{return GR(e,t),!0}catch{return!1}}function KZ(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var HR=I({SaveableVectorStore:()=>WZ,VectorStore:()=>Um,VectorStoreRetriever:()=>Lm}),Lm=class extends Zu{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)}},Um=class extends lt{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 Lm({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 Lm({...o,searchKwargs:e.searchKwargs}):new Lm({...o})}}},WZ=class extends Um{static load(e,t){throw new Error("Not implemented")}};var qR=class extends pa{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Ae(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(`
292
+ `);return await r?.handleLLMNewToken(i),{generations:[{message:new Ae(i),text:i}],llmOutput:{}}}},JR=class KR extends pa{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:bt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:bt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:bt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:bt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new KR({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 Ae({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 Ji({message:new vt({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 Ae(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 Ji({message:new vt({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})}}},WR=class XR extends pa{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 Ae(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 Ji({message:new vt({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:bt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:bt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:bt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:bt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new XR({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 zt.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 YR=class extends Pf{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})}},QR=class extends Pf{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 ej=class extends qf{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}},tj=class extends qf{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 rj=class extends Ew{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 nt(e))}async addAIMessage(e){this.messages.push(new Ae(e))}async clear(){this.messages=[]}},nj=class extends Nf{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},ij=class extends Ot{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var aj=class extends _n{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var oj=class extends Zu{lc_namespace=["test","fake"];output=[new Ar({pageContent:"foo"}),new Ar({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var sj=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 cj=class extends ul{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 uj=class extends Ot{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 lj=class dj extends Um{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...i}={}){super(t,i),this.similarity=r??Mm}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 Ar({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 Ar({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 Ar({pageContent:t[o],metadata:s});a.push(c)}return dj.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 pj=I({FakeChatMessageHistory:()=>rj,FakeChatModel:()=>qR,FakeEmbeddings:()=>QR,FakeLLM:()=>ej,FakeListChatMessageHistory:()=>nj,FakeListChatModel:()=>WR,FakeRetriever:()=>oj,FakeRunnable:()=>sj,FakeSplitIntoListParser:()=>aj,FakeStreamingChatModel:()=>JR,FakeStreamingLLM:()=>tj,FakeTool:()=>cj,FakeTracer:()=>ij,FakeVectorStore:()=>lj,SingleRunExtractor:()=>uj,SyntheticEmbeddings:()=>YR});var fj=I({agents:()=>sk,caches:()=>c$,callbacks__base:()=>_$,callbacks__manager:()=>WT,callbacks__promises:()=>qT,chat_history:()=>EN,document_loaders__base:()=>ON,document_loaders__langsmith:()=>CN,documents:()=>TN,embeddings:()=>AN,errors:()=>dk,example_selectors:()=>UN,index:()=>ok,indexing:()=>VN,language_models__base:()=>XN,language_models__chat_models:()=>b1,language_models__llms:()=>w1,language_models__profile:()=>S1,language_models__structured_output:()=>y1,load__serializable:()=>XS,memory:()=>k1,messages:()=>$N,messages__tool:()=>Ak,output_parsers:()=>m1,output_parsers__openai_functions:()=>I1,output_parsers__openai_tools:()=>T1,outputs:()=>fO,prompt_values:()=>ZN,prompts:()=>F1,retrievers:()=>V1,retrievers__document_compressors:()=>B1,runnables:()=>r1,runnables__graph:()=>eN,singletons:()=>rO,stores:()=>Z1,structured_query:()=>X1,testing:()=>rP,tools:()=>bR,tracers__base:()=>RT,tracers__console:()=>UT,tracers__log_stream:()=>pO,tracers__run_collector:()=>kR,tracers__tracer_langchain:()=>BT,types__stream:()=>$R,utils__async_caller:()=>yO,utils__chunk_array:()=>ER,utils__context:()=>IR,utils__env:()=>QS,utils__event_source_parse:()=>TR,utils__format:()=>NR,utils__function_calling:()=>PR,utils__hash:()=>ck,utils__json_patch:()=>n1,utils__json_schema:()=>qA,utils__math:()=>zR,utils__ssrf:()=>LR,utils__standard_schema:()=>vO,utils__stream:()=>nO,utils__testing:()=>pj,utils__tiktoken:()=>KN,utils__types:()=>h1,vectorstores:()=>HR});var XZ=50;function YZ(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 Fm(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((p,f)=>Fm.call({...this,path:[...o,`${f}`],depth:s+1},p)));let l=e;if(jh(l))return Ul(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[p]=l.id;if(p in n)return n[p];if(a){let f=Zt(p);if(f)return f}throw new Error(`Missing secret "${p}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let p=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${p}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let p=l,f=JSON.stringify(p),[m,..._]=p.id.slice().reverse(),v=_.reverse(),k={langchain_core:fj,langchain:i},w=null,x=[v.join("/")];v[0]==="langchain_community"&&x.push(["langchain",...v.slice(1)].join("/"));let $=x.find(O=>O in t);if(ak.concat(r).includes(v.join("/"))||$)if($!==void 0)w=await t[$];else throw new Error(`Missing key "${v.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let O;if(v[0]==="langchain"||v[0]==="langchain_core")O=k[v[0]],v.shift();else throw new Error(`Invalid namespace: ${u} -> ${f}`);if(v.length===0)throw new Error(`Invalid namespace: ${u} -> ${f}`);let y;do{if(y=v.join("__"),y in O)break;v.pop()}while(v.length>0);y in O&&(w=O[y])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${u} -> ${f}`);let T=w[m]??Object.values(w).find(O=>typeof O=="function"&&Bo(O)===m);if(typeof T!="function")throw new Error(`Invalid identifer: ${u} -> ${f}`);let B=new T(Dl(await Fm.call({...this,path:[...o,"kwargs"],depth:s+1},p.kwargs),qS,YZ(T)));return Object.defineProperty(B.constructor,"name",{value:m}),B}let d={};for(let[p,f]of Object.entries(l))d[p]=await Fm.call({...this,path:[...o,p],depth:s+1},f);return d}async function mj(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??XZ};return Fm.call(i,r)}function QZ(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function j0(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>j0(t)));{let t={};for(let[r,i]of Object.entries(e))t[r]=await j0(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(QZ(t))return mj(JSON.stringify(t));return t}}return e}function Bm(e,t,r,i){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:i??{}}}function e3(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Set||e instanceof Map?Bm(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?Bm(RegExp,void 0,[e.source,e.flags]):e instanceof Error?Bm(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args}:e instanceof Uint8Array?Bm(Uint8Array,"from",[Array.from(e)]):e}var Vm=class{_dumps(e){return new TextEncoder().encode(RS(e,(t,r)=>e3(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return j0(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 M0(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]=M0(e[r]));return t}function ac(){return{v:4,id:$c(-2),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function bn(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:M0(e.versions_seen)}}var Zm=class{serde=new Vm;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 Gm(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function ll(...e){return e.reduce((t,r,i)=>i===0?r:Gm(t,r)>=0?t:r)}var dl={[Oh]:-1,[Ca]:-2,[Ch]:-3,[Ah]:-4};function z0(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}function pl(e,t,r){return JSON.stringify([e,t,r])}function t3(e){let[t,r,i]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:i}}var hj=class extends Zm{storage={};writes={};constructor(e){super(e)}async _migratePendingSends(e,t,r,i){let n=e,a=pl(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?ll(...Object.values(n.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",i=z0(e);if(i){let n=this.storage[t]?.[r]?.[i];if(n!==void 0){let[a,o,s]=n,c=pl(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([p,f,m])=>[p,f,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((p,f)=>f.localeCompare(p))[0];let[a,o,s]=n[i],c=pl(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([p,f,m])=>[p,f,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((p,f)=>f[0].localeCompare(p[0]));for(let[p,[f,m,_]]of d){if(s&&p!==s||r&&r.configurable?.checkpoint_id&&p>=r.configurable.checkpoint_id)continue;let v=await this.serde.loadsTyped("json",m);if(n&&!Object.entries(n).every(([B,O])=>v[B]===O))continue;if(i!==void 0){if(i<=0)break;i-=1}let k=pl(c,u,p),w=Object.values(this.writes[k]||{}),x=await Promise.all(w.map(async([B,O,y])=>[B,O,await this.serde.loadsTyped("json",y)])),$=await this.serde.loadsTyped("json",f);$.v<4&&_!==void 0&&await this._migratePendingSends($,c,u,_);let T={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:p}},checkpoint:$,metadata:v,pendingWrites:x};_!==void 0&&(T.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:_}}),yield T}}}async put(e,t,r){let i=bn(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.');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');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=pl(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),p=[r,dl[c]||l],f=`${p[0]},${p[1]}`;p[1]>=0&&s&&f in s||(this.writes[o][f]=[r,c,d])}))}async deleteThread(e){delete this.storage[e];for(let t of Object.keys(this.writes))t3(t).threadId===e&&delete this.writes[t]}};var oc=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function r3(e){if(e.length===0)throw new oc("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new oc(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new oc(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new oc(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new oc(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var sc=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){r3(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 n3=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,Hm=class extends sc{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=n3(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 i3(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 gj(e,t){return i3(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 _j(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 p=n;for(let f of d)if(p&&typeof p=="object"&&f in p)p=p[f];else{p=void 0;break}p!==void 0&&(typeof p=="string"||typeof p=="number"||typeof p=="boolean"?c.push(String(p)):(Array.isArray(p)||typeof p=="object")&&c.push(JSON.stringify(p,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 yj=class extends sc{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])=>gj(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 p of d)n.push(l),a.push(p);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 p=`${d.namespace.join(":")}:${d.key}`;if(c.has(p))continue;let f=c.size;if(f>=r+i)break;if(f<r){c.add(p);continue}c.add(p),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=_j(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 qm=class{serde=new Vm;constructor(e){this.serde=e||this.serde}};function L0(e){return e!=null&&e.lg_is_channel===!0}var $t=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Pe.unminifiable_name)return!1;throw e}}equals(e){return this===e}},D0=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function ml(e){if(e[D0]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];L0(i)&&(t[r]=i)}return Object.assign(t,{[D0]:!0}),t}function fa(e,t){let r=ml(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,{[D0]:!0}),i}function wn(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!==Pe.unminifiable_name)throw o}}return{v:4,id:i?.id??$c(r),ts:new Date().toISOString(),channel_values:n,channel_versions:e.channel_versions,versions_seen:e.versions_seen}}var a3=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",Ii=class vj extends $t{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 vj(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]=Tl(n);a?this.value=o:this.value=n,r=r.slice(1)}let i=!1;for(let n of r)if($S(n)){if(i)throw new xe("Can receive only one Overwrite value per step.");let[,a]=Tl(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 Pe;return this.value}checkpoint(){if(this.value===void 0)throw new Pe;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:a3(t)?this.operator===t.operator:!1}};var xn=class bj extends $t{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new bj(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new xe("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 Pe;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Pe;return this.value[0]}isAvailable(){return this.value.length!==0}},U0=class wj extends $t{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new wj;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 Pe;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 Jm=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"}},hl=function(e){return e?Km(e):new xn};hl.Root=e=>new Jm(e);function Km(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new Ii(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new Ii(e.value,e.default):new xn}var o3=["tags","metadata","callbacks","configurable"],s3=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","executionInfo","serverInfo"],c3=25;function cc(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:c3,configurable:{}},r=Oe.getRunnableConfig();if(r!==void 0){for(let[i,n]of Object.entries(r))if(n!==void 0)if(o3.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&&s3.includes(n)&&(t[n]=a);for(let[i,n]of Object.entries(t.configurable))t.metadata=t.metadata??{},!i.startsWith("__")&&(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&!(i in t.metadata)&&(t.metadata[i]=n);return t}function u3(e){let t=e??Oe.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(`
293
+ `));return t?.store}function l3(e){let t=e??Oe.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(`
294
+ `));return t?.writer||t?.configurable?.writer}function F0(){return Oe.getRunnableConfig()}function d3(e){let t=e??Oe.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(`
295
+ `));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[or].currentTaskInput}function Wm(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function xj(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var U=e=>BigInt(e),De=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),Ej=U("0x9E3779B1"),Ij=U("0x85EBCA77"),p3=U("0xC2B2AE3D"),ma=U("0x9E3779B185EBCA87"),To=U("0xC2B2AE3D27D4EB4F"),Tj=U("0x165667B19E3779F9"),Z0=U("0x85EBCA77C2B2AE63"),f3=U("0x27D4EB2F165667C5"),m3=U("0x165667919E3779F9"),h3=U("0x9FB21C651E98DF25"),g3=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)},ti=g3("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),uc=(U(1)<<U(128))-U(1),we=(U(1)<<U(64))-U(1),eh=(U(1)<<U(32))-U(1),Ti=64,Oj=Ti/8,_3=8,Xm=4;function lc(e){if(!e)throw new Error("Assert failed")}function y3(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function v3(e){let t=e;return t=(t&U(65535))<<U(16)|(t&U(4294901760))>>U(16),t=(t&U(16711935))<<U(8)|(t&U(4278255360))>>U(8),t}function b3(e,t){return(e&eh)*(t&eh)&we}function w3(e,t){return(e<<t|e>>U(32)-t)&eh}function Cj(e,t,r){for(let i=0;i<Oj;i+=1){let n=t.getBigUint64(i*8,!0),a=n^r.getBigUint64(i*8,!0);e[i^1]+=n,e[i]+=b3(a,a>>U(32))}return e}function Sj(e,t,r,i){for(let n=0;n<i;n+=1)Cj(e,De(t,n*Ti),De(r,n*8));return e}function x3(e,t){for(let r=0;r<Oj;r+=1){let i=t.getBigUint64(r*8,!0),n=e[r];n=B0(n,U(47)),n^=i,n*=Ej,e[r]=n&we}return e}function Ym(e,t){return Aj(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(_3,!0))}function kj(e,t,r){let i=r;return i+=Ym(e.slice(0),De(t,0*Xm)),i+=Ym(e.slice(2),De(t,4*Xm)),i+=Ym(e.slice(4),De(t,8*Xm)),i+=Ym(e.slice(6),De(t,12*Xm)),ri(i&we)}function S3(e,t,r,i,n){let a=e,o=Math.floor((r.byteLength-Ti)/8),s=Ti*o,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)a=Sj(a,De(t,u*s),r,o),a=n(a,De(r,r.byteLength-Ti));{let u=Math.floor((t.byteLength-1-s*c)/Ti);a=Sj(a,De(t,c*s),r,u),a=i(a,De(t,t.byteLength-Ti),De(r,r.byteLength-Ti-7))}return a}function k3(e,t){let r=new BigUint64Array([p3,ma,To,Tj,Z0,Ij,f3,Ej]);lc(e.byteLength>128),r=S3(r,e,t,Cj,x3),lc(r.length*8===64);{let i=kj(r,De(t,11),U(e.byteLength)*ma&we);return kj(r,De(t,t.byteLength-Ti-11),~(U(e.byteLength)*To)&we)<<U(64)|i}}function Aj(e,t){let r=e*t&uc;return r&we^r>>U(64)}function $j(e,t,r){return Aj((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&we,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&we)}function Qm(e,t,r,i,n){let a=e&we,o=e>>U(64)&we;return a+=$j(t,i,n),a^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),a&=we,o+=$j(r,De(i,16),n),o^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),o&=we,o<<U(64)|a}function ri(e){let t=e;return t^=t>>U(37),t*=m3,t&=we,t^=t>>U(32),t}function th(e){let t=e;return t^=t>>U(33),t*=To,t&=we,t^=t>>U(29),t*=Tj,t&=we,t^=t>>U(32),t}function $3(e,t,r){let i=e.byteLength;lc(i>0&&i<=3);let n=U(e.getUint8(i-1))|U(i<<8)|U(e.getUint8(0)<<16)|U(e.getUint8(i>>1)<<24),a=(n^(U(t.getUint32(0,!0))^U(t.getUint32(4,!0)))+r)&we,o=(U(t.getUint32(8,!0))^U(t.getUint32(12,!0)))-r;return(th((w3(v3(n),U(13))^o)&we)&we)<<U(64)|th(a)}function B0(e,t){return e^e>>t}function E3(e,t,r){let i=e.byteLength;lc(i>=4&&i<=8);{let n=e.getUint32(0,!0),a=e.getUint32(i-4,!0),o=((U(n)|U(a)<<U(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&we)*(ma+(U(i)<<U(2)))&uc;return o+=(o&we)<<U(65),o&=uc,o^=o>>U(67),B0(B0(o&we,U(35))*h3&we,U(28))|ri(o>>U(64))<<U(64)}}function I3(e,t,r){let i=e.byteLength;lc(i>=9&&i<=16);{let n=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&we,a=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&we,o=e.getBigUint64(0,!0),s=e.getBigUint64(i-8,!0),c=(o^s^n)*ma,u=(c&we)+(U(i-1)<<U(54));c=c&(uc^we)|u,s^=a,c+=s+(s&eh)*(Ij-U(1))<<U(64),c&=uc,c^=y3(c>>U(64));let l=(c&we)*To;return l+=(c>>U(64))*To<<U(64),l&=uc,ri(l&we)|ri(l>>U(64))<<U(64)}}function T3(e,t){let r=e.byteLength;return lc(r<=16),r>8?I3(e,ti,t):r>=4?E3(e,ti,t):r>0?$3(e,ti,t):th(t^ti.getBigUint64(64,!0)^ti.getBigUint64(72,!0))|th(t^ti.getBigUint64(80,!0)^ti.getBigUint64(88,!0))<<U(64)}function V0(e){return~e+U(1)&we}function O3(e,t,r){let i=U(e.byteLength)*ma&we,n=U(e.byteLength-1)/U(32);for(;n>=0;){let s=Number(n);i=Qm(i,De(e,16*s),De(e,e.byteLength-16*(s+1)),De(t,32*s),r),n-=U(1)}let a=i+(i>>U(64))&we;a=ri(a);let o=(i&we)*ma+(i>>U(64))*Z0+(U(e.byteLength)-r&we)*To;return o&=we,o=V0(ri(o)),a|o<<U(64)}function C3(e,t,r){let i=U(e.byteLength)*ma&we;for(let o=32;o<160;o+=32)i=Qm(i,De(e,o-32),De(e,o-16),De(t,o-32),r);i=ri(i&we)|ri(i>>U(64))<<U(64);for(let o=160;o<=e.byteLength;o+=32)i=Qm(i,De(e,o-32),De(e,o-16),De(t,3+o-160),r);i=Qm(i,De(e,e.byteLength-16),De(e,e.byteLength-32),De(t,103),V0(r));let n=i+(i>>U(64))&we;n=ri(n);let a=(i&we)*ma+(i>>U(64))*Z0+(U(e.byteLength)-r&we)*To;return a&=we,a=V0(ri(a)),n|a<<U(64)}function Oi(e,t=U(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(T3(i,t)):n<=128?a(O3(i,ti,t)):n<=240?a(C3(i,ti,t)):a(k3(i,ti))}function rh(e){return/^[0-9a-f]{32}$/.test(e)}function G0(e){let t=Oe.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 Ia("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=r[or];i.interruptCounter+=1;let n=i.interruptCounter;if(i.resume.length>0&&n<i.resume.length)return r[Pr]?.([[vr,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[Pr]?.([[vr,i.resume]]),o}let a=r[Rr]?.split("|");throw new oi([{id:a?Oi(a.join("|")):void 0,value:e}])}var Ft=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=Ie(t,{callbacks:r?.getChild()});Oe.runWithConfig(a,async()=>{try{i(await this.func(e,a))}catch(o){n(o)}})})}async invoke(e,t){let r,i=cc(t),n=St(this.config,i);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,n):r=await Oe.runWithConfig(n,async()=>this.func(e,n)),ae.isRunnable(r)&&this.recurse?await Oe.runWithConfig(n,async()=>r.invoke(e,n)):r}};function*Ci(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function Sn(e){let t=[];for await(let r of await e)t.push(r);return t}function Oo(e){let t=[];for(let r of e)t.push(r);return t}function Co(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function H0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function q0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function A3(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var _r={[Symbol.for("LG_PASSTHROUGH")]:!0};function nh(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var J0=Symbol("IS_WRITER"),st=class W0 extends Ft{writes;constructor(t,r){let i=`ChannelWrite<${t.map(n=>ft(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=>K0(n)&&nh(n.value)?{mapper:n.mapper,value:t}:ih(n)&&nh(n.value)?{channel:n.channel,value:t,skipNone:n.skipNone,mapper:n.mapper}:n);return await W0.doWrite(r,i),t}static async doWrite(t,r){for(let a of r){if(ih(a)){if(a.channel==="__pregel_tasks")throw new xe("Cannot write to the reserved channel TASKS");if(nh(a.value))throw new xe("PASSTHROUGH value must be replaced")}if(K0(a)&&nh(a.value))throw new xe("PASSTHROUGH value must be replaced")}let i=[];for(let a of r)if(ft(a))i.push([An,a]);else if(K0(a)){let o=await a.mapper.invoke(a.value,t);o!=null&&o.length>0&&i.push(...o)}else if(ih(a)){let o=a.mapper!==void 0?await a.mapper.invoke(a.value,t):a.value;if(A3(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?.[Pr];n(i)}static isWriter(t){return t instanceof W0||J0 in t&&!!t[J0]}static registerWriter(t){return Object.defineProperty(t,J0,{value:!0})}};function ih(e){return e!==void 0&&typeof e.channel=="string"}function K0(e){return e!==void 0&&!ih(e)&&ae.isRunnable(e.mapper)}var Nj=class Pj extends Ft{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,i=!1){super({trace:!1,func:(n,a)=>Pj.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?.[en];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)}},dc=new Si,kn=class gl extends Jr{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=dc;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:p,ends:f}=t,m=[...t.config?.tags?t.config.tags:[],...d??[]];super({...t,bound:t.bound??dc,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=p,this.ends=f}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof st&&t[t.length-2]instanceof st;){let r=t.slice(-2),i=r[0].writes.concat(r[1].writes);t[t.length-2]=new st(i,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===dc&&t.length===0))return this.bound===dc&&t.length===1?t[0]:this.bound===dc?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 gl({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 st.isWriter(t)?new gl({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===dc?new gl({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:rt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):new gl({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 N3(e){return"steps"in e&&Array.isArray(e.steps)}function _l(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function ah(e){let t=[e];for(let r of t){if(_l(r))return r;N3(r)&&t.push(...r.steps)}}function Ao(e,t,r=!0,i=!1){try{return e[t].get()}catch(n){if(n.name===Pe.unminifiable_name){if(i)return n;if(r)return null}throw n}}function $n(e,t,r=!0){if(Array.isArray(t)){let i={};for(let n of t)try{i[n]=Ao(e,n,!r)}catch(a){if(a.name===Pe.unminifiable_name)continue}return i}else return Ao(e,t)}function*Rj(e,t){if(e.graph===ar.PARENT)throw new xe("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(ft(i))yield[br,An,i];else if(typeof i=="string")yield[br,`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(rh))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,vr,n]}else yield[br,vr,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[br,r,i];else for(let[r,i]of Object.entries(e.update))yield[br,r,i]}}function*oh(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*sh(e,t,r){Array.isArray(e)?(t===!0||t.find(([i,n])=>e.includes(i)))&&(yield $n(r,e)):(t===!0||t.some(([i,n])=>i===e))&&(yield Ao(r,e))}function*jj(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===Mi).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 ch(e){let t=typeof e[Ge];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 pc(e,t){if(Object.keys(e).length>0){let r=ch(t);return Object.fromEntries(Object.entries(t).filter(([i,n])=>n>(e[i]??r)))}else return t}function Mj(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function yr(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function ha(e,t){let r=t?.parents??{};return Object.keys(r).length>0?yr(e,{[jr]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function fc(...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 zj=(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 Dj=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 Lj(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function Uj(e,t){return new Cr({name:e,first:new Ft({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new st([{channel:Mi,value:_r}],[pt])})}function Fj(e,t){return new Ft({func:(r,i)=>t(r,i),name:e,trace:!1,recurse:!1})}function Bj({func:e,name:t,cache:r,retry:i},...n){let a=Oe.getRunnableConfig();if(typeof a.configurable?.__pregel_call=="function")return a.configurable[zo](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 Vj=e=>e!==void 0?e+1:1;function P3(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function R3(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=ll(t,e[r]));return t}function vl(e,t,r){let i=ch(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(pt):t.includes(s.name));return a&&o}function yl(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=wn(e,s,-1),u=fa(s,c);nr(bn(c),u,[r],void 0,void 0),o=$n({...t,...u},i)}else o=$n(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(!ft(n))throw new xe(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(n)}`);if(!(n.node in t))throw new xe(`Invalid node name "${n.node}" in Send packet`)}e(r)}var j3=new Set([bc,Mr,vr,He,Mi,Mo]);function nr(e,t,r,i,n){r.sort((p,f)=>{let m=p.path?.slice(0,3)||[],_=f.path?.slice(0,3)||[];for(let v=0;v<Math.min(m.length,_.length);v+=1){if(m[v]<_[v])return-1;if(m[v]>_[v])return 1}return m.length-_.length});let a=r.some(p=>p.triggers.length>0),o=ml(t);for(let p of r){e.versions_seen[p.name]??={};for(let f of p.triggers)f in e.channel_versions&&(e.versions_seen[p.name][f]=e.channel_versions[f])}let s=R3(e.channel_versions),c=new Set(r.flatMap(p=>p.triggers).filter(p=>!SS.includes(p))),u=!1;for(let p of c)p in o&&o[p].consume()&&i!==void 0&&(e.channel_versions[p]=i(s),u=!0);let l={};for(let p of r)for(let[f,m]of p.writes)j3.has(f)||f in o&&(l[f]??=[],l[f].push(m));s!=null&&i!=null&&(s=u?i(s):s);let d=new Set;for(let[p,f]of Object.entries(l))if(p in o){let m=o[p],_;try{_=m.update(f)}catch(v){if(v.name===xe.unminifiable_name){let k=new xe(`Invalid update for channel "${p}" with values ${JSON.stringify(f)}: ${v.message}`);throw k.lc_error_code=v.lc_error_code,k}else throw v}_&&i!==void 0&&(e.channel_versions[p]=i(s),m.isAvailable()&&d.add(p))}if(a)for(let p in o){if(!Object.prototype.hasOwnProperty.call(o,p))continue;let f=o[p];f.isAvailable()&&!d.has(p)&&f.update([])&&i!==void 0&&(e.channel_versions[p]=i(s),f.isAvailable()&&d.add(p))}if(a&&!P3(d,n))for(let p in o){if(!Object.prototype.hasOwnProperty.call(o,p))continue;let f=o[p];f.finish()&&i!==void 0&&(e.channel_versions[p]=i(s),f.isAvailable()&&d.add(p))}return d}function*M3(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 ga(e,t,r,i,n,a,o){let s={},c=i[An];if(c?.isAvailable()){let u=c.get().length;for(let l=0;l<u;l+=1){let d=uh([Mr,l],e,t,r,i,n,a,o);d!==void 0&&(s[d.id]=d)}}for(let u of M3(e,r,o)){let l=uh([El,u],e,t,r,i,n,a,o);l!==void 0&&(s[l.id]=l)}return s}function uh(e,t,r,i,n,a,o,s){let{step:c,checkpointer:u,manager:l}=s,d=a.configurable??{},p=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&Lj(e[e.length-1])){let f=e[e.length-1],m=Uj(f.name,f.func),_=[Mr],v=p===""?f.name:`${p}|${f.name}`,k=ci(JSON.stringify([v,c.toString(),f.name,Mr,e[1],e[2]]),t.id),w=`${v}:${k}`,x=[...e.slice(0,3),!0],$={langgraph_step:c,langgraph_node:f.name,langgraph_triggers:_,langgraph_path:x,langgraph_checkpoint_ns:w};if(o){let T=[],B={checkpointId:t.id,checkpointNs:w,taskId:k,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:f.name,input:f.input,proc:m,writes:T,config:{...Ie(St(a,{metadata:$,store:s.store??a.store}),{runName:f.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[yc]:k,[Pr]:O=>X0(y=>T.push(...y),i,O),[en]:(O,y=!1)=>yl(t,n,{name:f.name,writes:T,triggers:_,path:x},O,y),[tn]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[p]:t.id},[or]:Y0({pendingWrites:r??[],taskId:k,currentTaskInput:f.input,resumeMap:a.configurable?.[Lo],namespaceHash:Oi(w)}),[$a]:t.channel_values[Ea],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:B},triggers:_,retry_policy:f.retry,cache_key:f.cache?{key:Oi((f.cache.keyFunc??JSON.stringify)([f.input])),ns:[kl,f.name??"__dynamic__"],ttl:f.cache.ttl}:void 0,id:k,path:x,writers:[]}}else return{id:k,name:f.name,interrupts:[],path:x}}else if(e[0]==="__pregel_push"){let f=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!n.__pregel_tasks?.isAvailable())return;let m=n[An].get();if(f<0||f>=m.length)return;let _=Il(m[f])&&!ft(m[f])?new ka(m[f].node,m[f].args):m[f];if(!Il(_)){console.warn(`Ignoring invalid packet ${JSON.stringify(_)} in pending sends.`);return}if(!(_.node in i)){console.warn(`Ignoring unknown node name ${_.node} in pending sends.`);return}let v=[Mr],k=p===""?_.node:`${p}|${_.node}`,w=ci(JSON.stringify([k,c.toString(),_.node,Mr,f.toString()]),t.id),x=`${k}:${w}`,$={langgraph_step:c,langgraph_node:_.node,langgraph_triggers:v,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x};if(o){let T=i[_.node],B=T.getNode();if(B!==void 0){T.metadata!==void 0&&($={...$,...T.metadata});let O=[],y={checkpointId:t.id,checkpointNs:x,taskId:w,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:_.node,input:_.args,proc:B,subgraphs:T.subgraphs,writes:O,config:{...Ie(St(a,{metadata:$,tags:T.tags,store:s.store??a.store}),{runName:_.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[yc]:w,[Pr]:K=>X0(A=>O.push(...A),i,K),[en]:(K,A=!1)=>yl(t,n,{name:_.node,writes:O,triggers:v,path:e},K,A),[tn]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[p]:t.id},[or]:Y0({pendingWrites:r??[],taskId:w,currentTaskInput:_.args,resumeMap:a.configurable?.[Lo],namespaceHash:Oi(x)}),[$a]:t.channel_values[Ea],checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:y},triggers:v,retry_policy:T.retryPolicy,cache_key:T.cachePolicy?{key:Oi((T.cachePolicy.keyFunc??JSON.stringify)([_.args])),ns:[kl,T.name??"__dynamic__",_.node],ttl:T.cachePolicy.ttl}:void 0,id:w,path:e,writers:T.getWriters()}}}else return{id:w,name:_.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let f=e[1].toString(),m=i[f];if(m===void 0)return;if(r?.length){let w=p===""?f:`${p}|${f}`,x=ci(JSON.stringify([w,c.toString(),f,El,f]),t.id);if(r.some($=>$[0]===x&&$[1]!=="__error__"))return}let _=ch(t.channel_versions);if(_===void 0)return;let v=t.versions_seen[f]??{},k=m.triggers.find(w=>n[w].isAvailable()?(t.channel_versions[w]??_)>(v[w]??_):!1);if(k!==void 0){let w=z3(m,n,o);if(w===void 0)return;let x=p===""?f:`${p}|${f}`,$=ci(JSON.stringify([x,c.toString(),f,El,[k]]),t.id),T=`${x}:${$}`,B={langgraph_step:c,langgraph_node:f,langgraph_triggers:[k],langgraph_path:e,langgraph_checkpoint_ns:T};if(o){let O=m.getNode();if(O!==void 0){m.metadata!==void 0&&(B={...B,...m.metadata});let y=[],K={checkpointId:t.id,checkpointNs:T,taskId:$,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:f,input:w,proc:O,subgraphs:m.subgraphs,writes:y,config:{...Ie(St(a,{metadata:B,tags:m.tags,store:s.store??a.store}),{runName:f,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[yc]:$,[Pr]:A=>X0(F=>{y.push(...F)},i,A),[en]:(A,F=!1)=>yl(t,n,{name:f,writes:y,triggers:[k],path:e},A,F),[tn]:u??d.__pregel_checkpointer,[jr]:{...d[jr],[p]:t.id},[or]:Y0({pendingWrites:r??[],taskId:$,currentTaskInput:w,resumeMap:a.configurable?.[Lo],namespaceHash:Oi(T)}),[$a]:t.channel_values[Ea],checkpoint_id:void 0,checkpoint_ns:T}}),executionInfo:K},triggers:[k],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:Oi((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[kl,m.name??"__dynamic__",f],ttl:m.cachePolicy.ttl}:void 0,id:$,path:e,writers:m.getWriters()}}}else return{id:$,name:f,interrupts:[],path:e}}}}function z3(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]=Ao(t,a,!1)}catch(o){if(o.name===Pe.unminifiable_name)return;throw o}else if(a in t)try{i[n]=Ao(t,a,!1)}catch(o){if(o.name===Pe.unminifiable_name)continue;throw o}}else if(Array.isArray(e.channels)){let n=!1;for(let a of e.channels)try{i=Ao(t,a,!1),n=!0;break}catch(o){if(o.name===Pe.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 Zj(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 ka(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 bl={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},wl=(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 D3(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function Gj(e){let t={};for(let[r,i]of e){let n=String(r);if(n in t){let a=D3(t[n])?t[n].$writes:[t[n]];a.push(i),t[n]={$writes:a}}else t[n]=i}return t}function*Hj(e,t){for(let[{id:r,name:i,config:n},a]of e)n?.tags?.includes("langsmith:hidden")||(yield{id:r,name:i,result:Gj(a.filter(([o])=>Array.isArray(t)?t.includes(o):o===t)),interrupts:a.filter(o=>o[0]===He).map(o=>o[1])})}function*qj(e,t,r,i,n,a,o,s){function c(d){let p={};return d.callbacks!=null&&(p.callbacks=d.callbacks),d.configurable!=null&&(p.configurable=d.configurable),d.maxConcurrency!=null&&(p.max_concurrency=d.maxConcurrency),d.metadata!=null&&(p.metadata=d.metadata),d.recursionLimit!=null&&(p.recursion_limit=d.recursionLimit),d.runId!=null&&(p.run_id=d.runId),d.runName!=null&&(p.run_name=d.runName),d.tags!=null&&(p.tags=d.tags),p}let u=e.configurable?.checkpoint_ns,l={};for(let d of n){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(ah))continue;let p=`${d.name}:${d.id}`;u&&(p=`${u}|${p}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:p}}}yield{config:c(e),values:$n(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,p])=>d===n.id&&i.includes(p)).map(([,d,p])=>[d,p]);return l.length?Gj(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 Jj(e,t,r){console.log([`${wl(bl.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
296
+ `,JSON.stringify($n(t,r),null,2)].join(""))}function lh(e,t){let r=t.length;console.log([`${wl(bl.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
297
+ `,t.map(i=>`- ${wl(bl.green,String(i.name))} -> ${JSON.stringify(i.input,null,2)}`).join(`
298
+ `)].join(""))}function Kj(e,t,r){let i={};for(let[n,a]of t)r.includes(n)&&(i[n]||(i[n]=[]),i[n].push(a));console.log([`${wl(bl.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(i).length} channel${Object.keys(i).length!==1?"s":""}:\x1B[0m
299
+ `,Object.entries(i).map(([n,a])=>`- ${wl(bl.yellow,n)} -> ${a.map(o=>JSON.stringify(o)).join(", ")}`).join(`
300
+ `)].join(""))}var rS=class extends mt{_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}},dh=class extends mt{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)}},Yj=class extends un{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 L3(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 U3(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function nS(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function tS(e){return!nS(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 Wj(e){if(nS(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 Xj(e){let t={...e,checkpoint:tS(e.config),parent_checkpoint:tS(e.parentConfig),config:Wj(e.config),parent_config:Wj(e.parentConfig),tasks:e.tasks.map(r=>{if(nS(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 Qj(e){let t=new TextEncoder;return new ReadableStream({async start(r){let i=n=>{r.enqueue(t.encode(`event: ${n.event}
301
+ data: ${L3(n.data)}
302
+
303
+ `))};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:Xj(u.payload)})}o==="checkpoints"&&(c=Xj(s)),i({event:a?.length?`${o}|${a.join("|")}`:o,data:c})}}catch(n){i({event:"error",data:U3(n)})}r.close()}})}var ph=Symbol.for("INPUT_DONE"),iS=Symbol.for("INPUT_RESUMING"),F3=25;function B3(...e){return new dh({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 V3=class extends qm{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}},eM=class tM{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=_t(this.input)&&this.input.resume!=null,a=this.input===iS,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=Vj,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 V3(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=B3(i,r.configurable[vc]));let n=r.configurable?!("checkpoint_id"in r.configurable):!0,a=r.configurable?.[or];r.configurable&&a&&(a.subgraphCounter>0&&(r=yr(r,{[Rr]:[r.configurable[Rr],a.subgraphCounter.toString()].join("|")})),a.subgraphCounter+=1);let o=en in(r.configurable??{});!o&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=yr(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=yr(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:ac(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};s={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let l=u.parentConfig,d=bn(u.checkpoint),p={...u.metadata},f=u.pendingWrites??[],m=fa(t.channelSpecs,d),_=(p.step??0)+1,v=_+(r.recursionLimit??F3)+1,k={...d.channel_versions},w=t.store?new Hm(t.store):void 0;return w&&await w.start(),new tM({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:d,checkpointMetadata:p,checkpointConfig:s,prevCheckpointConfig:l,checkpointNamespace:c,channels:m,isNested:o,manager:t.manager,skipDoneTasks:n,step:_,stop:v,checkpointPreviousVersions:k,checkpointPendingWrites:f,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 dl)&&(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"&&ft(u)?[c,Zj(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=yr(this.checkpointConfig,{[Rr]:this.config.configurable?.checkpoint_ns??"",[$l]: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]===He).flatMap(o=>o[1]);this._emit([["updates",{[He]:a}],["values",{[He]:a}]])}else r[0][0]!=="__error__"&&this._emit(Oo(Ci(jj(this.outputKeys,[[n,r]],i),"updates")));i||this._emit(Oo(Ci(Hj([[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(![ph,iS].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new oi;if(Object.values(this.tasks).every(n=>n.writes.length>0)){let n=Object.values(this.tasks).flatMap(o=>o.writes);this.updatedChannels=nr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let a=await Sn(Ci(sh(this.outputKeys,n,this.channels),"values"));if(this._emit(a),this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),vl(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new oi;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[Do]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=ga(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 Sn(Ci(qj(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(vl(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new oi;let i=await Sn(Ci(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=$n(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=nr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emit(Oo(Ci(sh(this.outputKeys,Object.values(this.tasks).flatMap(i=>i.writes),this.channels),"values")))),si(t)&&!t.interrupts.length&&this._emit([["updates",{[He]:[]}],["values",{[He]:[]}]])),r}async acceptPush(t,r,i){if(this.interruptAfter?.length>0&&vl(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let n=uh([Mr,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&&vl(this.checkpoint,this.interruptBefore,[n])){this.toInterrupt.push(n);return}this._emit(Oo(Ci(Q0([n]),"tasks"))),this.debug&&lh(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 si(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,i=r?.[or];if(i&&i.nullResume!==void 0&&this.putWrites(br,[[vr,i.nullResume]]),_t(this.input)){let o=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(rh)&&(this.config.configurable??={},this.config.configurable[Lo]=this.input.resume),o&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let s={};for(let[c,u,l]of Rj(this.input,this.checkpointPendingWrites))s[c]??=[],s[c].push([u,l]);if(Object.keys(s).length===0)throw new Al("Received empty Command input");for(let[c,u]of Object.entries(s))this.putWrites(c,u)}let n=(this.checkpointPendingWrites??[]).filter(o=>o[0]===br).map(o=>o.slice(1));n.length>0&&nr(this.checkpoint,this.channels,[{name:Cn,writes:n,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let a=_t(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[He]={...this.checkpoint.versions_seen[He],[s]:c}}let o=await Sn(Ci(sh(this.outputKeys,!0,this.channels),"values"));this._emit(o)}if(this.isResuming)this.input=iS;else if(a)await this._putCheckpoint({source:"input"}),this.input=ph;else{let o=await Sn(oh(t,this.input));if(o.length>0){let s=ga(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=nr(this.checkpoint,this.channels,Object.values(s).concat([{name:Cn,writes:o,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=ph}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=ph;else throw new Al(`Received no input writes for ${JSON.stringify(t,null,2)}`)}this.isNested||(this.config=yr(this.config,{[Do]:this.isResuming}))}_emit(t){for(let[r,i]of t)if(this.stream.modes.has(r)&&this.stream.push([this.checkpointNamespace,r,i]),(r==="checkpoints"||r==="tasks")&&this.stream.modes.has("debug")){let n=r==="checkpoints"?this.step-1:this.step,a=new Date().toISOString(),o=r==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([this.checkpointNamespace,"debug",{step:n,type:o,timestamp:a,payload:i}])}}_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=yr(this.checkpointConfig,{[Rr]:this.config.configurable?.checkpoint_ns??""});let o={...this.checkpoint.channel_versions},s=pc(this.checkpointPreviousVersions,o);this.checkpointPreviousVersions=o,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:bn(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=wn(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=yr(this.checkpointConfig,{[Rr]:this.config.configurable?.checkpoint_ns??"",[$l]: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 Z3(e){return Xe(e?.message)}var rM=class extends un{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&&(Cc(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]=[o.langgraph_checkpoint_ns.split("|"),{tags:a,name:s,...o}])}handleLLMNewToken(e,t,r,i,n,a){let o=a?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(Z3(o)?this._emit(this.metadatas[r],o.message,r):this._emit(this.metadatas[r],new vt({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];Xe(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]=[a.langgraph_checkpoint_ns.split("|"),{tags:n,name:s,...a}],typeof t=="object")){for(let c of Object.values(t))if((Xe(c)||li(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(Xe(u)||li(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(Xe(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let i of e)Xe(i)&&this._emit(r,i,t,!0);else if(e!=null&&typeof e=="object"){for(let i of Object.values(e))if(Xe(i))this._emit(r,i,t,!0);else if(Array.isArray(i))for(let n of i)Xe(n)&&this._emit(r,n,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};var G3=[400,401,402,403,404,405,406,407,409],H3=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&&G3.includes(+t)||e?.error?.code==="insufficient_quota")};async function aS(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=yr(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,bh(s)){let m=u?.configurable?.checkpoint_ns,_=s.command;if(_.graph===m){for(let v of e.writers)await v.invoke(_,u);s=void 0;break}else if(_.graph===ar.PARENT){let v=xj(m);s.command=new ar({...s.command,graph:v})}}if(Ta(s)||n===void 0||(o+=1,o>=(n.maxAttempts??3))||!(n.retryOn??H3)(s))break;a=Math.min(n.maxInterval??128e3,a*(n.backoffFactor??2));let p=n.jitter?Math.floor(a+Math.random()*1e3):a;await new Promise(m=>setTimeout(m,p));let f=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 ${f}: ${s}`),u=yr(u,{[Do]:!0}),u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:l})}}return{task:e,result:c,error:s,signalAborted:i?.aborted}}var oS=Symbol.for("promiseAdded");function q3(){let e={next:()=>{},wait:Promise.resolve(oS)};function t(r){e.next=()=>{e.wait=new Promise(t),r(oS)}}return e.wait=new Promise(t),e}var nM=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:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),f=this._executeTasksWithRetry(l,{signals:d,retryPolicy:r,maxConcurrency:n});for await(let{task:m,error:_,signalAborted:v}of f)this._commit(m,_),si(_)||Ta(_)&&!si(o)?o=_:_&&(a.size===0||!v)&&(s.abort(),a.add(_));if(p?.(),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(si(o)||Ta(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}=fc(n,a,e),c={externalAbortSignal:n,timeoutAbortSignal:a,composedAbortSignal:o};return this.loop.config=yr(this.loop.config,{[xS]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:i,signals:n}=t??{},a=q3(),o={},s={executingTasksMap:o,barrier:a,retryPolicy:r,scheduleTask:async(p,f,m)=>this.loop.acceptPush(p,f,m)};if(n?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=fc(n?.externalAbortSignal,n?.timeoutAbortSignal),d=l.signal?new Promise((p,f)=>{u=()=>f(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(o).length>0)&&e.length;){for(;Object.values(o).length<(i??e.length)&&c<e.length;c+=1){let f=e[c];o[f.id]=aS(f,r,{[zo]:iM?.bind(s,this,f)},n?.composedAbortSignal).catch(m=>({task:f,error:m,signalAborted:n?.composedAbortSignal?.aborted}))}let p=await Promise.race([...Object.values(o),...d?[d]:[],a.wait]);p!==oS&&(yield p,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete o[p.task.id])}}_commit(e,t){if(t!==void 0)if(si(t)){if(t.interrupts.length){let r=t.interrupts.map(n=>[He,n]),i=e.writes.filter(n=>n[0]===vr);i.length&&r.push(...i),this.loop.putWrites(e.id,r)}}else Ta(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([bc,null]),this.loop.putWrites(e.id,e.writes)}};async function iM(e,t,r,i,n,a={}){let o=t.config?.configurable?.[or];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 Dj({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(([f])=>f===Mi),p=u.writes.filter(([f])=>f===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(p.length>0){if(p.length===1){let f=p[0][1],m=f instanceof Error?f:new Error(String(f));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${u.name}__${u.id}`)}return}else{let d=aS(u,a.retry,{[zo]:iM.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:p,error:f})=>f?Promise.reject(f):p)}}var Ai=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function aM({nodes:e,channels:t,inputChannels:r,outputChannels:i,streamChannels:n,interruptAfterNodes:a,interruptBeforeNodes:o}){if(!t)throw new Ai("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Ai(`"Node name ${He} is reserved"`);if(l.constructor===kn)l.triggers.forEach(d=>s.add(d));else throw new Ai(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new Ai(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new Ai(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Ai(`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 Ai(`Output channel '${String(u)}' not in channels`);if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new Ai(`Node ${String(u)} not in nodes`)}if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new Ai(`Node ${String(u)} not in nodes`)}}function sS(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 cS=class oM extends $t{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 oM({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 Pe;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};var sM=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 kn({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:_r,skipNone:!1});for(let[i,n]of Object.entries(t??{}))ae.isRunnable(n)||typeof n=="function"?r.push({channel:i,value:_r,skipNone:!0,mapper:rt(n)}):r.push({channel:i,value:n,skipNone:!1});return new st(r)}},J3=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)}},fh=class extends J3{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;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 '${An}' is reserved and cannot be used in the graph.`);this.channels[An]=new cS({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.autoValidate&&this.validate()}withConfig(e){let t=St(this.config,e);return new this.constructor({...this,config:t})}validate(){aM({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=ah(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=fa(this.channels,t.checkpoint);if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([p,f])=>p===br).map(([p,f,m])=>[String(f),m]);d.length>0&&nr(t.checkpoint,n,[{name:Cn,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let a=Object.values(ga(t.checkpoint,t.pendingWrites,this.nodes,n,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),o=await Sn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of a){let p=o.find(([m])=>m===d.name);if(!p)continue;let f=`${String(d.name)}:${d.id}`;if(s&&(f=`${s}|${f}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:f}};c[d.id]=m}else{let m={configurable:{[tn]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:f}},_=p[1];c[d.id]=await _.getState(m,{subgraphs:!0})}}if(i&&t.pendingWrites?.length){let d=Object.fromEntries(a.map(f=>[f.id,f]));for(let[f,m,_]of t.pendingWrites)["__error__","__interrupt__",Ca].includes(m)||f in d&&d[f].writes.push([String(m),_]);let p=a.filter(f=>f.writes.length>0);p.length>0&&nr(t.checkpoint,n,p,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=a.filter(d=>d.writes.length===0).map(d=>d.name);return{values:$n(n,this.streamChannelsAsIs),next:l,tasks:eS(a,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:ha(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 Ia("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Wm(i);for await(let[s,c]of this.getSubgraphsAsync(o,!0))if(s===o)return await c.getState(Co(e,{[tn]:r}),{subgraphs:t?.subgraphs})}let n=St(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 Ia("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Wm(i);for await(let[o,s]of this.getSubgraphsAsync(a,!0))if(o===a){yield*s.getStateHistory(Co(e,{[tn]:r}),t);return}}let n=St(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 Ia("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=Wm(i);for await(let[,s]of this.getSubgraphsAsync(o,!0))return await s.bulkUpdateState(Co(e,{[tn]:r}),t);throw new Error(`Subgraph "${o}" not found`)}let n=async(o,s)=>{let c=this.config?St(this.config,o):o,u=await r.getTuple(c),l=u!==void 0?bn(u.checkpoint):ac(),d={...u?.checkpoint.channel_versions},p=u?.metadata?.step??-1,f=Co(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(f=Co(c,u.config.configurable),m={...u.metadata,...m});let{values:_,asNode:v}=s[0];if(_==null&&v===void 0){if(s.length>1)throw new xe("Cannot create empty checkpoint with multiple updates");return ha(await r.put(f,wn(l,void 0,p),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let k=fa(this.channels,l);if(_===null&&v==="__end__"){if(s.length>1)throw new xe("Cannot apply multiple updates when clearing state");if(u){let O=ga(l,u.pendingWrites||[],this.nodes,k,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),y=(u.pendingWrites||[]).filter(K=>K[0]===br).map(K=>K.slice(1));y.length>0&&nr(l,k,[{name:Cn,writes:y,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[K,A,F]of u.pendingWrites||[])["__error__","__interrupt__",Ca].includes(A)||K in O&&O[K].writes.push([A,F]);nr(l,k,Object.values(O),r.getNextVersion.bind(r),this.triggerToNodes)}return ha(await r.put(f,wn(l,k,p),{...m,source:"update",step:p+1,parents:u?.metadata?.parents??{}},pc(d,l.channel_versions)),u?u.metadata:void 0)}if(v==="__copy__"){if(s.length>1)throw new xe("Cannot copy checkpoint with multiple updates");if(u==null)throw new xe("Cannot copy a non-existent checkpoint");let O=A=>!Array.isArray(A)||A.length===0?!1:A.every(F=>Array.isArray(F)&&F.length===2),y=wn(l,void 0,p),K=await r.put(u.parentConfig??Co(u.config,{checkpoint_id:void 0}),y,{source:"fork",step:p+1,parents:u.metadata?.parents??{}},{});if(O(_)){let A=ga(y,u.pendingWrites,this.nodes,k,K,!1,{step:p+2}),F=Object.values(A).reduce((Ze,{name:Vt,id:In})=>(Ze[Vt]??=[],Ze[Vt].push({id:In}),Ze),{}),he=_.reduce((Ze,Vt)=>{let[In,$e]=Vt;Ze[$e]??=[];let wa=Ze[$e].length,ii=F[$e]?.[wa]?.id;return Ze[$e].push({values:In,asNode:$e,taskId:ii}),Ze},{});return n(ha(K,u.metadata),Object.values(he).flat())}return ha(K,u.metadata)}if(v==="__input__"){if(s.length>1)throw new xe("Cannot apply multiple updates when updating as input");let O=await Sn(oh(this.inputChannels,_));if(O.length===0)throw new xe(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);nr(l,k,[{name:Cn,writes:O,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let y=u?.metadata?.step!=null?u.metadata.step+1:-1,K=await r.put(f,wn(l,k,y),{source:"input",step:y,parents:u?.metadata?.parents??{}},pc(d,l.channel_versions));return await r.putWrites(K,O,ci(Cn,l.id)),ha(K,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let O=ga(l,u.pendingWrites,this.nodes,k,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),y=(u.pendingWrites??[]).filter(A=>A[0]===br).map(A=>A.slice(1));y.length>0&&nr(u.checkpoint,k,[{name:Cn,writes:y,triggers:[]}],void 0,this.triggerToNodes);for(let[A,F,he]of u.pendingWrites)["__error__","__interrupt__",Ca].includes(F)||O[A]===void 0||O[A].writes.push([F,he]);let K=Object.values(O).filter(A=>A.writes.length>0);K.length>0&&nr(l,k,K,void 0,this.triggerToNodes)}let w=Object.values(l.versions_seen).map(O=>Object.values(O)).flat().find(O=>!!O),x=[];if(s.length===1){let{values:O,asNode:y,taskId:K}=s[0];if(y===void 0&&Object.keys(this.nodes).length===1)[y]=Object.keys(this.nodes);else if(y===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(y=this.inputChannels);else if(y===void 0){let A=Object.entries(l.versions_seen).map(([F,he])=>Object.values(he).map(Ze=>[Ze,F])).flat().filter(([F,he])=>he!==He).sort(([F],[he])=>Gm(F,he));A&&(A.length===1?y=A[0][1]:A[A.length-1][0]!==A[A.length-2][0]&&(y=A[A.length-1][1]))}if(y===void 0)throw new xe('Ambiguous update, specify "asNode"');x.push({values:O,asNode:y,taskId:K})}else for(let{asNode:O,values:y,taskId:K}of s){if(O==null)throw new xe('"asNode" is required when applying multiple updates');x.push({values:y,asNode:O,taskId:K})}let $=[];for(let{asNode:O,values:y,taskId:K}of x){if(this.nodes[O]===void 0)throw new xe(`Node "${O.toString()}" does not exist`);let A=this.nodes[O].getWriters();if(!A.length)throw new xe(`No writers found for node "${O.toString()}"`);$.push({name:O,input:y,proc:A.length>1?Cr.from(A,{omitSequenceTags:!0}):A[0],writes:[],triggers:[He],id:K??ci("__interrupt__",l.id),writers:[]})}for(let O of $)await O.proc.invoke(O.input,Ie({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[Pr]:y=>O.writes.push(...y),[en]:(y,K=!1)=>yl(l,k,O,y,K)}}));for(let O of $){let y=O.writes.filter(K=>K[0]!==Mr);u!==void 0&&y.length>0&&await r.putWrites(f,y,O.id)}nr(l,k,$,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let T=pc(d,l.channel_versions),B=await r.put(f,wn(l,k,p+1),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},T);for(let O of $){let y=O.writes.filter(K=>K[0]===Mr);y.length>0&&await r.putWrites(B,y,O.id)}return ha(B,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:sS(l,this.channels);let d=i;d===void 0?d=this.inputChannels:sS(d,this.channels);let p=o??this.interruptBefore??[],f=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 _;if(this.checkpointer===!1)_=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)_=e.configurable[tn];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");_=this.checkpointer}let v=e.store??this.store,k=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,p,f,_,v,c,k,x]}async stream(e,t){let r=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:fc(t?.signal,r.signal).signal},n=await super.stream(e,i);return new rS(t?.encoding==="text/event-stream"?Qj(n):n,r)}streamEvents(e,t,r){let i=new AbortController,n={recursionLimit:this.config?.recursionLimit,...t,callbacks:zj(this.config?.callbacks,t?.callbacks),signal:fc(t?.signal,i.signal).signal};return new rS(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=cc(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,p,f,m,_,v,k,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 dh({modes:new Set(u)});if(this.checkpointer===!0){d.configurable??={};let A=d.configurable.checkpoint_ns??"";d.configurable[Rr]=A.split("|").map(F=>F.split(":")[0]).join("|")}if(u.includes("messages")){let A=new rM(he=>x.push(he)),{callbacks:F}=d;if(F===void 0)d.callbacks=[A];else if(Array.isArray(F))d.callbacks=F.concat(A);else{let he=F.copy();he.addHandler(A,!0),d.callbacks=he}}if(u.includes("tools")){let A=new Yj(he=>x.push(he)),{callbacks:F}=d;if(F===void 0)d.callbacks=[A];else if(Array.isArray(F))d.callbacks=F.concat(A);else{let he=F.copy();he.addHandler(A,!0),d.callbacks=he}}d.writer??=A=>{if(!u.includes("custom"))return;let F=F0()?.configurable?.[Rr]?.split("|").slice(0,-1);x.push([F??[],"custom",A])},d.interrupt??=this.userInterrupt??G0,d.serverInfo==null&&(d.serverInfo=K3(d));let $=await(await xt(d))?.handleChainStart(this.toJSON(),Mj(e,"input"),o,void 0,void 0,void 0,d?.runName??this.getName()),T=ml(this.channels),B,O,K=(async()=>{try{B=await eM.initialize({input:a,config:d,checkpointer:m,nodes:this.nodes,channelSpecs:T,outputKeys:l,streamKeys:this.streamChannelsAsIs,store:_,cache:k,stream:x,interruptAfter:f,interruptBefore:p,manager:$,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:w});let A=new nM({loop:B,nodeFinished:d.configurable?.[wS]});t?.subgraphs&&(B.config.configurable={...B.config.configurable,[vc]:B.stream}),await this._runLoop({loop:B,runner:A,debug:c,config:d}),w==="sync"&&await Promise.all(B?.checkpointerPromises??[])}catch(A){O=A}finally{try{B&&(await B.store?.stop(),await B.cache?.stop()),await Promise.all(B?.checkpointerPromises??[])}catch(A){O=O??A}O?x.error(O):x.close()}})();try{for await(let A of x){if(A===void 0)throw new Error("Data structure error.");let[F,he,Ze]=A;if(u.includes(he)){if(r==="text/event-stream"){i?yield[F,he,Ze]:yield[null,he,Ze];continue}i&&!v?yield[F,he,Ze]:v?i?yield[F,Ze]:yield Ze:yield[he,Ze]}}}catch(A){throw await $?.handleChainError(O),A}finally{await K}await $?.handleChainEnd(B?.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"?wc(c)?o.push(c[He]):s=c:n.push(c);if(r==="values"){if(o.length>0){let c=o.flat(1);if(s==null)return{[He]:c};if(typeof s=="object")return{...s,[He]: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&&Jj(t.checkpointMetadata.step,t.channels,this.streamChannelsList),i&&lh(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(o,s)=>{i&&Kj(o,s,this.streamChannelsList)},maxConcurrency:n.maxConcurrency,signal:n.signal})}if(t.status==="out_of_steps")throw new vh([`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 K3(e){let t=e.metadata??{},r=e.configurable??{},i=t.assistant_id,n=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 En=class cM extends $t{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new cM(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 xe("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Pe;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Pe;return this.value[0]}isAvailable(){return this.value.length!==0}};var uS=class{path;ends;constructor(e){ae.isRunnable(e.path)?this.path=e.path:this.path=rt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return st.registerWriter(new Ft({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.
304
+ 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=>ft(o)?o:this.ends[o]):a=n,a.some(o=>!o))throw new Error("Branch condition returned unknown or null destination");if(a.filter(ft).some(o=>o.node==="__end__"))throw new xe("Cannot send a packet to the END node");return await r(a,t)??e}},lS=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=rt(n);this.nodes[i]={runnable:o,metadata:a?.metadata,subgraphs:_l(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=rt(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 uS(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(Ge,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,Qe)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let n=new dS({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Ge]:new En,[Qe]:new En},inputChannels:Ge,outputChannels:Qe,streamChannels:[],streamMode:"values",name:i});for(let[a,o]of Object.entries(this.nodes))n.attachNode(a,o);for(let[a,o]of this.edges)n.attachEdge(a,o);for(let[a,o]of Object.entries(this.branches))for(let[s,c]of Object.entries(o))n.attachBranch(a,s,c);return n.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(Qe);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 wh([`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(`
305
+ `),{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}},dS=class extends fh{builder;constructor({builder:e,...t}){super(t),this.builder=e}attachNode(e,t){this.channels[e]=new En,this.nodes[e]=new kn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new st([{channel:e,value:_r}],[pt])),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 st([{channel:Qe,value:_r}],[pt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Ge]=sM.subscribeTo(Ge,{tags:[pt]})),this.nodes[e].pipe(r.run(n=>new st(n.map(a=>ft(a)?a:{channel:a==="__end__"?Qe:`branch:${e}:${t}:${a}`,value:_r}),[pt])));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 En,this.nodes[n].triggers.push(a),this.nodes[n].channels.push(a)}}async getGraphAsync(e){let t=e?.xray,r=new wo,i={[Ge]:r.addNode({schema:Xr.any()},Ge)},n={},a={};t&&(a=Object.fromEntries((await Sn(this.getSubgraphsAsync())).filter(c=>uM(c[1]))));function o(c,u,l,d=!1){if(u==="__end__"&&n.__end__===void 0&&(n[Qe]=r.addNode({schema:Xr.any()},Qe)),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=Bt(c),d=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?p.__interrupt="before,after":this.interruptBefore?.includes(c)?p.__interrupt="before":this.interruptAfter?.includes(c)&&(p.__interrupt="after"),t){let f=typeof t=="number"?t-1:t,m=a[c]!==void 0?await a[c].getGraphAsync({...e,xray:f}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let k=function(x){return x?x.lc_runnable:!1},w=function(x,$){if(x!==void 0&&!Uo(x))return x;if(k($))try{let T=$.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,v]=r.extend(m,l);if(_===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);v!==void 0&&(i[l]={name:w(v.id,v.data),...v}),n[l]={name:w(_.id,_.data),..._}}else{let _=r.addNode(d,l,p);i[l]=_,n[l]=_}}else{let f=r.addNode(d,l,p);i[l]=f,n[l]=f}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Bt(c),Bt(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=>[Bt(d),Bt(d)])),[Qe]:Qe};for(let d of Object.values(u)){let p;d.ends!==void 0?p=d.ends:p=l;for(let[f,m]of Object.entries(p))o(Bt(c),Bt(m),f,!0)}}for(let[c,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let l of u.ends)o(Bt(c),Bt(l),void 0,!0);return r}getGraph(e){let t=e?.xray,r=new wo,i={[Ge]:r.addNode({schema:Xr.any()},Ge)},n={},a={};t&&(a=Object.fromEntries(Oo(this.getSubgraphs()).filter(c=>uM(c[1]))));function o(c,u,l,d=!1){return u==="__end__"&&n.__end__===void 0&&(n[Qe]=r.addNode({schema:Xr.any()},Qe)),r.addEdge(i[c],n[u],l!==u?l:void 0,d)}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Bt(c),d=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?p.__interrupt="before,after":this.interruptBefore?.includes(c)?p.__interrupt="before":this.interruptAfter?.includes(c)&&(p.__interrupt="after"),t){let f=typeof t=="number"?t-1:t,m=a[c]!==void 0?a[c].getGraph({...e,xray:f}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let k=function(x){return x?x.lc_runnable:!1},w=function(x,$){if(x!==void 0&&!Uo(x))return x;if(k($))try{let T=$.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,v]=r.extend(m,l);if(_===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);v!==void 0&&(i[l]={name:w(v.id,v.data),...v}),n[l]={name:w(_.id,_.data),..._}}else{let _=r.addNode(d,l,p);i[l]=_,n[l]=_}}else{let f=r.addNode(d,l,p);i[l]=f,n[l]=f}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Bt(c),Bt(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=>[Bt(d),Bt(d)])),[Qe]:Qe};for(let d of Object.values(u)){let p;d.ends!==void 0?p=d.ends:p=l;for(let[f,m]of Object.entries(p))o(Bt(c),Bt(m),f,!0)}}return r}};function uM(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Bt(e){return e==="subgraph"?`"${e}"`:e}function Ni(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function pS(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function W3(e){return Ni(e)&&pS(e)}function _a(e){if(pS(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function ya(e){if(e!=null&&Ni(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"),mh=class lM extends $t{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 lM({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new xe("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 Pe;return this._value}checkpoint(){}isAvailable(){return this._value!==fS}};var va=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),mS=class dM extends $t{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new dM(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 xe(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!va(this.names,this.seen))throw new Pe}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&va(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&va(this.names,this.seen)}},hS=class pM extends $t{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 pM(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 xe(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!va(this.names,this.seen))throw new Pe}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&va(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&va(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&va(this.names,this.seen)}};var gS=Symbol.for("langgraph.state.reduced_value"),Pi=class{[gS]=!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&&gS in e&&e[gS]===!0}};var fM=Symbol.for("langgraph.state.untracked_value"),No=class{[fM]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&fM in e}};var _S=Symbol.for("langgraph.state.state_schema"),ni=class{[_S]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(Pi.isInstance(r)){let i=ya(r.valueSchema);e[t]=new Ii(r.reducer,i)}else if(No.isInstance(r)){let i=r.schema?ya(r.schema):void 0;e[t]=new mh({guard:r.guard,initialValueFactory:i})}else if(Ni(r))e[t]=new xn(ya(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(Pi.isInstance(i)?(n=_a(i.valueSchema),i.jsonSchemaExtra&&(n={...n??{},...i.jsonSchemaExtra})):No.isInstance(i)?n=i.schema?_a(i.schema):void 0:Ni(i)&&(n=_a(i)),n){e[r]=n;let a=!1;Pi.isInstance(i)?a=ya(i.valueSchema)!==void 0:No.isInstance(i)?a=i.schema?ya(i.schema)!==void 0:!1:a=ya(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;Pi.isInstance(r)?(i=_a(r.inputSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):No.isInstance(r)?i=r.schema?_a(r.schema):void 0:Ni(r)&&(i=_a(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(Pi.isInstance(n)?a=n.inputSchema:No.isInstance(n)?a=n.schema:Ni(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&&_S in e&&e[_S]===!0}};var X3="__remove_all__";function ba(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=Nn(),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=Nn(),d.lc_kwargs.id=d.id),cn.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)cn.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(cn.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 Y3=new Pi(Xr.custom().default(()=>[]),{inputSchema:Xr.custom(),reducer:ba,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var Q3=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 Ii(a.reducer.fn,a.default):t[i]=new xn(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=yi(u)??yi(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[o,u]});n=pf(e,Object.fromEntries(a)),ot(n)&&(n._def.unknownKeys="strip")}return t.asPartial&&(n=Ns(n)),i.set(e,n),this._extensionCache.set(r,i),n}},xl=new Q3;function mM(e,t){if(t.reducer&&!t.default){let r=ff(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return xl.extend(r,()=>t),r}else return xl.extend(e,()=>t),e}function Po(e){return e==null?!1:!!(ni.isInstance(e)||er(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"||L0(t)))}function hM(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 Ri="__root__",hh=Symbol.for("langgraph.state.partial"),yS=class extends lS{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=xl;_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 xc;let n=this._getChannelsFromSchema(i);this._schemaDefinition=n,ni.isInstance(i)?this._schemaRuntimeDefinition=i:er(i)&&(this._schemaRuntimeDefinition=i),r.input?ni.isInstance(r.input)?this._inputRuntimeDefinition=r.input:er(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=hh:this._inputRuntimeDefinition=hh,r.output?ni.isInstance(r.output)?this._outputRuntimeDefinition=r.output:er(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&&er(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}_normalizeToStateGraphInit(e,t){if(hM(e)){if(er(t)||Jm.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(er(t)||Jm.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(tG(e))return{state:eG(e.channels)};throw new xc}_getChannelsFromSchema(e){if(ni.isInstance(e))return e.getChannels();if(er(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 xc("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 Ft({func:n,name:i,trace:!1}):s=rt(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:_l(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}={}){this.validate([...Array.isArray(i)?i:[],...Array.isArray(n)?n:[]]);let s=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),c=s.length===1&&s[0]===Ri?Ri:s,u=Object.keys(this.channels),l=u.length===1&&u[0]===Ri?Ri:u,d=this._interrupt,p=new _M({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:i,autoValidate:!1,nodes:{},channels:{...this.channels,[Ge]:new En},inputChannels:Ge,outputChannels:c,streamChannels:l,streamMode:"updates",store:t,cache:r,name:a,description:o,userInterrupt:d});p.attachNode(Ge);for(let[f,m]of Object.entries(this.nodes))p.attachNode(f,m);p.attachBranch(Ge,_h,gM(),{withReader:!1});for(let[f]of Object.entries(this.nodes))p.attachBranch(f,_h,gM(),{withReader:!1});for(let[f,m]of this.edges)p.attachEdge(f,m);for(let[f,m]of this.waitingEdges)p.attachEdge(f,m);for(let[f,m]of Object.entries(this.branches))for(let[_,v]of Object.entries(m))p.attachBranch(f,_,v);return p.validate()}};function eG(e){let t={};for(let[r,i]of Object.entries(e))r===Ri?t[r]=Km(i):t[r]=Km(i);return t}var _M=class extends dS{description;_metaRegistry=xl;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(_t(s))return s.graph===ar.PARENT?null:s._updateAsTuples();if(Array.isArray(s)&&s.length>0&&s.some(c=>_t(c))){let c=[];for(let u of s)if(_t(u)){if(u.graph===ar.PARENT)continue;c.push(...u._updateAsTuples())}else c.push([Ri,u]);return c}else if(s!=null)return[[Ri,s]];return null}let n=e;function a(s){if(s){if(_t(s))return s.graph===ar.PARENT?null:s._updateAsTuples().filter(([c])=>r.includes(c));if(Array.isArray(s)&&s.length>0&&s.some(_t)){let c=[];for(let u of s)if(_t(u)){if(u.graph===ar.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 xe(`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:_r,mapper:new Ft({func:r.length&&r[0]===Ri?i:a,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new kn({tags:[pt],triggers:[Ge],channels:[Ge],writers:[new st(o,[pt])]});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&&Ri in c,l=`branch:to:${e}`;this.channels[l]=t?.defer?new U0:new En(!1),this.nodes[e]=new kn({triggers:[l],channels:u?Object.keys(c):c,writers:[new st(o,[pt])],mapper:u?void 0:d=>Object.fromEntries(Object.entries(d).filter(([p])=>p 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 st([{channel:`branch:to:${t}`,value:null}],[pt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new hS(new Set(e)):new mS(new Set(e)),this.nodes[t].triggers.push(r);for(let i of e)this.nodes[i].writers.push(new st([{channel:r,value:i}],[pt]))}}}attachBranch(e,t,r,i={withReader:!0}){let n=async(a,o)=>{let s=a.filter(u=>u!==Qe);if(!s.length)return;let c=s.map(u=>ft(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await st.doWrite({...o,tags:(o.tags??[]).concat([pt])},c)};this.nodes[e].writers.push(r.run(n,i.withReader?a=>Nj.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(ni.isInstance(t)){if(_t(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===hh&&ni.isInstance(r)){if(_t(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(er(t))return n(t);if(t===hh)return er(r)?Ns(n(r)):void 0})();if(_t(e)){let n=e;return e.update&&i!=null&&(n.update=Cs(i,e.update)),n}return i!=null?Cs(i,e):e}isInterrupted(e){return wc(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return er(t)&&Cs(t,e),e}};function tG(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function rG(e){if(ft(e))return[e];let t=[];_t(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(_t));let r=[];for(let i of t){if(i.graph===ar.PARENT)throw new Cl(i);ft(i.goto)||typeof i.goto=="string"?r.push(i.goto):Array.isArray(i.goto)&&r.push(...i.goto)}return r}function gM(){return new uS({path:new Ft({func:rG,tags:[pt],trace:!1,recurse:!1,name:"<control_branch>"})})}var nG=class extends yS{constructor(){super({channels:{__root__:{reducer:ba,default:()=>[]}}})}};function iG(e,t){let{stateKey:r,...i}=t??{},n=cc(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 aG(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0}:e,{name:i,retry:n}=r;if(H0(t)||q0(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)=>Bj({func:t,name:i,retry:n,cache:o},...s)}var yM=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(H0(r)||q0(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let s="updates",c=Fj(i,r);function u(f){return typeof f=="object"&&f!==null&&"__lg_type"in f&&f.__lg_type==="__pregel_final"}let l=new Ft({name:"pluckReturnValue",func:f=>u(f)?f.value:f}),d=new Ft({name:"pluckSaveValue",func:f=>u(f)?f.save:f}),p=new kn({bound:c,triggers:[Ge],channels:[Ge],writers:[new st([{channel:Qe,value:_r,mapper:l},{channel:Ea,value:_r,mapper:d}],[pt])]});return new fh({name:i,checkpointer:n,nodes:{[i]:p},channels:{[Ge]:new En,[Qe]:new xn,[Ea]:new xn},inputChannels:Ge,outputChannels:Qe,streamChannels:Qe,streamMode:s,store:a,cache:o})};yM.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function oG(){return Oe.getRunnableConfig().configurable?.[$a]}var sG=hl.Root({messages:hl({reducer:ba,default:()=>[]})}),vM={reducer:{fn:ba},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},cG=kt.object({messages:mM(kt.custom(),vM)});function uG(e){let t=Oe.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{Ge as a,Qe as b,He as c,gh as d,kS as e,ka as f,ft as g,xM as h,wc as i,ar as j,_t as k,rn as l,yh as m,vh as n,Ia as o,oi as p,Ol as q,Cl as r,bh as s,Ta as t,si as u,Al as v,Pe as w,xe as x,SM as y,wh as z,kM as A,xc as B,$M as C,ik as D,Zt as E,a4 as F,Pn as G,mk as H,Ic as I,hk as J,Ue as K,Xe as L,Ht as M,Ho as N,Cc as O,qo as P,Ae as Q,Ko as R,vt as S,sn as T,Na as U,Ra as V,nt as W,ja as X,cn as Y,qt as Z,di as _,a$ as $,Wo as aa,Xh as ba,Oe as ca,xt as da,St as ea,Se as fa,ur as ga,kr as ha,mt as ia,Gi as ja,Ji as ka,Ha as la,ea as ma,Np as na,to as oa,Be as pa,ot as qa,pr as ra,df as sa,KC as ta,Cs as ua,yi as va,er as wa,no as xa,Ns as ya,ff as za,XC as Aa,D as Ba,kt as Ca,$f as Da,bt as Ea,ae as Fa,Jr as Ga,Cr as Ha,zt as Ia,bN as Ja,Pf as Ka,YN as La,kV as Ma,Ru as Na,Ff as Oa,Fw as Pa,g1 as Qa,_1 as Ra,OV as Sa,CV as Ta,Vw as Ua,pa as Va,ix as Wa,Ks as Xa,Wu as Ya,Xr as Za,xZ as _a,EZ as $a,RZ as ab,ac as bb,bn as cb,Zm as db,hj as eb,sc as fb,Hm as gb,yj as hb,$t as ib,Ii as jb,hl as kb,u3 as lb,l3 as mb,F0 as nb,d3 as ob,G0 as pb,Ft as qb,lS as rb,Ni as sb,W3 as tb,_a as ub,ya as vb,mh as wb,Pi as xb,No as yb,ni as zb,X3 as Ab,ba as Bb,Y3 as Cb,xl as Db,mM as Eb,yS as Fb,_M as Gb,nG as Hb,iG as Ib,aG as Jb,yM as Kb,oG as Lb,sG as Mb,vM as Nb,cG as Ob,uG as Pb};