@copilotkit/runtime 0.0.0-max-changeset-20260109200053 → 0.0.0-max-umd-20260122170341

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,48 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("graphql"),require("@copilotkit/shared"),require("node:path"),require("node:fs"),require("node:fs/promises"),require("rxjs"),require("graphql-yoga"),require("node:crypto"),require("@copilotkitnext/runtime"),require("@copilotkitnext/agent"),require("tty"),require("stream"),require("worker_threads"),require("fs"),require("path"),require("node:stream")):"function"==typeof define&&define.amd?define(["exports","graphql","@copilotkit/shared","node:path","node:fs","node:fs/promises","rxjs","graphql-yoga","node:crypto","@copilotkitnext/runtime","@copilotkitnext/agent","tty","stream","worker_threads","fs","path","node:stream"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CopilotKitRuntime={},e.GraphQL,e.CopilotKitShared,e.path,e.fs,null,e.rxjs,e.GraphQLYoga,e.node_crypto,e.CopilotKitNextRuntime,e.CopilotKitNextAgent,e.require$$0,e.require$$0$1,e.require$$2$1,e.require$$0$2,e.require$$3,e.node_stream)}(this,function(e,t,r,n,i,o,a,s,c,u,l,d,f,p,h,m,y){"use strict";function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var b=g(t),v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function _(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var E,S={};
2
+ /*! *****************************************************************************
3
+ Copyright (C) Microsoft. All rights reserved.
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this file except in compliance with the License. You may obtain a copy of the
6
+ License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
+
13
+ See the Apache Version 2.0 License for specific language governing permissions
14
+ and limitations under the License.
15
+ ***************************************************************************** */!function(){return E||(E=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof v?v:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),r=n(e);function n(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==t.Reflect&&(r=n(t.Reflect,r)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!a&&!s,u={create:a?function(){return de(Object.create(null))}:s?function(){return de({__proto__:null})}:function(){return de({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},l=Object.getPrototypeOf(Function),d="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ue(),p="function"==typeof WeakMap?WeakMap:le(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),y=oe(m);function g(e,t,r,n){if($(r)){if(!W(e))throw new TypeError;if(!K(t))throw new TypeError;return x(e,t)}if(!W(e))throw new TypeError;if(!F(t))throw new TypeError;if(!F(n)&&!$(n)&&!D(n))throw new TypeError;return D(n)&&(n=void 0),I(e,t,r=V(r),n)}function b(e,t){function r(r,n){if(!F(r))throw new TypeError;if(!$(n)&&!Z(n))throw new TypeError;P(e,t,r,n)}return r}function v(e,t,r,n){if(!F(r))throw new TypeError;return $(n)||(n=V(n)),P(e,t,r,n)}function w(e,t,r){if(!F(t))throw new TypeError;return $(r)||(r=V(r)),k(e,t,r)}function _(e,t,r){if(!F(t))throw new TypeError;return $(r)||(r=V(r)),j(e,t,r)}function E(e,t,r){if(!F(t))throw new TypeError;return $(r)||(r=V(r)),R(e,t,r)}function S(e,t,r){if(!F(t))throw new TypeError;return $(r)||(r=V(r)),N(e,t,r)}function O(e,t){if(!F(e))throw new TypeError;return $(t)||(t=V(t)),C(e,t)}function A(e,t){if(!F(e))throw new TypeError;return $(t)||(t=V(t)),L(e,t)}function T(e,t,r){if(!F(t))throw new TypeError;if($(r)||(r=V(r)),!F(t))throw new TypeError;$(r)||(r=V(r));var n=se(t,r,!1);return!$(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function x(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!$(n)&&!D(n)){if(!K(n))throw new TypeError;t=n}}return t}function I(e,t,r,n){for(var i=e.length-1;i>=0;--i){var o=(0,e[i])(t,r,n);if(!$(o)&&!D(o)){if(!F(o))throw new TypeError;n=o}}return n}function k(e,t,r){if(j(e,t,r))return!0;var n=re(t);return!D(n)&&k(e,n,r)}function j(e,t,r){var n=se(t,r,!1);return!$(n)&&G(n.OrdinaryHasOwnMetadata(e,t,r))}function R(e,t,r){if(j(e,t,r))return N(e,t,r);var n=re(t);return D(n)?void 0:R(e,n,r)}function N(e,t,r){var n=se(t,r,!1);if(!$(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function P(e,t,r,n){se(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function C(e,t){var r=L(e,t),n=re(e);if(null===n)return r;var i=C(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new f,a=[],s=0,c=r;s<c.length;s++){var u=c[s];o.has(u)||(o.add(u),a.push(u))}for(var l=0,d=i;l<d.length;l++){u=d[l];o.has(u)||(o.add(u),a.push(u))}return a}function L(e,t){var r=se(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function M(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function $(e){return void 0===e}function D(e){return null===e}function B(e){return"symbol"==typeof e}function F(e){return"object"==typeof e?null!==e:"function"==typeof e}function U(e,t){switch(M(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r="string",n=Y(e,i);if(void 0!==n){var o=n.call(e,r);if(F(o))throw new TypeError;return o}return z(e)}function z(e,t){var r,n,i=e.toString;if(H(i)&&!F(n=i.call(e)))return n;if(H(r=e.valueOf)&&!F(n=r.call(e)))return n;throw new TypeError}function G(e){return!!e}function q(e){return""+e}function V(e){var t=U(e);return B(t)?t:q(t)}function W(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function H(e){return"function"==typeof e}function K(e){return"function"==typeof e}function Z(e){switch(M(e)){case 3:case 4:return!0;default:return!1}}function J(e,t){return e===t||e!=e&&t!=t}function Y(e,t){var r=e[t];if(null!=r){if(!H(r))throw new TypeError;return r}}function Q(e){var t=Y(e,o);if(!H(t))throw new TypeError;var r=t.call(e);if(!F(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===l)return t;if(t!==l)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function ne(){var e,r,n,i;$(h)||void 0===t.Reflect||h in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=ae(t.Reflect));var o=new p,a={registerProvider:s,getProvider:u,setProvider:m};return a;function s(t){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case $(r):r=t;break;case r===t:break;case $(n):n=t;break;case n===t:break;default:void 0===i&&(i=new f),i.add(t)}}function c(t,o){if(!$(r)){if(r.isProviderFor(t,o))return r;if(!$(n)){if(n.isProviderFor(t,o))return r;if(!$(i))for(var a=Q(i);;){var s=ee(a);if(!s)return;var c=X(s);if(c.isProviderFor(t,o))return te(a),c}}}if(!$(e)&&e.isProviderFor(t,o))return e}function u(e,t){var r,n=o.get(e);return $(n)||(r=n.get(t)),$(r)?($(r=c(e,t))||($(n)&&(n=new d,o.set(e,n)),n.set(t,r)),r):r}function l(e){if($(e))throw new TypeError;return r===e||n===e||!$(i)&&i.has(e)}function m(e,t,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(e,t);if(n!==r){if(!$(n))return!1;var i=o.get(e);$(i)&&(i=new d,o.set(e,i)),i.set(t,r)}return!0}}function ie(){var e;return!$(h)&&F(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[h]),$(e)&&(e=ne()),!$(h)&&F(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function oe(e){var t=new p,r={isProviderFor:function(e,r){var n=t.get(e);return!$(n)&&n.has(r)},OrdinaryDefineOwnMetadata:a,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(r),r;function n(n,i,o){var a=t.get(n),s=!1;if($(a)){if(!o)return;a=new d,t.set(n,a),s=!0}var c=a.get(i);if($(c)){if(!o)return;if(c=new d,a.set(i,c),!e.setProvider(n,i,r))throw a.delete(i),s&&t.delete(n),new Error("Wrong provider for target.")}return c}function i(e,t,r){var i=n(t,r,!1);return!$(i)&&G(i.has(e))}function o(e,t,r){var i=n(t,r,!1);if(!$(i))return i.get(e)}function a(e,t,r,i){n(r,i,!0).set(e,t)}function s(e,t){var r=[],i=n(e,t,!1);if($(i))return r;for(var o=Q(i.keys()),a=0;;){var s=ee(o);if(!s)return r.length=a,r;var c=X(s);try{r[a]=c}catch(e){try{te(o)}finally{throw e}}a++}}function c(e,r,i){var o=n(r,i,!1);if($(o))return!1;if(!o.delete(e))return!1;if(0===o.size){var a=t.get(r);$(a)||(a.delete(i),0===a.size&&t.delete(a))}return!0}}function ae(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,o=e.deleteMetadata,a=new p;return{isProviderFor:function(e,t){var r=a.get(e);return!($(r)||!r.has(t))||!!i(e,t).length&&($(r)&&(r=new f,a.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:o}}function se(e,t,r){var n=m.getProvider(e,t);if(!$(n))return n;if(r){if(m.setProvider(e,t,y))return y;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[o]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,J(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,a)},t.prototype.entries=function(){return new r(this._keys,this._values,s)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[o]=function(){return this.entries()},t.prototype._find=function(e,t){if(!J(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(J(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function i(e,t){return e}function a(e,t){return t}function s(e,t){return[e,t]}}function ue(){return function(){function e(){this._map=new d}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[o]=function(){return this.keys()},e}()}function le(){var e=16,t=u.create(),n=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=o(e,!1);return void 0!==t&&u.has(t,this._key)},e.prototype.get=function(e){var t=o(e,!1);return void 0!==t?u.get(t,this._key):void 0},e.prototype.set=function(e,t){return o(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=o(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do{e="@@WeakMap@@"+c()}while(u.has(t,e));return t[e]=!0,e}function o(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:u.create()})}return e[n]}function a(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function s(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):a(t,e),t}return a(new Array(e),e)}function c(){var t=s(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function de(e){return e.__=void 0,delete e.__,e}e("decorate",g),e("metadata",b),e("defineMetadata",v),e("hasMetadata",w),e("hasOwnMetadata",_),e("getMetadata",E),e("getOwnMetadata",S),e("getMetadataKeys",O),e("getOwnMetadataKeys",A),e("deleteMetadata",T)}(r,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}))),S;var e}();var O=function(e,t){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},O(e,t)};function A(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}O(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var T=function(){return T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},T.apply(this,arguments)};function x(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function I(e,t){return function(r,n){t(r,n,e)}}function k(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function j(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}c((n=n.apply(e,t||[])).next())})}function R(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function N(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=N(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function L(e,t,r,n){n||(n=function(e){return $[e]||M}(r));var i=[],o=function(e,t){if(0===t.length)return 0;var r=JSON.stringify(t);return B(e,r)}(r,t);if(o>n)throw new Error("Too many tokens in function definitions: ".concat(o," > ").concat(n));n-=o;for(var a=0,s=e;a<s.length;a++){var c=s[a];if(["system","developer"].includes(c.role))if((n-=f=D(r,c))<0)throw new Error("Not enough tokens for system message.")}for(var u=!1,l=0,d=P([],e,!0).reverse();l<d.length;l++){var f;c=d[l];if(["system","developer"].includes(c.role))i.unshift(c);else if(!u)n<(f=D(r,c))?u=!0:(i.unshift(c),n-=f)}return i}"function"==typeof SuppressedError&&SuppressedError;var M=128e3,$={o1:2e5,"o1-2024-12-17":2e5,"o1-mini":128e3,"o1-mini-2024-09-12":128e3,"o1-preview":128e3,"o1-preview-2024-09-12":128e3,"o3-mini":2e5,"o3-mini-2025-01-31":2e5,"gpt-4o":128e3,"chatgpt-4o-latest":128e3,"gpt-4o-2024-08-06":128e3,"gpt-4o-2024-05-13":128e3,"gpt-4o-mini":128e3,"gpt-4o-mini-2024-07-18":128e3,"gpt-4-turbo":128e3,"gpt-4-turbo-2024-04-09":128e3,"gpt-4-0125-preview":128e3,"gpt-4-turbo-preview":128e3,"gpt-4-1106-preview":128e3,"gpt-4-vision-preview":128e3,"gpt-4-1106-vision-preview":128e3,"gpt-4-32k":32768,"gpt-4-32k-0613":32768,"gpt-4-32k-0314":32768,"gpt-4":8192,"gpt-4-0613":8192,"gpt-4-0314":8192,"gpt-3.5-turbo-0125":16385,"gpt-3.5-turbo":16385,"gpt-3.5-turbo-1106":16385,"gpt-3.5-turbo-instruct":4096,"gpt-3.5-turbo-16k":16385,"gpt-3.5-turbo-0613":4096,"gpt-3.5-turbo-16k-0613":16385,"gpt-3.5-turbo-0301":4097};function D(e,t){return B(e,t.content||"")}function B(e,t){return t.length/3}function F(e){return{type:"function",function:{name:e.name,description:e.description,parameters:r.parseJson(e.jsonSchema,{})}}}function U(e,t){var r=(t||{keepSystemRole:!1}).keepSystemRole;if(e.isTextMessage()){var n=e.role;return"system"!==e.role||r||(n="developer"),{role:n,content:e.content}}return e.isImageMessage()?{role:"user",content:[{type:"image_url",image_url:{url:"data:image/".concat(e.format,";base64,").concat(e.bytes)}}]}:e.isActionExecutionMessage()?{role:"assistant",tool_calls:[{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.arguments)}}]}:e.isResultMessage()?{role:"tool",content:e.result,tool_call_id:e.actionExecutionId}:void 0}function z(e){return T(T({},e),["system","developer"].includes(e.role)&&{role:"assistant",content:"THE FOLLOWING MESSAGE IS A SYSTEM MESSAGE: "+e.content})}function G(e,t){var n,i,o,a,s=(null===(n=null==e?void 0:e.constructor)||void 0===n?void 0:n.name)||e.name,c=(null==e?void 0:e.message)||String(e),u=e.status||e.statusCode||(null===(i=e.response)||void 0===i?void 0:i.status),l=e.error||(null===(o=e.response)||void 0===o?void 0:o.data)||e.data,d=new r.CopilotKitLowLevelError({error:e instanceof Error?e:new Error(c),url:"".concat(t," service adapter"),message:"".concat(t," API error: ").concat(c)});return u&&(d.statusCode=u),l&&(d.responseData=l),s&&(d.originalErrorType=s),a=401===u?r.CopilotKitErrorCode.AUTHENTICATION_ERROR:u>=400&&u<500?r.CopilotKitErrorCode.CONFIGURATION_ERROR:u>=500?r.CopilotKitErrorCode.NETWORK_ERROR:u?r.CopilotKitErrorCode.CONFIGURATION_ERROR:r.CopilotKitErrorCode.NETWORK_ERROR,d.code=a,d.extensions&&(d.extensions.code=a),d}var q,V,W=function(){function e(e){var t;this.model="gpt-4o",this.provider="openai",this.disableParallelToolCalls=!1,this.keepSystemRole=!1,(null==e?void 0:e.openai)&&(this._openai=e.openai),(null==e?void 0:e.model)&&(this.model=e.model),this.disableParallelToolCalls=(null==e?void 0:e.disableParallelToolCalls)||!1,this.keepSystemRole=null!==(t=null==e?void 0:e.keepSystemRole)&&void 0!==t&&t}return Object.defineProperty(e.prototype,"openai",{get:function(){return this._openai},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"OpenAIAdapter"},enumerable:!1,configurable:!0}),e.prototype.ensureOpenAI=function(){if(!this._openai){var e=require("openai").default;this._openai=new e}return this._openai},e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w=this;return R(this,function(_){for(t=e.threadId,n=e.model,i=void 0===n?this.model:n,o=e.messages,a=e.actions,s=e.eventSource,c=e.forwardedParameters,u=a.map(F),l=null!=t?t:r.randomUUID(),d=new Set,f=0,p=o;f<p.length;f++)(h=p[f]).isActionExecutionMessage()&&d.add(h.id);m=o.filter(function(e){return!e.isResultMessage()||!!d.has(e.actionExecutionId)&&(d.delete(e.actionExecutionId),!0)}),y=L(y=m.map(function(e){return U(e,{keepSystemRole:w.keepSystemRole})}),u,i),g=null==c?void 0:c.toolChoice,"function"===(null==c?void 0:c.toolChoice)&&(g={type:"function",function:{name:c.toolChoiceFunctionName}});try{b=this.ensureOpenAI(),v=b.beta.chat.completions.stream(T(T(T(T(T(T({model:i,stream:!0,messages:y},u.length>0&&{tools:u}),(null==c?void 0:c.maxTokens)&&{max_completion_tokens:c.maxTokens}),(null==c?void 0:c.stop)&&{stop:c.stop}),g&&{tool_choice:g}),this.disableParallelToolCalls&&{parallel_tool_calls:!1}),(null==c?void 0:c.temperature)&&{temperature:c.temperature})),s.stream(function(e){return j(w,void 0,void 0,function(){var t,r,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g;return R(this,function(b){switch(b.label){case 0:t=null,b.label=1;case 1:b.trys.push([1,14,,15]),b.label=2;case 2:b.trys.push([2,7,8,13]),i=!0,o=C(v),b.label=3;case 3:return[4,o.next()];case 4:if(a=b.sent(),f=a.done)return[3,6];if(m=a.value,i=!1,0===(s=m).choices.length)return[3,5];c=null===(y=s.choices[0].delta.tool_calls)||void 0===y?void 0:y[0],u=s.choices[0].delta.content,"message"===t&&(null==c?void 0:c.id)?(t=null,e.sendTextMessageEnd({messageId:r})):"function"!==t||void 0!==c&&!(null==c?void 0:c.id)||(t=null,e.sendActionExecutionEnd({actionExecutionId:n})),null===t&&((null==c?void 0:c.id)?(t="function",n=c.id,e.sendActionExecutionStart({actionExecutionId:n,parentMessageId:s.id,actionName:c.function.name})):u&&(t="message",r=s.id,e.sendTextMessageStart({messageId:r}))),"message"===t&&u?e.sendTextMessageContent({messageId:r,content:u}):"function"===t&&(null===(g=null==c?void 0:c.function)||void 0===g?void 0:g.arguments)&&e.sendActionExecutionArgs({actionExecutionId:n,args:c.function.arguments}),b.label=5;case 5:return i=!0,[3,3];case 6:return[3,13];case 7:return l=b.sent(),p={error:l},[3,13];case 8:return b.trys.push([8,,11,12]),i||f||!(h=o.return)?[3,10]:[4,h.call(o)];case 9:b.sent(),b.label=10;case 10:return[3,12];case 11:if(p)throw p.error;return[7];case 12:return[7];case 13:return"message"===t?e.sendTextMessageEnd({messageId:r}):"function"===t&&e.sendActionExecutionEnd({actionExecutionId:n}),[3,15];case 14:throw d=b.sent(),console.error("[OpenAI] Error during API call:",d),G(d,"OpenAI");case 15:return e.complete(),[2]}})})})}catch(e){throw console.error("[OpenAI] Error during API call:",e),G(e,"OpenAI")}return[2,{threadId:l}]})})},e}();function H(e){if(void 0===e)return null;try{return JSON.parse(e)}catch(e){}let t="";const r=[];let n=!1,i=!1;for(let o of e){if(n)'"'!==o||i?"\n"!==o||i?i="\\"===o&&!i:o="\\n":n=!1;else if('"'===o)n=!0,i=!1;else if("{"===o)r.push("}");else if("["===o)r.push("]");else if("}"===o||"]"===o){if(!r||r[r.length-1]!==o)return null;r.pop()}t+=o}n&&(t+='"');for(let e=r.length-1;e>=0;e-=1)t+=r[e];try{return JSON.parse(t)}catch(e){return null}}var K,Z=w(V?q:(V=1,q=function(e,t){if("string"!=typeof e)throw new TypeError("Expected a string");return t=void 0===t?"_":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()})),J={exports:{}};function Y(e,t){return t?.[e]||Z(e)}!function(){if(K)return J.exports;K=1;const e=/[\p{Lu}]/u,t=/[\p{Ll}]/u,r=/^[\p{Lu}](?![\p{Lu}])/gu,n=/([\p{Alpha}\p{N}_]|$)/u,i=/[_.\- ]+/,o=new RegExp("^"+i.source),a=new RegExp(i.source+n.source,"gu"),s=new RegExp("\\d+"+n.source,"gu"),c=(n,i)=>{if("string"!=typeof n&&!Array.isArray(n))throw new TypeError("Expected the input to be `string | string[]`");if(i={pascalCase:!1,preserveConsecutiveUppercase:!1,...i},0===(n=Array.isArray(n)?n.map(e=>e.trim()).filter(e=>e.length).join("-"):n.trim()).length)return"";const c=!1===i.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(i.locale),u=!1===i.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(i.locale);if(1===n.length)return i.pascalCase?u(n):c(n);return n!==c(n)&&(n=((r,n,i)=>{let o=!1,a=!1,s=!1;for(let c=0;c<r.length;c++){const u=r[c];o&&e.test(u)?(r=r.slice(0,c)+"-"+r.slice(c),o=!1,s=a,a=!0,c++):a&&s&&t.test(u)?(r=r.slice(0,c-1)+"-"+r.slice(c-1),s=a,a=!1,o=!0):(o=n(u)===u&&i(u)!==u,s=a,a=i(u)===u&&n(u)!==u)}return r})(n,c,u)),n=n.replace(o,""),n=i.preserveConsecutiveUppercase?((e,t)=>(r.lastIndex=0,e.replace(r,e=>t(e))))(n,c):c(n),i.pascalCase&&(n=u(n.charAt(0))+n.slice(1)),((e,t)=>(a.lastIndex=0,s.lastIndex=0,e.replace(a,(e,r)=>t(r)).replace(s,e=>t(e))))(n,u)};J.exports=c,J.exports.default=c,J.exports}();const Q="__lc_escaped__";function X(e){if(null!==e&&"object"==typeof e&&!Array.isArray(e)){if(null!==(t=e)&&"object"==typeof t&&"lc_serializable"in t&&"function"==typeof t.toJSON)return e;const r=e;if(function(e){return"lc"in e||1===Object.keys(e).length&&Q in e}(r))return function(e){return{[Q]:e}}(r);const n={};for(const[e,t]of Object.entries(r))n[e]=X(t);return n}var t;return Array.isArray(e)?e.map(e=>X(e)):e}function ee(e){return Array.isArray(e)?[...e]:{...e}}function te(e){const t=Object.getPrototypeOf(e);return"function"==typeof e.lc_name&&("function"!=typeof t.lc_name||e.lc_name()!==t.lc_name())?e.lc_name():e.name}class re{static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,te(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(e,...t){Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),void 0!==this.lc_serializable_keys?this.lc_kwargs=Object.fromEntries(Object.entries(e||{}).filter(([e])=>this.lc_serializable_keys?.includes(e))):this.lc_kwargs=e??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof re||"object"!=typeof this.lc_kwargs||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();const e={},t={},r=Object.keys(this.lc_kwargs).reduce((e,t)=>(e[t]=t in this?this[t]:this.lc_kwargs[t],e),{});for(let n=Object.getPrototypeOf(this);n;n=Object.getPrototypeOf(n))Object.assign(e,Reflect.get(n,"lc_aliases",this)),Object.assign(t,Reflect.get(n,"lc_secrets",this)),Object.assign(r,Reflect.get(n,"lc_attributes",this));Object.keys(t).forEach(e=>{let t=this,n=r;const[i,...o]=e.split(".").reverse();for(const e of o.reverse()){if(!(e in t)||void 0===t[e])return;e in n&&void 0!==n[e]||("object"==typeof t[e]&&null!=t[e]?n[e]={}:Array.isArray(t[e])&&(n[e]=[])),t=t[e],n=n[e]}i in t&&void 0!==t[i]&&(n[i]=n[i]||t[i])});const n={};for(const[e,t]of Object.entries(r))n[e]=X(t);const i=Object.keys(t).length?function(e,t){const r=ee(e);for(const[e,n]of Object.entries(t)){const[t,...i]=e.split(".").reverse();let o=r;for(const e of i.reverse()){if(void 0===o[e])break;o[e]=ee(o[e]),o=o[e]}void 0!==o[t]&&(o[t]={lc:1,type:"secret",id:[n]})}return r}(n,t):n,o=function(e,t,r){const n={};for(const i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}(i,Y,e);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}}function ne(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type&&"source_type"in e&&("url"===e.source_type||"base64"===e.source_type||"text"===e.source_type||"id"===e.source_type)}class ie extends re{get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}get text(){return"string"==typeof this.content?this.content:Array.isArray(this.content)?this.content.map(e=>"string"==typeof e?e:"text"===e.type?e.text:"").join(""):""}getType(){return this._getType()}constructor(e,t){"string"==typeof e&&(e={content:e,additional_kwargs:t,response_metadata:{}}),e.additional_kwargs||(e.additional_kwargs={}),e.response_metadata||(e.response_metadata={}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","messages"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"content",{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,"additional_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.content=e.content,this.additional_kwargs=e.additional_kwargs,this.response_metadata=e.response_metadata,this.id=e.id}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}}_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(null===e)return this;const t=(r=this._printableFields,n=Math.max(4,e),JSON.stringify(function e(t,r){if("object"!=typeof t||null==t)return t;if(r>=n)return Array.isArray(t)?"[Array]":"[Object]";if(Array.isArray(t))return t.map(t=>e(t,r+1));const i={};for(const n of Object.keys(t))i[n]=e(t[n],r+1);return i}(r,0),null,2));var r,n;return`${this.constructor.lc_name()} ${t}`}}function oe(e,t){const r={...e};for(const[e,n]of Object.entries(t))if(null==r[e])r[e]=n;else{if(null==n)continue;if(typeof r[e]!=typeof n||Array.isArray(r[e])!==Array.isArray(n))throw new Error(`field[${e}] already exists in the message chunk, but with a different type.`);if("string"==typeof r[e]){if("type"===e)continue;["id","name","output_version","model_provider"].includes(e)?r[e]=n:r[e]+=n}else if("object"!=typeof r[e]||Array.isArray(r[e]))if(Array.isArray(r[e]))r[e]=ae(r[e],n);else{if(r[e]===n)continue;console.warn(`field[${e}] already exists in this message chunk and value has unsupported type.`)}else r[e]=oe(r[e],n)}return r}function ae(e,t){if(void 0!==e||void 0!==t){if(void 0===e||void 0===t)return e||t;{const r=[...e];for(const e of t)if("object"==typeof e&&null!==e&&"index"in e&&"number"==typeof e.index){const t=r.findIndex(t=>{const r="object"==typeof t,n="index"in t&&t.index===e.index;return r&&n&&("id"in t&&"id"in e&&t?.id===e?.id||!("id"in t&&t?.id&&"id"in e&&e?.id))});-1!==t&&"object"==typeof r[t]&&null!==r[t]?r[t]=oe(r[t],e):r.push(e)}else{if("object"==typeof e&&null!==e&&"text"in e&&""===e.text)continue;r.push(e)}return r}}}class se extends ie{}class ce extends ie{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}constructor(e,t,r){"string"==typeof e&&(e={content:e,name:r,tool_call_id:t}),super(e),Object.defineProperty(this,"lc_direct_tool_output",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tool_call_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"artifact",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status,this.metadata=e.metadata}_getType(){return"tool"}static isInstance(e){return"tool"===e._getType()}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}}class ue extends ie{get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls"}}constructor(e,t){let r;if("string"==typeof e)r={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:t??{}};else{r=e;const t=r.additional_kwargs?.tool_calls,n=r.tool_calls;null!=t&&t.length>0&&(void 0===n||0===n.length)&&console.warn(["New LangChain packages are available that more efficiently handle","tool calling.\n\nPlease upgrade your packages to versions that set","message tool calls. e.g., `yarn add @langchain/anthropic`,","yarn add @langchain/openai`, etc."].join(" "));try{if(null!=t&&void 0===n){const[e,n]=function(e){const t=[],r=[];for(const n of e)if(n.function){const e=n.function.name;try{const r={name:e||"",args:JSON.parse(n.function.arguments)||{},id:n.id};t.push(r)}catch(t){r.push({name:e,args:n.function.arguments,id:n.id,error:"Malformed args."})}}return[t,r]}(t);r.tool_calls=e??[],r.invalid_tool_calls=n??[]}else r.tool_calls=r.tool_calls??[],r.invalid_tool_calls=r.invalid_tool_calls??[]}catch(e){r.tool_calls=[],r.invalid_tool_calls=[]}}super(r),Object.defineProperty(this,"tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"invalid_tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"usage_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),"string"!=typeof r&&(this.tool_calls=r.tool_calls??this.tool_calls,this.invalid_tool_calls=r.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=r.usage_metadata}static lc_name(){return"AIMessage"}_getType(){return"ai"}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}}class le extends se{constructor(e){let t;if("string"==typeof e)t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(void 0===e.tool_call_chunks||0===e.tool_call_chunks.length)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:void 0!==e.usage_metadata?e.usage_metadata:void 0};else{const r=(e.tool_call_chunks??[]).reduce((e,t)=>{const r=e.findIndex(([e])=>"id"in t&&t.id&&"index"in t&&void 0!==t.index?t.id===e.id&&t.index===e.index:"id"in t&&t.id?t.id===e.id:"index"in t&&void 0!==t.index&&t.index===e.index);return-1!==r?e[r].push(t):e.push([t]),e},[]),n=[],i=[];for(const e of r){let t={};const r=e[0]?.name??"",o=e.map(e=>e.args||"").join(""),a=o.length?o:"{}",s=e[0]?.id;try{if(t=H(a),!s||null===t||"object"!=typeof t||Array.isArray(t))throw new Error("Malformed tool call chunk args.");n.push({name:r,args:t,id:s,type:"tool_call"})}catch(e){i.push({name:r,args:a,id:s,error:"Malformed args.",type:"invalid_tool_call"})}}t={...e,tool_calls:n,invalid_tool_calls:i,usage_metadata:void 0!==e.usage_metadata?e.usage_metadata:void 0}}super(t),Object.defineProperty(this,"tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"invalid_tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tool_call_chunks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"usage_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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"}}static lc_name(){return"AIMessageChunk"}_getType(){return"ai"}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){const t={content:(r=this.content,n=e.content,"string"==typeof r?""===r?n:"string"==typeof n?r+n:Array.isArray(n)&&n.some(e=>ne(e))?[{type:"text",source_type:"text",text:r},...n]:[{type:"text",text:r},...n]:Array.isArray(n)?ae(r,n)??[...r,...n]:""===n?r:Array.isArray(r)&&r.some(e=>ne(e))?[...r,{type:"file",source_type:"text",text:n}]:[...r,{type:"text",text:n}]),additional_kwargs:oe(this.additional_kwargs,e.additional_kwargs),response_metadata:oe(this.response_metadata,e.response_metadata),tool_call_chunks:[],id:this.id??e.id};var r,n;if(void 0!==this.tool_call_chunks||void 0!==e.tool_call_chunks){const r=ae(this.tool_call_chunks,e.tool_call_chunks);void 0!==r&&r.length>0&&(t.tool_call_chunks=r)}if(void 0!==this.usage_metadata||void 0!==e.usage_metadata){const r={...(void 0!==this.usage_metadata?.input_token_details?.audio||void 0!==e.usage_metadata?.input_token_details?.audio)&&{audio:(this.usage_metadata?.input_token_details?.audio??0)+(e.usage_metadata?.input_token_details?.audio??0)},...(void 0!==this.usage_metadata?.input_token_details?.cache_read||void 0!==e.usage_metadata?.input_token_details?.cache_read)&&{cache_read:(this.usage_metadata?.input_token_details?.cache_read??0)+(e.usage_metadata?.input_token_details?.cache_read??0)},...(void 0!==this.usage_metadata?.input_token_details?.cache_creation||void 0!==e.usage_metadata?.input_token_details?.cache_creation)&&{cache_creation:(this.usage_metadata?.input_token_details?.cache_creation??0)+(e.usage_metadata?.input_token_details?.cache_creation??0)}},n={...(void 0!==this.usage_metadata?.output_token_details?.audio||void 0!==e.usage_metadata?.output_token_details?.audio)&&{audio:(this.usage_metadata?.output_token_details?.audio??0)+(e.usage_metadata?.output_token_details?.audio??0)},...(void 0!==this.usage_metadata?.output_token_details?.reasoning||void 0!==e.usage_metadata?.output_token_details?.reasoning)&&{reasoning:(this.usage_metadata?.output_token_details?.reasoning??0)+(e.usage_metadata?.output_token_details?.reasoning??0)}},i=this.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},o=e.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},a={input_tokens:i.input_tokens+o.input_tokens,output_tokens:i.output_tokens+o.output_tokens,total_tokens:i.total_tokens+o.total_tokens,...Object.keys(r).length>0&&{input_token_details:r},...Object.keys(n).length>0&&{output_token_details:n}};t.usage_metadata=a}return new le(t)}}class de extends ie{static lc_name(){return"HumanMessage"}_getType(){return"human"}constructor(e,t){super(e,t)}}class fe extends ie{static lc_name(){return"SystemMessage"}_getType(){return"system"}constructor(e,t){super(e,t)}}function pe(e){return!(!e||"object"!=typeof e||!("type"in e)||"tool_call"!==e.type)}class he extends Error{constructor(e,t){super(e),Object.defineProperty(this,"output",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.output=t}}var me,ye;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},e.getValidEnumValues=t=>{const r=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),n={};for(const e of r)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(const r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(me||(me={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(ye||(ye={}));const ge=me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),be=e=>{switch(typeof e){case"undefined":return ge.undefined;case"string":return ge.string;case"number":return Number.isNaN(e)?ge.nan:ge.number;case"boolean":return ge.boolean;case"function":return ge.function;case"bigint":return ge.bigint;case"symbol":return ge.symbol;case"object":return Array.isArray(e)?ge.array:null===e?ge.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?ge.promise:"undefined"!=typeof Map&&e instanceof Map?ge.map:"undefined"!=typeof Set&&e instanceof Set?ge.set:"undefined"!=typeof Date&&e instanceof Date?ge.date:ge.object;default:return ge.unknown}},ve=me.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"]);class we extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(const i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;n<i.path.length;){const r=i.path[n];n===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof we))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,me.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},r=[];for(const n of this.issues)if(n.path.length>0){const r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}we.create=e=>new we(e);const _e=(e,t)=>{let r;switch(e.code){case ve.invalid_type:r=e.received===ge.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case ve.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,me.jsonStringifyReplacer)}`;break;case ve.unrecognized_keys:r=`Unrecognized key(s) in object: ${me.joinValues(e.keys,", ")}`;break;case ve.invalid_union:r="Invalid input";break;case ve.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${me.joinValues(e.options)}`;break;case ve.invalid_enum_value:r=`Invalid enum value. Expected ${me.joinValues(e.options)}, received '${e.received}'`;break;case ve.invalid_arguments:r="Invalid function arguments";break;case ve.invalid_return_type:r="Invalid function return type";break;case ve.invalid_date:r="Invalid date";break;case ve.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(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}"`:me.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case ve.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case ve.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case ve.custom:r="Invalid input";break;case ve.invalid_intersection_types:r="Intersection results could not be merged";break;case ve.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case ve.not_finite:r="Number must be finite";break;default:r=t.defaultError,me.assertNever(e)}return{message:r}};let Ee=_e;function Se(e,t){const r=Ee,n=(e=>{const{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],a={...i,path:o};if(void 0!==i.message)return{...i,path:o,message:i.message};let s="";const c=n.filter(e=>!!e).slice().reverse();for(const e of c)s=e(a,{data:t,defaultError:s}).message;return{...i,path:o,message:s}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===_e?void 0:_e].filter(e=>!!e)});e.common.issues.push(n)}class Oe{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if("aborted"===n.status)return Ae;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,n=await e.value;r.push({key:t,value:n})}return Oe.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:t,value:i}=n;if("aborted"===t.status)return Ae;if("aborted"===i.status)return Ae;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!n.alwaysSet||(r[t.value]=i.value)}return{status:e.value,value:r}}}const Ae=Object.freeze({status:"aborted"}),Te=e=>({status:"dirty",value:e}),xe=e=>({status:"valid",value:e}),Ie=e=>"aborted"===e.status,ke=e=>"dirty"===e.status,je=e=>"valid"===e.status,Re=e=>"undefined"!=typeof Promise&&e instanceof Promise;var Ne;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(Ne||(Ne={}));class Pe{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,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}}const Ce=(e,t)=>{if(je(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;const t=new we(e.common.issues);return this._error=t,this._error}}};function Le(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:i};return{errorMap:(t,i)=>{const{message:o}=e;return"invalid_enum_value"===t.code?{message:o??i.defaultError}:void 0===i.data?{message:o??n??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:o??r??i.defaultError}},description:i}}class Me{get description(){return this._def.description}_getType(e){return be(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:be(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Oe,ctx:{common:e.parent.common,data:e.data,parsedType:be(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Re(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:be(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Ce(r,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:be(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return je(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>je(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:be(e)},n=this._parse({data:e,path:r.path,parent:r}),i=await(Re(n)?n:Promise.resolve(n));return Ce(r,i)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{const i=e(t),o=()=>n.addIssue({code:ve.custom,...r(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(o(),!1)):!!i||(o(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new Ct({schema:this,typeName:Gt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Lt.create(this,this._def)}nullable(){return Mt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vt.create(this)}promise(){return Pt.create(this,this._def)}or(e){return Et.create([this,e],this._def)}and(e){return Ot.create(this,e,this._def)}transform(e){return new Ct({...Le(this._def),schema:this,typeName:Gt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new $t({...Le(this._def),innerType:this,defaultValue:t,typeName:Gt.ZodDefault})}brand(){return new Ft({typeName:Gt.ZodBranded,type:this,...Le(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Dt({...Le(this._def),innerType:this,catchValue:t,typeName:Gt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ut.create(this,e)}readonly(){return zt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $e=/^c[^\s-]{8,}$/i,De=/^[0-9a-z]+$/,Be=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fe=/^[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,Ue=/^[a-z0-9_-]{21}$/i,ze=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ge=/^[-+]?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)?)??$/,qe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ve;const We=/^(?:(?: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])$/,He=/^(?:(?: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])$/,Ke=/^(([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]))$/,Ze=/^(([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])$/,Je=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ye=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qe="((\\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])))",Xe=new RegExp(`^${Qe}$`);function et(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function tt(e){return new RegExp(`^${et(e)}$`)}function rt(e){let t=`${Qe}T${et(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function nt(e,t){return!("v4"!==t&&t||!We.test(e))||!("v6"!==t&&t||!Ke.test(e))}function it(e,t){if(!ze.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return"object"==typeof i&&null!==i&&((!("typ"in i)||"JWT"===i?.typ)&&(!!i.alg&&(!t||i.alg===t)))}catch{return!1}}function ot(e,t){return!("v4"!==t&&t||!He.test(e))||!("v6"!==t&&t||!Ze.test(e))}class at extends Me{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==ge.string){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.string,received:t.parsedType}),Ae}const t=new Oe;let r;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const i=e.data.length>n.value,o=e.data.length<n.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?Se(r,{code:ve.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&Se(r,{code:ve.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)qe.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"email",code:ve.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)Ve||(Ve=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ve.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"emoji",code:ve.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)Fe.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"uuid",code:ve.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)Ue.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"nanoid",code:ve.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)$e.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"cuid",code:ve.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)De.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"cuid2",code:ve.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)Be.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"ulid",code:ve.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),Se(r,{validation:"url",code:ve.invalid_string,message:n.message}),t.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"regex",code:ve.invalid_string,message:n.message}),t.dirty())}else if("trim"===n.kind)e.data=e.data.trim();else if("includes"===n.kind)e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty());else if("toLowerCase"===n.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===n.kind)e.data=e.data.toUpperCase();else if("startsWith"===n.kind)e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty());else if("endsWith"===n.kind)e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty());else if("datetime"===n.kind){rt(n).test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:"datetime",message:n.message}),t.dirty())}else if("date"===n.kind){Xe.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:"date",message:n.message}),t.dirty())}else if("time"===n.kind){tt(n).test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.invalid_string,validation:"time",message:n.message}),t.dirty())}else"duration"===n.kind?Ge.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"duration",code:ve.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?nt(e.data,n.version)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"ip",code:ve.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?it(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"jwt",code:ve.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?ot(e.data,n.version)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"cidr",code:ve.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?Je.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"base64",code:ve.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?Ye.test(e.data)||(r=this._getOrReturnCtx(e,r),Se(r,{validation:"base64url",code:ve.invalid_string,message:n.message}),t.dirty()):me.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:ve.invalid_string,...Ne.errToObj(r)})}_addCheck(e){return new at({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ne.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ne.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ne.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ne.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ne.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ne.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ne.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ne.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ne.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ne.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ne.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ne.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ne.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Ne.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...Ne.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ne.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ne.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Ne.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ne.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ne.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ne.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ne.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ne.errToObj(t)})}nonempty(e){return this.min(1,Ne.errToObj(e))}trim(){return new at({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function st(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}at.create=e=>new at({checks:[],typeName:Gt.ZodString,coerce:e?.coerce??!1,...Le(e)});class ct extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==ge.number){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.number,received:t.parsedType}),Ae}let t;const r=new Oe;for(const n of this._def.checks)if("int"===n.kind)me.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty())}else"multipleOf"===n.kind?0!==st(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.not_finite,message:n.message}),r.dirty()):me.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ne.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ne.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ne.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ne.toString(t))}setLimit(e,t,r,n){return new ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ne.toString(n)}]})}_addCheck(e){return new ct({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ne.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ne.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ne.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&me.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ct.create=e=>new ct({checks:[],typeName:Gt.ZodNumber,coerce:e?.coerce||!1,...Le(e)});class ut extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ge.bigint)return this._getInvalidInput(e);let t;const r=new Oe;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Se(t,{code:ve.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):me.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.bigint,received:t.parsedType}),Ae}gte(e,t){return this.setLimit("min",e,!0,Ne.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ne.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ne.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ne.toString(t))}setLimit(e,t,r,n){return new ut({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Ne.toString(n)}]})}_addCheck(e){return new ut({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ne.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ut.create=e=>new ut({checks:[],typeName:Gt.ZodBigInt,coerce:e?.coerce??!1,...Le(e)});class lt extends Me{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==ge.boolean){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.boolean,received:t.parsedType}),Ae}return xe(e.data)}}lt.create=e=>new lt({typeName:Gt.ZodBoolean,coerce:e?.coerce||!1,...Le(e)});class dt extends Me{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==ge.date){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.date,received:t.parsedType}),Ae}if(Number.isNaN(e.data.getTime())){return Se(this._getOrReturnCtx(e),{code:ve.invalid_date}),Ae}const t=new Oe;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),Se(r,{code:ve.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):me.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new dt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ne.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ne.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}dt.create=e=>new dt({checks:[],coerce:e?.coerce||!1,typeName:Gt.ZodDate,...Le(e)});class ft extends Me{_parse(e){if(this._getType(e)!==ge.symbol){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.symbol,received:t.parsedType}),Ae}return xe(e.data)}}ft.create=e=>new ft({typeName:Gt.ZodSymbol,...Le(e)});class pt extends Me{_parse(e){if(this._getType(e)!==ge.undefined){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.undefined,received:t.parsedType}),Ae}return xe(e.data)}}pt.create=e=>new pt({typeName:Gt.ZodUndefined,...Le(e)});class ht extends Me{_parse(e){if(this._getType(e)!==ge.null){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.null,received:t.parsedType}),Ae}return xe(e.data)}}ht.create=e=>new ht({typeName:Gt.ZodNull,...Le(e)});class mt extends Me{constructor(){super(...arguments),this._any=!0}_parse(e){return xe(e.data)}}mt.create=e=>new mt({typeName:Gt.ZodAny,...Le(e)});class yt extends Me{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xe(e.data)}}yt.create=e=>new yt({typeName:Gt.ZodUnknown,...Le(e)});class gt extends Me{_parse(e){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.never,received:t.parsedType}),Ae}}gt.create=e=>new gt({typeName:Gt.ZodNever,...Le(e)});class bt extends Me{_parse(e){if(this._getType(e)!==ge.undefined){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.void,received:t.parsedType}),Ae}return xe(e.data)}}bt.create=e=>new bt({typeName:Gt.ZodVoid,...Le(e)});class vt extends Me{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==ge.array)return Se(t,{code:ve.invalid_type,expected:ge.array,received:t.parsedType}),Ae;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(e||i)&&(Se(t,{code:e?ve.too_big:ve.too_small,minimum:i?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(Se(t,{code:ve.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(Se(t,{code:ve.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new Pe(t,e,t.path,r)))).then(e=>Oe.mergeArray(r,e));const i=[...t.data].map((e,r)=>n.type._parseSync(new Pe(t,e,t.path,r)));return Oe.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new vt({...this._def,minLength:{value:e,message:Ne.toString(t)}})}max(e,t){return new vt({...this._def,maxLength:{value:e,message:Ne.toString(t)}})}length(e,t){return new vt({...this._def,exactLength:{value:e,message:Ne.toString(t)}})}nonempty(e){return this.min(1,e)}}function wt(e){if(e instanceof _t){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Lt.create(wt(n))}return new _t({...e._def,shape:()=>t})}return e instanceof vt?new vt({...e._def,type:wt(e.element)}):e instanceof Lt?Lt.create(wt(e.unwrap())):e instanceof Mt?Mt.create(wt(e.unwrap())):e instanceof At?At.create(e.items.map(e=>wt(e))):e}vt.create=(e,t)=>new vt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gt.ZodArray,...Le(t)});class _t extends Me{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=me.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ge.object){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.object,received:t.parsedType}),Ae}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof gt&&"strip"===this._def.unknownKeys))for(const e in r.data)i.includes(e)||o.push(e);const a=[];for(const e of i){const t=n[e],i=r.data[e];a.push({key:{status:"valid",value:e},value:t._parse(new Pe(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof gt){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)a.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)o.length>0&&(Se(r,{code:ve.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const n=r.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new Pe(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of a){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>Oe.mergeObjectSync(t,e)):Oe.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return Ne.errToObj,new _t({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{const n=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:Ne.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new _t({...this._def,unknownKeys:"strip"})}passthrough(){return new _t({...this._def,unknownKeys:"passthrough"})}extend(e){return new _t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new _t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Gt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new _t({...this._def,catchall:e})}pick(e){const t={};for(const r of me.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new _t({...this._def,shape:()=>t})}omit(e){const t={};for(const r of me.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new _t({...this._def,shape:()=>t})}deepPartial(){return wt(this)}partial(e){const t={};for(const r of me.objectKeys(this.shape)){const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new _t({...this._def,shape:()=>t})}required(e){const t={};for(const r of me.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof Lt;)e=e._def.innerType;t[r]=e}return new _t({...this._def,shape:()=>t})}keyof(){return jt(me.objectKeys(this.shape))}}_t.create=(e,t)=>new _t({shape:()=>e,unknownKeys:"strip",catchall:gt.create(),typeName:Gt.ZodObject,...Le(t)}),_t.strictCreate=(e,t)=>new _t({shape:()=>e,unknownKeys:"strict",catchall:gt.create(),typeName:Gt.ZodObject,...Le(t)}),_t.lazycreate=(e,t)=>new _t({shape:e,unknownKeys:"strip",catchall:gt.create(),typeName:Gt.ZodObject,...Le(t)});class Et extends Me{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map(e=>new we(e.ctx.common.issues));return Se(t,{code:ve.invalid_union,unionErrors:r}),Ae});{let e;const n=[];for(const i of r){const r={...t,common:{...t.common,issues:[]},parent:null},o=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===o.status)return o;"dirty"!==o.status||e||(e={result:o,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=n.map(e=>new we(e));return Se(t,{code:ve.invalid_union,unionErrors:i}),Ae}}get options(){return this._def.options}}function St(e,t){const r=be(e),n=be(t);if(e===t)return{valid:!0,data:e};if(r===ge.object&&n===ge.object){const r=me.objectKeys(t),n=me.objectKeys(e).filter(e=>-1!==r.indexOf(e)),i={...e,...t};for(const r of n){const n=St(e[r],t[r]);if(!n.valid)return{valid:!1};i[r]=n.data}return{valid:!0,data:i}}if(r===ge.array&&n===ge.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const i=St(e[n],t[n]);if(!i.valid)return{valid:!1};r.push(i.data)}return{valid:!0,data:r}}return r===ge.date&&n===ge.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}Et.create=(e,t)=>new Et({options:e,typeName:Gt.ZodUnion,...Le(t)});class Ot extends Me{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(Ie(e)||Ie(n))return Ae;const i=St(e.value,n.value);return i.valid?((ke(e)||ke(n))&&t.dirty(),{status:t.value,value:i.data}):(Se(r,{code:ve.invalid_intersection_types}),Ae)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ot.create=(e,t,r)=>new Ot({left:e,right:t,typeName:Gt.ZodIntersection,...Le(r)});class At extends Me{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.array)return Se(r,{code:ve.invalid_type,expected:ge.array,received:r.parsedType}),Ae;if(r.data.length<this._def.items.length)return Se(r,{code:ve.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ae;!this._def.rest&&r.data.length>this._def.items.length&&(Se(r,{code:ve.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new Pe(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>Oe.mergeArray(t,e)):Oe.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new At({...this._def,rest:e})}}At.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new At({items:e,typeName:Gt.ZodTuple,rest:null,...Le(t)})};class Tt extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.map)return Se(r,{code:ve.invalid_type,expected:ge.map,received:r.parsedType}),Ae;const n=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([e,t],o)=>({key:n._parse(new Pe(r,e,r.path,[o,"key"])),value:i._parse(new Pe(r,t,r.path,[o,"value"]))}));if(r.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const r of o){const n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return Ae;"dirty"!==n.status&&"dirty"!==i.status||t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{const e=new Map;for(const r of o){const n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return Ae;"dirty"!==n.status&&"dirty"!==i.status||t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}Tt.create=(e,t,r)=>new Tt({valueType:t,keyType:e,typeName:Gt.ZodMap,...Le(r)});class xt extends Me{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.set)return Se(r,{code:ve.invalid_type,expected:ge.set,received:r.parsedType}),Ae;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(Se(r,{code:ve.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(Se(r,{code:ve.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const i=this._def.valueType;function o(e){const r=new Set;for(const n of e){if("aborted"===n.status)return Ae;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const a=[...r.data.values()].map((e,t)=>i._parse(new Pe(r,e,r.path,t)));return r.common.async?Promise.all(a).then(e=>o(e)):o(a)}min(e,t){return new xt({...this._def,minSize:{value:e,message:Ne.toString(t)}})}max(e,t){return new xt({...this._def,maxSize:{value:e,message:Ne.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}xt.create=(e,t)=>new xt({valueType:e,minSize:null,maxSize:null,typeName:Gt.ZodSet,...Le(t)});class It extends Me{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}It.create=(e,t)=>new It({getter:e,typeName:Gt.ZodLazy,...Le(t)});class kt extends Me{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Se(t,{received:t.data,code:ve.invalid_literal,expected:this._def.value}),Ae}return{status:"valid",value:e.data}}get value(){return this._def.value}}function jt(e,t){return new Rt({values:e,typeName:Gt.ZodEnum,...Le(t)})}kt.create=(e,t)=>new kt({value:e,typeName:Gt.ZodLiteral,...Le(t)});class Rt extends Me{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return Se(t,{expected:me.joinValues(r),received:t.parsedType,code:ve.invalid_type}),Ae}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return Se(t,{received:t.data,code:ve.invalid_enum_value,options:r}),Ae}return xe(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Rt.create(e,{...this._def,...t})}exclude(e,t=this._def){return Rt.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}Rt.create=jt;class Nt extends Me{_parse(e){const t=me.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ge.string&&r.parsedType!==ge.number){const e=me.objectValues(t);return Se(r,{expected:me.joinValues(e),received:r.parsedType,code:ve.invalid_type}),Ae}if(this._cache||(this._cache=new Set(me.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=me.objectValues(t);return Se(r,{received:r.data,code:ve.invalid_enum_value,options:e}),Ae}return xe(e.data)}get enum(){return this._def.values}}Nt.create=(e,t)=>new Nt({values:e,typeName:Gt.ZodNativeEnum,...Le(t)});class Pt extends Me{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ge.promise&&!1===t.common.async)return Se(t,{code:ve.invalid_type,expected:ge.promise,received:t.parsedType}),Ae;const r=t.parsedType===ge.promise?t.data:Promise.resolve(t.data);return xe(r.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Pt.create=(e,t)=>new Pt({type:e,typeName:Gt.ZodPromise,...Le(t)});class Ct extends Me{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{Se(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){const e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return Ae;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?Ae:"dirty"===n.status||"dirty"===t.value?Te(n.value):n});{if("aborted"===t.value)return Ae;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?Ae:"dirty"===n.status||"dirty"===t.value?Te(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?Ae:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?Ae:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))))}if("transform"===n.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!je(e))return Ae;const o=n.transform(e.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>je(e)?Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})):Ae)}me.assertNever(n)}}Ct.create=(e,t,r)=>new Ct({schema:e,typeName:Gt.ZodEffects,effect:t,...Le(r)}),Ct.createWithPreprocess=(e,t,r)=>new Ct({schema:t,effect:{type:"preprocess",transform:e},typeName:Gt.ZodEffects,...Le(r)});class Lt extends Me{_parse(e){return this._getType(e)===ge.undefined?xe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Lt.create=(e,t)=>new Lt({innerType:e,typeName:Gt.ZodOptional,...Le(t)});class Mt extends Me{_parse(e){return this._getType(e)===ge.null?xe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Mt.create=(e,t)=>new Mt({innerType:e,typeName:Gt.ZodNullable,...Le(t)});class $t extends Me{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===ge.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}$t.create=(e,t)=>new $t({innerType:e,typeName:Gt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...Le(t)});class Dt extends Me{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Re(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Dt.create=(e,t)=>new Dt({innerType:e,typeName:Gt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...Le(t)});class Bt extends Me{_parse(e){if(this._getType(e)!==ge.nan){const t=this._getOrReturnCtx(e);return Se(t,{code:ve.invalid_type,expected:ge.nan,received:t.parsedType}),Ae}return{status:"valid",value:e.data}}}Bt.create=e=>new Bt({typeName:Gt.ZodNaN,...Le(e)});class Ft extends Me{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ut extends Me{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Ae:"dirty"===e.status?(t.dirty(),Te(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})()}{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Ae:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new Ut({in:e,out:t,typeName:Gt.ZodPipeline})}}class zt extends Me{_parse(e){const t=this._def.innerType._parse(e),r=e=>(je(e)&&(e.value=Object.freeze(e.value)),e);return Re(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}var Gt;zt.create=(e,t)=>new zt({innerType:e,typeName:Gt.ZodReadonly,...Le(t)}),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"}(Gt||(Gt={}));const qt=at.create,Vt=mt.create;gt.create,vt.create;const Wt=_t.create;Et.create,Ot.create,At.create,Rt.create,Pt.create,Lt.create,Mt.create;var Ht,Kt,Zt,Jt,Yt,Qt,Xt={exports:{}},er={};function tr(){return Zt||(Zt=1,e=er,t=function(){if(Kt)return Ht;function e(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return Kt=1,Ht=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(void 0===r){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1)}var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=r&&(t=i,r=a)}return t},Ht}(),e.operation=function(r){var n=e.timeouts(r);return new t(n,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(e,t){return e-t}),n},e.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout)},e.wrap=function(t,r,n){if(r instanceof Array&&(n=r,r=null),!n)for(var i in n=[],t)"function"==typeof t[i]&&n.push(i);for(var o=0;o<n.length;o++){var a=n[o],s=t[a];t[a]=function(n){var i=e.operation(r),o=Array.prototype.slice.call(arguments,1),a=o.pop();o.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),a.apply(this,arguments))}),i.attempt(function(){n.apply(t,o)})}.bind(t,s),t[a].options=r}}),er;var e,t}function rr(){return Yt?Jt:(Yt=1,Jt=tr())}var nr=function(){if(Qt)return Xt.exports;Qt=1;const e=rr(),t=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class r 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}}const n=(n,i)=>new Promise((o,a)=>{i={onFailedAttempt:()=>{},retries:10,...i};const s=e.operation(i);s.attempt(async e=>{try{o(await n(e))}catch(n){if(!(n instanceof Error))return void a(new TypeError(`Non-error was thrown: "${n}". You should only throw errors.`));if(n instanceof r)s.stop(),a(n.originalError);else if(n instanceof TypeError&&(c=n.message,!t.includes(c)))s.stop(),a(n);else{((e,t,r)=>{const n=r.retries-(t-1);e.attemptNumber=t,e.retriesLeft=n})(n,e,i);try{await i.onFailedAttempt(n)}catch(e){return void a(e)}s.retry(n)||a(s.mainError())}}var c})});return Xt.exports=n,Xt.exports.default=n,Xt.exports.AbortError=r,Xt.exports}(),ir=w(nr),or=/^(?:[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 ar(e){return"string"==typeof e&&or.test(e)}for(var sr,cr=[],ur=0;ur<256;++ur)cr.push((ur+256).toString(16).slice(1));function lr(e,t=0){return(cr[e[t+0]]+cr[e[t+1]]+cr[e[t+2]]+cr[e[t+3]]+"-"+cr[e[t+4]]+cr[e[t+5]]+"-"+cr[e[t+6]]+cr[e[t+7]]+"-"+cr[e[t+8]]+cr[e[t+9]]+"-"+cr[e[t+10]]+cr[e[t+11]]+cr[e[t+12]]+cr[e[t+13]]+cr[e[t+14]]+cr[e[t+15]]).toLowerCase()}var dr=new Uint8Array(16);function fr(){if(!sr&&!(sr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return sr(dr)}var pr={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function hr(e,t,r){if(pr.randomUUID&&!e)return pr.randomUUID();var n=(e=e||{}).random||(e.rng||fr)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,lr(n)}function mr(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function yr(e,t){return e<<t|e>>>32-t}var gr=function(e,t,r){function n(e,n,i,o){var a;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof n&&(n=function(e){if(!ar(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]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,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]=255&t,r}(n)),16!==(null===(a=n)||void 0===a?void 0:a.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+e.length);if(s.set(n),s.set(e,n.length),(s=r(s))[6]=15&s[6]|t,s[8]=63&s[8]|128,i){o=o||0;for(var c=0;c<16;++c)i[o+c]=s[c];return i}return lr(s)}try{n.name=e}catch(e){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}("v5",80,function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i<n.length;++i)e.push(n.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,a=Math.ceil(o/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var h=16;h<80;++h)f[h]=yr(f[h-3]^f[h-8]^f[h-14]^f[h-16],1);for(var m=r[0],y=r[1],g=r[2],b=r[3],v=r[4],w=0;w<80;++w){var _=Math.floor(w/20),E=yr(m,5)+mr(_,y,g,b)+v+t[_]+f[w]>>>0;v=b,b=g,g=yr(y,30)>>>0,y=m,m=E}r[0]=r[0]+m>>>0,r[1]=r[1]+y>>>0,r[2]=r[2]+g>>>0,r[3]=r[3]+b>>>0,r[4]=r[4]+v>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}),br=null,vr=null,wr=0;const _r=Symbol.for("ls:tracing_async_local_storage"),Er=new class{getStore(){}run(e,t){return t()}};const Sr=new class{getInstance(){return globalThis[_r]??Er}initializeGlobalInstance(e){void 0===globalThis[_r]&&(globalThis[_r]=e)}};function Or(e){return"function"==typeof e&&"langsmith:traceable"in e}
16
+ /*!
17
+ * https://github.com/Starcounter-Jack/JSON-Patch
18
+ * (c) 2017-2022 Joachim Wester
19
+ * MIT licensed
20
+ */const Ar=Object.prototype.hasOwnProperty;function Tr(e,t){return Ar.call(e,t)}function xr(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Ir(e){let t=0;const r=e.length;let n;for(;t<r;){if(n=e.charCodeAt(t),!(n>=48&&n<=57))return!1;t++}return!0}function kr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function jr(e){if(void 0===e)return!0;if(e)if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(jr(e[t]))return!0}else if("object"==typeof e){const r=function(e){if(Array.isArray(e)){const t=new Array(e.length);for(let e=0;e<t.length;e++)t[e]=""+e;return t}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)Tr(e,r)&&t.push(r);return t}(e),n=r.length;for(var t=0;t<n;t++)if(jr(e[r[t]]))return!0}return!1}function Rr(e,t){const r=[e];for(const e in t){const n="object"==typeof t[e]?JSON.stringify(t[e],null,2):t[e];void 0!==n&&r.push(`${e}: ${n}`)}return r.join("\n")}class Nr extends Error{constructor(e,t,r,n,i){super(Rr(e,{name:t,index:r,operation:n,tree:i})),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"operation",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"tree",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.setPrototypeOf(this,new.target.prototype),this.message=Rr(e,{name:t,index:r,operation:n,tree:i})}}const Pr=Nr,Cr={add:function(e,t,r){return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){var n=e[t];return delete e[t],{newDocument:r,removed:n}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){let n=Mr(r,this.path);n&&(n=xr(n));const i=$r(r,{op:"remove",path:this.from}).removed;return $r(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){const n=Mr(r,this.from);return $r(r,{op:"add",path:this.path,value:xr(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Fr(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}};var Lr={add:function(e,t,r){return Ir(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:Cr.move,copy:Cr.copy,test:Cr.test,_get:Cr._get};function Mr(e,t){if(""==t)return e;var r={op:"_get",path:t};return $r(e,r),r.value}function $r(e,t,r=!1,n=!0,i=!0,o=0){if(r&&("function"==typeof r?r(t,0,e,t.path):Br(t,0)),""===t.path){let n={newDocument:e};if("add"===t.op)return n.newDocument=t.value,n;if("replace"===t.op)return n.newDocument=t.value,n.removed=e,n;if("move"===t.op||"copy"===t.op)return n.newDocument=Mr(e,t.from),"move"===t.op&&(n.removed=e),n;if("test"===t.op){if(n.test=Fr(e,t.value),!1===n.test)throw new Pr("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return n.newDocument=e,n}if("remove"===t.op)return n.removed=e,n.newDocument=null,n;if("_get"===t.op)return t.value=e,n;if(r)throw new Pr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,t,e);return n}{n||(e=xr(e));const a=(t.path||"").split("/");let s,c,u,l=e,d=1,f=a.length;for(u="function"==typeof r?r:Br;;){if(c=a[d],c&&-1!=c.indexOf("~")&&(c=kr(c)),i&&("__proto__"==c||"prototype"==c&&d>0&&"constructor"==a[d-1]))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&&void 0===s&&(void 0===l[c]?s=a.slice(0,d).join("/"):d==f-1&&(s=t.path),void 0!==s&&u(t,0,e,s)),d++,Array.isArray(l)){if("-"===c)c=l.length;else{if(r&&!Ir(c))throw new Pr("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,t,e);Ir(c)&&(c=~~c)}if(d>=f){if(r&&"add"===t.op&&c>l.length)throw new Pr("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);const n=Lr[t.op].call(t,l,c,e);if(!1===n.test)throw new Pr("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return n}}else if(d>=f){const r=Cr[t.op].call(t,l,c,e);if(!1===r.test)throw new Pr("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return r}if(l=l[c],r&&d<f&&(!l||"object"!=typeof l))throw new Pr("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,t,e)}}}function Dr(e,t,r,n=!0,i=!0){if(r&&!Array.isArray(t))throw new Pr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=xr(e));const o=new Array(t.length);for(let n=0,a=t.length;n<a;n++)o[n]=$r(e,t[n],r,!0,i,n),e=o[n].newDocument;return o.newDocument=e,o}function Br(e,t,r,n){if("object"!=typeof e||null===e||Array.isArray(e))throw new Pr("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(!Cr[e.op])throw new Pr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r);if("string"!=typeof e.path)throw new Pr("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(0!==e.path.indexOf("/")&&e.path.length>0)throw new Pr('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if(("move"===e.op||"copy"===e.op)&&"string"!=typeof e.from)throw new Pr("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&void 0===e.value)throw new Pr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&jr(e.value))throw new Pr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r)if("add"==e.op){var i=e.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new Pr("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if("replace"===e.op||"remove"===e.op||"_get"===e.op){if(e.path!==n)throw new Pr("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if("move"===e.op||"copy"===e.op){var a=function(e,t,r){try{if(!Array.isArray(e))throw new Pr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Dr(xr(t),xr(e),r||!0);else{r=r||Br;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(e){if(e instanceof Pr)return e;throw e}}([{op:"_get",path:e.from,value:void 0}],r);if(a&&"OPERATION_PATH_UNRESOLVABLE"===a.name)throw new Pr("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}function Fr(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){var r,n,i,o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if((n=e.length)!=t.length)return!1;for(r=n;0!==r--;)if(!Fr(e[r],t[r]))return!1;return!0}if(o!=a)return!1;var s=Object.keys(e);if((n=s.length)!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!t.hasOwnProperty(s[r]))return!1;for(r=n;0!==r--;)if(!Fr(e[i=s[r]],t[i]))return!1;return!0}return e!=e&&t!=t}const Ur="gen_ai.request.model",zr="gen_ai.usage.input_tokens",Gr="gen_ai.usage.output_tokens",qr="gen_ai.usage.total_tokens",Vr="langsmith.span.tags",Wr=(...e)=>fetch(...e),Hr=Symbol.for("ls:fetch_implementation"),Kr=e=>async(...t)=>{if(e||"true"===dn("DEBUG")){const[e,r]=t;console.log(`→ ${r?.method||"GET"} ${e}`)}const r=await(globalThis[Hr]??Wr)(...t);return(e||"true"===dn("DEBUG"))&&console.log(`← ${r.status} ${r.statusText} ${r.url}`),r},Zr=()=>dn("PROJECT")??ln("LANGCHAIN_SESSION")??"default",Jr={};function Yr(e){Jr[e]||(console.warn(e),Jr[e]=!0)}const Qr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Xr(e,t){if(!Qr.test(e)){throw new Error(void 0!==t?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`)}return e}function en(e){return function(e,t){e=e||{};var r=0,n=new Uint8Array(16),i=e.random||(e.rng||fr)(),o=void 0!==e.msecs?e.msecs:Date.now(),a=void 0!==e.seq?e.seq:null,s=vr,c=br;return o>wr&&void 0===e.msecs&&(wr=o,null!==a&&(s=null,c=null)),null!==a&&(a>2147483647&&(a=2147483647),s=a>>>19&4095,c=524287&a),null!==s&&null!==c||(s=(s=127&i[6])<<8|i[7],c=(c=(c=63&i[8])<<8|i[9])<<5|i[10]>>>3),o+1e4>wr&&null===a?++c>524287&&(c=0,++s>4095&&(s=0,wr++)):wr=o,vr=s,br=c,n[r++]=wr/1099511627776&255,n[r++]=wr/4294967296&255,n[r++]=wr/16777216&255,n[r++]=wr/65536&255,n[r++]=wr/256&255,n[r++]=255&wr,n[r++]=s>>>4&15|112,n[r++]=255&s,n[r++]=c>>>13&63|128,n[r++]=c>>>5&255,n[r++]=c<<3&255|7&i[10],n[r++]=i[11],n[r++]=i[12],n[r++]=i[13],n[r++]=i[14],n[r++]=i[15],t||lr(n)}({msecs:"string"==typeof e?Date.parse(e):e,seq:0})}const tn="0.3.87";let rn;const nn=()=>"undefined"!=typeof Deno,on=()=>rn||(rn="undefined"!=typeof Bun?"bun":"undefined"!=typeof window&&void 0!==window.document?"browser":"undefined"==typeof process||void 0===process.versions||void 0===process.versions.node||nn()?"object"==typeof globalThis&&globalThis.constructor&&"DedicatedWorkerGlobalScope"===globalThis.constructor.name?"webworker":"undefined"!=typeof window&&"nodejs"===window.name||"undefined"!=typeof navigator&&navigator.userAgent.includes("jsdom")?"jsdom":nn()?"deno":"other":"node",rn);let an,sn;function cn(){if(void 0===an){const e=on(),t=function(){if(void 0!==sn)return sn;const 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(const r of e){const e=ln(r);void 0!==e&&(t[r]=e)}return sn=t,t}();an={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:tn,...t}}return an}function un(){const e=function(){const e={};try{if("undefined"!=typeof process&&process.env)for(const[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&null!=r&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&"string"==typeof r?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch(e){}return e}(),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(const[n,i]of Object.entries(e))"string"!=typeof i||r.includes(n)||n.toLowerCase().includes("key")||n.toLowerCase().includes("secret")||n.toLowerCase().includes("token")||("LANGCHAIN_REVISION_ID"===n?t.revision_id=i:t[n]=i);return t}function ln(e){try{return"undefined"!=typeof process?process.env?.[e]:void 0}catch(e){return}}function dn(e){return ln(`LANGSMITH_${e}`)||ln(`LANGCHAIN_${e}`)}function fn(){return"true"===ln("OTEL_ENABLED")||"true"===dn("OTEL_ENABLED")}class pn{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(e,...t){let r;if(!this.hasWarned&&fn()&&(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),1===t.length&&"function"==typeof t[0]?r=t[0]:2===t.length&&"function"==typeof t[1]?r=t[1]:3===t.length&&"function"==typeof t[2]&&(r=t[2]),"function"==typeof r)return r()}}const hn=Symbol.for("ls:otel_trace"),mn=Symbol.for("ls:otel_context"),yn=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),gn=new class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new pn})}getTracer(e,t){return this.mockTracer}getActiveSpan(){}setSpan(e,t){return e}getSpan(e){}setSpanContext(e,t){return e}getTracerProvider(){}setGlobalTracerProvider(e){return!1}},bn=new class{active(){return{}}with(e,t){return t()}};const vn=new class{getTraceInstance(){return globalThis[hn]??gn}getContextInstance(){return globalThis[mn]??bn}initializeGlobalInstances(e){void 0===globalThis[hn]&&(globalThis[hn]=e.trace),void 0===globalThis[mn]&&(globalThis[mn]=e.context)}setDefaultOTLPTracerComponents(e){globalThis[yn]=e}getDefaultOTLPTracerComponents(){return globalThis[yn]??void 0}};function wn(){return vn.getTraceInstance()}const _n={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};class En{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(e,t){for(const r of e)try{if(!r.run)continue;if("post"===r.operation){const e=this.createSpanForRun(r,r.run,t.get(r.id));e&&!r.run.end_time&&this.spans.set(r.id,e)}else this.updateSpanForRun(r,r.run)}catch(e){console.error(`Error processing operation ${r.id}:`,e)}}createSpanForRun(e,t,r){const n=r&&wn().getSpan(r);if(n)try{return this.finishSpanSetup(n,t,e)}catch(t){return void console.error(`Failed to create span for run ${e.id}:`,t)}}finishSpanSetup(e,t,r){return this.setSpanAttributes(e,t,r),t.error?(e.setStatus({code:2}),e.recordException(new Error(t.error))):e.setStatus({code:1}),t.end_time&&e.end(new Date(t.end_time)),e}updateSpanForRun(e,t){try{const r=this.spans.get(e.id);if(!r)return void console.debug(`No span found for run ${e.id} during update`);this.setSpanAttributes(r,t,e),t.error?(r.setStatus({code:2}),r.recordException(new Error(t.error))):r.setStatus({code:1});const n=t.end_time;n&&(r.end(new Date(n)),this.spans.delete(e.id))}catch(t){console.error(`Failed to update span for run ${e.id}:`,t)}}extractModelName(e){if(e.extra?.metadata){const t=e.extra.metadata;if(t.ls_model_name)return t.ls_model_name;if(t.invocation_params){const e=t.invocation_params;if(e.model)return e.model;if(e.model_name)return e.model_name}}}setSpanAttributes(e,t,r){if("run_type"in t&&t.run_type){e.setAttribute("langsmith.span.kind",t.run_type);const r=(n=t.run_type||"chain",_n[n]||n);e.setAttribute("gen_ai.operation.name",r)}var n;"name"in t&&t.name&&e.setAttribute("langsmith.trace.name",t.name),"session_id"in t&&t.session_id&&e.setAttribute("langsmith.trace.session_id",t.session_id),"session_name"in t&&t.session_name&&e.setAttribute("langsmith.trace.session_name",t.session_name),this.setGenAiSystem(e,t);const i=this.extractModelName(t);i&&e.setAttribute(Ur,i),"prompt_tokens"in t&&"number"==typeof t.prompt_tokens&&e.setAttribute(zr,t.prompt_tokens),"completion_tokens"in t&&"number"==typeof t.completion_tokens&&e.setAttribute(Gr,t.completion_tokens),"total_tokens"in t&&"number"==typeof t.total_tokens&&e.setAttribute(qr,t.total_tokens),this.setInvocationParameters(e,t);const o=t.extra?.metadata||{};for(const[t,r]of Object.entries(o))null!=r&&e.setAttribute(`langsmith.metadata.${t}`,String(r));const a=t.tags;if(a&&Array.isArray(a)?e.setAttribute(Vr,a.join(", ")):a&&e.setAttribute(Vr,String(a)),"serialized"in t&&"object"==typeof t.serialized){const r=t.serialized;r.name&&e.setAttribute("gen_ai.serialized.name",String(r.name)),r.signature&&e.setAttribute("gen_ai.serialized.signature",String(r.signature)),r.doc&&e.setAttribute("gen_ai.serialized.doc",String(r.doc))}this.setIOAttributes(e,r)}setGenAiSystem(e,t){let r="langchain";const n=this.extractModelName(t);if(n){const e=n.toLowerCase();e.includes("anthropic")||e.startsWith("claude")?r="anthropic":e.includes("bedrock")?r="aws.bedrock":e.includes("azure")&&e.includes("openai")?r="az.ai.openai":e.includes("azure")&&e.includes("inference")?r="az.ai.inference":e.includes("cohere")?r="cohere":e.includes("deepseek")?r="deepseek":e.includes("gemini")?r="gemini":e.includes("groq")?r="groq":e.includes("watson")||e.includes("ibm")?r="ibm.watsonx.ai":e.includes("mistral")?r="mistral_ai":e.includes("gpt")||e.includes("openai")?r="openai":e.includes("perplexity")||e.includes("sonar")?r="perplexity":e.includes("vertex")?r="vertex_ai":(e.includes("xai")||e.includes("grok"))&&(r="xai")}e.setAttribute("gen_ai.system",r)}setInvocationParameters(e,t){if(!t.extra?.metadata?.invocation_params)return;const r=t.extra.metadata.invocation_params;void 0!==r.max_tokens&&e.setAttribute("gen_ai.request.max_tokens",r.max_tokens),void 0!==r.temperature&&e.setAttribute("gen_ai.request.temperature",r.temperature),void 0!==r.top_p&&e.setAttribute("gen_ai.request.top_p",r.top_p),void 0!==r.frequency_penalty&&e.setAttribute("gen_ai.request.frequency_penalty",r.frequency_penalty),void 0!==r.presence_penalty&&e.setAttribute("gen_ai.request.presence_penalty",r.presence_penalty)}setIOAttributes(e,t){if(t.run.inputs)try{const r=t.run.inputs;"object"==typeof r&&null!==r&&(r.model&&Array.isArray(r.messages)&&e.setAttribute(Ur,r.model),void 0!==r.stream&&e.setAttribute("langsmith.request.streaming",r.stream),r.extra_headers&&e.setAttribute("langsmith.request.headers",JSON.stringify(r.extra_headers)),r.extra_query&&e.setAttribute("gen_ai.request.extra_query",JSON.stringify(r.extra_query)),r.extra_body&&e.setAttribute("gen_ai.request.extra_body",JSON.stringify(r.extra_body))),e.setAttribute("gen_ai.prompt",JSON.stringify(r))}catch(e){console.debug(`Failed to process inputs for run ${t.id}`,e)}if(t.run.outputs)try{const r=t.run.outputs,n=this.getUnifiedRunTokens(r);if(n&&(e.setAttribute(zr,n[0]),e.setAttribute(Gr,n[1]),e.setAttribute(qr,n[0]+n[1])),r&&"object"==typeof r){if(r.model&&e.setAttribute("gen_ai.response.model",String(r.model)),r.id&&e.setAttribute("gen_ai.response.id",r.id),r.choices&&Array.isArray(r.choices)){const t=r.choices.map(e=>e.finish_reason).filter(e=>e).map(String);t.length>0&&e.setAttribute("gen_ai.response.finish_reasons",t.join(", "))}if(r.service_tier&&e.setAttribute("gen_ai.response.service_tier",r.service_tier),r.system_fingerprint&&e.setAttribute("gen_ai.response.system_fingerprint",r.system_fingerprint),r.usage_metadata&&"object"==typeof r.usage_metadata){const t=r.usage_metadata;t.input_token_details&&e.setAttribute("gen_ai.usage.input_token_details",JSON.stringify(t.input_token_details)),t.output_token_details&&e.setAttribute("gen_ai.usage.output_token_details",JSON.stringify(t.output_token_details))}}e.setAttribute("gen_ai.completion",JSON.stringify(r))}catch(e){console.debug(`Failed to process outputs for run ${t.id}`,e)}}getUnifiedRunTokens(e){if(!e)return null;let t=this.extractUnifiedRunTokens(e.usage_metadata);if(t)return t;const r=Object.keys(e);for(const n of r){const r=e[n];if(r&&"object"==typeof r){if(t=this.extractUnifiedRunTokens(r.usage_metadata),t)return t;if(1===r.lc&&r.kwargs&&"object"==typeof r.kwargs&&(t=this.extractUnifiedRunTokens(r.kwargs.usage_metadata),t))return t}}const n=e.generations||[];if(!Array.isArray(n))return null;const i=Array.isArray(n[0])?n.flat():n;for(const e of i)if("object"==typeof e&&e.message&&"object"==typeof e.message&&e.message.kwargs&&"object"==typeof e.message.kwargs&&(t=this.extractUnifiedRunTokens(e.message.kwargs.usage_metadata),t))return t;return null}extractUnifiedRunTokens(e){return e&&"object"==typeof e?"number"!=typeof e.input_tokens||"number"!=typeof e.output_tokens?null:[e.input_tokens,e.output_tokens]:null}}const Sn=Object.prototype.toString,On=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 An(e){var t;if(!(e&&(t=e,"[object Error]"===Sn.call(t))&&"TypeError"===e.name&&"string"==typeof e.message))return!1;const{message:r,stack:n}=e;return"Load failed"===r?void 0===n||"__sentry_captured__"in e:!!r.startsWith("error sending request for url")||On.has(r)}function Tn(e,t,{min:r=0,allowInfinity:n=!1}={}){if(void 0!==t){if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be ≥ ${r}.`)}}class xn 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 In(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function kn({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){const o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof xn)throw o.originalError;const a=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await i.onFailedAttempt(c),In(n,s)<=0)throw o;const u=await i.shouldConsumeRetry(c),l=In(n,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!An(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;const d=function(e,t){const r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1;let i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}(r,i),f=Math.min(d,l);return f>0&&await new Promise((e,t)=>{const r=()=>{clearTimeout(n),i.signal?.removeEventListener("abort",r),t(i.signal.reason)},n=setTimeout(()=>{i.signal?.removeEventListener("abort",r),e()},f);i.unref&&n.unref?.(),i.signal?.addEventListener("abort",r,{once:!0})}),i.signal?.throwIfAborted(),!0}async function jn(e,t={}){if(function(e){if("number"==typeof e){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(void 0!==e)throw new TypeError("Expected `retries` to be a number or Infinity.")}((t={...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,Tn("factor",t.factor,{min:0,allowInfinity:!1}),Tn("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Tn("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Tn("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0;const i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();const n=await e(r);return t.signal?.throwIfAborted(),n}catch(e){await kn({error:e,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Rn,Nn={},Pn={exports:{}};var Cn,Ln,Mn,$n={exports:{}};function Dn(){return Ln?Cn:(Ln=1,Cn=(e,t)=>(t=t||(()=>{}),e.then(e=>new Promise(e=>{e(t())}).then(()=>e),e=>new Promise(e=>{e(t())}).then(()=>{throw e}))))}var Bn,Fn,Un,zn={},Gn={};function qn(){if(Fn)return zn;Fn=1,Object.defineProperty(zn,"__esModule",{value:!0});const e=(Bn||(Bn=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.default=function(e,t,r){let n=0,i=e.length;for(;i>0;){const o=i/2|0;let a=n+o;r(e[a],t)<=0?(n=++a,i-=o+1):i=o}return n}),Gn);return zn.default=class{constructor(){this._queue=[]}enqueue(t,r){const n={priority:(r=Object.assign({priority:0},r)).priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority)return void this._queue.push(n);const i=e.default(this._queue,n,(e,t)=>t.priority-e.priority);this._queue.splice(i,0,n)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this._queue.length}},zn}var Vn=function(){if(Un)return Nn;Un=1,Object.defineProperty(Nn,"__esModule",{value:!0});const e=(Rn||(Rn=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(Pn)),Pn.exports),t=function(){if(Mn)return $n.exports;Mn=1;const e=Dn();class t extends Error{constructor(e){super(e),this.name="TimeoutError"}}const r=(r,n,i)=>new Promise((o,a)=>{if("number"!=typeof n||n<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(n===1/0)return void o(r);const s=setTimeout(()=>{if("function"==typeof i){try{o(i())}catch(e){a(e)}return}const e=i instanceof Error?i:new t("string"==typeof i?i:`Promise timed out after ${n} milliseconds`);"function"==typeof r.cancel&&r.cancel(),a(e)},n);e(r.then(o,a),()=>{clearTimeout(s)})});return $n.exports=r,$n.exports.default=r,$n.exports.TimeoutError=t,$n.exports}(),r=qn(),n=()=>{},i=new t.TimeoutError;return Nn.default=class extends e{constructor(e){var t,i,o,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=n,this._resolveIdle=n,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:r.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(i=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==i?i:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(a=null===(o=e.interval)||void 0===o?void 0:o.toString())&&void 0!==a?a:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}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=n,0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=n,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){const e=Date.now();if(void 0===this._intervalId){const t=this._intervalEnd-e;if(!(t<0))return void 0===this._timeoutId&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&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(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,r={}){return new Promise((n,o)=>{this._queue.enqueue(async()=>{this._pendingCount++,this._intervalCount++;try{const a=void 0===this._timeout&&void 0===r.timeout?e():t.default(Promise.resolve(e()),void 0===r.timeout?this._timeout:r.timeout,()=>{(void 0===r.throwOnTimeout?this._throwOnTimeout:r.throwOnTimeout)&&o(i)});n(await a)}catch(e){o(e)}this._next()},r),this._tryToStartAnother(),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise(e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}})}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}},Nn}(),Wn=w(Vn);const Hn=[408,425,429,500,502,503,504];let Kn=class{constructor(e){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=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.maxQueueSizeBytes=e.maxQueueSizeBytes,this.queue="default"in Wn?new Wn.default({concurrency:this.maxConcurrency}):new Wn({concurrency:this.maxConcurrency}),this.onFailedResponseHook=e?.onFailedResponseHook}call(e,...t){return this.callWithOptions({},e,...t)}callWithOptions(e,t,...r){const n=e.sizeBytes??0;if(void 0!==this.maxQueueSizeBytes&&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);const i=this.onFailedResponseHook;let o=this.queue.add(()=>jn(()=>t(...r).catch(e=>{throw e instanceof Error?e:new Error(e)}),{async onFailedAttempt({error:e}){if(e.message.startsWith("Cancel")||e.message.startsWith("TimeoutError")||"TimeoutError"===e.name||e.message.startsWith("AbortError"))throw e;if("ECONNABORTED"===e?.code)throw e;const t=e?.response;if(i){if(await i(t))return}const r=t?.status??e?.status;if(r&&!Hn.includes(+r))throw e},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),e.signal?Promise.race([o,new Promise((t,r)=>{e.signal?.addEventListener("abort",()=>{r(new Error("AbortError"))})})]):o}};function Zn(e){return"function"==typeof e?._getType}function Jn(e){const 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 Yn,Qn,Xn,ei,ti,ri,ni,ii,oi,ai,si,ci,ui,li,di,fi,pi,hi,mi,yi,gi,bi,vi,wi,_i,Ei,Si,Oi,Ai,Ti,xi,Ii,ki,ji,Ri,Ni,Pi,Ci,Li,Mi,$i,Di,Bi,Fi,Ui,zi,Gi,qi,Vi,Wi,Hi,Ki,Zi,Ji,Yi,Qi,Xi,eo,to,ro,no,io,oo,ao,so,co,uo,lo,fo,po,ho,mo,yo,go,bo,vo,wo,_o,Eo,So,Oo,Ao,To,xo,Io,ko,jo,Ro,No,Po={exports:{}};function Co(){if(Qn)return Yn;Qn=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Yn={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function Lo(){if(ei)return Xn;ei=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return Xn=e}function Mo(){return ti||(ti=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Co(),o=Lo(),a=(t=e.exports={}).re=[],s=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let d=0;const f="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[f,n]],h=(e,t,r)=>{const n=(e=>{for(const[t,r]of p)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=d++;o(e,i,t),l[e]=i,c[i]=t,u[i]=n,a[i]=new RegExp(t,r?"g":void 0),s[i]=new RegExp(n,r?"g":void 0)};h("NUMERICIDENTIFIER","0|[1-9]\\d*"),h("NUMERICIDENTIFIERLOOSE","\\d+"),h("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),h("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),h("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),h("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),h("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),h("BUILDIDENTIFIER",`${f}+`),h("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),h("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),h("FULL",`^${c[l.FULLPLAIN]}$`),h("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),h("LOOSE",`^${c[l.LOOSEPLAIN]}$`),h("GTLT","((?:<|>)?=?)"),h("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),h("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),h("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),h("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),h("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),h("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),h("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),h("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?`+`(?:${c[l.BUILD]})?(?:$|[^\\d])`),h("COERCERTL",c[l.COERCE],!0),h("COERCERTLFULL",c[l.COERCEFULL],!0),h("LONETILDE","(?:~>?)"),h("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",h("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),h("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),h("LONECARET","(?:\\^)"),h("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",h("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),h("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),h("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),h("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),h("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",h("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),h("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),h("STAR","(<|>)?=?\\s*\\*"),h("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),h("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Po,Po.exports)),Po.exports}function $o(){if(ni)return ri;ni=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return ri=r=>r?"object"!=typeof r?e:r:t}function Do(){if(oi)return ii;oi=1;const e=/^[0-9]+$/,t=(t,r)=>{if("number"==typeof t&&"number"==typeof r)return t===r?0:t<r?-1:1;const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return ii={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)}}function Bo(){if(si)return ai;si=1;const e=Lo(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=Co(),{safeRe:n,t:i}=Mo(),o=$o(),{compareIdentifiers:a}=Do();class s{constructor(a,c){if(c=o(c),a instanceof s){if(a.loose===!!c.loose&&a.includePrerelease===!!c.includePrerelease)return a;a=a.version}else if("string"!=typeof a)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof a}".`);if(a.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",a,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const u=a.trim().match(c.loose?n[i.LOOSE]:n[i.FULL]);if(!u)throw new TypeError(`Invalid Version: ${a}`);if(this.raw=a,this.major=+u[1],this.minor=+u[2],this.patch=+u[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");u[4]?this.prerelease=u[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):this.prerelease=[],this.build=u[5]?u[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(e("SemVer.compare",this.version,this.options,t),!(t instanceof s)){if("string"==typeof t&&t===this.version)return 0;t=new s(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof s||(e=new s(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(t){if(t instanceof s||(t=new s(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{const n=this.prerelease[r],i=t.prerelease[r];if(e("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return a(n,i)}while(++r)}compareBuild(t){t instanceof s||(t=new s(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return a(n,i)}while(++r)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===a(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return ai=s}function Fo(){if(ui)return ci;ui=1;const e=Bo();return ci=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}},ci}function Uo(){if(xi)return Ti;xi=1;const e=Bo();return Ti=(t,r,n)=>new e(t,n).compare(new e(r,n))}function zo(){if(Pi)return Ni;Pi=1;const e=Bo();return Ni=(t,r,n)=>{const i=new e(t,n),o=new e(r,n);return i.compare(o)||i.compareBuild(o)}}function Go(){if(Bi)return Di;Bi=1;const e=Uo();return Di=(t,r,n)=>e(t,r,n)>0}function qo(){if(Ui)return Fi;Ui=1;const e=Uo();return Fi=(t,r,n)=>e(t,r,n)<0}function Vo(){if(Gi)return zi;Gi=1;const e=Uo();return zi=(t,r,n)=>0===e(t,r,n)}function Wo(){if(Vi)return qi;Vi=1;const e=Uo();return qi=(t,r,n)=>0!==e(t,r,n)}function Ho(){if(Hi)return Wi;Hi=1;const e=Uo();return Wi=(t,r,n)=>e(t,r,n)>=0}function Ko(){if(Zi)return Ki;Zi=1;const e=Uo();return Ki=(t,r,n)=>e(t,r,n)<=0}function Zo(){if(Yi)return Ji;Yi=1;const e=Vo(),t=Wo(),r=Go(),n=Ho(),i=qo(),o=Ko();return Ji=(a,s,c,u)=>{switch(s){case"===":return"object"==typeof a&&(a=a.version),"object"==typeof c&&(c=c.version),a===c;case"!==":return"object"==typeof a&&(a=a.version),"object"==typeof c&&(c=c.version),a!==c;case"":case"=":case"==":return e(a,c,u);case"!=":return t(a,c,u);case">":return r(a,c,u);case">=":return n(a,c,u);case"<":return i(a,c,u);case"<=":return o(a,c,u);default:throw new TypeError(`Invalid operator: ${s}`)}}}function Jo(){if(no)return ro;no=1;const e=/\s+/g;class t{constructor(r,o){if(o=n(o),r instanceof t)return r.loose===!!o.loose&&r.includePrerelease===!!o.includePrerelease?r:new t(r.raw,o);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=r.trim().replace(e," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&f)|(this.options.loose&&p))+":"+e,n=r.get(t);if(n)return n;const a=this.options.loose,m=a?s[c.HYPHENRANGELOOSE]:s[c.HYPHENRANGE];e=e.replace(m,x(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(s[c.COMPARATORTRIM],u),o("comparator trim",e),e=e.replace(s[c.TILDETRIM],l),o("tilde trim",e),e=e.replace(s[c.CARETTRIM],d),o("caret trim",e);let y=e.split(" ").map(e=>g(e,this.options)).join(" ").split(/\s+/).map(e=>T(e,this.options));a&&(y=y.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(s[c.COMPARATORLOOSE])))),o("range list",y);const b=new Map,v=y.map(e=>new i(e,this.options));for(const e of v){if(h(e))return[e];b.set(e.value,e)}b.size>1&&b.has("")&&b.delete("");const w=[...b.values()];return r.set(t,w),w}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(t=>y(t,r)&&e.set.some(e=>y(e,r)&&t.every(t=>e.every(e=>t.intersects(e,r)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new a(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(I(this.set[t],e,this.options))return!0;return!1}}ro=t;const r=new(to?eo:(to=1,eo=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}})),n=$o(),i=Yo(),o=Lo(),a=Bo(),{safeRe:s,t:c,comparatorTrimReplace:u,tildeTrimReplace:l,caretTrimReplace:d}=Mo(),{FLAG_INCLUDE_PRERELEASE:f,FLAG_LOOSE:p}=Co(),h=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,y=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every(e=>i.intersects(e,t)),i=n.pop();return r},g=(e,t)=>(e=e.replace(s[c.BUILD],""),o("comp",e,t),e=_(e,t),o("caret",e),e=v(e,t),o("tildes",e),e=S(e,t),o("xrange",e),e=A(e,t),o("stars",e),e),b=e=>!e||"x"===e.toLowerCase()||"*"===e,v=(e,t)=>e.trim().split(/\s+/).map(e=>w(e,t)).join(" "),w=(e,t)=>{const r=t.loose?s[c.TILDELOOSE]:s[c.TILDE];return e.replace(r,(t,r,n,i,a)=>{let s;return o("tilde",e,t,r,n,i,a),b(r)?s="":b(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:b(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:a?(o("replaceTilde pr",a),s=`>=${r}.${n}.${i}-${a} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,o("tilde return",s),s})},_=(e,t)=>e.trim().split(/\s+/).map(e=>E(e,t)).join(" "),E=(e,t)=>{o("caret",e,t);const r=t.loose?s[c.CARETLOOSE]:s[c.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,a,s)=>{let c;return o("caret",e,t,r,i,a,s),b(r)?c="":b(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:b(a)?c="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(o("replaceCaret pr",s),c="0"===r?"0"===i?`>=${r}.${i}.${a}-${s} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a}-${s} <${+r+1}.0.0-0`):(o("no pr"),c="0"===r?"0"===i?`>=${r}.${i}.${a}${n} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a} <${+r+1}.0.0-0`),o("caret return",c),c})},S=(e,t)=>(o("replaceXRanges",e,t),e.split(/\s+/).map(e=>O(e,t)).join(" ")),O=(e,t)=>{e=e.trim();const r=t.loose?s[c.XRANGELOOSE]:s[c.XRANGE];return e.replace(r,(r,n,i,a,s,c)=>{o("xRange",e,r,n,i,a,s,c);const u=b(i),l=u||b(a),d=l||b(s),f=d;return"="===n&&f&&(n=""),c=t.includePrerelease?"-0":"",u?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&f?(l&&(a=0),s=0,">"===n?(n=">=",l?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):"<="===n&&(n="<",l?i=+i+1:a=+a+1),"<"===n&&(c="-0"),r=`${n+i}.${a}.${s}${c}`):l?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(r=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o("xRange return",r),r})},A=(e,t)=>(o("replaceStars",e,t),e.trim().replace(s[c.STAR],"")),T=(e,t)=>(o("replaceGTE0",e,t),e.trim().replace(s[t.includePrerelease?c.GTE0PRE:c.GTE0],"")),x=e=>(t,r,n,i,o,a,s,c,u,l,d,f)=>`${r=b(n)?"":b(i)?`>=${n}.0.0${e?"-0":""}`:b(o)?`>=${n}.${i}.0${e?"-0":""}`:a?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=b(u)?"":b(l)?`<${+u+1}.0.0-0`:b(d)?`<${u}.${+l+1}.0-0`:f?`<=${u}.${l}.${d}-${f}`:e?`<${u}.${l}.${+d+1}-0`:`<=${c}`}`.trim(),I=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(o(e[r].semver),e[r].semver!==i.ANY&&e[r].semver.prerelease.length>0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return ro}function Yo(){if(oo)return io;oo=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),a("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,a("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=t.match(r);if(!o)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new s(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(a("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new s(t,this.options)}catch(e){return!1}return o(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(this.value,n).test(e.semver):(!(n=r(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}io=t;const r=$o(),{safeRe:n,t:i}=Mo(),o=Zo(),a=Lo(),s=Bo(),c=Jo();return io}function Qo(){if(so)return ao;so=1;const e=Jo();return ao=(t,r,n)=>{try{r=new e(r,n)}catch(e){return!1}return r.test(t)},ao}function Xo(){if(bo)return go;bo=1;const e=Jo();return go=(t,r)=>{try{return new e(t,r).range||"*"}catch(e){return null}},go}function ea(){if(wo)return vo;wo=1;const e=Bo(),t=Yo(),{ANY:r}=t,n=Jo(),i=Qo(),o=Go(),a=qo(),s=Ko(),c=Ho();return vo=(u,l,d,f)=>{let p,h,m,y,g;switch(u=new e(u,f),l=new n(l,f),d){case">":p=o,h=s,m=a,y=">",g=">=";break;case"<":p=a,h=c,m=o,y="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(u,l,f))return!1;for(let e=0;e<l.set.length;++e){const n=l.set[e];let i=null,o=null;if(n.forEach(e=>{e.semver===r&&(e=new t(">=0.0.0")),i=i||e,o=o||e,p(e.semver,i.semver,f)?i=e:m(e.semver,o.semver,f)&&(o=e)}),i.operator===y||i.operator===g)return!1;if((!o.operator||o.operator===y)&&h(u,o.semver))return!1;if(o.operator===g&&m(u,o.semver))return!1}return!0},vo}var ta=function(){if(No)return Ro;No=1;const e=Mo(),t=Co(),r=Bo(),n=Do(),i=Fo(),o=function(){if(di)return li;di=1;const e=Fo();return li=(t,r)=>{const n=e(t,r);return n?n.version:null},li}(),a=function(){if(pi)return fi;pi=1;const e=Fo();return fi=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null},fi}(),s=function(){if(mi)return hi;mi=1;const e=Bo();return hi=(t,r,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new e(t instanceof e?t.version:t,n).inc(r,i,o).version}catch(e){return null}},hi}(),c=function(){if(gi)return yi;gi=1;const e=Fo();return yi=(t,r)=>{const n=e(t,null,!0),i=e(r,null,!0),o=n.compare(i);if(0===o)return null;const a=o>0,s=a?n:i,c=a?i:n,u=!!s.prerelease.length;if(c.prerelease.length&&!u){if(!c.patch&&!c.minor)return"major";if(0===c.compareMain(s))return c.minor&&!c.patch?"minor":"patch"}const l=u?"pre":"";return n.major!==i.major?l+"major":n.minor!==i.minor?l+"minor":n.patch!==i.patch?l+"patch":"prerelease"}}(),u=function(){if(vi)return bi;vi=1;const e=Bo();return bi=(t,r)=>new e(t,r).major}(),l=function(){if(_i)return wi;_i=1;const e=Bo();return wi=(t,r)=>new e(t,r).minor}(),d=function(){if(Si)return Ei;Si=1;const e=Bo();return Ei=(t,r)=>new e(t,r).patch}(),f=function(){if(Ai)return Oi;Ai=1;const e=Fo();return Oi=(t,r)=>{const n=e(t,r);return n&&n.prerelease.length?n.prerelease:null},Oi}(),p=Uo(),h=function(){if(ki)return Ii;ki=1;const e=Uo();return Ii=(t,r,n)=>e(r,t,n)}(),m=function(){if(Ri)return ji;Ri=1;const e=Uo();return ji=(t,r)=>e(t,r,!0)}(),y=zo(),g=function(){if(Li)return Ci;Li=1;const e=zo();return Ci=(t,r)=>t.sort((t,n)=>e(t,n,r))}(),b=function(){if($i)return Mi;$i=1;const e=zo();return Mi=(t,r)=>t.sort((t,n)=>e(n,t,r))}(),v=Go(),w=qo(),_=Vo(),E=Wo(),S=Ho(),O=Ko(),A=Zo(),T=function(){if(Xi)return Qi;Xi=1;const e=Bo(),t=Fo(),{safeRe:r,t:n}=Mo();return Qi=(i,o)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let a=null;if((o=o||{}).rtl){const e=o.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let t;for(;(t=e.exec(i))&&(!a||a.index+a[0].length!==i.length);)a&&t.index+t[0].length===a.index+a[0].length||(a=t),e.lastIndex=t.index+t[1].length+t[2].length;e.lastIndex=-1}else a=i.match(o.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);if(null===a)return null;const s=a[2],c=a[3]||"0",u=a[4]||"0",l=o.includePrerelease&&a[5]?`-${a[5]}`:"",d=o.includePrerelease&&a[6]?`+${a[6]}`:"";return t(`${s}.${c}.${u}${l}${d}`,o)},Qi}(),x=Yo(),I=Jo(),k=Qo(),j=function(){if(uo)return co;uo=1;const e=Jo();return co=(t,r)=>new e(t,r).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),co}(),R=function(){if(fo)return lo;fo=1;const e=Bo(),t=Jo();return lo=(r,n,i)=>{let o=null,a=null,s=null;try{s=new t(n,i)}catch(e){return null}return r.forEach(t=>{s.test(t)&&(o&&-1!==a.compare(t)||(o=t,a=new e(o,i)))}),o},lo}(),N=function(){if(ho)return po;ho=1;const e=Bo(),t=Jo();return po=(r,n,i)=>{let o=null,a=null,s=null;try{s=new t(n,i)}catch(e){return null}return r.forEach(t=>{s.test(t)&&(o&&1!==a.compare(t)||(o=t,a=new e(o,i)))}),o},po}(),P=function(){if(yo)return mo;yo=1;const e=Bo(),t=Jo(),r=Go();return mo=(n,i)=>{n=new t(n,i);let o=new e("0.0.0");if(n.test(o))return o;if(o=new e("0.0.0-0"),n.test(o))return o;o=null;for(let t=0;t<n.set.length;++t){const i=n.set[t];let a=null;i.forEach(t=>{const n=new e(t.semver.version);switch(t.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":a&&!r(n,a)||(a=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}}),!a||o&&!r(o,a)||(o=a)}return o&&n.test(o)?o:null},mo}(),C=Xo(),L=ea(),M=function(){if(Eo)return _o;Eo=1;const e=ea();return _o=(t,r,n)=>e(t,r,">",n),_o}(),$=function(){if(Oo)return So;Oo=1;const e=ea();return So=(t,r,n)=>e(t,r,"<",n),So}(),D=function(){if(To)return Ao;To=1;const e=Jo();return Ao=(t,r,n)=>(t=new e(t,n),r=new e(r,n),t.intersects(r,n))}(),B=function(){if(Io)return xo;Io=1;const e=Qo(),t=Uo();return xo=(r,n,i)=>{const o=[];let a=null,s=null;const c=r.sort((e,r)=>t(e,r,i));for(const t of c)e(t,n,i)?(s=t,a||(a=t)):(s&&o.push([a,s]),s=null,a=null);a&&o.push([a,null]);const u=[];for(const[e,t]of o)e===t?u.push(e):t||e!==c[0]?t?e===c[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");const l=u.join(" || "),d="string"==typeof n.raw?n.raw:String(n);return l.length<d.length?l:n},xo}(),F=function(){if(jo)return ko;jo=1;const e=Jo(),t=Yo(),{ANY:r}=t,n=Qo(),i=Uo(),o=[new t(">=0.0.0-0")],a=[new t(">=0.0.0")],s=(e,t,s)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===r){if(1===t.length&&t[0].semver===r)return!0;e=s.includePrerelease?o:a}if(1===t.length&&t[0].semver===r){if(s.includePrerelease)return!0;t=a}const l=new Set;let d,f,p,h,m,y,g;for(const t of e)">"===t.operator||">="===t.operator?d=c(d,t,s):"<"===t.operator||"<="===t.operator?f=u(f,t,s):l.add(t.semver);if(l.size>1)return null;if(d&&f){if(p=i(d.semver,f.semver,s),p>0)return null;if(0===p&&(">="!==d.operator||"<="!==f.operator))return null}for(const e of l){if(d&&!n(e,String(d),s))return null;if(f&&!n(e,String(f),s))return null;for(const r of t)if(!n(e,String(r),s))return!1;return!0}let b=!(!f||s.includePrerelease||!f.semver.prerelease.length)&&f.semver,v=!(!d||s.includePrerelease||!d.semver.prerelease.length)&&d.semver;b&&1===b.prerelease.length&&"<"===f.operator&&0===b.prerelease[0]&&(b=!1);for(const e of t){if(g=g||">"===e.operator||">="===e.operator,y=y||"<"===e.operator||"<="===e.operator,d)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(h=c(d,e,s),h===e&&h!==d)return!1}else if(">="===d.operator&&!n(d.semver,String(e),s))return!1;if(f)if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),"<"===e.operator||"<="===e.operator){if(m=u(f,e,s),m===e&&m!==f)return!1}else if("<="===f.operator&&!n(f.semver,String(e),s))return!1;if(!e.operator&&(f||d)&&0!==p)return!1}return!(d&&y&&!f&&0!==p||f&&g&&!d&&0!==p||v||b)},c=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},u=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};return ko=(t,r,n={})=>{if(t===r)return!0;t=new e(t,n),r=new e(r,n);let i=!1;e:for(const e of t.set){for(const t of r.set){const r=s(e,t,n);if(i=i||null!==r,r)continue e}if(i)return!1}return!0}}();return Ro={parse:i,valid:o,clean:a,inc:s,diff:c,major:u,minor:l,patch:d,prerelease:f,compare:p,rcompare:h,compareLoose:m,compareBuild:y,sort:g,rsort:b,gt:v,lt:w,eq:_,neq:E,gte:S,lte:O,cmp:A,coerce:T,Comparator:x,Range:I,satisfies:k,toComparators:j,maxSatisfying:R,minSatisfying:N,minVersion:P,validRange:C,outside:L,gtr:M,ltr:$,intersects:D,simplifyRange:B,subset:F,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}(),ra=w(ta);function na(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(`Invalid identifier format: ${e}`);const[t,r]=e.split(":"),n=r||"latest";if(t.includes("/")){const[r,i]=t.split("/",2);if(!r||!i)throw new Error(`Invalid identifier format: ${e}`);return[r,i,n]}if(!t)throw new Error(`Invalid identifier format: ${e}`);return["-",t,n]}class ia extends Error{constructor(e){super(e),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}}async function oa(e,t,r){let n;if(e.ok)return void(r&&(n=await e.text()));if(403===e.status)try{const t=await e.json(),r=t?.error;"org_scoped_key_requires_workspace"===r&&(n="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch(t){const r=new Error(`${e.status} ${e.statusText}`);throw r.status=e?.status,r}if(void 0===n)try{n=await e.text()}catch(e){n=""}const i=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${n}`;if(409===e.status)throw new ia(i);const o=new Error(i);throw o.status=e.status,o}const aa="ERR_CONFLICTING_ENDPOINTS";class sa 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:aa}),this.name="ConflictingEndpointsError"}}var ca="[...]",ua={result:"[Circular]"},la=[],da=[];const fa=new TextEncoder;function pa(e){return fa.encode(e)}function ha(e){if(e&&"object"==typeof e&&null!==e){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("bigint"==typeof e)return e.toString();return e}function ma(e,t,r,n,i){try{return pa(JSON.stringify(e,function(e,t){return ha(t)},n))}catch(o){if(!o.message?.includes("Converting circular structure to JSON"))return console.warn("[WARNING]: LangSmith received unserializable value."+(t?`\nContext: ${t}`:"")),pa("[Unserializable]");let a;"true"!==dn("SUPPRESS_CIRCULAR_JSON_WARNINGS")&&console.warn("[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. "+(t?`\nContext: ${t}`:"")),void 0===i&&(i={depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}),ga(e,"",0,[],void 0,0,i);try{a=0===da.length?JSON.stringify(e,r,n):JSON.stringify(e,function(e){return e=void 0!==e?e:function(e,t){return t},function(t,r){if(da.length>0)for(var n=0;n<da.length;n++){var i=da[n];if(i[1]===t&&i[0]===r){r=i[2],da.splice(n,1);break}}return e.call(this,t,r)}}(r),n)}catch(e){return pa("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==la.length;){const e=la.pop();4===e.length?Object.defineProperty(e[0],e[1],e[3]):e[0][e[1]]=e[2]}}return pa(a)}}function ya(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);void 0!==i.get?i.configurable?(Object.defineProperty(n,r,{value:e}),la.push([n,r,t,i])):da.push([t,r,e]):(n[r]=e,la.push([n,r,t]))}function ga(e,t,r,n,i,o,a){var s;if(o+=1,"object"==typeof e&&null!==e){for(s=0;s<n.length;s++)if(n[s]===e)return void ya(ua,e,t,i);if(void 0!==a.depthLimit&&o>a.depthLimit)return void ya(ca,e,t,i);if(void 0!==a.edgesLimit&&r+1>a.edgesLimit)return void ya(ca,e,t,i);if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)ga(e[s],s,s,n,e,o,a);else{e=ha(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];ga(e[u],u,s,n,e,o,a)}}n.pop()}}function ba(e,t,r){if(r)return e;const n=cn(),i=t??un(),o=e.extra??{},a=o.metadata;return e.extra={...o,runtime:{...n,...o?.runtime},metadata:{...i,...i.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??i.revision_id}:{},...a}},e}function va(e){if(void 0!==e)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}const wa=async e=>{if(429===e?.status){const t=1e3*parseInt(e.headers.get("retry-after")??"10",10);if(t>0)return await new Promise(e=>setTimeout(e,t)),!0}return!1};function _a(e){return"number"==typeof e?Number(e.toFixed(4)):e}const Ea=1073741824,Sa="https://api.smith.langchain.com";class Oa{constructor(e){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=e??Ea}peek(){return this.items[0]}push(e){let t;const r=new Promise(e=>{t=e}),n=ma(e.item,`Serializing run with id: ${e.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: ${e.item.id}. Current queue size: ${this.sizeBytes} bytes, attempted addition: ${n} bytes.`),t(),r):(this.items.push({action:e.action,payload:e.item,otelContext:e.otelContext,apiKey:e.apiKey,apiUrl:e.apiUrl,itemPromiseResolve:t,itemPromise:r,size:n}),this.sizeBytes+=n,r)}pop({upToSizeBytes:e,upToSize:t}){if(e<1)throw new Error("Number of bytes to pop off may not be less than 1.");const r=[];let n=0;for(;n+(this.peek()?.size??0)<e&&this.items.length>0&&r.length<t;){const e=this.items.shift();e&&(r.push(e),n+=e.size,this.sizeBytes-=e.size)}if(0===r.length&&this.items.length>0){const e=this.items.shift();r.push(e),n+=e.size,this.sizeBytes-=e.size}return[r.map(e=>({action:e.action,item:e.payload,otelContext:e.otelContext,apiKey:e.apiKey,apiUrl:e.apiUrl,size:e.size})),()=>r.forEach(e=>e.itemPromiseResolve())]}}class Aa{get _fetch(){return this.fetchImplementation||Kr(this.debug)}constructor(e={}){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:"false"===ln("LANGSMITH_TRACING_BACKGROUND")}),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,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:"true"===ln("LANGSMITH_DEBUG")});const t=Aa.getDefaultClientConfig();if(this.tracingSampleRate=(e=>{const t=e?.toString()??dn("TRACING_SAMPLING_RATE");if(void 0===t)return;const 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})(e.tracingSamplingRate),this.apiUrl=va(e.apiUrl??t.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1)),this.apiKey=va(e.apiKey??t.apiKey),this.webUrl=va(e.webUrl??t.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=va(e.workspaceId??dn("WORKSPACE_ID")),this.timeout_ms=e.timeout_ms??9e4,this.caller=new Kn({...e.callerOptions??{},maxRetries:4,debug:e.debug??this.debug}),this.traceBatchConcurrency=e.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=e.debug??this.debug,this.fetchImplementation=e.fetchImplementation;const r=e.maxIngestMemoryBytes??Ea;this.batchIngestCaller=new Kn({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:r,...e.callerOptions??{},onFailedResponseHook:wa,debug:e.debug??this.debug}),this.hideInputs=e.hideInputs??e.anonymizer??t.hideInputs,this.hideOutputs=e.hideOutputs??e.anonymizer??t.hideOutputs,this.omitTracedRuntimeInfo=e.omitTracedRuntimeInfo??!1,this.autoBatchTracing=e.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new Oa(r),this.blockOnRootRunFinalization=e.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=e.batchSizeBytesLimit,this.batchSizeLimit=e.batchSizeLimit,this.fetchOptions=e.fetchOptions||{},this.manualFlushMode=e.manualFlushMode??this.manualFlushMode,fn()&&(this.langSmithToOTELTranslator=new En),this.cachedLSEnvVarsForMetadata=un()}static getDefaultClientConfig(){const e=dn("API_KEY");return{apiUrl:dn("ENDPOINT")??Sa,apiKey:e,webUrl:void 0,hideInputs:"true"===dn("HIDE_INPUTS"),hideOutputs:"true"===dn("HIDE_OUTPUTS")}}getHostUrl(){return this.webUrl?this.webUrl:(e=>{const t=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return"localhost"===t||"127.0.0.1"===t||"::1"===t})(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(){const e={"User-Agent":`langsmith-js/${tn}`};return this.apiKey&&(e["x-api-key"]=`${this.apiKey}`),this.workspaceId&&(e["x-tenant-id"]=this.workspaceId),e}_getPlatformEndpointPath(e){return"/v1"!==this.apiUrl.slice(-3)&&"/v1/"!==this.apiUrl.slice(-4)?`/v1/platform/${e}`:`/platform/${e}`}async processInputs(e){return!1===this.hideInputs?e:!0===this.hideInputs?{}:"function"==typeof this.hideInputs?this.hideInputs(e):e}async processOutputs(e){return!1===this.hideOutputs?e:!0===this.hideOutputs?{}:"function"==typeof this.hideOutputs?this.hideOutputs(e):e}async prepareRunCreateOrUpdateInputs(e){const t={...e};return void 0!==t.inputs&&(t.inputs=await this.processInputs(t.inputs)),void 0!==t.outputs&&(t.outputs=await this.processOutputs(t.outputs)),t}async _getResponse(e,t){const r=t?.toString()??"",n=`${this.apiUrl}${e}?${r}`;return await this.caller.call(async()=>{const t=await this._fetch(n,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,`fetch ${e}`),t})}async _get(e,t){return(await this._getResponse(e,t)).json()}async*_getPaginated(e,t=new URLSearchParams,r){let n=Number(t.get("offset"))||0;const i=Number(t.get("limit"))||100;for(;;){t.set("offset",String(n)),t.set("limit",String(i));const o=`${this.apiUrl}${e}?${t}`,a=await this.caller.call(async()=>{const t=await this._fetch(o,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,`fetch ${e}`),t}),s=r?r(await a.json()):await a.json();if(0===s.length)break;if(yield s,s.length<i)break;n+=s.length}}async*_getCursorPaginatedList(e,t=null,r="POST",n="runs"){const i=t?{...t}:{};for(;;){const t=JSON.stringify(i),o=await this.caller.call(async()=>{const n=await this._fetch(`${this.apiUrl}${e}`,{method:r,headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await oa(n,`fetch ${e}`),n}),a=await o.json();if(!a)break;if(!a[n])break;yield a[n];const s=a.cursors;if(!s)break;if(!s.next)break;i.cursor=s.next}}_shouldSample(){return void 0===this.tracingSampleRate||Math.random()<this.tracingSampleRate}_filterForSampling(e,t=!1){if(void 0===this.tracingSampleRate)return e;if(t){const t=[];for(const r of e)this.filteredPostUuids.has(r.trace_id)?r.id===r.trace_id&&this.filteredPostUuids.delete(r.trace_id):t.push(r);return t}{const t=[];for(const r of e){const e=r.trace_id??r.id;this.filteredPostUuids.has(e)||(r.id===e?this._shouldSample()?t.push(r):this.filteredPostUuids.add(e):t.push(r))}return t}}async _getBatchSizeLimitBytes(){const e=await this._ensureServerInfo();return this.batchSizeBytesLimit??e.batch_ingest_config?.size_limit_bytes??25165824}async _getBatchSizeLimit(){const e=await this._ensureServerInfo();return this.batchSizeLimit??e.batch_ingest_config?.size_limit??100}async _getDatasetExamplesMultiPartSupport(){const e=await this._ensureServerInfo();return e.instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:e,batchSizeLimit:t}){const r=[];for(;this.autoBatchQueue.items.length>0;){const[n,i]=this.autoBatchQueue.pop({upToSizeBytes:e,upToSize:t});if(!n.length){i();break}const o=n.reduce((e,t)=>{const r=t.apiUrl??this.apiUrl,n=t.apiKey??this.apiKey,i=t.apiKey===this.apiKey&&t.apiUrl===this.apiUrl?"default":`${r}|${n}`;return e[i]||(e[i]=[]),e[i].push(t),e},{}),a=[];for(const[e,t]of Object.entries(o)){const r=this._processBatch(t,{apiUrl:"default"===e?void 0:e.split("|")[0],apiKey:"default"===e?void 0:e.split("|")[1]});a.push(r)}const s=Promise.all(a).finally(i);r.push(s)}return Promise.all(r)}async _processBatch(e,t){if(!e.length)return;const r=e.reduce((e,t)=>e+(t.size??0),0);try{if(void 0!==this.langSmithToOTELTranslator)this._sendBatchToOTELTranslator(e);else{const n={runCreates:e.filter(e=>"create"===e.action).map(e=>e.item),runUpdates:e.filter(e=>"update"===e.action).map(e=>e.item)},i=await this._ensureServerInfo();if(i?.batch_ingest_config?.use_multipart_endpoint){const e=i?.instance_flags?.gzip_body_enabled;await this.multipartIngestRuns(n,{...t,useGzip:e,sizeBytes:r})}else await this.batchIngestRuns(n,{...t,sizeBytes:r})}}catch(e){console.error("Error exporting batch:",e)}}_sendBatchToOTELTranslator(e){if(void 0!==this.langSmithToOTELTranslator){const t=new Map,r=[];for(const n of e)n.item.id&&n.otelContext&&(t.set(n.item.id,n.otelContext),"create"===n.action?r.push({operation:"post",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}):r.push({operation:"patch",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}));this.langSmithToOTELTranslator.exportBatch(r,t)}}async processRunOperation(e){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,e.item=ba(e.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);const t=this.autoBatchQueue.push(e);if(this.manualFlushMode)return t;const r=await this._getBatchSizeLimitBytes(),n=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>r||this.autoBatchQueue.items.length>n)&&this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:n}),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:n})},this.autoBatchAggregationDelayMs)),t}async _getServerInfo(){const e=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(1e4),...this.fetchOptions});return await oa(e,"get server info"),e}),t=await e.json();return this.debug&&console.log("\n=== LangSmith Server Configuration ===\n"+JSON.stringify(t,null,2)+"\n"),t}async _ensureServerInfo(){return void 0===this._getServerInfoPromise&&(this._getServerInfoPromise=(async()=>{if(void 0===this._serverInfo)try{this._serverInfo=await this._getServerInfo()}catch(e){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${e.status??"Unspecified status code"} ${e.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(e=>(void 0===this._serverInfo&&(this._getServerInfoPromise=void 0),e))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){const e=await this._getBatchSizeLimitBytes(),t=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:e,batchSizeLimit:t})}_cloneCurrentOTELContext(){const e=wn(),t=vn.getContextInstance();if(void 0!==this.langSmithToOTELTranslator){const r=e.getActiveSpan();if(r)return e.setSpan(t.active(),r)}}async createRun(e,t){if(!this._filterForSampling([e]).length)return;const r={...this.headers,"Content-Type":"application/json"},n=e.project_name;delete e.project_name;const i=await this.prepareRunCreateOrUpdateInputs({session_name:n,...e,start_time:e.start_time??Date.now()});if(this.autoBatchTracing&&void 0!==i.trace_id&&void 0!==i.dotted_order){const e=this._cloneCurrentOTELContext();return void this.processRunOperation({action:"create",item:i,otelContext:e,apiKey:t?.apiKey,apiUrl:t?.apiUrl}).catch(console.error)}const o=ba(i,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);void 0!==t?.apiKey&&(r["x-api-key"]=t.apiKey),void 0!==t?.workspaceId&&(r["x-tenant-id"]=t.workspaceId);const a=ma(o,`Creating run with id: ${o.id}`);await this.caller.call(async()=>{const e=await this._fetch(`${t?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await oa(e,"create run",!0),e})}async batchIngestRuns({runCreates:e,runUpdates:t},r){if(void 0===e&&void 0===t)return;let n=await Promise.all(e?.map(e=>this.prepareRunCreateOrUpdateInputs(e))??[]),i=await Promise.all(t?.map(e=>this.prepareRunCreateOrUpdateInputs(e))??[]);if(n.length>0&&i.length>0){const e=n.reduce((e,t)=>t.id?(e[t.id]=t,e):e,{}),t=[];for(const r of i)void 0!==r.id&&e[r.id]?e[r.id]={...e[r.id],...r}:t.push(r);n=Object.values(e),i=t}const o={post:n,patch:i};if(!o.post.length&&!o.patch.length)return;const a={post:[],patch:[]};for(const e of["post","patch"]){const t=e,r=o[t].reverse();let n=r.pop();for(;void 0!==n;)a[t].push(n),n=r.pop()}if(a.post.length>0||a.patch.length>0){const e=a.post.map(e=>e.id).concat(a.patch.map(e=>e.id)).join(",");await this._postBatchIngestRuns(ma(a,`Ingesting runs with ids: ${e}`),r)}}async _postBatchIngestRuns(e,t){const r={...this.headers,"Content-Type":"application/json",Accept:"application/json"};void 0!==t?.apiKey&&(r["x-api-key"]=t.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:t?.sizeBytes},async()=>{const n=await this._fetch(`${t?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:e});return await oa(n,"batch create run",!0),n})}async multipartIngestRuns({runCreates:e,runUpdates:t},r){if(void 0===e&&void 0===t)return;const n={};let i=[];for(const t of e??[]){const e=await this.prepareRunCreateOrUpdateInputs(t);void 0!==e.id&&void 0!==e.attachments&&(n[e.id]=e.attachments),delete e.attachments,i.push(e)}let o=[];for(const e of t??[])o.push(await this.prepareRunCreateOrUpdateInputs(e));if(void 0!==i.find(e=>void 0===e.trace_id||void 0===e.dotted_order))throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(void 0!==o.find(e=>void 0===e.trace_id||void 0===e.dotted_order))throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(i.length>0&&o.length>0){const e=i.reduce((e,t)=>t.id?(e[t.id]=t,e):e,{}),t=[];for(const r of o)void 0!==r.id&&e[r.id]?e[r.id]={...e[r.id],...r}:t.push(r);i=Object.values(e),o=t}if(0===i.length&&0===o.length)return;const a=[],s=[];for(const[e,t]of[["post",i],["patch",o]])for(const r of t){const{inputs:t,outputs:i,events:o,extra:c,error:u,serialized:l,attachments:d,...f}=r,p={inputs:t,outputs:i,events:o,extra:c,error:u,serialized:l},h=ma(f,`Serializing for multipart ingestion of run with id: ${f.id}`);s.push({name:`${e}.${f.id}`,payload:new Blob([h],{type:`application/json; length=${h.length}`})});for(const[t,r]of Object.entries(p)){if(void 0===r)continue;const n=ma(r,`Serializing ${t} for multipart ingestion of run with id: ${f.id}`);s.push({name:`${e}.${f.id}.${t}`,payload:new Blob([n],{type:`application/json; length=${n.length}`})})}if(void 0!==f.id){const e=n[f.id];if(e){delete n[f.id];for(const[t,r]of Object.entries(e)){let e,n;Array.isArray(r)?[e,n]=r:(e=r.mimeType,n=r.data),t.includes(".")?console.warn(`Skipping attachment '${t}' for run ${f.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`):s.push({name:`attachment.${f.id}.${t}`,payload:new Blob([n],{type:`${e}; length=${n.byteLength}`})})}}}a.push(`trace=${f.trace_id},id=${f.id}`)}await this._sendMultipartRequest(s,a.join("; "),r)}async _createNodeFetchBody(e,t){const r=[];for(const n of e)r.push(new Blob([`--${t}\r\n`])),r.push(new Blob([`Content-Disposition: form-data; name="${n.name}"\r\n`,`Content-Type: ${n.payload.type}\r\n\r\n`])),r.push(n.payload),r.push(new Blob(["\r\n"]));r.push(new Blob([`--${t}--\r\n`]));const n=new Blob(r);return await n.arrayBuffer()}async _createMultipartStream(e,t){const r=new TextEncoder;return new ReadableStream({async start(n){const i=async e=>{"string"==typeof e?n.enqueue(r.encode(e)):n.enqueue(e)};for(const r of e){await i(`--${t}\r\n`),await i(`Content-Disposition: form-data; name="${r.name}"\r\n`),await i(`Content-Type: ${r.payload.type}\r\n\r\n`);const e=r.payload.stream().getReader();try{let t;for(;!(t=await e.read()).done;)n.enqueue(t.value)}finally{e.releaseLock()}await i("\r\n")}await i(`--${t}--\r\n`),n.close()}})}async _sendMultipartRequest(e,t,r){const n="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),i=(()=>{const e=globalThis[Hr];return!!e&&"function"==typeof e&&"Headers"in e&&"Request"in e&&"Response"in e})(),o=()=>this._createNodeFetchBody(e,n),a=()=>this._createMultipartStream(e,n),s=async e=>this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{const t=await e(),i={...this.headers,"Content-Type":`multipart/form-data; boundary=${n}`};void 0!==r?.apiKey&&(i["x-api-key"]=r.apiKey);let o=t;r?.useGzip&&"object"==typeof t&&"pipeThrough"in t&&(o=t.pipeThrough(new CompressionStream("gzip")),i["Content-Encoding"]="gzip");const a=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:i,body:o,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(a,"Failed to send multipart request",!0),a});try{let e,n=!1;i||this.multipartStreamingDisabled||"bun"===on()?e=await s(o):(n=!0,e=await s(a)),this.multipartStreamingDisabled&&!n||422!==e.status||(r?.apiUrl??this.apiUrl)===Sa||(console.warn(`Streaming multipart upload to ${r?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${t}".`),this.multipartStreamingDisabled=!0,e=await s(o))}catch(e){console.warn(`${e.message.trim()}\n\nContext: ${t}`)}}async updateRun(e,t,r){Xr(e),t.inputs&&(t.inputs=await this.processInputs(t.inputs)),t.outputs&&(t.outputs=await this.processOutputs(t.outputs));const n={...t,id:e};if(!this._filterForSampling([n],!0).length)return;if(this.autoBatchTracing&&void 0!==n.trace_id&&void 0!==n.dotted_order){const e=this._cloneCurrentOTELContext();return void 0!==t.end_time&&void 0===n.parent_run_id&&this.blockOnRootRunFinalization&&!this.manualFlushMode?void await this.processRunOperation({action:"update",item:n,otelContext:e,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error):void this.processRunOperation({action:"update",item:n,otelContext:e,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error)}const i={...this.headers,"Content-Type":"application/json"};void 0!==r?.apiKey&&(i["x-api-key"]=r.apiKey),void 0!==r?.workspaceId&&(i["x-tenant-id"]=r.workspaceId);const o=ma(t,`Serializing payload to update run with id: ${e}`);await this.caller.call(async()=>{const t=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/${e}`,{method:"PATCH",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await oa(t,"update run",!0),t})}async readRun(e,{loadChildRuns:t}={loadChildRuns:!1}){Xr(e);let r=await this._get(`/runs/${e}`);return t&&(r=await this._loadChildRuns(r)),r}async getRunUrl({runId:e,run:t,projectOpts:r}){if(void 0!==t){let e;if(t.session_id)e=t.session_id;else if(r?.projectName)e=(await this.readProject({projectName:r?.projectName})).id;else if(r?.projectId)e=r?.projectId;else{e=(await this.readProject({projectName:dn("PROJECT")||"default"})).id}const n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${e}/r/${t.id}?poll=true`}if(void 0!==e){const t=await this.readRun(e);if(!t.app_path)throw new Error(`Run ${e} has no app_path`);return`${this.getHostUrl()}${t.app_path}`}throw new Error("Must provide either runId or run")}async _loadChildRuns(e){const t=await async function(e){const t=[];for await(const r of e)t.push(r);return t}(this.listRuns({isRoot:!1,projectId:e.session_id,traceId:e.trace_id})),r={},n={};t.sort((e,t)=>(e?.dotted_order??"").localeCompare(t?.dotted_order??""));for(const i of t){if(null===i.parent_run_id||void 0===i.parent_run_id)throw new Error(`Child run ${i.id} has no parent`);i.dotted_order?.startsWith(e.dotted_order??"")&&i.id!==e.id&&(i.parent_run_id in r||(r[i.parent_run_id]=[]),r[i.parent_run_id].push(i),n[i.id]=i)}e.child_runs=r[e.id]||[];for(const t in r)t!==e.id&&(n[t].child_runs=r[t]);return e}async*listRuns(e){const{projectId:t,projectName:r,parentRunId:n,traceId:i,referenceExampleId:o,startTime:a,executionOrder:s,isRoot:c,runType:u,error:l,id:d,query:f,filter:p,traceFilter:h,treeFilter:m,limit:y,select:g,order:b}=e;let v=[];if(t&&(v=Array.isArray(t)?t:[t]),r){const e=Array.isArray(r)?r:[r],t=await Promise.all(e.map(e=>this.readProject({projectName:e}).then(e=>e.id)));v.push(...t)}const w={session:v.length?v:null,run_type:u,reference_example:o,query:f,filter:p,trace_filter:h,tree_filter:m,execution_order:s,parent_run:n,start_time:a?a.toISOString():null,error:l,id:d,limit:y,trace:i,select:g||["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"],is_root:c,order:b};w.select.includes("child_run_ids")&&Yr("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let _=0;for await(const e of this._getCursorPaginatedList("/runs/query",w))if(y){if(_>=y)break;if(e.length+_>y){const t=e.slice(0,y-_);yield*t;break}_+=e.length,yield*e}else yield*e}async*listGroupRuns(e){const{projectId:t,projectName:r,groupBy:n,filter:i,startTime:o,endTime:a,limit:s,offset:c}=e,u={session_id:t||(await this.readProject({projectName:r})).id,group_by:n,filter:i,start_time:o?o.toISOString():null,end_time:a?a.toISOString():null,limit:Number(s)||100};let l=Number(c)||0;const d="/runs/group",f=`${this.apiUrl}${d}`;for(;;){const e={...u,offset:l},t=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t)),r=JSON.stringify(t),n=await this.caller.call(async()=>{const e=await this._fetch(f,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await oa(e,`Failed to fetch ${d}`),e}),i=await n.json(),{groups:o,total:a}=i;if(0===o.length)break;for(const e of o)yield e;if(l+=o.length,l>=a)break}}async getRunStats({id:e,trace:t,parentRun:r,runType:n,projectNames:i,projectIds:o,referenceExampleIds:a,startTime:s,endTime:c,error:u,query:l,filter:d,traceFilter:f,treeFilter:p,isRoot:h,dataSourceType:m}){let y=o||[];i&&(y=[...o||[],...await Promise.all(i.map(e=>this.readProject({projectName:e}).then(e=>e.id)))]);const g={id:e,trace:t,parent_run:r,run_type:n,session:y,reference_example:a,start_time:s,end_time:c,error:u,query:l,filter:d,trace_filter:f,tree_filter:p,is_root:h,data_source_type:m},b=Object.fromEntries(Object.entries(g).filter(([e,t])=>void 0!==t)),v=JSON.stringify(b),w=await this.caller.call(async()=>{const e=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:v});return await oa(e,"get run stats"),e});return await w.json()}async shareRun(e,{shareId:t}={}){const r={run_id:e,share_token:t||hr()};Xr(e);const n=JSON.stringify(r),i=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await oa(t,"share run"),t}),o=await i.json();if(null===o||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`}async unshareRun(e){Xr(e),await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"unshare run",!0),t})}async readRunSharedLink(e){Xr(e);const t=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"read run shared link"),t}),r=await t.json();if(null!==r&&"share_token"in r)return`${this.getHostUrl()}/public/${r.share_token}/r`}async listSharedRuns(e,{runIds:t}={}){const r=new URLSearchParams({share_token:e});if(void 0!==t)for(const e of t)r.append("id",e);Xr(e);const n=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/public/${e}/runs${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"list shared runs"),t});return await n.json()}async readDatasetSharedSchema(e,t){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");if(!e){const r=await this.readDataset({datasetName:t});e=r.id}Xr(e);const r=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"read dataset shared schema"),t}),n=await r.json();return n.url=`${this.getHostUrl()}/public/${n.share_token}/d`,n}async shareDataset(e,t){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");if(!e){const r=await this.readDataset({datasetName:t});e=r.id}const r={dataset_id:e};Xr(e);const n=JSON.stringify(r),i=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await oa(t,"share dataset"),t}),o=await i.json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(e){Xr(e),await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"unshare dataset",!0),t})}async readSharedDataset(e){Xr(e);const t=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/public/${e}/datasets`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"read shared dataset"),t});return await t.json()}async listSharedExamples(e,t){const r={};t?.exampleIds&&(r.id=t.exampleIds);const n=new URLSearchParams;Object.entries(r).forEach(([e,t])=>{Array.isArray(t)?t.forEach(t=>n.append(e,t)):n.append(e,t)});const i=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/public/${e}/examples?${n.toString()}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"list shared examples"),t}),o=await i.json();if(!i.ok){if("detail"in o)throw new Error(`Failed to list shared examples.\nStatus: ${i.status}\nMessage: ${Array.isArray(o.detail)?o.detail.join("\n"):"Unspecified error"}`);throw new Error(`Failed to list shared examples: ${i.status} ${i.statusText}`)}return o.map(e=>({...e,_hostUrl:this.getHostUrl()}))}async createProject({projectName:e,description:t=null,metadata:r=null,upsert:n=!1,projectExtra:i=null,referenceDatasetId:o=null}){const a=n?"?upsert=true":"",s=`${this.apiUrl}/sessions${a}`,c=i||{};r&&(c.metadata=r);const u={name:e,extra:c,description:t};null!==o&&(u.reference_dataset_id=o);const l=JSON.stringify(u),d=await this.caller.call(async()=>{const e=await this._fetch(s,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await oa(e,"create project"),e});return await d.json()}async updateProject(e,{name:t=null,description:r=null,metadata:n=null,projectExtra:i=null,endTime:o=null}){const a=`${this.apiUrl}/sessions/${e}`;let s=i;n&&(s={...s||{},metadata:n});const c=JSON.stringify({name:t,extra:s,description:r,end_time:o?new Date(o).toISOString():null}),u=await this.caller.call(async()=>{const e=await this._fetch(a,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await oa(e,"update project"),e});return await u.json()}async hasProject({projectId:e,projectName:t}){let r="/sessions";const n=new URLSearchParams;if(void 0!==e&&void 0!==t)throw new Error("Must provide either projectName or projectId, not both");if(void 0!==e)Xr(e),r+=`/${e}`;else{if(void 0===t)throw new Error("Must provide projectName or projectId");n.append("name",t)}const i=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}${r}?${n}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"has project"),e});try{const e=await i.json();return!!i.ok&&(!Array.isArray(e)||e.length>0)}catch(e){return!1}}async readProject({projectId:e,projectName:t,includeStats:r}){let n="/sessions";const i=new URLSearchParams;if(void 0!==e&&void 0!==t)throw new Error("Must provide either projectName or projectId, not both");if(void 0!==e)Xr(e),n+=`/${e}`;else{if(void 0===t)throw new Error("Must provide projectName or projectId");i.append("name",t)}void 0!==r&&i.append("include_stats",r.toString());const o=await this._get(n,i);let a;if(Array.isArray(o)){if(0===o.length)throw new Error(`Project[id=${e}, name=${t}] not found`);a=o[0]}else a=o;return a}async getProjectUrl({projectId:e,projectName:t}){if(void 0===e&&void 0===t)throw new Error("Must provide either projectName or projectId");const r=await this.readProject({projectId:e,projectName:t}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${r.id}`}async getDatasetUrl({datasetId:e,datasetName:t}){if(void 0===e&&void 0===t)throw new Error("Must provide either datasetName or datasetId");const r=await this.readDataset({datasetId:e,datasetName:t}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/datasets/${r.id}`}async _getTenantId(){if(null!==this._tenantId)return this._tenantId;const e=new URLSearchParams({limit:"1"});for await(const t of this._getPaginated("/sessions",e))return this._tenantId=t[0].tenant_id,t[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:e,name:t,nameContains:r,referenceDatasetId:n,referenceDatasetName:i,includeStats:o,datasetVersion:a,referenceFree:s,metadata:c}={}){const u=new URLSearchParams;if(void 0!==e)for(const t of e)u.append("id",t);if(void 0!==t&&u.append("name",t),void 0!==r&&u.append("name_contains",r),void 0!==n)u.append("reference_dataset",n);else if(void 0!==i){const e=await this.readDataset({datasetName:i});u.append("reference_dataset",e.id)}void 0!==o&&u.append("include_stats",o.toString()),void 0!==a&&u.append("dataset_version",a),void 0!==s&&u.append("reference_free",s.toString()),void 0!==c&&u.append("metadata",JSON.stringify(c));for await(const e of this._getPaginated("/sessions",u))yield*e}async deleteProject({projectId:e,projectName:t}){let r;if(void 0===e&&void 0===t)throw new Error("Must provide projectName or projectId");if(void 0!==e&&void 0!==t)throw new Error("Must provide either projectName or projectId, not both");r=void 0===e?(await this.readProject({projectName:t})).id:e,Xr(r),await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/sessions/${r}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,`delete session ${r} (${t})`,!0),e})}async uploadCsv({csvFile:e,fileName:t,inputKeys:r,outputKeys:n,description:i,dataType:o,name:a}){const s=`${this.apiUrl}/datasets/upload`,c=new FormData;c.append("file",e,t),r.forEach(e=>{c.append("input_keys",e)}),n.forEach(e=>{c.append("output_keys",e)}),i&&c.append("description",i),o&&c.append("data_type",o),a&&c.append("name",a);const u=await this.caller.call(async()=>{const e=await this._fetch(s,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await oa(e,"upload CSV"),e});return await u.json()}async createDataset(e,{description:t,dataType:r,inputsSchema:n,outputsSchema:i,metadata:o}={}){const a={name:e,description:t,extra:o?{metadata:o}:void 0};r&&(a.data_type=r),n&&(a.inputs_schema_definition=n),i&&(a.outputs_schema_definition=i);const s=JSON.stringify(a),c=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await oa(e,"create dataset"),e});return await c.json()}async readDataset({datasetId:e,datasetName:t}){let r="/datasets";const n=new URLSearchParams({limit:"1"});if(e&&t)throw new Error("Must provide either datasetName or datasetId, not both");if(e)Xr(e),r+=`/${e}`;else{if(!t)throw new Error("Must provide datasetName or datasetId");n.append("name",t)}const i=await this._get(r,n);let o;if(Array.isArray(i)){if(0===i.length)throw new Error(`Dataset[id=${e}, name=${t}] not found`);o=i[0]}else o=i;return o}async hasDataset({datasetId:e,datasetName:t}){try{return await this.readDataset({datasetId:e,datasetName:t}),!0}catch(e){if(e instanceof Error&&e.message.toLocaleLowerCase().includes("not found"))return!1;throw e}}async diffDatasetVersions({datasetId:e,datasetName:t,fromVersion:r,toVersion:n}){let i=e;if(void 0===i&&void 0===t)throw new Error("Must provide either datasetName or datasetId");if(void 0!==i&&void 0!==t)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===i){i=(await this.readDataset({datasetName:t})).id}const o=new URLSearchParams({from_version:"string"==typeof r?r:r.toISOString(),to_version:"string"==typeof n?n:n.toISOString()});return await this._get(`/datasets/${i}/versions/diff`,o)}async readDatasetOpenaiFinetuning({datasetId:e,datasetName:t}){if(void 0!==e);else{if(void 0===t)throw new Error("Must provide either datasetName or datasetId");e=(await this.readDataset({datasetName:t})).id}const r=await this._getResponse(`/datasets/${e}/openai_ft`);return(await r.text()).trim().split("\n").map(e=>JSON.parse(e))}async*listDatasets({limit:e=100,offset:t=0,datasetIds:r,datasetName:n,datasetNameContains:i,metadata:o}={}){const a=new URLSearchParams({limit:e.toString(),offset:t.toString()});if(void 0!==r)for(const e of r)a.append("id",e);void 0!==n&&a.append("name",n),void 0!==i&&a.append("name_contains",i),void 0!==o&&a.append("metadata",JSON.stringify(o));for await(const e of this._getPaginated("/datasets",a))yield*e}async updateDataset(e){const{datasetId:t,datasetName:r,...n}=e;if(!t&&!r)throw new Error("Must provide either datasetName or datasetId");const i=t??(await this.readDataset({datasetName:r})).id;Xr(i);const o=JSON.stringify(n),a=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/datasets/${i}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await oa(e,"update dataset"),e});return await a.json()}async updateDatasetTag(e){const{datasetId:t,datasetName:r,asOf:n,tag:i}=e;if(!t&&!r)throw new Error("Must provide either datasetName or datasetId");const o=t??(await this.readDataset({datasetName:r})).id;Xr(o);const a=JSON.stringify({as_of:"string"==typeof n?n:n.toISOString(),tag:i});await this.caller.call(async()=>{const e=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:a});return await oa(e,"update dataset tags",!0),e})}async deleteDataset({datasetId:e,datasetName:t}){let r="/datasets",n=e;if(void 0!==e&&void 0!==t)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0!==t){n=(await this.readDataset({datasetName:t})).id}if(void 0===n)throw new Error("Must provide datasetName or datasetId");Xr(n),r+=`/${n}`,await this.caller.call(async()=>{const e=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,`delete ${r}`,!0),e})}async indexDataset({datasetId:e,datasetName:t,tag:r}){let n=e;if(!n&&!t)throw new Error("Must provide either datasetName or datasetId");if(n&&t)throw new Error("Must provide either datasetName or datasetId, not both");if(!n){const e=await this.readDataset({datasetName:t});n=e.id}Xr(n);const i={tag:r},o=JSON.stringify(i),a=await this.caller.call(async()=>{const e=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 oa(e,"index dataset"),e});await a.json()}async similarExamples(e,t,r,{filter:n}={}){const i={limit:r,inputs:e};void 0!==n&&(i.filter=n),Xr(t);const o=JSON.stringify(i),a=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/datasets/${t}/search`,{headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,method:"POST",body:o});return await oa(e,"fetch similar examples"),e});return(await a.json()).examples}async createExample(e,t,r){if(Ta(e)&&(void 0!==t||void 0!==r))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let n=t?r?.datasetId:e.dataset_id;const i=t?r?.datasetName:e.dataset_name;if(void 0===n&&void 0===i)throw new Error("Must provide either datasetName or datasetId");if(void 0!==n&&void 0!==i)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===n){n=(await this.readDataset({datasetName:i})).id}const o=(t?r?.createdAt:e.created_at)||new Date;let a;a=Ta(e)?e:{inputs:e,outputs:t,created_at:o?.toISOString(),id:r?.exampleId,metadata:r?.metadata,split:r?.split,source_run_id:r?.sourceRunId,use_source_run_io:r?.useSourceRunIO,use_source_run_attachments:r?.useSourceRunAttachments,attachments:r?.attachments};const s=await this._uploadExamplesMultipart(n,[a]);return await this.readExample(s.example_ids?.[0]??hr())}async createExamples(e){if(Array.isArray(e)){if(0===e.length)return[];const t=e;let r=t[0].dataset_id;const n=t[0].dataset_name;if(void 0===r&&void 0===n)throw new Error("Must provide either datasetName or datasetId");if(void 0!==r&&void 0!==n)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===r){r=(await this.readDataset({datasetName:n})).id}const i=await this._uploadExamplesMultipart(r,t);return await Promise.all(i.example_ids.map(e=>this.readExample(e)))}const{inputs:t,outputs:r,metadata:n,splits:i,sourceRunIds:o,useSourceRunIOs:a,useSourceRunAttachments:s,attachments:c,exampleIds:u,datasetId:l,datasetName:d}=e;if(void 0===t)throw new Error("Must provide inputs when using legacy parameters");let f=l;const p=d;if(void 0===f&&void 0===p)throw new Error("Must provide either datasetName or datasetId");if(void 0!==f&&void 0!==p)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===f){const e=await this.readDataset({datasetName:p});f=e.id}const h=t.map((e,t)=>({dataset_id:f,inputs:e,outputs:r?.[t],metadata:n?.[t],split:i?.[t],id:u?.[t],attachments:c?.[t],source_run_id:o?.[t],use_source_run_io:a?.[t],use_source_run_attachments:s?.[t]})),m=await this._uploadExamplesMultipart(f,h);return await Promise.all(m.example_ids.map(e=>this.readExample(e)))}async createLLMExample(e,t,r){return this.createExample({input:e},{output:t},r)}async createChatExample(e,t,r){const n=e.map(e=>Zn(e)?Jn(e):e),i=Zn(t)?Jn(t):t;return this.createExample({input:n},{output:i},r)}async readExample(e){Xr(e);const t=`/examples/${e}`,r=await this._get(t),{attachment_urls:n,...i}=r,o=i;return n&&(o.attachments=Object.entries(n).reduce((e,[t,r])=>(e[t.slice(11)]={presigned_url:r.presigned_url,mime_type:r.mime_type},e),{})),o}async*listExamples({datasetId:e,datasetName:t,exampleIds:r,asOf:n,splits:i,inlineS3Urls:o,metadata:a,limit:s,offset:c,filter:u,includeAttachments:l}={}){let d;if(void 0!==e&&void 0!==t)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0!==e)d=e;else{if(void 0===t)throw new Error("Must provide a datasetName or datasetId");d=(await this.readDataset({datasetName:t})).id}const f=new URLSearchParams({dataset:d}),p=n?"string"==typeof n?n:n?.toISOString():void 0;p&&f.append("as_of",p);const h=o??!0;if(f.append("inline_s3_urls",h.toString()),void 0!==r)for(const e of r)f.append("id",e);if(void 0!==i)for(const e of i)f.append("splits",e);if(void 0!==a){const e=JSON.stringify(a);f.append("metadata",e)}void 0!==s&&f.append("limit",s.toString()),void 0!==c&&f.append("offset",c.toString()),void 0!==u&&f.append("filter",u),!0===l&&["attachment_urls","outputs","metadata"].forEach(e=>f.append("select",e));let m=0;for await(const e of this._getPaginated("/examples",f)){for(const t of e){const{attachment_urls:e,...r}=t,n=r;e&&(n.attachments=Object.entries(e).reduce((e,[t,r])=>(e[t.slice(11)]={presigned_url:r.presigned_url,mime_type:r.mime_type||void 0},e),{})),yield n,m++}if(void 0!==s&&m>=s)break}}async deleteExample(e){Xr(e);const t=`/examples/${e}`;await this.caller.call(async()=>{const e=await this._fetch(this.apiUrl+t,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,`delete ${t}`,!0),e})}async deleteExamples(e,t){if(e.forEach(e=>Xr(e)),t?.hardDelete){const t=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}${t}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},body:JSON.stringify({example_ids:e,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(r,"hard delete examples",!0),r})}else{const t=new URLSearchParams;e.forEach(e=>t.append("example_ids",e)),await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/examples?${t.toString()}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"delete examples",!0),e})}}async updateExample(e,t){let r,n,i;if(r=t?e:e.id,Xr(r),n=t?{id:r,...t}:e,void 0!==n.dataset_id)i=n.dataset_id;else{i=(await this.readExample(r)).dataset_id}return this._updateExamplesMultipart(i,[n])}async updateExamples(e){let t;if(void 0===e[0].dataset_id){t=(await this.readExample(e[0].id)).dataset_id}else t=e[0].dataset_id;return this._updateExamplesMultipart(t,e)}async readDatasetVersion({datasetId:e,datasetName:t,asOf:r,tag:n}){let i;if(e)i=e;else{const e=await this.readDataset({datasetName:t});i=e.id}if(Xr(i),r&&n||!r&&!n)throw new Error("Exactly one of asOf and tag must be specified.");const o=new URLSearchParams;void 0!==r&&o.append("as_of","string"==typeof r?r:r.toISOString()),void 0!==n&&o.append("tag",n);const a=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/datasets/${i}/version?${o.toString()}`,{method:"GET",headers:{...this.headers},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"read dataset version"),e});return await a.json()}async listDatasetSplits({datasetId:e,datasetName:t,asOf:r}){let n;if(void 0===e&&void 0===t)throw new Error("Must provide dataset name or ID");if(void 0!==e&&void 0!==t)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===e){n=(await this.readDataset({datasetName:t})).id}else n=e;Xr(n);const i=new URLSearchParams,o=r?"string"==typeof r?r:r?.toISOString():void 0;o&&i.append("as_of",o);return await this._get(`/datasets/${n}/splits`,i)}async updateDatasetSplits({datasetId:e,datasetName:t,splitName:r,exampleIds:n,remove:i=!1}){let o;if(void 0===e&&void 0===t)throw new Error("Must provide dataset name or ID");if(void 0!==e&&void 0!==t)throw new Error("Must provide either datasetName or datasetId, not both");if(void 0===e){const e=await this.readDataset({datasetName:t});o=e.id}else o=e;Xr(o);const a={split_name:r,examples:n.map(e=>(Xr(e),e)),remove:i},s=JSON.stringify(a);await this.caller.call(async()=>{const e=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:s});return await oa(e,"update dataset splits",!0),e})}async evaluateRun(e,t,{sourceInfo:r,loadChildRuns:n,referenceExample:i}={loadChildRuns:!1}){let o;if(Yr("This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead."),"string"==typeof e)o=await this.readRun(e,{loadChildRuns:n});else{if("object"!=typeof e||!("id"in e))throw new Error("Invalid run type: "+typeof e);o=e}null!==o.reference_example_id&&void 0!==o.reference_example_id&&(i=await this.readExample(o.reference_example_id));const a=await t.evaluateRun(o,i),[s,c]=await this._logEvaluationFeedback(a,o,r);return c[0]}async createFeedback(e,t,{score:r,value:n,correction:i,comment:o,sourceInfo:a,feedbackSourceType:s="api",sourceRunId:c,feedbackId:u,feedbackConfig:l,projectId:d,comparativeExperimentId:f}){if(!e&&!d)throw new Error("One of runId or projectId must be provided");if(e&&d)throw new Error("Only one of runId or projectId can be provided");const p={type:s??"api",metadata:a??{}};void 0===c||void 0===p?.metadata||p.metadata.__run||(p.metadata.__run={run_id:c}),void 0!==p?.metadata&&void 0!==p.metadata.__run?.run_id&&Xr(p.metadata.__run.run_id);const h={id:u??hr(),run_id:e,key:t,score:_a(r),value:n,correction:i,comment:o,feedback_source:p,comparative_experiment_id:f,feedbackConfig:l,session_id:d},m=JSON.stringify(h),y=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{const e=await this._fetch(y,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:m});return await oa(e,"create feedback",!0),e}),h}async updateFeedback(e,{score:t,value:r,correction:n,comment:i}){const o={};null!=t&&(o.score=_a(t)),null!=r&&(o.value=r),null!=n&&(o.correction=n),null!=i&&(o.comment=i),Xr(e);const a=JSON.stringify(o);await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/feedback/${e}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await oa(t,"update feedback",!0),t})}async readFeedback(e){Xr(e);const t=`/feedback/${e}`;return await this._get(t)}async deleteFeedback(e){Xr(e);const t=`/feedback/${e}`;await this.caller.call(async()=>{const e=await this._fetch(this.apiUrl+t,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,`delete ${t}`,!0),e})}async*listFeedback({runIds:e,feedbackKeys:t,feedbackSourceTypes:r}={}){const n=new URLSearchParams;if(e)for(const t of e)Xr(t),n.append("run",t);if(t)for(const e of t)n.append("key",e);if(r)for(const e of r)n.append("source",e);for await(const e of this._getPaginated("/feedback",n))yield*e}async createPresignedFeedbackToken(e,t,{expiration:r,feedbackConfig:n}={}){const i={run_id:e,feedback_key:t,feedback_config:n};r?"string"==typeof r?i.expires_at=r:(r?.hours||r?.minutes||r?.days)&&(i.expires_in=r):i.expires_in={hours:3};const o=JSON.stringify(i),a=await this.caller.call(async()=>{const e=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 oa(e,"create presigned feedback token"),e});return await a.json()}async createComparativeExperiment({name:e,experimentIds:t,referenceDatasetId:r,createdAt:n,description:i,metadata:o,id:a}){if(0===t.length)throw new Error("At least one experiment is required");if(r||(r=(await this.readProject({projectId:t[0]})).reference_dataset_id),null==!r)throw new Error("A reference dataset is required");const s={id:a,name:e,experiment_ids:t,reference_dataset_id:r,description:i,created_at:(n??new Date)?.toISOString(),extra:{}};o&&(s.extra.metadata=o);const c=JSON.stringify(s);return(await this.caller.call(async()=>{const e=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:c});return await oa(e,"create comparative experiment"),e})).json()}async*listPresignedFeedbackTokens(e){Xr(e);const t=new URLSearchParams({run_id:e});for await(const e of this._getPaginated("/feedback/tokens",t))yield*e}_selectEvalResults(e){let t;return t="results"in e?e.results:Array.isArray(e)?e:[e],t}async _logEvaluationFeedback(e,t,r){const n=this._selectEvalResults(e),i=[];for(const e of n){let n=r||{};e.evaluatorInfo&&(n={...e.evaluatorInfo,...n});let o=null;e.targetRunId?o=e.targetRunId:t&&(o=t.id),i.push(await this.createFeedback(o,e.key,{score:e.score,value:e.value,comment:e.comment,correction:e.correction,sourceInfo:n,sourceRunId:e.sourceRunId,feedbackConfig:e.feedbackConfig,feedbackSourceType:"model"}))}return[n,i]}async logEvaluationFeedback(e,t,r){const[n]=await this._logEvaluationFeedback(e,t,r);return n}async*listAnnotationQueues(e={}){const{queueIds:t,name:r,nameContains:n,limit:i}=e,o=new URLSearchParams;t&&t.forEach((e,t)=>{Xr(e,`queueIds[${t}]`),o.append("ids",e)}),r&&o.append("name",r),n&&o.append("name_contains",n),o.append("limit",(void 0!==i?Math.min(i,100):100).toString());let a=0;for await(const e of this._getPaginated("/annotation-queues",o))if(yield*e,a++,void 0!==i&&a>=i)break}async createAnnotationQueue(e){const{name:t,description:r,queueId:n,rubricInstructions:i}=e,o={name:t,description:r,id:n||hr(),rubric_instructions:i},a=JSON.stringify(Object.fromEntries(Object.entries(o).filter(([e,t])=>void 0!==t)));return(await this.caller.call(async()=>{const e=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:a});return await oa(e,"create annotation queue"),e})).json()}async readAnnotationQueue(e){return(await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"read annotation queue"),t})).json()}async updateAnnotationQueue(e,t){const{name:r,description:n,rubricInstructions:i}=t,o=JSON.stringify({name:r,description:n,rubric_instructions:i});await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await oa(t,"update annotation queue",!0),t})}async deleteAnnotationQueue(e){await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"delete annotation queue",!0),t})}async addRunsToAnnotationQueue(e,t){const r=JSON.stringify(t.map((e,t)=>Xr(e,`runIds[${t}]`).toString()));await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}/runs`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await oa(t,"add runs to annotation queue",!0),t})}async getRunFromAnnotationQueue(e,t){const r=`/annotation-queues/${Xr(e,"queueId")}/run`;return(await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}${r}/${t}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"get run from annotation queue"),e})).json()}async deleteRunFromAnnotationQueue(e,t){await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}/runs/${Xr(t,"queueRunId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(r,"delete run from annotation queue",!0),r})}async getSizeFromAnnotationQueue(e){return(await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${Xr(e,"queueId")}/size`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"get size from annotation queue"),t})).json()}async _currentTenantIsOwner(e){const t=await this._getSettings();return"-"==e||t.tenant_handle===e}async _ownerConflictError(e,t){const r=await this._getSettings();return new Error(`Cannot ${e} for another tenant.\n\n Current tenant: ${r.tenant_handle}\n\n Requested tenant: ${t}`)}async _getLatestCommitHash(e){const t=await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/commits/${e}/?limit=1&offset=0`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(t,"get latest commit hash"),t}),r=await t.json();if(0!==r.commits.length)return r.commits[0].commit_hash}async _likeOrUnlikePrompt(e,t){const[r,n,i]=na(e),o=JSON.stringify({like:t});return(await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/likes/${r}/${n}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await oa(e,(t?"like":"unlike")+" prompt"),e})).json()}async _getPromptUrl(e){const[t,r,n]=na(e);if(await this._currentTenantIsOwner(t)){const e=await this._getSettings();return"latest"!==n?`${this.getHostUrl()}/prompts/${r}/${n.substring(0,8)}?organizationId=${e.id}`:`${this.getHostUrl()}/prompts/${r}?organizationId=${e.id}`}return"latest"!==n?`${this.getHostUrl()}/hub/${t}/${r}/${n.substring(0,8)}`:`${this.getHostUrl()}/hub/${t}/${r}`}async promptExists(e){return!!await this.getPrompt(e)}async likePrompt(e){return this._likeOrUnlikePrompt(e,!0)}async unlikePrompt(e){return this._likeOrUnlikePrompt(e,!1)}async*listCommits(e){for await(const t of this._getPaginated(`/commits/${e}/`,new URLSearchParams,e=>e.commits))yield*t}async*listPrompts(e){const t=new URLSearchParams;t.append("sort_field",e?.sortField??"updated_at"),t.append("sort_direction","desc"),t.append("is_archived",(!!e?.isArchived).toString()),void 0!==e?.isPublic&&t.append("is_public",e.isPublic.toString()),e?.query&&t.append("query",e.query);for await(const e of this._getPaginated("/repos",t,e=>e.repos))yield*e}async getPrompt(e){const[t,r,n]=na(e),i=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return 404===e?.status?null:(await oa(e,"get prompt"),e)}),o=await(i?.json());return o?.repo?o.repo:null}async createPrompt(e,t){const r=await this._getSettings();if(t?.isPublic&&!r.tenant_handle)throw new Error("Cannot create a public prompt without first\n\n creating a LangChain Hub handle.\n You can add a handle by creating a public prompt at:\n\n https://smith.langchain.com/prompts");const[n,i,o]=na(e);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("create a prompt",n);const a={repo_handle:i,...t?.description&&{description:t.description},...t?.readme&&{readme:t.readme},...t?.tags&&{tags:t.tags},is_public:!!t?.isPublic},s=JSON.stringify(a),c=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await oa(e,"create prompt"),e}),{repo:u}=await c.json();return u}async createCommit(e,t,r){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[n,i,o]=na(e),a="latest"!==r?.parentCommitHash&&r?.parentCommitHash?r?.parentCommitHash:await this._getLatestCommitHash(`${n}/${i}`),s={manifest:JSON.parse(JSON.stringify(t)),parent_commit:a},c=JSON.stringify(s),u=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/commits/${n}/${i}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await oa(e,"create commit"),e}),l=await u.json();return this._getPromptUrl(`${n}/${i}${l.commit_hash?`:${l.commit_hash}`:""}`)}async updateExamplesMultipart(e,t=[]){return this._updateExamplesMultipart(e,t)}async _updateExamplesMultipart(e,t=[]){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.");const r=new FormData;for(const e of t){const t=e.id,n=ma({...e.metadata&&{metadata:e.metadata},...e.split&&{split:e.split}},`Serializing body for example with id: ${t}`),i=new Blob([n],{type:"application/json"});if(r.append(t,i),e.inputs){const n=ma(e.inputs,`Serializing inputs for example with id: ${t}`),i=new Blob([n],{type:"application/json"});r.append(`${t}.inputs`,i)}if(e.outputs){const n=ma(e.outputs,`Serializing outputs whle updating example with id: ${t}`),i=new Blob([n],{type:"application/json"});r.append(`${t}.outputs`,i)}if(e.attachments)for(const[n,i]of Object.entries(e.attachments)){let e,o;Array.isArray(i)?[e,o]=i:(e=i.mimeType,o=i.data);const a=new Blob([o],{type:`${e}; length=${o.byteLength}`});r.append(`${t}.attachment.${n}`,a)}if(e.attachments_operations){const n=ma(e.attachments_operations,`Serializing attachments while updating example with id: ${t}`),i=new Blob([n],{type:"application/json"});r.append(`${t}.attachments_operations`,i)}}const n=e??t[0]?.dataset_id;return(await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${n}/examples`)}`,{method:"PATCH",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await oa(e,"update examples"),e})).json()}async uploadExamplesMultipart(e,t=[]){return this._uploadExamplesMultipart(e,t)}async _uploadExamplesMultipart(e,t=[]){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.");const r=new FormData;for(const e of t){const t=(e.id??hr()).toString(),n=ma({created_at:e.created_at,...e.metadata&&{metadata:e.metadata},...e.split&&{split:e.split},...e.source_run_id&&{source_run_id:e.source_run_id},...e.use_source_run_io&&{use_source_run_io:e.use_source_run_io},...e.use_source_run_attachments&&{use_source_run_attachments:e.use_source_run_attachments}},`Serializing body for uploaded example with id: ${t}`),i=new Blob([n],{type:"application/json"});if(r.append(t,i),e.inputs){const n=ma(e.inputs,`Serializing inputs for uploaded example with id: ${t}`),i=new Blob([n],{type:"application/json"});r.append(`${t}.inputs`,i)}if(e.outputs){const n=ma(e.outputs,`Serializing outputs for uploaded example with id: ${t}`),i=new Blob([n],{type:"application/json"});r.append(`${t}.outputs`,i)}if(e.attachments)for(const[n,i]of Object.entries(e.attachments)){let e,o;Array.isArray(i)?[e,o]=i:(e=i.mimeType,o=i.data);const a=new Blob([o],{type:`${e}; length=${o.byteLength}`});r.append(`${t}.attachment.${n}`,a)}}return(await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${e}/examples`)}`,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await oa(t,"upload examples"),t})).json()}async updatePrompt(e,t){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[r,n]=na(e);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("update a prompt",r);const i={};if(void 0!==t?.description&&(i.description=t.description),void 0!==t?.readme&&(i.readme=t.readme),void 0!==t?.tags&&(i.tags=t.tags),void 0!==t?.isPublic&&(i.is_public=t.isPublic),void 0!==t?.isArchived&&(i.is_archived=t.isArchived),0===Object.keys(i).length)throw new Error("No valid update options provided");const o=JSON.stringify(i);return(await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await oa(e,"update prompt"),e})).json()}async deletePrompt(e){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[t,r,n]=na(e);if(!await this._currentTenantIsOwner(t))throw await this._ownerConflictError("delete a prompt",t);return(await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"delete prompt"),e})).json()}async pullPromptCommit(e,t){const[r,n,i]=na(e),o=await this.caller.call(async()=>{const e=await this._fetch(`${this.apiUrl}/commits/${r}/${n}/${i}${t?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await oa(e,"pull prompt commit"),e}),a=await o.json();return{owner:r,repo:n,commit_hash:a.commit_hash,manifest:a.manifest,examples:a.examples}}async _pullPrompt(e,t){const r=await this.pullPromptCommit(e,{includeModel:t?.includeModel});return JSON.stringify(r.manifest)}async pushPrompt(e,t){if(await this.promptExists(e)?t&&Object.keys(t).some(e=>"object"!==e)&&await this.updatePrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic}):await this.createPrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic}),!t?.object)return await this._getPromptUrl(e);return await this.createCommit(e,t?.object,{parentCommitHash:t?.parentCommitHash})}async clonePublicDataset(e,t={}){const{sourceApiUrl:r=this.apiUrl,datasetName:n}=t,[i,o]=this.parseTokenOrUrl(e,r),a=new Aa({apiUrl:i,apiKey:"placeholder"}),s=await a.readSharedDataset(o),c=n||s.name;try{if(await this.hasDataset({datasetId:c}))return void console.log(`Dataset ${c} already exists in your tenant. Skipping.`)}catch(e){}const u=await a.listSharedExamples(o),l=await this.createDataset(c,{description:s.description,dataType:s.data_type||"kv",inputsSchema:s.inputs_schema_definition??void 0,outputsSchema:s.outputs_schema_definition??void 0});try{await this.createExamples({inputs:u.map(e=>e.inputs),outputs:u.flatMap(e=>e.outputs?[e.outputs]:[]),datasetId:l.id})}catch(e){throw console.error(`An error occurred while creating dataset ${c}. You should delete it manually.`),e}}parseTokenOrUrl(e,t,r=2,n="dataset"){try{return Xr(e),[t,e]}catch(e){}try{const i=new URL(e).pathname.split("/").filter(e=>""!==e);if(i.length>=r){return[t,i[i.length-r]]}throw new Error(`Invalid public ${n} URL: ${e}`)}catch(t){throw new Error(`Invalid public ${n} URL or token: ${e}`)}}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 Promise.all([...this.autoBatchQueue.items.map(({itemPromise:e})=>e),this.batchIngestCaller.queue.onIdle()]),void 0!==this.langSmithToOTELTranslator&&await(vn.getDefaultOTLPTracerComponents()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush())}}function Ta(e){return"dataset_id"in e||"dataset_name"in e}const xa=Symbol.for("lc:context_variables"),Ia=Symbol.for("langsmith:replica_trace_roots");function ka(e,t){if(xa in e){return e[xa][t]}}const ja="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function Ra(e){const t=Object.keys(e).sort().map(t=>`${t}:${e[t]??""}`).join("|");return gr(t,ja)}function Na(e,t=1){const r=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${r}Z`}function Pa(e,t,r=1){const n=Na(e,r);return{dottedOrder:(i=n,i.replace(/[-:.]/g,"")+t),microsecondPrecisionDatestring:n};var i}class Ca{constructor(e,t,r,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=e,this.tags=t,this.project_name=r,this.replicas=n}static fromHeader(e){const t=e.split(",");let r,n,i={},o=[];for(const e of t){const[t,a]=e.split("="),s=decodeURIComponent(a);"langsmith-metadata"===t?i=JSON.parse(s):"langsmith-tags"===t?o=s.split(","):"langsmith-project"===t?r=s:"langsmith-replicas"===t&&(n=JSON.parse(s))}return new Ca(i,o,r,n)}toHeader(){const e=[];return this.metadata&&Object.keys(this.metadata).length>0&&e.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&e.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&e.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),e.join(",")}}class La{constructor(e){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}),null!=(t=e)&&"function"==typeof t.createChild&&"function"==typeof t.postRun)return void Object.assign(this,{...e});var t;const r=La.getDefaultConfig(),{metadata:n,...i}=e,o=i.client??La.getSharedClient(),a={...n,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:a},"id"in i&&null==i.id&&delete i.id,Object.assign(this,{...r,...i,client:o}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=Na(this.start_time,this.execution_order)),this.id||(this.id=en(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=function(e){if(e)return e.map(e=>Array.isArray(e)?{projectName:e[0],updates:e[1]}:e);return function(){const e=ln("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t)){const e=[];for(const r of t)"object"==typeof r&&null!==r?"string"==typeof r.api_url?"string"==typeof r.api_key?e.push({apiUrl:r.api_url.replace(/\/$/,""),apiKey:r.api_key}):console.warn("Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got "+typeof r.api_key):console.warn("Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got "+typeof r.api_url):console.warn("Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got "+typeof r);return e}if("object"==typeof t&&null!==t){!function(e){if(Object.keys(e).length>0&&dn("ENDPOINT"))throw new sa}(t);const e=[];for(const[r,n]of Object.entries(t)){const t=r.replace(/\/$/,"");"string"==typeof n?e.push({apiUrl:t,apiKey:n}):console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${r}: expected string, got `+typeof n)}return e}return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got "+typeof t),[]}catch(e){if("object"==typeof(t=e)&&null!==t&&t.code===aa)throw e;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}var t}()}(this.replicas),!this.dotted_order){const{dottedOrder:e}=Pa(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+e:this.dotted_order=e}}set metadata(e){this.extra={...this.extra,metadata:{...this.extra?.metadata,...e}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){const e=Date.now();return{run_type:"chain",project_name:Zr(),child_runs:[],api_url:ln("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:ln("LANGCHAIN_API_KEY"),caller_options:{},start_time:e,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return La.sharedClient||(La.sharedClient=new Aa),La.sharedClient}createChild(e){const t=this.child_execution_order+1,r=this.replicas?.map(e=>{const{reroot:t,...r}=e;return r}),n=e.replicas??r,i=new La({...e,parent_run:this,project_name:this.project_name,replicas:n,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:t,child_execution_order:t});xa in this&&(i[xa]=this[xa]);const o=Symbol.for("lc:child_config"),a=e.extra?.[o]??this.extra[o];if(function(e){const t=e?.callbacks;return null!=e&&"object"==typeof t&&($a(t?.handlers)||$a(t))}(a)){const e={...a},t="object"==typeof(s=e.callbacks)&&null!=s&&Array.isArray(s.handlers)?e.callbacks.copy?.():void 0;t&&(Object.assign(t,{_parentRunId:i.id}),t.handlers?.find(Ma)?.updateFromRunTree?.(i),e.callbacks=t),i.extra[o]=e}var s;const c=new Set;let u=this;for(;null!=u&&!c.has(u.id);)c.add(u.id),u.child_execution_order=Math.max(u.child_execution_order,t),u=u.parent_run;return this.child_runs.push(i),i}async end(e,t,r=Date.now(),n){this.outputs=this.outputs??e,this.error=this.error??t,this.end_time=this.end_time??r,n&&Object.keys(n).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...n}}:{metadata:n})}_convertToCreate(e,t,r=!0){const n=e.extra??{};if(void 0===n?.runtime?.library&&(n.runtime||(n.runtime={}),t))for(const[e,r]of Object.entries(t))n.runtime[e]||(n.runtime[e]=r);let i,o;return r?(o=e.parent_run?.id??e.parent_run_id,i=[]):(i=e.child_runs.map(e=>this._convertToCreate(e,t,r)),o=void 0),{id:e.id,name:e.name,start_time:e._serialized_start_time??e.start_time,end_time:e.end_time,run_type:e.run_type,reference_example_id:e.reference_example_id,extra:n,serialized:e.serialized,error:e.error,inputs:e.inputs,outputs:e.outputs,session_name:e.project_name,child_runs:i,parent_run_id:o,trace_id:e.trace_id,dotted_order:e.dotted_order,tags:e.tags,attachments:e.attachments,events:e.events}}_sliceParentId(e,t){if(t.dotted_order){const r=t.dotted_order.split(".");let n=null;for(let t=0;t<r.length;t++){if(r[t].slice(-36)===e){n=t;break}}if(null!==n){const e=r.slice(n+1);t.dotted_order=e.join("."),e.length>0?t.trace_id=e[0].slice(-36):t.trace_id=t.id}}t.parent_run_id===e&&(t.parent_run_id=void 0)}_setReplicaTraceRoot(e,t){const r=ka(this,Ia)??{};r[e]=t,function(e,t,r){const n=xa in e?e[xa]:{};n[t]=r,e[xa]=n}(this,Ia,r);for(const r of this.child_runs)r._setReplicaTraceRoot(e,t)}_remapForProject(e){const{projectName:t,runtimeEnv:r,excludeChildRuns:n=!0,reroot:i=!1,distributedParentId:o,apiUrl:a,apiKey:s,workspaceId:c}=e,u=this._convertToCreate(this,r,n);if(t===this.project_name)return{...u,session_name:t};if(i){if(o)this._sliceParentId(o,u);else if(u.parent_run_id=void 0,u.dotted_order){const e=u.dotted_order.split(".");e.length>0&&(u.dotted_order=e[e.length-1],u.trace_id=u.id)}const e=Ra({projectName:t,apiUrl:a,apiKey:s,workspaceId:c});this._setReplicaTraceRoot(e,u.id)}let l;if(!i){if(l=(ka(this,Ia)??{})[Ra({projectName:t,apiUrl:a,apiKey:s,workspaceId:c})],l&&(u.trace_id=l,u.dotted_order)){const e=u.dotted_order.split(".");let t=null;for(let r=0;r<e.length;r++){if(e[r].slice(-36)===l){t=r;break}}if(null!==t){const r=e.slice(t);u.dotted_order=r.join(".")}}}const d=u.id,f=gr(`${d}:${t}`,ja);let p,h,m;if(p=u.trace_id?gr(`${u.trace_id}:${t}`,ja):f,u.parent_run_id&&(h=gr(`${u.parent_run_id}:${t}`,ja)),u.dotted_order){m=u.dotted_order.split(".").map(e=>{const r=e.slice(-36),n=gr(`${r}:${t}`,ja);return e.slice(0,-36)+n}).join(".")}return{...u,id:f,trace_id:p,parent_run_id:h,dotted_order:m,session_name:t}}async postRun(e=!0){try{const t=cn();if(this.replicas&&this.replicas.length>0)for(const{projectName:e,apiKey:r,apiUrl:n,workspaceId:i,reroot:o}of this.replicas){const a=this._remapForProject({projectName:e??this.project_name,runtimeEnv:t,excludeChildRuns:!0,reroot:o,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:r,workspaceId:i});await this.client.createRun(a,{apiKey:r,apiUrl:n,workspaceId:i})}else{const r=this._convertToCreate(this,t,e);await this.client.createRun(r)}if(!e){Yr("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(const e of this.child_runs)await e.postRun(!1)}}catch(e){console.error(`Error in postRun for run ${this.id}:`,e)}}async patchRun(e){if(this.replicas&&this.replicas.length>0)for(const{projectName:t,apiKey:r,apiUrl:n,workspaceId:i,updates:o,reroot:a}of this.replicas){const s=this._remapForProject({projectName:t??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:a,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:r,workspaceId:i}),c={id:s.id,name:s.name,run_type:s.run_type,start_time:s.start_time,outputs:s.outputs,error:s.error,parent_run_id:s.parent_run_id,session_name:s.session_name,reference_example_id:s.reference_example_id,end_time:s.end_time,dotted_order:s.dotted_order,trace_id:s.trace_id,events:s.events,tags:s.tags,extra:s.extra,attachments:this.attachments,...o};e?.excludeInputs||(c.inputs=s.inputs),await this.client.updateRun(s.id,c,{apiKey:r,apiUrl:n,workspaceId:i})}else try{const t={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};e?.excludeInputs||(t.inputs=this.inputs),await this.client.updateRun(this.id,t)}catch(e){console.error(`Error in patchRun for run ${this.id}`,e)}}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(e){this.events||(this.events=[]),"string"==typeof e?this.events.push({name:"event",time:(new Date).toISOString(),message:e}):this.events.push({...e,time:e.time??(new Date).toISOString()})}static fromRunnableConfig(e,t){const r=e?.callbacks;let n,i,o,a=!!["TRACING_V2","TRACING"].find(e=>"true"===dn(e));if(r){const e=r?.getParentRunId?.()??"",t=r?.handlers?.find(e=>"langchain_tracer"==e?.name);n=t?.getRun?.(e),i=t?.projectName,o=t?.client,a=a||!!t}if(!n)return new La({...t,client:o,tracingEnabled:a,project_name:i});return new La({name:n.name,id:n.id,trace_id:n.trace_id,dotted_order:n.dotted_order,client:o,tracingEnabled:a,project_name:i,tags:[...new Set((n?.tags??[]).concat(e?.tags??[]))],extra:{metadata:{...n?.extra?.metadata,...e?.metadata}}}).createChild(t)}static fromDottedOrder(e){return this.fromHeaders({"langsmith-trace":e})}static fromHeaders(e,t){const r="get"in e&&"function"==typeof e.get?{"langsmith-trace":e.get("langsmith-trace"),baggage:e.get("baggage")}:e,n=r["langsmith-trace"];if(!n||"string"!=typeof n)return;const i=n.trim(),o=i.split(".").map(e=>{const[t,r]=e.split("Z");return{strTime:t,time:Date.parse(t+"Z"),uuid:r}}),a=o[0].uuid,s={...t,name:t?.name??"parent",run_type:t?.run_type??"chain",start_time:t?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:a,dotted_order:i};if(r.baggage&&"string"==typeof r.baggage){const e=Ca.fromHeader(r.baggage);s.metadata=e.metadata,s.tags=e.tags,s.project_name=e.project_name,s.replicas=e.replicas}const c=new La(s);return c.distributedParentId=c.id,c}toHeaders(e){const t={"langsmith-trace":this.dotted_order,baggage:new Ca(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(e)for(const[r,n]of Object.entries(t))e.set(r,n);return t}}function Ma(e){return"object"==typeof e&&null!=e&&"string"==typeof e.name&&"langchain_tracer"===e.name}function $a(e){return Array.isArray(e)&&e.some(e=>Ma(e))}Object.defineProperty(La,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});const Da=()=>"undefined"!=typeof Deno,Ba=()=>{let e;return e="undefined"!=typeof window&&void 0!==window.document?"browser":"undefined"==typeof process||void 0===process.versions||void 0===process.versions.node||Da()?"object"==typeof globalThis&&globalThis.constructor&&"DedicatedWorkerGlobalScope"===globalThis.constructor.name?"webworker":"undefined"!=typeof window&&"nodejs"===window.name||"undefined"!=typeof navigator&&navigator.userAgent.includes("jsdom")?"jsdom":Da()?"deno":"other":"node",e};let Fa;function Ua(){if(void 0===Fa){const e=Ba();Fa={library:"langchain-js",runtime:e}}return Fa}function za(e){try{return"undefined"!=typeof process?process.env?.[e]:Da()?Deno?.env.get(e):void 0}catch(e){return}}class Ga{}class qa extends Ga{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,te(this.constructor)]}constructor(e){super(),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ignoreLLM",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreChain",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreAgent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreRetriever",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreCustomEvent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"raiseError",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"awaitHandlers",{enumerable:!0,configurable:!0,writable:!0,value:"false"===za("LANGCHAIN_CALLBACKS_BACKGROUND")}),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 re.prototype.toJSON.call(this)}toJSONNotImplemented(){return re.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){return new class extends qa{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:hr()}),Object.assign(this,e)}}}}const Va=e=>{const t=e;return void 0!==t&&"function"==typeof t.copy&&"string"==typeof t.name&&"boolean"==typeof t.awaitHandlers};function Wa(e,t){if(e)return new La({...e,start_time:e._serialized_start_time??e.start_time,parent_run:Wa(t),child_runs:e.child_runs.map(e=>Wa(e)).filter(e=>void 0!==e),extra:{...e.extra,runtime:Ua()},tracingEnabled:!1})}function Ha(e,t){return e&&!Array.isArray(e)&&"object"==typeof e?e:{[t]:e}}function Ka(e){return"function"==typeof e._addRunToRunMap}class Za extends qa{constructor(e){super(...arguments),Object.defineProperty(this,"runMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"runTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"usesRunTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:!1})}copy(){return this}getRunById(e){if(void 0!==e)return this.usesRunTreeMap?(e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e})(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`\n\n${e.stack}`:""):"string"==typeof e?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){const{dottedOrder:t,microsecondPrecisionDatestring:r}=Pa(new Date(e.start_time).getTime(),e.id,e.execution_order),n={...e},i=this.getRunById(n.parent_run_id);if(void 0!==n.parent_run_id?i&&(this._addChildRun(i,n),i.child_execution_order=Math.max(i.child_execution_order,n.child_execution_order),n.trace_id=i.trace_id,void 0!==i.dotted_order&&(n.dotted_order=[i.dotted_order,t].join("."),n._serialized_start_time=r)):(n.trace_id=n.id,n.dotted_order=t,n._serialized_start_time=r),this.usesRunTreeMap){const e=Wa(n,i);void 0!==e&&this.runTreeMap.set(n.id,e)}else this.runMap.set(n.id,n);return n}async _endTrace(e){const t=void 0!==e.parent_run_id&&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){const t=void 0!==e&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,n,i,o,a,s){const c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,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:o||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,n,i,o,a,s){const c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,n,i,o,a,s);return await(this.onRunCreate?.(c)),await(this.onLLMStart?.(c)),c}_createRunForChatModelStart(e,t,r,n,i,o,a,s){const c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,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:o||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,n,i,o,a,s){const c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,n,i,o,a,s);return await(this.onRunCreate?.(c)),await(this.onLLMStart?.(c)),c}async handleLLMEnd(e,t,r,n,i){const o=this.getRunById(t);if(!o||"llm"!==o?.run_type)throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.outputs=e,o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await(this.onLLMEnd?.(o)),await this._endTrace(o),o}async handleLLMError(e,t,r,n,i){const o=this.getRunById(t);if(!o||"llm"!==o?.run_type)throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await(this.onLLMError?.(o)),await this._endTrace(o),o}_createRunForChainStart(e,t,r,n,i,o,a,s){const c=this._getExecutionOrder(n),u=Date.now(),l={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:t,execution_order:c,child_execution_order:c,run_type:a??"chain",child_runs:[],extra:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(l)}async handleChainStart(e,t,r,n,i,o,a,s){const c=this.getRunById(r)??this._createRunForChainStart(e,t,r,n,i,o,a,s);return await(this.onRunCreate?.(c)),await(this.onChainStart?.(c)),c}async handleChainEnd(e,t,r,n,i){const o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.outputs=Ha(e,"output"),o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),void 0!==i?.inputs&&(o.inputs=Ha(i.inputs,"input")),await(this.onChainEnd?.(o)),await this._endTrace(o),o}async handleChainError(e,t,r,n,i){const o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),void 0!==i?.inputs&&(o.inputs=Ha(i.inputs,"input")),await(this.onChainError?.(o)),await this._endTrace(o),o}_createRunForToolStart(e,t,r,n,i,o,a){const s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,n,i,o,a){const s=this.getRunById(r)??this._createRunForToolStart(e,t,r,n,i,o,a);return await(this.onRunCreate?.(s)),await(this.onToolStart?.(s)),s}async handleToolEnd(e,t){const r=this.getRunById(t);if(!r||"tool"!==r?.run_type)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){const r=this.getRunById(t);if(!r||"tool"!==r?.run_type)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){const r=this.getRunById(t);if(!r||"chain"!==r?.run_type)return;const n=r;n.actions=n.actions||[],n.actions.push(e),n.events.push({name:"agent_action",time:(new Date).toISOString(),kwargs:{action:e}}),await(this.onAgentAction?.(r))}async handleAgentEnd(e,t){const r=this.getRunById(t);r&&"chain"===r?.run_type&&(r.events.push({name:"agent_end",time:(new Date).toISOString(),kwargs:{action:e}}),await(this.onAgentEnd?.(r)))}_createRunForRetrieverStart(e,t,r,n,i,o,a){const s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,n,i,o,a){const s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,n,i,o,a);return await(this.onRunCreate?.(s)),await(this.onRetrieverStart?.(s)),s}async handleRetrieverEnd(e,t){const r=this.getRunById(t);if(!r||"retriever"!==r?.run_type)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){const r=this.getRunById(t);if(!r||"retriever"!==r?.run_type)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){const r=this.getRunById(t);r&&"chain"===r?.run_type&&(r.events.push({name:"text",time:(new Date).toISOString(),kwargs:{text:e}}),await(this.onText?.(r)))}async handleLLMNewToken(e,t,r,n,i,o){const a=this.getRunById(r);if(!a||"llm"!==a?.run_type)throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return a.events.push({name:"new_token",time:(new Date).toISOString(),kwargs:{token:e,idx:t,chunk:o?.chunk}}),await(this.onLLMNewToken?.(a,e,{chunk:o?.chunk})),a}}var Ja,Ya={exports:{}};var Qa=(Ja||(Ja=1,function(e){const t=(e=0)=>t=>`[${38+e};5;${t}m`,r=(e=0)=>(t,r,n)=>`[${38+e};2;${t};${r};${n}m`;Object.defineProperty(e,"exports",{enumerable:!0,get:function(){const e=new Map,n={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]}};n.color.gray=n.color.blackBright,n.bgColor.bgGray=n.bgColor.bgBlackBright,n.color.grey=n.color.blackBright,n.bgColor.bgGrey=n.bgColor.bgBlackBright;for(const[t,r]of Object.entries(n)){for(const[t,i]of Object.entries(r))n[t]={open:`[${i[0]}m`,close:`[${i[1]}m`},r[t]=n[t],e.set(i[0],i[1]);Object.defineProperty(n,t,{value:r,enumerable:!1})}return Object.defineProperty(n,"codes",{value:e,enumerable:!1}),n.color.close="",n.bgColor.close="",n.color.ansi256=t(),n.color.ansi16m=r(),n.bgColor.ansi256=t(10),n.bgColor.ansi16m=r(10),Object.defineProperties(n,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:e=>{const t=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(e.toString(16));if(!t)return[0,0,0];let{colorString:r}=t.groups;3===r.length&&(r=r.split("").map(e=>e+e).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>n.rgbToAnsi256(...n.hexToRgb(e)),enumerable:!1}}),n}})}(Ya)),Ya.exports),Xa=w(Qa);function es(e,t){return`${e.open}${t}${e.close}`}function ts(e,t){try{return JSON.stringify(e,null,2)}catch(e){return t}}function rs(e){return"string"==typeof e?e.trim():null==e?e:ts(e,e.toString())}function ns(e){if(!e.end_time)return"";const t=e.end_time-e.start_time;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}const{color:is}=Xa;class os extends Za{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"console_callback_handler"})}persistRun(e){return Promise.resolve()}getParents(e){const t=[];let r=e;for(;r.parent_run_id;){const e=this.runMap.get(r.parent_run_id);if(!e)break;t.push(e),r=e}return t}getBreadcrumbs(e){const t=[...this.getParents(e).reverse(),e].map((e,t,r)=>{const n=`${e.execution_order}:${e.run_type}:${e.name}`;return t===r.length-1?es(Xa.bold,n):n}).join(" > ");return es(is.grey,t)}onChainStart(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.green,"[chain/start]")} [${t}] Entering Chain run with input: ${ts(e.inputs,"[inputs]")}`)}onChainEnd(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.cyan,"[chain/end]")} [${t}] [${ns(e)}] Exiting Chain run with output: ${ts(e.outputs,"[outputs]")}`)}onChainError(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.red,"[chain/error]")} [${t}] [${ns(e)}] Chain run errored with error: ${ts(e.error,"[error]")}`)}onLLMStart(e){const t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(e=>e.trim())}:e.inputs;console.log(`${es(is.green,"[llm/start]")} [${t}] Entering LLM run with input: ${ts(r,"[inputs]")}`)}onLLMEnd(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.cyan,"[llm/end]")} [${t}] [${ns(e)}] Exiting LLM run with output: ${ts(e.outputs,"[response]")}`)}onLLMError(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.red,"[llm/error]")} [${t}] [${ns(e)}] LLM run errored with error: ${ts(e.error,"[error]")}`)}onToolStart(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.green,"[tool/start]")} [${t}] Entering Tool run with input: "${rs(e.inputs.input)}"`)}onToolEnd(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.cyan,"[tool/end]")} [${t}] [${ns(e)}] Exiting Tool run with output: "${rs(e.outputs?.output)}"`)}onToolError(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.red,"[tool/error]")} [${t}] [${ns(e)}] Tool run errored with error: ${ts(e.error,"[error]")}`)}onRetrieverStart(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${ts(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.cyan,"[retriever/end]")} [${t}] [${ns(e)}] Exiting Retriever run with output: ${ts(e.outputs,"[outputs]")}`)}onRetrieverError(e){const t=this.getBreadcrumbs(e);console.log(`${es(is.red,"[retriever/error]")} [${t}] [${ns(e)}] Retriever run errored with error: ${ts(e.error,"[error]")}`)}onAgentAction(e){const t=e,r=this.getBreadcrumbs(e);console.log(`${es(is.blue,"[agent/action]")} [${r}] Agent selected action: ${ts(t.actions[t.actions.length-1],"[action]")}`)}}let as;const ss=()=>{if(void 0===as){const e="false"===za("LANGCHAIN_CALLBACKS_BACKGROUND")?{blockOnRootRunFinalization:!0}:{};as=new Aa(e)}return as};class cs extends Za{constructor(e={}){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"langchain_tracer"}),Object.defineProperty(this,"projectName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleId",{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,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usesRunTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:!0});const{exampleId:t,projectName:r,client:n,replicas:i}=e;this.projectName=r??Zr(),this.replicas=i,this.exampleId=t,this.client=n??ss();const o=cs.getTraceableRunTree();o&&this.updateFromRunTree(o)}async persistRun(e){}async onRunCreate(e){const t=this.getRunTreeWithTracingConfig(e.id);await(t?.postRun())}async onRunUpdate(e){const t=this.getRunTreeWithTracingConfig(e.id);await(t?.patchRun())}getRun(e){return this.runTreeMap.get(e)}updateFromRunTree(e){this.runTreeMap.set(e.id,e);let t=e;const r=new Set;for(;t.parent_run&&!r.has(t.id)&&(r.add(t.id),t.parent_run);)t=t.parent_run;r.clear();const n=[t];for(;n.length>0;){const e=n.shift();e&&!r.has(e.id)&&(r.add(e.id),this.runTreeMap.set(e.id,e),e.child_runs&&n.push(...e.child_runs))}this.client=e.client??this.client,this.replicas=e.replicas??this.replicas,this.projectName=e.project_name??this.projectName,this.exampleId=e.reference_example_id??this.exampleId}getRunTreeWithTracingConfig(e){const t=this.runTreeMap.get(e);if(t)return new La({...t,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return function(e=!1){const t=Sr.getInstance().getStore();if(!e&&void 0===t)throw new Error("Could not get the current run tree.\n\nPlease make sure you are calling this method within a traceable function and that tracing is enabled.");return t}(!0)}catch{return}}}const us=Symbol.for("ls:tracing_async_local_storage"),ls=Symbol.for("lc:context_variables"),ds=()=>globalThis[us];let fs;function ps(){return void 0===fs&&(fs=new("default"in Wn?Wn.default:Wn)({autoStart:!0,concurrency:1})),fs}async function hs(e,t){if(!0===t){const t=ds();void 0!==t?await t.run(void 0,async()=>e()):await e()}else fs=ps(),fs.add(async()=>{const t=ds();void 0!==t?await t.run(void 0,async()=>e()):await e()})}function ms(e){const t=ds();if(void 0===t)return;const r=t.getStore();return r?.[ls]?.[e]}const ys=Symbol("lc:configure_hooks");function gs(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}class bs{setHandler(e){return this.setHandlers([e])}}class vs{constructor(e,t,r,n,i,o,a,s){Object.defineProperty(this,"runId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:s})}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>hs(async()=>{try{await(t.handleText?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,n,i){await Promise.all(this.handlers.map(r=>hs(async()=>{try{await(r.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata))}catch(e){if((r.raiseError?console.error:console.warn)(`Error in handler ${r.constructor.name}, handleCustomEvent: ${e}`),r.raiseError)throw e}},r.awaitHandlers)))}}class ws extends vs{getChild(e){const t=new Os(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=>hs(async()=>{if(!t.ignoreRetriever)try{await(t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw e}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>hs(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)))}}class _s extends vs{async handleLLMNewToken(e,t,r,n,i,o){await Promise.all(this.handlers.map(r=>hs(async()=>{if(!r.ignoreLLM)try{await(r.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,o))}catch(e){if((r.raiseError?console.error:console.warn)(`Error in handler ${r.constructor.name}, handleLLMNewToken: ${e}`),r.raiseError)throw e}},r.awaitHandlers)))}async handleLLMError(e,t,r,n,i){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreLLM)try{await(t.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,i))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleLLMError: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleLLMEnd(e,t,r,n,i){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreLLM)try{await(t.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,i))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleLLMEnd: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}}class Es extends vs{getChild(e){const t=new Os(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,n,i){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreChain)try{await(t.handleChainError?.(e,this.runId,this._parentRunId,this.tags,i))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChainError: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleChainEnd(e,t,r,n,i){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreChain)try{await(t.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,i))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChainEnd: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreAgent)try{await(t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreAgent)try{await(t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}}class Ss extends vs{getChild(e){const t=new Os(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=>hs(async()=>{if(!t.ignoreAgent)try{await(t.handleToolError?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>hs(async()=>{if(!t.ignoreAgent)try{await(t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags))}catch(e){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${e}`),t.raiseError)throw e}},t.awaitHandlers)))}}class Os extends bs{constructor(e,t){super(),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"callback_manager"}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.handlers=t?.handlers??this.handlers,this.inheritableHandlers=t?.inheritableHandlers??this.inheritableHandlers,this.tags=t?.tags??this.tags,this.inheritableTags=t?.inheritableTags??this.inheritableTags,this.metadata=t?.metadata??this.metadata,this.inheritableMetadata=t?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=e}getParentRunId(){return this._parentRunId}async handleLLMStart(e,t,r=void 0,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0){return Promise.all(t.map(async(t,n)=>{const o=0===n&&r?r:hr();return await Promise.all(this.handlers.map(r=>{if(!r.ignoreLLM)return Ka(r)&&r._createRunForLLMStart(e,[t],o,this._parentRunId,i,this.tags,this.metadata,s),hs(async()=>{try{await(r.handleLLMStart?.(e,[t],o,this._parentRunId,i,this.tags,this.metadata,s))}catch(e){if((r.raiseError?console.error:console.warn)(`Error in handler ${r.constructor.name}, handleLLMStart: ${e}`),r.raiseError)throw e}},r.awaitHandlers)})),new _s(o,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(e,t,r=void 0,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0){return Promise.all(t.map(async(t,n)=>{const o=0===n&&r?r:hr();return await Promise.all(this.handlers.map(r=>{if(!r.ignoreLLM)return Ka(r)&&r._createRunForChatModelStart(e,[t],o,this._parentRunId,i,this.tags,this.metadata,s),hs(async()=>{try{if(r.handleChatModelStart)await(r.handleChatModelStart?.(e,[t],o,this._parentRunId,i,this.tags,this.metadata,s));else if(r.handleLLMStart){const n=function(e,t="Human",r="AI"){const n=[];for(const i of e){let e;if("human"===i._getType())e=t;else if("ai"===i._getType())e=r;else if("system"===i._getType())e="System";else if("function"===i._getType())e="Function";else if("tool"===i._getType())e="Tool";else{if("generic"!==i._getType())throw new Error(`Got unsupported message type: ${i._getType()}`);e=i.role}const o=i.name?`${i.name}, `:"",a="string"==typeof i.content?i.content:JSON.stringify(i.content,null,2);n.push(`${e}: ${o}${a}`)}return n.join("\n")}(t);await(r.handleLLMStart?.(e,[n],o,this._parentRunId,i,this.tags,this.metadata,s))}}catch(e){if((r.raiseError?console.error:console.warn)(`Error in handler ${r.constructor.name}, handleLLMStart: ${e}`),r.raiseError)throw e}},r.awaitHandlers)})),new _s(o,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(e,t,r=hr(),n=void 0,i=void 0,o=void 0,a=void 0){return await Promise.all(this.handlers.map(i=>{if(!i.ignoreChain)return Ka(i)&&i._createRunForChainStart(e,t,r,this._parentRunId,this.tags,this.metadata,n,a),hs(async()=>{try{await(i.handleChainStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,n,a))}catch(e){if((i.raiseError?console.error:console.warn)(`Error in handler ${i.constructor.name}, handleChainStart: ${e}`),i.raiseError)throw e}},i.awaitHandlers)})),new Es(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(e,t,r=hr(),n=void 0,i=void 0,o=void 0,a=void 0){return await Promise.all(this.handlers.map(n=>{if(!n.ignoreAgent)return Ka(n)&&n._createRunForToolStart(e,t,r,this._parentRunId,this.tags,this.metadata,a),hs(async()=>{try{await(n.handleToolStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,a))}catch(e){if((n.raiseError?console.error:console.warn)(`Error in handler ${n.constructor.name}, handleToolStart: ${e}`),n.raiseError)throw e}},n.awaitHandlers)})),new Ss(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(e,t,r=hr(),n=void 0,i=void 0,o=void 0,a=void 0){return await Promise.all(this.handlers.map(n=>{if(!n.ignoreRetriever)return Ka(n)&&n._createRunForRetrieverStart(e,t,r,this._parentRunId,this.tags,this.metadata,a),hs(async()=>{try{await(n.handleRetrieverStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,a))}catch(e){if((n.raiseError?console.error:console.warn)(`Error in handler ${n.constructor.name}, handleRetrieverStart: ${e}`),n.raiseError)throw e}},n.awaitHandlers)})),new ws(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(e,t,r,n,i){await Promise.all(this.handlers.map(n=>hs(async()=>{if(!n.ignoreCustomEvent)try{await(n.handleCustomEvent?.(e,t,r,this.tags,this.metadata))}catch(e){if((n.raiseError?console.error:console.warn)(`Error in handler ${n.constructor.name}, handleCustomEvent: ${e}`),n.raiseError)throw e}},n.awaitHandlers)))}addHandler(e,t=!0){this.handlers.push(e),t&&this.inheritableHandlers.push(e)}removeHandler(e){this.handlers=this.handlers.filter(t=>t!==e),this.inheritableHandlers=this.inheritableHandlers.filter(t=>t!==e)}setHandlers(e,t=!0){this.handlers=[],this.inheritableHandlers=[];for(const r of e)this.addHandler(r,t)}addTags(e,t=!0){this.removeTags(e),this.tags.push(...e),t&&this.inheritableTags.push(...e)}removeTags(e){this.tags=this.tags.filter(t=>!e.includes(t)),this.inheritableTags=this.inheritableTags.filter(t=>!e.includes(t))}addMetadata(e,t=!0){this.metadata={...this.metadata,...e},t&&(this.inheritableMetadata={...this.inheritableMetadata,...e})}removeMetadata(e){for(const t of Object.keys(e))delete this.metadata[t],delete this.inheritableMetadata[t]}copy(e=[],t=!0){const r=new Os(this._parentRunId);for(const e of this.handlers){const t=this.inheritableHandlers.includes(e);r.addHandler(e,t)}for(const e of this.tags){const t=this.inheritableTags.includes(e);r.addTags([e],t)}for(const e of Object.keys(this.metadata)){const t=Object.keys(this.inheritableMetadata).includes(e);r.addMetadata({[e]:this.metadata[e]},t)}for(const n of e)r.handlers.filter(e=>"console_callback_handler"===e.name).some(e=>e.name===n.name)||r.addHandler(n,t);return r}static fromHandlers(e){const t=new this;return t.addHandler(new class extends qa{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:hr()}),Object.assign(this,e)}}),t}static configure(e,t,r,n,i,o,a){return this._configureSync(e,t,r,n,i,o,a)}static _configureSync(e,t,r,n,i,o,a){let s;(e||t)&&(Array.isArray(e)||!e?(s=new Os,s.setHandlers(e?.map(As)??[],!0)):s=e,s=s.copy(Array.isArray(t)?t.map(As):t?.handlers,!1));const c="true"===za("LANGCHAIN_VERBOSE")||a?.verbose,u=cs.getTraceableRunTree()?.tracingEnabled||!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(e=>"true"===za(e)),l=u||(za("LANGCHAIN_TRACING")??!1);if(c||l){if(s||(s=new Os),c&&!s.handlers.some(e=>e.name===os.prototype.name)){const e=new os;s.addHandler(e,!0)}if(l&&!s.handlers.some(e=>"langchain_tracer"===e.name)&&u){const e=new cs;s.addHandler(e,!0)}if(u){const e=cs.getTraceableRunTree();if(e&&void 0===s._parentRunId){s._parentRunId=e.id;const t=s.handlers.find(e=>"langchain_tracer"===e.name);t?.updateFromRunTree(e)}}}for(const{contextVar:e,inheritable:t=!0,handlerClass:r,envVar:n}of ms(ys)||[]){const i=n&&"true"===za(n)&&r;let o;const a=void 0!==e?ms(e):void 0;a&&Va(a)?o=a:i&&(o=new r({})),void 0!==o&&(s||(s=new Os),s.handlers.some(e=>e.name===o.name)||s.addHandler(o,t))}return(r||n)&&s&&(s.addTags(r??[]),s.addTags(n??[],!1)),(i||o)&&s&&(s.addMetadata(i??{}),s.addMetadata(o??{},!1)),s}}function As(e){return"name"in e?e:qa.fromMethods(e)}const Ts=new class{getStore(){}run(e,t){return t()}enterWith(e){}},xs=Symbol.for("lc:child_config");const Is=new class{getInstance(){return ds()??Ts}getRunnableConfig(){const e=this.getInstance();return e.getStore()?.extra?.[xs]}runWithConfig(e,t,r){const n=Os._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),o=i.getStore(),a=n?.getParentRunId(),s=n?.handlers?.find(e=>"langchain_tracer"===e?.name);let c;return s&&a?c=s.getRunTreeWithTracingConfig(a):r||(c=new La({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[xs]:e}),void 0!==o&&void 0!==o[ls]&&(void 0===c&&(c={}),c[ls]=o[ls]),i.run(c,t)}initializeGlobalInstance(e){void 0===ds()&&(e=>{globalThis[us]=e})(e)}};async function ks(e){return Os._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function js(...e){const t={};for(const r of e.filter(e=>!!e))for(const e of Object.keys(r))if("metadata"===e)t[e]={...t[e],...r[e]};else if("tags"===e){const n=t[e]??[];t[e]=[...new Set(n.concat(r[e]??[]))]}else if("configurable"===e)t[e]={...t[e],...r[e]};else if("timeout"===e)void 0===t.timeout?t.timeout=r.timeout:void 0!==r.timeout&&(t.timeout=Math.min(t.timeout,r.timeout));else if("signal"===e)void 0===t.signal?t.signal=r.signal:void 0!==r.signal&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,r.signal]):t.signal=r.signal);else if("callbacks"===e){const e=t.callbacks,n=r.callbacks;if(Array.isArray(n))if(e)if(Array.isArray(e))t.callbacks=e.concat(n);else{const r=e.copy();for(const e of n)r.addHandler(As(e),!0);t.callbacks=r}else t.callbacks=n;else if(n)if(e)if(Array.isArray(e)){const r=n.copy();for(const t of e)r.addHandler(As(t),!0);t.callbacks=r}else t.callbacks=new Os(n._parentRunId,{handlers:e.handlers.concat(n.handlers),inheritableHandlers:e.inheritableHandlers.concat(n.inheritableHandlers),tags:Array.from(new Set(e.tags.concat(n.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(n.inheritableTags))),metadata:{...e.metadata,...n.metadata}});else t.callbacks=n}else{const n=e;t[n]=r[n]??t[n]}return t}const Rs=new Set(["string","number","boolean"]);function Ns(e){const t=Is.getRunnableConfig();let r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){const{runId:e,runName:n,...i}=t;r=Object.entries(i).reduce((e,[t,r])=>(void 0!==r&&(e[t]=r),e),r)}if(e&&(r=Object.entries(e).reduce((e,[t,r])=>(void 0!==r&&(e[t]=r),e),r)),r?.configurable)for(const e of Object.keys(r.configurable))Rs.has(typeof r.configurable[e])&&!r.metadata?.[e]&&(r.metadata||(r.metadata={}),r.metadata[e]=r.configurable[e]);if(void 0!==r.timeout){if(r.timeout<=0)throw new Error("Timeout must be a positive number");const e=AbortSignal.timeout(r.timeout);void 0!==r.signal?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,e])):r.signal=e,delete r.timeout}return r}function Ps(e={},{callbacks:t,maxConcurrency:r,recursionLimit:n,runName:i,configurable:o,runId:a}={}){const s=Ns(e);return void 0!==t&&(delete s.runName,s.callbacks=t),void 0!==n&&(s.recursionLimit=n),void 0!==r&&(s.maxConcurrency=r),void 0!==i&&(s.runName=i),void 0!==o&&(s.configurable={...s.configurable,...o}),void 0!==a&&delete s.runId,s}function Cs(e){return e?{configurable:e.configurable,recursionLimit:e.recursionLimit,callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,maxConcurrency:e.maxConcurrency,timeout:e.timeout,signal:e.signal}:void 0}async function Ls(e,t){if(void 0===t)return e;let r;return Promise.race([e.catch(e=>{if(!t?.aborted)throw e}),new Promise((e,n)=>{r=()=>{n(new Error("Aborted"))},t.addEventListener("abort",r),t.aborted&&n(new Error("Aborted"))})]).finally(()=>t.removeEventListener("abort",r))}class Ms extends ReadableStream{constructor(){super(...arguments),Object.defineProperty(this,"reader",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{const e=await this.reader.read();return e.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}}catch(e){throw this.reader.releaseLock(),e}}async return(){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}return{done:!0,value:void 0}}async throw(e){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}throw e}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(e){const t=e.getReader();return new Ms({start:e=>function r(){return t.read().then(({done:t,value:n})=>{if(!t)return e.enqueue(n),r();e.close()})}(),cancel(){t.releaseLock()}})}static fromAsyncGenerator(e){return new Ms({async pull(t){const{value:r,done:n}=await e.next();n&&t.close(),t.enqueue(r)},async cancel(t){await e.return(t)}})}}function $s(e,t=2){const r=Array.from({length:t},()=>[]);return r.map(async function*(t){for(;;)if(0===t.length){const t=await e.next();for(const e of r)e.push(t)}else{if(t[0].done)return;yield t.shift().value}})}function Ds(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if("string"==typeof e&&"string"==typeof t)return e+t;if("number"==typeof e&&"number"==typeof t)return e+t;if("concat"in e&&"function"==typeof e.concat)return e.concat(t);if("object"==typeof e&&"object"==typeof t){const r={...e};for(const[e,n]of Object.entries(t))e in r&&!Array.isArray(r[e])?r[e]=Ds(r[e],n):r[e]=n;return r}throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}class Bs{constructor(e){Object.defineProperty(this,"generator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResultUsed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{Is.runWithConfig(Cs(e.config),async()=>{this.firstResult=e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(e=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Is.runWithConfig(Cs(this.config),this.signal?async()=>Ls(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()}}class Fs{constructor(e){Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.ops=e.ops??[]}concat(e){const t=this.ops.concat(e.ops),r=Dr({},t);return new Us({ops:t,state:r[r.length-1].newDocument})}}class Us extends Fs{constructor(e){super(e),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=e.state}concat(e){const t=this.ops.concat(e.ops),r=Dr(this.state,e.ops);return new Us({ops:t,state:r[r.length-1].newDocument})}static fromRunLogPatch(e){const t=Dr({},e.ops);return new Us({ops:e.ops,state:t[t.length-1].newDocument})}}const zs=e=>"log_stream_tracer"===e.name;async function Gs(e,t){if("original"===t)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.");const{inputs:r}=e;return["retriever","llm","prompt"].includes(e.run_type)?r:1!==Object.keys(r).length||""!==r?.input?r.input:void 0}async function qs(e,t){const{outputs:r}=e;return"original"===t||["retriever","llm","prompt"].includes(e.run_type)?r:void 0!==r&&1===Object.keys(r).length&&void 0!==r?.output?r.output:r}class Vs extends Za{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_schemaFormat",{enumerable:!0,configurable:!0,writable:!0,value:"original"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyMapByRunId",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"counterMapByRunName",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"log_stream_tracer"}),Object.defineProperty(this,"lc_prefer_streaming",{enumerable:!0,configurable:!0,writable:!0,value:!0}),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=Ms.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;const t=e.tags??[];let r=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(r=r||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(r=r||this.includeTypes.includes(e.run_type)),void 0!==this.includeTags&&(r=r||void 0!==t.find(e=>this.includeTags?.includes(e))),void 0!==this.excludeNames&&(r=r&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(r=r&&!this.excludeTypes.includes(e.run_type)),void 0!==this.excludeTags&&(r=r&&t.every(e=>!this.excludeTags?.includes(e))),r}async*tapOutputIterable(e,t){for await(const r of t){if(e!==this.rootId){const t=this.keyMapByRunId[e];t&&await this.writer.write(new Fs({ops:[{op:"add",path:`/logs/${t}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(void 0===this.rootId&&(this.rootId=e.id,await this.writer.write(new Fs({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;void 0===this.counterMapByRunName[e.name]&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;const t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=1===t?e.name:`${e.name}:${t}`;const 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};"streaming_events"===this._schemaFormat&&(r.inputs=await Gs(e,this._schemaFormat)),await this.writer.write(new Fs({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{const t=this.keyMapByRunId[e.id];if(void 0===t)return;const r=[];"streaming_events"===this._schemaFormat&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await Gs(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await qs(e,this._schemaFormat)}),void 0!==e.end_time&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});const n=new Fs({ops:r});await this.writer.write(n)}finally{if(e.id===this.rootId){const t=new Fs({ops:[{op:"replace",path:"/final_output",value:await qs(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){const n=this.keyMapByRunId[e.id];if(void 0===n)return;let i;var o;void 0!==e.inputs.messages?(o=r?.chunk,i=void 0!==o&&void 0!==o.message?r?.chunk:new le({id:`run-${e.id}`,content:t})):i=t;const a=new Fs({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:i}]});await this.writer.write(a)}}class Ws{constructor(e){Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generationInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.text=e.text,this.generationInfo=e.generationInfo}concat(e){return new Ws({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo}})}}function Hs({name:e,serialized:t}){return void 0!==e?e:void 0!==t?.name?t.name:void 0!==t?.id&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}const Ks=e=>"event_stream_tracer"===e.name;class Zs extends Za{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runInfoMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"tappedPromises",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"event_stream_tracer"}),Object.defineProperty(this,"lc_prefer_streaming",{enumerable:!0,configurable:!0,writable:!0,value:!0}),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,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Ms.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){const t=e.tags??[];let r=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(r=r||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(r=r||this.includeTypes.includes(e.runType)),void 0!==this.includeTags&&(r=r||void 0!==t.find(e=>this.includeTags?.includes(e))),void 0!==this.excludeNames&&(r=r&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(r=r&&!this.excludeTypes.includes(e.runType)),void 0!==this.excludeTags&&(r=r&&t.every(e=>!this.excludeTags?.includes(e))),r}async*tapOutputIterable(e,t){const r=await t.next();if(r.done)return;const n=this.runInfoMap.get(e);if(void 0===n)return void(yield r.value);function i(e,t){return"llm"===e&&"string"==typeof t?new Ws({text:t}):t}let o=this.tappedPromises.get(e);if(void 0===o){let a;o=new Promise(e=>{a=e}),this.tappedPromises.set(e,o);try{const o={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...o,data:{chunk:i(n.runType,r.value)}},n),yield r.value;for await(const e of t)"tool"!==n.runType&&"retriever"!==n.runType&&await this.send({...o,data:{chunk:i(n.runType,e)}},n),yield e}finally{a()}}else{yield r.value;for await(const e of t)yield e}}async send(e,t){this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){const r=this.tappedPromises.get(e.run_id);void 0!==r?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){const t=Hs(e),r=void 0!==e.inputs.messages?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,n);const i=`on_${r}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,r){const n=this.runInfoMap.get(e.id);let i,o;if(void 0===n)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(1!==this.runInfoMap.size){if("chat_model"===n.runType)o="on_chat_model_stream",i=void 0===r?.chunk?new le({content:t,id:`run-${e.id}`}):r.chunk.message;else{if("llm"!==n.runType)throw new Error(`Unexpected run type ${n.runType}`);o="on_llm_stream",i=void 0===r?.chunk?new Ws({text:t}):r.chunk}await this.send({event:o,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}async onLLMEnd(e){const t=this.runInfoMap.get(e.id);let r;if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);const n=e.outputs?.generations;let i;if("chat_model"===t.runType){for(const e of n??[]){if(void 0!==i)break;i=e[0]?.message}r="on_chat_model_end"}else{if("llm"!==t.runType)throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);i={generations:n?.map(e=>e.map(e=>({text:e.text,generationInfo:e.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end"}await this.sendEndEvent({event:r,data:{output:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){const t=Hs(e),r=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type};let i={};""===e.inputs.input&&1===Object.keys(e.inputs).length?(i={},n.inputs={}):void 0!==e.inputs.input?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${r}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onChainEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);const r=`on_${e.run_type}_end`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&1===Object.keys(n).length&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:r,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){const t=Hs(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){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(void 0===t.inputs)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);const r=void 0===e.outputs?.output?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 onRetrieverStart(e){const t=Hs(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){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)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){const n=this.runInfoMap.get(r);if(void 0===n)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:n.tags,metadata:n.metadata,data:t},n)}async finish(){const e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}}const Js=[400,401,402,403,404,405,406,407,409],Ys=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||"AbortError"===e.name)throw e;if("ECONNABORTED"===e?.code)throw e;const t=e?.response?.status??e?.status;if(t&&Js.includes(+t))throw e;if("insufficient_quota"===e?.error?.code){const t=new Error(e?.message);throw t.name="InsufficientQuotaError",t}};class Qs{constructor(e){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,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??Ys;const t="default"in Wn?Wn.default:Wn;this.queue=new t({concurrency:this.maxConcurrency})}call(e,...t){return this.queue.add(()=>ir(()=>e(...t).catch(e=>{throw e instanceof Error?e:new Error(e)}),{onFailedAttempt:this.onFailedAttempt,retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){return e.signal?Promise.race([this.call(t,...r),new Promise((t,r)=>{e.signal?.addEventListener("abort",()=>{r(new Error("AbortError"))})})]):this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(e=>e.ok?e:Promise.reject(e)))}}class Xs extends Za{constructor({config:e,onStart:t,onEnd:r,onError:n}){super({_awaitHandler:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RootListenersTracer"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=n}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}}function ec(e){return!!e&&e.lc_runnable}class tc{constructor(e){Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 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}includeEvent(e,t){let r=void 0===this.includeNames&&void 0===this.includeTypes&&void 0===this.includeTags;const n=e.tags??[];return void 0!==this.includeNames&&(r=r||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(r=r||this.includeTypes.includes(t)),void 0!==this.includeTags&&(r=r||n.some(e=>this.includeTags?.includes(e))),void 0!==this.excludeNames&&(r=r&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(r=r&&!this.excludeTypes.includes(t)),void 0!==this.excludeTags&&(r=r&&n.every(e=>!this.excludeTags?.includes(e))),r}}function rc(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}const nc=["*","_","`"];function ic(e,t,r){const{firstNode:n,lastNode:i,nodeColors:o,withStyles:a=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{};let u=a?`%%{init: {'flowchart': {'curve': '${s}'}}}%%\ngraph TD;\n`:"graph TD;\n";if(a){const t="default",r={[t]:"{0}({1})"};void 0!==n&&(r[n]="{0}([{1}]):::first"),void 0!==i&&(r[i]="{0}([{1}]):::last");for(const[n,i]of Object.entries(e)){const e=i.name.split(":").pop()??"";let o=nc.some(t=>e.startsWith(t)&&e.endsWith(t))?`<p>${e}</p>`:e;Object.keys(i.metadata??{}).length&&(o+=`<hr/><small><em>${Object.entries(i.metadata??{}).map(([e,t])=>`${e} = ${t}`).join("\n")}</em></small>`);const a=(r[n]??r[t]).replace("{0}",rc(n)).replace("{1}",o);u+=`\t${a}\n`}}const l={};for(const e of t){const t=e.source.split(":"),r=e.target.split(":"),n=t.filter((e,t)=>e===r[t]).join(":");l[n]||(l[n]=[]),l[n].push(e)}const d=new Set;function f(e,t){const r=1===e.length&&e[0].source===e[0].target;if(t&&!r){const e=t.split(":").pop();if(d.has(e))throw new Error(`Found duplicate subgraph '${e}' -- 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(e),u+=`\tsubgraph ${e}\n`}for(const t of e){const{source:e,target:r,data:n,conditional:i}=t;let o="";if(void 0!==n){let e=n;const t=e.split(" ");t.length>c&&(e=Array.from({length:Math.ceil(t.length/c)},(e,r)=>t.slice(r*c,(r+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),o=i?` -. &nbsp;${e}&nbsp; .-> `:` -- &nbsp;${e}&nbsp; --\x3e `}else o=i?" -.-> ":" --\x3e ";u+=`\t${rc(e)}${o}${rc(r)};\n`}for(const e in l)e.startsWith(`${t}:`)&&e!==t&&f(l[e],e);t&&!r&&(u+="\tend\n")}f(l[""]??[],"");for(const e in l)e.includes(":")||""===e||f(l[e],e);return a&&(u+=function(e){let t="";for(const[r,n]of Object.entries(e))t+=`\tclassDef ${r} ${n};\n`;return t}(o??{})),u}async function oc(e,t){return async function(e,t){let r=t?.backgroundColor??"white";const n=t?.imageType,i=btoa(e);if(void 0!==r){/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`)}const o=`https://mermaid.ink/img/${i}?bgColor=${r}&type=${n}`,a=await fetch(o);if(!a.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${a.status}`,`Status text: ${a.statusText}`].join("\n"));return await a.blob()}(e,{...t,imageType:"png"})}function ac(e,t,r){function n(r,n){var i;Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,n);for(const e in a.prototype)e in r||Object.defineProperty(r,e,{value:a.prototype[e].bind(r)});r._zod.constr=a,r._zod.def=n}const i=r?.Parent??Object;class o extends i{}function a(e){var t;const i=r?.Parent?new o:this;n(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const e of i._zod.deferred)e();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class sc extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const cc={};function uc(e){return cc}function lc(e,t){return"bigint"==typeof t?t.toString():t}const dc=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function fc(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function pc(e,t=0){for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function hc(e){return"string"==typeof e?e:e?.message}function mc(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const i=hc(e.inst?._zod.def?.error?.(e))??hc(t?.error?.(e))??hc(r.customError?.(e))??hc(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}const yc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,lc,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gc=ac("$ZodError",yc),bc=ac("$ZodError",yc,{Parent:Error}),vc=e=>(t,r,n,i)=>{const o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new sc;if(a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>mc(e,o,uc())));throw dc(t,i?.callee),t}return a.value},wc=vc(bc),_c=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new sc;return o.issues.length?{success:!1,error:new(e??gc)(o.issues.map(e=>mc(e,i,uc())))}:{success:!0,data:o.value}},Ec=_c(bc),Sc=e=>async(t,r,n)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>mc(e,i,uc())))}:{success:!0,data:o.value}},Oc=Sc(bc),Ac={major:4,minor:0,patch:0},Tc=ac("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ac;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,i=pc(e);for(const o of t){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=o._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new sc;if(n||a instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(i||(i=pc(e,t)))});else{if(e.issues.length===t)continue;i||(i=pc(e,t))}}return n?n.then(()=>e):e};e._zod.run=(r,i)=>{const o=e._zod.parse(r,i);if(o instanceof Promise){if(!1===i.async)throw new sc;return o.then(e=>t(e,n,i))}return t(o,n,i)}}e["~standard"]={validate:t=>{try{const r=Ec(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return Oc(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),xc=ac("$ZodNever",(e,t)=>{Tc.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});class Ic{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function kc(){return new Ic}const jc=kc();class Rc{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??jc,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var r;const n=e._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(e);if(o){o.count++;return t.schemaPath.includes(e)&&(o.cycle=t.path),o.schema}const a={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const r={...t,schemaPath:[...t.schemaPath,e],path:t.path},o=e._zod.parent;if(o)a.ref=o,this.process(o,r),this.seen.get(o).isParent=!0;else{const t=a.schema;switch(n.type){case"string":{const r=t;r.type="string";const{minimum:n,maximum:o,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if("number"==typeof n&&(r.minLength=n),"number"==typeof o&&(r.maxLength=o),s&&(r.format=i[s]??s,""===r.format&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const e=[...c];1===e.length?r.pattern=e[0].source:e.length>1&&(a.schema.allOf=[...e.map(e=>({..."draft-7"===this.target?{type:"string"}:{},pattern:e.source}))])}break}case"number":{const r=t,{minimum:n,maximum:i,format:o,multipleOf:a,exclusiveMaximum:s,exclusiveMinimum:c}=e._zod.bag;"string"==typeof o&&o.includes("int")?r.type="integer":r.type="number","number"==typeof c&&(r.exclusiveMinimum=c),"number"==typeof n&&(r.minimum=n,"number"==typeof c&&(c>=n?delete r.minimum:delete r.exclusiveMinimum)),"number"==typeof s&&(r.exclusiveMaximum=s),"number"==typeof i&&(r.maximum=i,"number"==typeof s&&(s<=i?delete r.maximum:delete r.exclusiveMaximum)),"number"==typeof a&&(r.multipleOf=a);break}case"boolean":t.type="boolean";break;case"bigint":if("throw"===this.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema");break;case"symbol":if("throw"===this.unrepresentable)throw new Error("Symbols cannot be represented in JSON Schema");break;case"null":t.type="null";break;case"any":case"unknown":break;case"undefined":if("throw"===this.unrepresentable)throw new Error("Undefined cannot be represented in JSON Schema");break;case"void":if("throw"===this.unrepresentable)throw new Error("Void cannot be represented in JSON Schema");break;case"never":t.not={};break;case"date":if("throw"===this.unrepresentable)throw new Error("Date cannot be represented in JSON Schema");break;case"array":{const i=t,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(i.minItems=o),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=this.process(n.element,{...r,path:[...r.path,"items"]});break}case"object":{const e=t;e.type="object",e.properties={};const i=n.shape;for(const t in i)e.properties[t]=this.process(i[t],{...r,path:[...r.path,"properties",t]});const o=new Set(Object.keys(i)),a=new Set([...o].filter(e=>{const t=n.shape[e]._zod;return"input"===this.io?void 0===t.optin:void 0===t.optout}));a.size>0&&(e.required=Array.from(a)),"never"===n.catchall?._zod.def.type?e.additionalProperties=!1:n.catchall?n.catchall&&(e.additionalProperties=this.process(n.catchall,{...r,path:[...r.path,"additionalProperties"]})):"output"===this.io&&(e.additionalProperties=!1);break}case"union":t.anyOf=n.options.map((e,t)=>this.process(e,{...r,path:[...r.path,"anyOf",t]}));break;case"intersection":{const e=t,i=this.process(n.left,{...r,path:[...r.path,"allOf",0]}),o=this.process(n.right,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,s=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];e.allOf=s;break}case"tuple":{const i=t;i.type="array";const o=n.items.map((e,t)=>this.process(e,{...r,path:[...r.path,"prefixItems",t]}));if("draft-2020-12"===this.target?i.prefixItems=o:i.items=o,n.rest){const e=this.process(n.rest,{...r,path:[...r.path,"items"]});"draft-2020-12"===this.target?i.items=e:i.additionalItems=e}n.rest&&(i.items=this.process(n.rest,{...r,path:[...r.path,"items"]}));const{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s);break}case"record":{const e=t;e.type="object",e.propertyNames=this.process(n.keyType,{...r,path:[...r.path,"propertyNames"]}),e.additionalProperties=this.process(n.valueType,{...r,path:[...r.path,"additionalProperties"]});break}case"map":if("throw"===this.unrepresentable)throw new Error("Map cannot be represented in JSON Schema");break;case"set":if("throw"===this.unrepresentable)throw new Error("Set cannot be represented in JSON Schema");break;case"enum":{const e=t,r=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(n.entries);r.every(e=>"number"==typeof e)&&(e.type="number"),r.every(e=>"string"==typeof e)&&(e.type="string"),e.enum=r;break}case"literal":{const e=t,r=[];for(const e of n.values)if(void 0===e){if("throw"===this.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===this.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");r.push(Number(e))}else r.push(e);if(0===r.length);else if(1===r.length){const t=r[0];e.type=null===t?"null":typeof t,e.const=t}else r.every(e=>"number"==typeof e)&&(e.type="number"),r.every(e=>"string"==typeof e)&&(e.type="string"),r.every(e=>"boolean"==typeof e)&&(e.type="string"),r.every(e=>null===e)&&(e.type="null"),e.enum=r;break}case"file":{const r=t,n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:o,mime:a}=e._zod.bag;void 0!==i&&(n.minLength=i),void 0!==o&&(n.maxLength=o),a?1===a.length?(n.contentMediaType=a[0],Object.assign(r,n)):r.anyOf=a.map(e=>({...n,contentMediaType:e})):Object.assign(r,n);break}case"transform":if("throw"===this.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema");break;case"nullable":{const e=this.process(n.innerType,r);t.anyOf=[e,{type:"null"}];break}case"nonoptional":case"promise":case"optional":this.process(n.innerType,r),a.ref=n.innerType;break;case"success":t.type="boolean";break;case"default":this.process(n.innerType,r),a.ref=n.innerType,t.default=JSON.parse(JSON.stringify(n.defaultValue));break;case"prefault":this.process(n.innerType,r),a.ref=n.innerType,"input"===this.io&&(t._prefault=JSON.parse(JSON.stringify(n.defaultValue)));break;case"catch":{let e;this.process(n.innerType,r),a.ref=n.innerType;try{e=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=e;break}case"nan":if("throw"===this.unrepresentable)throw new Error("NaN cannot be represented in JSON Schema");break;case"template_literal":{const r=t,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=n.source;break}case"pipe":{const e="input"===this.io?"transform"===n.in._zod.def.type?n.out:n.in:n.out;this.process(e,r),a.ref=e;break}case"readonly":this.process(n.innerType,r),a.ref=n.innerType,t.readOnly=!0;break;case"lazy":{const t=e._zod.innerType;this.process(t,r),a.ref=t;break}case"custom":if("throw"===this.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")}}}const c=this.metadataRegistry.get(e);c&&Object.assign(a.schema,c),"input"===this.io&&Pc(e)&&(delete a.schema.examples,delete a.schema.default),"input"===this.io&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault;return this.seen.get(e).schema}emit(e,t){const r={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},n=this.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=e=>{const t="draft-2020-12"===this.target?"$defs":"definitions";if(r.external){const n=r.external.registry.get(e[0])?.id,i=r.external.uri??(e=>e);if(n)return{ref:i(n)};const o=e[1].defId??e[1].schema.id??"schema"+this.counter++;return e[1].defId=o,{defId:o,ref:`${i("__shared")}#/${t}/${o}`}}if(e[1]===n)return{ref:"#"};const i=`#/${t}/`,o=e[1].schema.id??"__schema"+this.counter++;return{defId:o,ref:i+o}},o=e=>{if(e[1].schema.$ref)return;const t=e[1],{ref:r,defId:n}=i(e);t.def={...t.schema},n&&(t.defId=n);const o=t.schema;for(const e in o)delete o[e];o.$ref=r};if("throw"===r.cycles)for(const e of this.seen.entries()){const t=e[1];if(t.cycle)throw new Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const t of this.seen.entries()){const n=t[1];if(e===t[0]){o(t);continue}if(r.external){const n=r.external.registry.get(t[0])?.id;if(e!==t[0]&&n){o(t);continue}}const i=this.metadataRegistry.get(t[0])?.id;i?o(t):(n.cycle||n.count>1&&"ref"===r.reused)&&o(t)}const a=(e,t)=>{const r=this.seen.get(e),n=r.def??r.schema,i={...n};if(null===r.ref)return;const o=r.ref;if(r.ref=null,o){a(o,t);const e=this.seen.get(o).schema;e.$ref&&"draft-7"===t.target?(n.allOf=n.allOf??[],n.allOf.push(e)):(Object.assign(n,e),Object.assign(n,i))}r.isParent||this.override({zodSchema:e,jsonSchema:n,path:r.path??[]})};for(const e of[...this.seen.entries()].reverse())a(e[0],{target:this.target});const s={};if("draft-2020-12"===this.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-7"===this.target?s.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),r.external?.uri){const t=r.external.registry.get(e)?.id;if(!t)throw new Error("Schema is missing an `id` property");s.$id=r.external.uri(t)}Object.assign(s,n.def);const c=r.external?.defs??{};for(const e of this.seen.entries()){const t=e[1];t.def&&t.defId&&(c[t.defId]=t.def)}r.external||Object.keys(c).length>0&&("draft-2020-12"===this.target?s.$defs=c:s.definitions=c);try{return JSON.parse(JSON.stringify(s))}catch(e){throw new Error("Error converting schema to JSON.")}}}function Nc(e,t){if(e instanceof Ic){const r=new Rc(t),n={};for(const t of e._idmap.entries()){const[e,n]=t;r.process(n)}const i={},o={registry:e,uri:t?.uri,defs:n};for(const n of e._idmap.entries()){const[e,a]=n;i[e]=r.emit(a,{...t,external:o})}if(Object.keys(n).length>0){const e="draft-2020-12"===r.target?"$defs":"definitions";i.__shared={[e]:n}}return{schemas:i}}const r=new Rc(t);return r.process(e),r.emit(e,t)}function Pc(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":case"custom":case"success":case"catch":return!1;case"array":return Pc(n.element,r);case"object":for(const e in n.shape)if(Pc(n.shape[e],r))return!0;return!1;case"union":for(const e of n.options)if(Pc(e,r))return!0;return!1;case"intersection":return Pc(n.left,r)||Pc(n.right,r);case"tuple":for(const e of n.items)if(Pc(e,r))return!0;return!(!n.rest||!Pc(n.rest,r));case"record":case"map":return Pc(n.keyType,r)||Pc(n.valueType,r);case"set":return Pc(n.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":case"default":case"prefault":return Pc(n.innerType,r);case"lazy":return Pc(n.getter(),r);case"transform":return!0;case"pipe":return Pc(n.in,r)||Pc(n.out,r)}throw new Error(`Unknown schema type: ${n.type}`)}const Cc=Symbol("Let zodToJsonSchema decide on which parser to use"),Lc={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"},Mc=e=>{const t=(e=>({...Lc,...e}))(e),r=void 0!==t.name?[...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(([e,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function $c(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Dc(e,t,r,n,i){e[t]=r,$c(e,t,n,i)}const Bc=(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 Fc(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?Bc(t,e.currentPath):t.join("/")}}function Uc(e,t){return hu(e.type._def,t)}function zc(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((r,n)=>zc(e,t,r))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Gc(e,t)}}const Gc=(e,t)=>{const r={type:"integer",format:"unix-time"};if("openApi3"===t.target)return r;for(const n of e.checks)switch(n.kind){case"min":Dc(r,"minimum",n.value,n.message,t);break;case"max":Dc(r,"maximum",n.value,n.message,t)}return r};let qc;const Vc=/^[cC][^\s-]{8,}$/,Wc=/^[0-9a-z]+$/,Hc=/^[0-9A-HJKMNP-TV-Z]{26}$/,Kc=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Zc=()=>(void 0===qc&&(qc=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),qc),Jc=/^(?:(?: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])$/,Yc=/^(([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])$/,Qc=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eu=/^[a-zA-Z0-9_-]{21}$/,tu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function ru(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":Dc(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":Dc(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":ou(r,"email",n.message,t);break;case"format:idn-email":ou(r,"idn-email",n.message,t);break;case"pattern:zod":au(r,Kc,n.message,t)}break;case"url":ou(r,"uri",n.message,t);break;case"uuid":ou(r,"uuid",n.message,t);break;case"regex":au(r,n.regex,n.message,t);break;case"cuid":au(r,Vc,n.message,t);break;case"cuid2":au(r,Wc,n.message,t);break;case"startsWith":au(r,RegExp(`^${nu(n.value,t)}`),n.message,t);break;case"endsWith":au(r,RegExp(`${nu(n.value,t)}$`),n.message,t);break;case"datetime":ou(r,"date-time",n.message,t);break;case"date":ou(r,"date",n.message,t);break;case"time":ou(r,"time",n.message,t);break;case"duration":ou(r,"duration",n.message,t);break;case"length":Dc(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t),Dc(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":au(r,RegExp(nu(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&ou(r,"ipv4",n.message,t),"v4"!==n.version&&ou(r,"ipv6",n.message,t);break;case"base64url":au(r,Xc,n.message,t);break;case"jwt":au(r,tu,n.message,t);break;case"cidr":"v6"!==n.version&&au(r,Jc,n.message,t),"v4"!==n.version&&au(r,Yc,n.message,t);break;case"emoji":au(r,Zc(),n.message,t);break;case"ulid":au(r,Hc,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":ou(r,"binary",n.message,t);break;case"contentEncoding:base64":Dc(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":au(r,Qc,n.message,t)}break;case"nanoid":au(r,eu,n.message,t)}return r}function nu(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)iu.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}const iu=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ou(e,t,r,n){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):Dc(e,"format",t,r,n)}function au(e,t,r,n){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:su(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Dc(e,"pattern",su(t,n),r,n)}function su(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const r=e.flags.includes("i"),n=e.flags.includes("m"),i=e.flags.includes("s"),o=r?e.source.toLowerCase():e.source;let a="",s=!1,c=!1,u=!1;for(let e=0;e<o.length;e++)if(s)a+=o[e],s=!1;else{if(r)if(c){if(o[e].match(/[a-z]/)){u?(a+=o[e],a+=`${o[e-2]}-${o[e]}`.toUpperCase(),u=!1):"-"===o[e+1]&&o[e+2]?.match(/[a-z]/)?(a+=o[e],u=!0):a+=`${o[e]}${o[e].toUpperCase()}`;continue}}else if(o[e].match(/[a-z]/)){a+=`[${o[e]}${o[e].toUpperCase()}]`;continue}if(n){if("^"===o[e]){a+="(^|(?<=[\r\n]))";continue}if("$"===o[e]){a+="($|(?=[\r\n]))";continue}}i&&"."===o[e]?a+=c?`${o[e]}\r\n`:`[${o[e]}\r\n]`:(a+=o[e],"\\"===o[e]?s=!0:c&&"]"===o[e]?c=!1:c||"["!==o[e]||(c=!0))}try{new RegExp(a)}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 a}function cu(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===Gt.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:hu(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??Fc(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const r={type:"object",additionalProperties:hu(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===Gt.ZodString&&e.keyType._def.checks?.length){const{type:n,...i}=ru(e.keyType._def,t);return{...r,propertyNames:i}}if(e.keyType?._def.typeName===Gt.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Gt.ZodBranded&&e.keyType._def.type._def.typeName===Gt.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...i}=Uc(e.keyType._def,t);return{...r,propertyNames:i}}return r}const uu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const lu=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>hu(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function du(e,t){const r="openAi"===t.target,n={type:"object",properties:{}},i=[],o=e.shape();for(const e in o){let a=o[e];if(void 0===a||void 0===a._def)continue;let s=fu(a);s&&r&&("ZodOptional"===a._def.typeName&&(a=a._def.innerType),a.isNullable()||(a=a.nullable()),s=!1);const c=hu(a._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(n.properties[e]=c,s||i.push(e))}i.length&&(n.required=i);const a=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return hu(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==a&&(n.additionalProperties=a),n}function fu(e){try{return e.isOptional()}catch{return!0}}const pu=(e,t,r)=>{switch(t){case Gt.ZodString:return ru(e,r);case Gt.ZodNumber:return function(e,t){const r={type:"number"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"int":r.type="integer",$c(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?Dc(r,"minimum",n.value,n.message,t):Dc(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Dc(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Dc(r,"maximum",n.value,n.message,t):Dc(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Dc(r,"maximum",n.value,n.message,t));break;case"multipleOf":Dc(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Gt.ZodObject:return du(e,r);case Gt.ZodBigInt:return function(e,t){const r={type:"integer",format:"int64"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?Dc(r,"minimum",n.value,n.message,t):Dc(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Dc(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Dc(r,"maximum",n.value,n.message,t):Dc(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Dc(r,"maximum",n.value,n.message,t));break;case"multipleOf":Dc(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Gt.ZodBoolean:return{type:"boolean"};case Gt.ZodDate:return zc(e,r);case Gt.ZodUndefined:return function(e){return{not:Fc(e)}}(r);case Gt.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(r);case Gt.ZodArray:return function(e,t){const r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Gt.ZodAny&&(r.items=hu(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Dc(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Dc(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Dc(r,"minItems",e.exactLength.value,e.exactLength.message,t),Dc(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case Gt.ZodUnion:case Gt.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return lu(e,t);const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in uu&&(!e._def.checks||!e._def.checks.length))){const e=r.reduce((e,t)=>{const r=uu[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=r.reduce((e,t)=>{const r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){const t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return lu(e,t)}(e,r);case Gt.ZodIntersection:return function(e,t){const r=[hu(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),hu(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return r.forEach(e=>{if((e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e)(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:r,...n}=e;t=n}else n=void 0;i.push(t)}}),i.length?{allOf:i,...n}:void 0}(e,r);case Gt.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>hu(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:hu(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>hu(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case Gt.ZodRecord:return cu(e,r);case Gt.ZodLiteral:return function(e,t){const r=typeof e.value;return"bigint"!==r&&"number"!==r&&"boolean"!==r&&"string"!==r?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===r?"integer":r,enum:[e.value]}:{type:"bigint"===r?"integer":r,const:e.value}}(e,r);case Gt.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Gt.ZodNativeEnum:return function(e){const t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(r.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:r}}(e);case Gt.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:uu[e.innerType._def.typeName],nullable:!0}:{type:[uu[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const r=hu(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const r=hu(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case Gt.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return hu(e.innerType._def,t);const r=hu(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Fc(t)},r]}:Fc(t)})(e,r);case Gt.ZodMap:return function(e,t){return"record"===t.mapStrategy?cu(e,t):{type:"array",maxItems:125,items:{type:"array",items:[hu(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Fc(t),hu(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Fc(t)],minItems:2,maxItems:2}}}(e,r);case Gt.ZodSet:return function(e,t){const r={type:"array",uniqueItems:!0,items:hu(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Dc(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Dc(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case Gt.ZodLazy:return()=>e.getter()._def;case Gt.ZodPromise:return function(e,t){return hu(e.type._def,t)}(e,r);case Gt.ZodNaN:case Gt.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:Fc({...e,currentPath:[...e.currentPath,"not"]})}}(r);case Gt.ZodEffects:return function(e,t){return"input"===t.effectStrategy?hu(e.schema._def,t):Fc(t)}(e,r);case Gt.ZodAny:return Fc(r);case Gt.ZodUnknown:return function(e){return Fc(e)}(r);case Gt.ZodDefault:return function(e,t){return{...hu(e.innerType._def,t),default:e.defaultValue()}}(e,r);case Gt.ZodBranded:return Uc(e,r);case Gt.ZodReadonly:case Gt.ZodCatch:return((e,t)=>hu(e.innerType._def,t))(e,r);case Gt.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return hu(e.in._def,t);if("output"===t.pipeStrategy)return hu(e.out._def,t);const r=hu(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,hu(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(e=>void 0!==e)}})(e,r);case Gt.ZodFunction:case Gt.ZodVoid:case Gt.ZodSymbol:default:return}};function hu(e,t,r=!1){const n=t.seen.get(e);if(t.override){const i=t.override?.(e,t,n,r);if(i!==Cc)return i}if(n&&!r){const e=mu(n,t);if(void 0!==e)return e}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const o=pu(e,e.typeName,t),a="function"==typeof o?hu(o(),t):o;if(a&&yu(e,t,a),t.postProcess){const r=t.postProcess(a,e,t);return i.jsonSchema=a,r}return i.jsonSchema=a,a}const mu=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Bc(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Fc(t)):"seen"===t.$refStrategy?Fc(t):void 0}},yu=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function gu(e,t){const r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;const r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(!gu(e[n],t[n]))return!1;return!0}if("object"===r){if(!e||!t)return e===t;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const n of r)if(!gu(e[n],t[n]))return!1;return!0}return e===t}function bu(e){return encodeURI(function(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}(e))}const vu={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},wu={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},_u={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};let Eu="undefined"!=typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function Su(e,t=Object.create(null),r=Eu,n=""){if(e&&"object"==typeof e&&!Array.isArray(e)){const i=e.$id||e.id;if(i){const o=new URL(i,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",""===n?r=o:Su(e,t,r))}}else if(!0!==e&&!1!==e)return t;const i=r.href+(n?"#"+n:"");if(void 0!==t[i])throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&void 0===e.__absolute_ref__){const t=new URL(e.$ref,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){const t=new URL(e.$recursiveRef,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){t[new URL("#"+e.$anchor,r.href).href]=e}for(let i in e){if(_u[i])continue;const o=`${n}/${bu(i)}`,a=e[i];if(Array.isArray(a)){if(vu[i]){const e=a.length;for(let n=0;n<e;n++)Su(a[n],t,r,`${o}/${n}`)}}else if(wu[i])for(let e in a)Su(a[e],t,r,`${o}/${bu(e)}`);else Su(a,t,r,o)}return t}const Ou=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Au=[0,31,28,31,30,31,30,31,31,30,31,30,31],Tu=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function xu(e){return e.test.bind(e)}const Iu={date:ku,time:ju.bind(void 0,!1),"date-time":function(e){const t=e.split(Ru);return 2==t.length&&ku(t[0])&&ju(!0,t[1])},duration: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)),uri:function(e){return Nu.test(e)&&Pu.test(e)},"uri-reference":xu(/^(?:[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),"uri-template":xu(/^(?:(?:[^\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),url:xu(/^(?:(?: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),email:e=>{if('"'===e[0])return!1;const[t,r,...n]=e.split("@");return!(!t||!r||0!==n.length||t.length>64||r.length>253)&&("."!==t[0]&&!t.endsWith(".")&&!t.includes("..")&&(!(!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))&&r.split(".").every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))))},hostname:xu(/^(?=.{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),ipv4:xu(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:xu(/^((([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),regex:function(e){if(Cu.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(e){return!1}},uuid:xu(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":xu(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":xu(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":xu(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function ku(e){const t=e.match(Ou);if(!t)return!1;const r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(2==n&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(r)?29:Au[n])}function ju(e,t){const r=t.match(Tu);if(!r)return!1;const n=+r[1],i=+r[2],o=+r[3],a=!!r[5];return(n<=23&&i<=59&&o<=59||23==n&&59==i&&60==o)&&(!e||a)}const Ru=/t|\s/i;const Nu=/\/|:/,Pu=/^(?:[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;const Cu=/[^\\]\\Z/;function Lu(e,t,r="2019-09",n=Su(t),i=!0,o=null,a="#",s="#",c=Object.create(null)){if(!0===t)return{valid:!0,errors:[]};if(!1===t)return{valid:!1,errors:[{instanceLocation:a,keyword:"false",keywordLocation:a,error:"False boolean schema."}]};const u=typeof e;let l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":l=null===e?"null":Array.isArray(e)?"array":"object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}const{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:h,const:m,enum:y,required:g,not:b,anyOf:v,allOf:w,oneOf:_,if:E,then:S,else:O,format:A,properties:T,patternProperties:x,additionalProperties:I,unevaluatedProperties:k,minProperties:j,maxProperties:R,propertyNames:N,dependentRequired:P,dependentSchemas:C,dependencies:L,prefixItems:M,items:$,additionalItems:D,unevaluatedItems:B,contains:F,minContains:U,maxContains:z,minItems:G,maxItems:q,uniqueItems:V,minimum:W,maximum:H,exclusiveMinimum:K,exclusiveMaximum:Z,multipleOf:J,minLength:Y,maxLength:Q,pattern:X,__absolute_ref__:ee,__absolute_recursive_ref__:te}=t,re=[];if(!0===p&&null===o&&(o=t),"#"===f){const u=null===o?n[te]:o,l=`${s}/$recursiveRef`,d=Lu(e,null===o?t:o,r,n,i,u,a,l,c);d.valid||re.push({instanceLocation:a,keyword:"$recursiveRef",keywordLocation:l,error:"A subschema had errors."},...d.errors)}if(void 0!==d){const t=n[ee||d];if(void 0===t){let e=`Unresolved $ref "${d}".`;throw ee&&ee!==d&&(e+=` Absolute URI "${ee}".`),e+=`\nKnown schemas:\n- ${Object.keys(n).join("\n- ")}`,new Error(e)}const u=`${s}/$ref`,l=Lu(e,t,r,n,i,o,a,u,c);if(l.valid||re.push({instanceLocation:a,keyword:"$ref",keywordLocation:u,error:"A subschema had errors."},...l.errors),"4"===r||"7"===r)return{valid:0===re.length,errors:re}}if(Array.isArray(h)){let t=h.length,r=!1;for(let n=0;n<t;n++)if(l===h[n]||"integer"===h[n]&&"number"===l&&e%1==0&&e==e){r=!0;break}r||re.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${h.join('", "')}".`})}else"integer"===h?("number"!==l||e%1||e!=e)&&re.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${h}".`}):void 0!==h&&l!==h&&re.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${h}".`});if(void 0!==m&&("object"===l||"array"===l?gu(e,m)||re.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(m)}.`}):e!==m&&re.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(m)}.`})),void 0!==y&&("object"===l||"array"===l?y.some(t=>gu(e,t))||re.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(t=>e===t)||re.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),void 0!==b){const t=`${s}/not`;Lu(e,b,r,n,i,o,a,t).valid&&re.push({instanceLocation:a,keyword:"not",keywordLocation:t,error:'Instance matched "not" schema.'})}let ne=[];if(void 0!==v){const t=`${s}/anyOf`,u=re.length;let l=!1;for(let s=0;s<v.length;s++){const u=v[s],d=Object.create(c),f=Lu(e,u,r,n,i,!0===p?o:null,a,`${t}/${s}`,d);re.push(...f.errors),l=l||f.valid,f.valid&&ne.push(d)}l?re.length=u:re.splice(u,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:t,error:"Instance does not match any subschemas."})}if(void 0!==w){const t=`${s}/allOf`,u=re.length;let l=!0;for(let s=0;s<w.length;s++){const u=w[s],d=Object.create(c),f=Lu(e,u,r,n,i,!0===p?o:null,a,`${t}/${s}`,d);re.push(...f.errors),l=l&&f.valid,f.valid&&ne.push(d)}l?re.length=u:re.splice(u,0,{instanceLocation:a,keyword:"allOf",keywordLocation:t,error:"Instance does not match every subschema."})}if(void 0!==_){const t=`${s}/oneOf`,u=re.length,l=_.filter((s,u)=>{const l=Object.create(c),d=Lu(e,s,r,n,i,!0===p?o:null,a,`${t}/${u}`,l);return re.push(...d.errors),d.valid&&ne.push(l),d.valid}).length;1===l?re.length=u:re.splice(u,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:t,error:`Instance does not match exactly one subschema (${l} matches).`})}if("object"!==l&&"array"!==l||Object.assign(c,...ne),void 0!==E){const t=`${s}/if`;if(Lu(e,E,r,n,i,o,a,t,c).valid){if(void 0!==S){const u=Lu(e,S,r,n,i,o,a,`${s}/then`,c);u.valid||re.push({instanceLocation:a,keyword:"if",keywordLocation:t,error:'Instance does not match "then" schema.'},...u.errors)}}else if(void 0!==O){const u=Lu(e,O,r,n,i,o,a,`${s}/else`,c);u.valid||re.push({instanceLocation:a,keyword:"if",keywordLocation:t,error:'Instance does not match "else" schema.'},...u.errors)}}if("object"===l){if(void 0!==g)for(const t of g)t in e||re.push({instanceLocation:a,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});const t=Object.keys(e);if(void 0!==j&&t.length<j&&re.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${j} properties.`}),void 0!==R&&t.length>R&&re.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${R} properties.`}),void 0!==N){const t=`${s}/propertyNames`;for(const s in e){const e=`${a}/${bu(s)}`,c=Lu(s,N,r,n,i,o,e,t);c.valid||re.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(void 0!==P){const t=`${s}/dependantRequired`;for(const r in P)if(r in e){const n=P[r];for(const i of n)i in e||re.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:t,error:`Instance has "${r}" but does not have "${i}".`})}}if(void 0!==C)for(const t in C){const u=`${s}/dependentSchemas`;if(t in e){const s=Lu(e,C[t],r,n,i,o,a,`${u}/${bu(t)}`,c);s.valid||re.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:u,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(void 0!==L){const t=`${s}/dependencies`;for(const s in L)if(s in e){const c=L[s];if(Array.isArray(c))for(const r of c)r in e||re.push({instanceLocation:a,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not have "${r}".`});else{const u=Lu(e,c,r,n,i,o,a,`${t}/${bu(s)}`);u.valid||re.push({instanceLocation:a,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...u.errors)}}}const u=Object.create(null);let l=!1;if(void 0!==T){const t=`${s}/properties`;for(const s in T){if(!(s in e))continue;const d=`${a}/${bu(s)}`,f=Lu(e[s],T[s],r,n,i,o,d,`${t}/${bu(s)}`);if(f.valid)c[s]=u[s]=!0;else if(l=i,re.push({instanceLocation:a,keyword:"properties",keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),l)break}}if(!l&&void 0!==x){const t=`${s}/patternProperties`;for(const s in x){const d=new RegExp(s,"u"),f=x[s];for(const p in e){if(!d.test(p))continue;const h=`${a}/${bu(p)}`,m=Lu(e[p],f,r,n,i,o,h,`${t}/${bu(s)}`);m.valid?c[p]=u[p]=!0:(l=i,re.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...m.errors))}}}if(l||void 0===I){if(!l&&void 0!==k){const t=`${s}/unevaluatedProperties`;for(const s in e)if(!c[s]){const u=`${a}/${bu(s)}`,l=Lu(e[s],k,r,n,i,o,u,t);l.valid?c[s]=!0:re.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...l.errors)}}}else{const t=`${s}/additionalProperties`;for(const s in e){if(u[s])continue;const d=`${a}/${bu(s)}`,f=Lu(e[s],I,r,n,i,o,d,t);f.valid?c[s]=!0:(l=i,re.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}}else if("array"===l){void 0!==q&&e.length>q&&re.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${q}).`}),void 0!==G&&e.length<G&&re.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${G}).`});const t=e.length;let u=0,l=!1;if(void 0!==M){const d=`${s}/prefixItems`,f=Math.min(M.length,t);for(;u<f;u++){const t=Lu(e[u],M[u],r,n,i,o,`${a}/${u}`,`${d}/${u}`);if(c[u]=!0,!t.valid&&(l=i,re.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:d,error:"Items did not match schema."},...t.errors),l))break}}if(void 0!==$){const d=`${s}/items`;if(Array.isArray($)){const s=Math.min($.length,t);for(;u<s;u++){const t=Lu(e[u],$[u],r,n,i,o,`${a}/${u}`,`${d}/${u}`);if(c[u]=!0,!t.valid&&(l=i,re.push({instanceLocation:a,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),l))break}}else for(;u<t;u++){const t=Lu(e[u],$,r,n,i,o,`${a}/${u}`,d);if(c[u]=!0,!t.valid&&(l=i,re.push({instanceLocation:a,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),l))break}if(!l&&void 0!==D){const d=`${s}/additionalItems`;for(;u<t;u++){const t=Lu(e[u],D,r,n,i,o,`${a}/${u}`,d);c[u]=!0,t.valid||(l=i,re.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:d,error:"Items did not match additional items schema."},...t.errors))}}}if(void 0!==F)if(0===t&&void 0===U)re.push({instanceLocation:a,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==U&&t<U)re.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${U}).`});else{const u=`${s}/contains`,l=re.length;let d=0;for(let s=0;s<t;s++){const t=Lu(e[s],F,r,n,i,o,`${a}/${s}`,u);t.valid?(c[s]=!0,d++):re.push(...t.errors)}d>=(U||0)&&(re.length=l),void 0===U&&void 0===z&&0===d?re.splice(l,0,{instanceLocation:a,keyword:"contains",keywordLocation:u,error:"Array does not contain item matching schema."}):void 0!==U&&d<U?re.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${U} items matching schema. Only ${d} items were found.`}):void 0!==z&&d>z&&re.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${z} items matching schema. ${d} items were found.`})}if(!l&&void 0!==B){const l=`${s}/unevaluatedItems`;for(;u<t;u++){if(c[u])continue;const t=Lu(e[u],B,r,n,i,o,`${a}/${u}`,l);c[u]=!0,t.valid||re.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:l,error:"Items did not match unevaluated items schema."},...t.errors)}}if(V)for(let r=0;r<t;r++){const n=e[r],i="object"==typeof n&&null!==n;for(let o=0;o<t;o++){if(r===o)continue;const t=e[o];(n===t||i&&("object"==typeof t&&null!==t)&&gu(n,t))&&(re.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${r} and ${o}.`}),r=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER)}}}else if("number"===l){if("4"===r?(void 0!==W&&(!0===K&&e<=W||e<W)&&re.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${K?"or equal to ":""} ${W}.`}),void 0!==H&&(!0===Z&&e>=H||e>H)&&re.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Z?"or equal to ":""} ${H}.`})):(void 0!==W&&e<W&&re.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${W}.`}),void 0!==H&&e>H&&re.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${H}.`}),void 0!==K&&e<=K&&re.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${K}.`}),void 0!==Z&&e>=Z&&re.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Z}.`})),void 0!==J){const t=e%J;Math.abs(0-t)>=1.1920929e-7&&Math.abs(J-t)>=1.1920929e-7&&re.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${J}.`})}}else if("string"===l){const t=void 0===Y&&void 0===Q?0:function(e){let t,r=0,n=e.length,i=0;for(;i<n;)r++,t=e.charCodeAt(i++),t>=55296&&t<=56319&&i<n&&(t=e.charCodeAt(i),56320==(64512&t)&&i++);return r}(e);void 0!==Y&&t<Y&&re.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${Y}).`}),void 0!==Q&&t>Q&&re.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Q}).`}),void 0===X||new RegExp(X,"u").test(e)||re.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),void 0!==A&&Iu[A]&&!Iu[A](e)&&re.push({instanceLocation:a,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${A}".`})}return{valid:0===re.length,errors:re}}function Mu(e){if("object"!=typeof e||null===e)return!1;if(!("_zod"in e))return!1;const t=e._zod;return"object"==typeof t&&null!==t&&"def"in t}function $u(e){if("object"!=typeof e||null===e)return!1;if(!("_def"in e)||"_zod"in e)return!1;const t=e._def;return"object"==typeof t&&null!=t&&"typeName"in t}function Du(e){return!!e&&("object"==typeof e&&(!Array.isArray(e)&&!(!Mu(e)&&!$u(e))))}async function Bu(e,t){if(Mu(e))return wc(e,t);if($u(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Fu(e){return!!Mu(e)&&("object"==typeof e&&null!==e&&"_zod"in e&&"object"==typeof e._zod&&null!==e._zod&&"def"in e._zod&&"object"==typeof e._zod.def&&null!==e._zod.def&&"type"in e._zod.def&&"object"===e._zod.def.type)}function Uu(e){return!!Mu(e)&&("object"==typeof e&&null!==e&&"_zod"in e&&"object"==typeof e._zod&&null!==e._zod&&"def"in e._zod&&"object"==typeof e._zod.def&&null!==e._zod.def&&"type"in e._zod.def&&"array"===e._zod.def.type)}function zu(e,t=!1){if($u(e))return e.strict();if(Fu(e)){const n=e._zod.def.shape;if(t)for(const[r,i]of Object.entries(e._zod.def.shape)){if(Fu(i)){const e=zu(i,t);n[r]=e}else if(Uu(i)){let e=i._zod.def.element;Fu(e)&&(e=zu(e,t)),n[r]=fc(i,{...i._zod.def,element:e})}else n[r]=i;const e=jc.get(i);e&&jc.add(n[r],e)}const i=fc(e,{...e._zod.def,shape:n,catchall:(r=xc,new r({type:"never"}))}),o=jc.get(e);return o&&jc.add(i,o),i}var r;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Gu(e,t=!1){if($u(e))return function(e){return $u(e)&&"typeName"in e._def&&"ZodEffects"===e._def.typeName}(e)?Gu(e._def.schema,t):e;if(Mu(e)){let r=e;if(function(e){return Mu(e)&&"pipe"===e._zod.def.type}(e)&&(r=Gu(e._zod.def.in,t)),t)if(Fu(r)){const e=r._zod.def.shape;for(const[n,i]of Object.entries(r._zod.def.shape))e[n]=Gu(i,t);r=fc(r,{...r._zod.def,shape:e})}else if(Uu(r)){const e=Gu(r._zod.def.element,t);r=fc(r,{...r._zod.def,element:e})}const n=jc.get(e);return n&&jc.add(r,n),r}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function qu(e){if(Mu(e)){const t=Gu(e,!0);if(Fu(t)){return Nc(zu(t,!0))}return Nc(e)}return $u(e)?((e,t)=>{const r=Mc(t);let n;const i=t?.name,o=hu(e._def,r,!1)??Fc(r);r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===r.$refStrategy?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const a=void 0===i?n?{...o,[r.definitionPath]:n}:o:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};return"jsonSchema7"===r.target?a.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(a.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a})(e):e}function Vu(e,t){if(void 0!==e&&!ar(e))return e;if(!ec(t))return t.name??"UnknownSchema";try{let e=t.getName();return e=e.startsWith("Runnable")?e.slice(8):e,e}catch(e){return t.getName()}}function Wu(e){return ec(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...qu(e.data.schema),title:e.data.name}}}class Hu{constructor(e){Object.defineProperty(this,"nodes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"edges",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.nodes=e?.nodes??this.nodes,this.edges=e?.edges??this.edges}toJSON(){const e={};return Object.values(this.nodes).forEach((t,r)=>{e[t.id]=ar(t.id)?r:t.id}),{nodes:Object.values(this.nodes).map(t=>({id:e[t.id],...Wu(t)})),edges:this.edges.map(t=>{const r={source:e[t.source],target:e[t.target]};return void 0!==t.data&&(r.data=t.data),void 0!==t.conditional&&(r.conditional=t.conditional),r})}}addNode(e,t,r){if(void 0!==t&&void 0!==this.nodes[t])throw new Error(`Node with id ${t} already exists`);const n=t??hr(),i={id:n,data:e,name:Vu(t,e),metadata:r};return this.nodes[n]=i,i}removeNode(e){delete this.nodes[e.id],this.edges=this.edges.filter(t=>t.source!==e.id&&t.target!==e.id)}addEdge(e,t,r,n){if(void 0===this.nodes[e.id])throw new Error(`Source node ${e.id} not in graph`);if(void 0===this.nodes[t.id])throw new Error(`Target node ${t.id} not in graph`);const i={source:e.id,target:t.id,data:r,conditional:n};return this.edges.push(i),i}firstNode(){return Ku(this)}lastNode(){return Zu(this)}extend(e,t=""){let r=t;Object.values(e.nodes).map(e=>e.id).every(ar)&&(r="");const n=e=>r?`${r}:${e}`:e;Object.entries(e.nodes).forEach(([e,t])=>{this.nodes[n(e)]={...t,id:n(e)}});const i=e.edges.map(e=>({...e,source:n(e.source),target:n(e.target)}));this.edges=[...this.edges,...i];const o=e.firstNode(),a=e.lastNode();return[o?{id:n(o.id),data:o.data}:void 0,a?{id:n(a.id),data:a.data}:void 0]}trimFirstNode(){const e=this.firstNode();e&&Ku(this,[e.id])&&this.removeNode(e)}trimLastNode(){const e=this.lastNode();e&&Zu(this,[e.id])&&this.removeNode(e)}reid(){const e=Object.fromEntries(Object.values(this.nodes).map(e=>[e.id,e.name])),t=new Map;Object.values(e).forEach(e=>{t.set(e,(t.get(e)||0)+1)});const r=r=>{const n=e[r];return ar(r)&&1===t.get(n)?n:r};return new Hu({nodes:Object.fromEntries(Object.entries(this.nodes).map(([e,t])=>[r(e),{...t,id:r(e)}])),edges:this.edges.map(e=>({...e,source:r(e.source),target:r(e.target)}))})}drawMermaid(e){const{withStyles:t,curveStyle:r,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:i}=e??{},o=this.reid(),a=o.firstNode(),s=o.lastNode();return ic(o.nodes,o.edges,{firstNode:a?.id,lastNode:s?.id,withStyles:t,curveStyle:r,nodeColors:n,wrapLabelNWords:i})}async drawMermaidPng(e){return oc(this.drawMermaid(e),{backgroundColor:e?.backgroundColor})}}function Ku(e,t=[]){const r=new Set(e.edges.filter(e=>!t.includes(e.source)).map(e=>e.target)),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||r.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function Zu(e,t=[]){const r=new Set(e.edges.filter(e=>!t.includes(e.target)).map(e=>e.source)),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||r.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function Ju(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.iterator]&&"function"==typeof e.next}function Yu(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.asyncIterator]}function*Qu(e,t){for(;;){const{value:r,done:n}=Is.runWithConfig(Cs(e),t.next.bind(t),!0);if(n)break;yield r}}async function*Xu(e,t){const r=t[Symbol.asyncIterator]();for(;;){const{value:n,done:i}=await Is.runWithConfig(Cs(e),r.next.bind(t),!0);if(i)break;yield n}}function el(e,t){return!e||Array.isArray(e)||e instanceof Date||"object"!=typeof e?{[t]:e}:e}class tl extends re{constructor(){super(...arguments),Object.defineProperty(this,"lc_runnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}getName(e){const t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}bind(e){return new rl({bound:this,kwargs:e,config:{}})}map(){return new nl({bound:this})}withRetry(e){return new il({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new rl({bound:this,config:e,kwargs:{}})}withFallbacks(e){const t=Array.isArray(e)?e:e.fallbacks;return new ul({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(Ns);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");const r=Object.fromEntries(Object.entries(e).filter(([e])=>"runId"!==e));return Array.from({length:t},(t,n)=>Ns(0===n?e:r))}return Array.from({length:t},()=>Ns(e))}async batch(e,t,r){const n=this._getOptionsList(t??{},e.length),i=n[0]?.maxConcurrency??r?.maxConcurrency,o=new Qs({maxConcurrency:i,onFailedAttempt:e=>{throw e}}),a=e.map((e,t)=>o.call(async()=>{try{return await this.invoke(e,n[t])}catch(e){if(r?.returnExceptions)return e;throw e}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){const r=Ns(t),n=new Bs({generator:this._streamIterator(e,r),config:r});return await n.setup,Ms.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;t=Ns(void 0===e?e:{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});const 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){const n=Ns(r),i=await ks(n),o=await(i?.handleChainStart(this.toJSON(),el(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName()));let a;delete n.runId;try{const i=e.call(this,t,n,o);a=await Ls(i,r?.signal)}catch(e){throw await(o?.handleChainError(e)),e}return await(o?.handleChainEnd(el(a,"output"))),a}async _batchWithConfig(e,t,r,n){const i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(ks)),a=await Promise.all(o.map(async(e,r)=>{const n=await(e?.handleChainStart(this.toJSON(),el(t[r],"input"),i[r].runId,i[r].runType,void 0,void 0,i[r].runName??this.getName()));return delete i[r].runId,n}));let s;try{const r=e.call(this,t,i,a,n);s=await Ls(r,i?.[0]?.signal)}catch(e){throw await Promise.all(a.map(t=>t?.handleChainError(e))),e}return await Promise.all(a.map(e=>e?.handleChainEnd(el(s,"output")))),s}_concatOutputChunks(e,t){return Ds(e,t)}async*_transformStreamWithConfig(e,t,r){let n,i,o=!0,a=!0;const s=Ns(r),c=await ks(s),u=this;let l;try{const d=await async function(e,t,r,n,...i){const o=new Bs({generator:t,startSetup:r,signal:n}),a=await o.setup;return{output:e(o,a,...i),setup:a}}(t.bind(this),async function*(){for await(const t of e){if(o)if(void 0===n)n=t;else try{n=u._concatOutputChunks(n,t)}catch{n=void 0,o=!1}yield t}}(),async()=>c?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName()),r?.signal,s);delete s.runId,l=d.setup;const f=l?.handlers.find(Ks);let p=d.output;void 0!==f&&void 0!==l&&(p=f.tapOutputIterable(l.runId,p));const h=l?.handlers.find(zs);void 0!==h&&void 0!==l&&(p=h.tapOutputIterable(l.runId,p));for await(const e of p)if(yield e,a)if(void 0===i)i=e;else try{i=this._concatOutputChunks(i,e)}catch{i=void 0,a=!1}}catch(e){throw await(l?.handleChainError(e,void 0,void 0,void 0,{inputs:el(n,"input")})),e}await(l?.handleChainEnd(i??{},void 0,void 0,void 0,{inputs:el(n,"input")}))}getGraph(e){const t=new Hu,r=t.addNode({name:`${this.getName()}Input`,schema:Vt()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:Vt()});return t.addEdge(r,n),t.addEdge(n,i),t}pipe(e){return new ol({first:this,last:ll(e)})}pick(e){return this.pipe(new fl(e))}assign(e){return this.pipe(new dl(new al({steps:e})))}async*transform(e,t){let r;for await(const t of e)r=void 0===r?t:this._concatOutputChunks(r,t);yield*this._streamIterator(r,Ns(t))}async*streamLog(e,t,r){const n=new Vs({...r,autoClose:!1,_schemaFormat:"original"}),i=Ns(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,r){const{callbacks:n}=r;if(void 0===n)r.callbacks=[t];else if(Array.isArray(n))r.callbacks=n.concat([t]);else{const e=n.copy();e.addHandler(t,!0),r.callbacks=e}const i=this.stream(e,r);const o=async function(){try{const e=await i;for await(const r of e){const e=new Fs({ops:[{op:"add",path:"/streamed_output/-",value:r}]});await t.writer.write(e)}}finally{await t.writer.close()}}();try{for await(const e of t)yield e}finally{await o}}streamEvents(e,t,r){let n;if("v1"===t.version)n=this._streamEventsV1(e,t,r);else{if("v2"!==t.version)throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');n=this._streamEventsV2(e,t,r)}return"text/event-stream"===t.encoding?function(e){const t=new TextEncoder,r=new ReadableStream({async start(r){for await(const n of e)r.enqueue(t.encode(`event: data\ndata: ${JSON.stringify(n)}\n\n`));r.enqueue(t.encode("event: end\n\n")),r.close()}});return Ms.fromReadableStream(r)}(n):Ms.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,r){const n=new Zs({...r,autoClose:!1}),i=Ns(t),o=i.runId??hr();i.runId=o;const a=i.callbacks;if(void 0===a)i.callbacks=[n];else if(Array.isArray(a))i.callbacks=a.concat(n);else{const e=a.copy();e.addHandler(n,!0),i.callbacks=e}const s=new AbortController,c=this;const u=async function(){let r,a=null;try{t?.signal?"any"in AbortSignal?r=AbortSignal.any([s.signal,t.signal]):(r=t.signal,a=()=>{s.abort()},t.signal.addEventListener("abort",a,{once:!0})):r=s.signal;const u=await c.stream(e,{...i,signal:r}),l=n.tapOutputIterable(o,u);for await(const e of l)if(s.signal.aborted)break}finally{await n.finish(),r&&a&&r.removeEventListener("abort",a)}}();let l,d=!1;try{for await(const t of n)d?(t.run_id===l&&t.event.endsWith("_end")&&t.data?.input&&delete t.data.input,yield t):(t.data.input=e,d=!0,l=t.run_id,yield t)}finally{s.abort(),await u}}async*_streamEventsV1(e,t,r){let n,i=!1;const o=Ns(t),a=o.tags??[],s=o.metadata??{},c=o.runName??this.getName(),u=new Vs({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new tc({...r}),d=this._streamLog(e,u,o);for await(const t of d){if(n=n?n.concat(t):Us.fromRunLogPatch(t),void 0===n.state)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;const t={...n.state},r={run_id:t.id,event:`on_${t.type}_start`,name:c,tags:a,metadata:s,data:{input:e}};l.includeEvent(r,t.type)&&(yield r)}const r=t.ops.filter(e=>e.path.startsWith("/logs/")).map(e=>e.path.split("/")[2]),o=[...new Set(r)];for(const e of o){let t,r={};const i=n.state.logs[e];if(t=void 0===i.end_time?i.streamed_output.length>0?"stream":"start":"end","start"===t)void 0!==i.inputs&&(r.input=i.inputs);else if("end"===t)void 0!==i.inputs&&(r.input=i.inputs),r.output=i.final_output;else if("stream"===t){const e=i.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${i.name}"`);r={chunk:i.streamed_output[0]},i.streamed_output=[]}yield{event:`on_${i.type}_${t}`,name:i.name,run_id:i.id,tags:i.tags,metadata:i.metadata,data:r}}const{state:u}=n;if(u.streamed_output.length>0){const e=u.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${u.name}"`);const t={chunk:u.streamed_output[0]};u.streamed_output=[];const r={event:`on_${u.type}_stream`,run_id:u.id,tags:a,metadata:s,name:c,data:t};l.includeEvent(r,u.type)&&(yield r)}}const f=n?.state;if(void 0!==f){const e={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:a,metadata:s,data:{output:f.final_output}};l.includeEvent(e,f.type)&&(yield e)}}static isRunnable(e){return ec(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new rl({bound:this,config:{},configFactories:[n=>({callbacks:[new Xs({config:n,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return function(e,t){const r=t.name??e.getName(),n=t.description??(i=t.schema,Mu(i)?jc.get(i)?.description:$u(i)||"description"in i&&"string"==typeof i.description?i.description:void 0);var i;if(function(e){if(!Du(e))return!1;if($u(e))return"ZodString"===e._def.typeName;if(Mu(e))return"string"===e._zod.def.type;return!1}(t.schema))return new pl({name:r,description:n,schema:Wt({input:qt()}).transform(e=>e.input),bound:e});return new pl({name:r,description:n,schema:t.schema,bound:e})}(this,e)}}class rl extends tl{static lc_name(){return"RunnableBinding"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"configFactories",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound,this.kwargs=e.kwargs,this.config=e.config,this.configFactories=e.configFactories}getName(e){return this.bound.getName(e)}async _mergeConfig(...e){const t=js(this.config,...e);return js(t,...this.configFactories?await Promise.all(this.configFactories.map(async e=>await e(t))):[])}bind(e){return new this.constructor({bound:this.bound,kwargs:{...this.kwargs,...e},config:this.config})}withConfig(e){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...e}})}withRetry(e){return new il({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:e?.stopAfterAttempt,...e})}async invoke(e,t){return this.bound.invoke(e,await this._mergeConfig(Ns(t),this.kwargs))}async batch(e,t,r){const n=Array.isArray(t)?await Promise.all(t.map(async e=>this._mergeConfig(Ns(e),this.kwargs))):await this._mergeConfig(Ns(t),this.kwargs);return this.bound.batch(e,n,r)}_concatOutputChunks(e,t){return this.bound._concatOutputChunks(e,t)}async*_streamIterator(e,t){yield*this.bound._streamIterator(e,await this._mergeConfig(Ns(t),this.kwargs))}async stream(e,t){return this.bound.stream(e,await this._mergeConfig(Ns(t),this.kwargs))}async*transform(e,t){yield*this.bound.transform(e,await this._mergeConfig(Ns(t),this.kwargs))}streamEvents(e,t,r){const n=this;return Ms.fromAsyncGenerator(async function*(){yield*n.bound.streamEvents(e,{...await n._mergeConfig(Ns(t),n.kwargs),version:t.version},r)}())}static isRunnableBinding(e){return e.bound&&tl.isRunnable(e.bound)}withListeners({onStart:e,onEnd:t,onError:r}){return new rl({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new Xs({config:n,onStart:e,onEnd:t,onError:r})]})]})}}class nl extends tl{static lc_name(){return"RunnableEach"}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound}bind(e){return new nl({bound:this.bound.bind(e)})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _invoke(e,t,r){return this.bound.batch(e,Ps(t,{callbacks:r?.getChild()}))}withListeners({onStart:e,onEnd:t,onError:r}){return new nl({bound:this.bound.withListeners({onStart:e,onEnd:t,onError:r})})}}class il extends rl{static lc_name(){return"RunnableRetry"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"maxAttemptNumber",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:()=>{}}),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){const n=e>1?`retry:attempt:${e}`:void 0;return Ps(t,{callbacks:r?.getChild(n)})}async _invoke(e,t,r){return ir(n=>super.invoke(e,this._patchConfigForRetry(n,t,r)),{onFailedAttempt:t=>this.onFailedAttempt(t,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,n){const i={};try{await ir(async o=>{const a=e.map((e,t)=>t).filter(e=>void 0===i[e.toString()]||i[e.toString()]instanceof Error),s=a.map(t=>e[t]),c=a.map(e=>this._patchConfigForRetry(o,t?.[e],r?.[e])),u=await super.batch(s,c,{...n,returnExceptions:!0});let l;for(let e=0;e<u.length;e+=1){const t=u[e],r=a[e];t instanceof Error&&void 0===l&&(l=t,l.input=s[e]),i[r.toString()]=t}if(l)throw l;return u},{onFailedAttempt:e=>this.onFailedAttempt(e,e.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(e){if(!0!==n?.returnExceptions)throw e}return Object.keys(i).sort((e,t)=>parseInt(e,10)-parseInt(t,10)).map(e=>i[parseInt(e,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}}class ol extends tl{static lc_name(){return"RunnableSequence"}constructor(e){super(e),Object.defineProperty(this,"first",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"middle",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitSequenceTags",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),this.first=e.first,this.middle=e.middle??this.middle,this.last=e.last,this.name=e.name,this.omitSequenceTags=e.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(e,t){const r=Ns(t),n=await ks(r),i=await(n?.handleChainStart(this.toJSON(),el(e,"input"),r.runId,void 0,void 0,void 0,r?.runName));delete r.runId;let o,a=e;try{const e=[this.first,...this.middle];for(let n=0;n<e.length;n+=1){const o=e[n].invoke(a,Ps(r,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${n+1}`)}));a=await Ls(o,t?.signal)}if(t?.signal?.aborted)throw new Error("Aborted");o=await this.last.invoke(a,Ps(r,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(el(o,"output"))),o}async batch(e,t,r){const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(ks)),o=await Promise.all(i.map(async(t,r)=>{const i=await(t?.handleChainStart(this.toJSON(),el(e[r],"input"),n[r].runId,void 0,void 0,void 0,n[r].runName));return delete n[r].runId,i}));let a=e;try{for(let e=0;e<this.steps.length;e+=1){const t=this.steps[e].batch(a,o.map((t,r)=>{const i=t?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`);return Ps(n[r],{callbacks:i})}),r);a=await Ls(t,n[0]?.signal)}}catch(e){throw await Promise.all(o.map(t=>t?.handleChainError(e))),e}return await Promise.all(o.map(e=>e?.handleChainEnd(el(a,"output")))),a}_concatOutputChunks(e,t){return this.last._concatOutputChunks(e,t)}async*_streamIterator(e,t){const r=await ks(t),{runId:n,...i}=t??{},o=await(r?.handleChainStart(this.toJSON(),el(e,"input"),n,void 0,void 0,void 0,i?.runName)),a=[this.first,...this.middle,this.last];let s,c=!0;try{let r=a[0].transform(async function*(){yield e}(),Ps(i,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let e=1;e<a.length;e+=1){const t=a[e];r=await t.transform(r,Ps(i,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`)}))}for await(const e of r)if(t?.signal?.throwIfAborted(),yield e,c)if(void 0===s)s=e;else try{s=this._concatOutputChunks(s,e)}catch(e){s=void 0,c=!1}}catch(e){throw await(o?.handleChainError(e)),e}await(o?.handleChainEnd(el(s,"output")))}getGraph(e){const t=new Hu;let r=null;return this.steps.forEach((n,i)=>{const o=n.getGraph(e);0!==i&&o.trimFirstNode(),i!==this.steps.length-1&&o.trimLastNode(),t.extend(o);const a=o.firstNode();if(!a)throw new Error(`Runnable ${n} has no first node`);r&&t.addEdge(r,a),r=o.lastNode()}),t}pipe(e){return ol.isRunnableSequence(e)?new ol({first:this.first,middle:this.middle.concat([this.last,e.first,...e.middle]),last:e.last,name:this.name??e.name}):new ol({first:this.first,middle:[...this.middle,this.last],last:ll(e),name:this.name})}static isRunnableSequence(e){return Array.isArray(e.middle)&&tl.isRunnable(e)}static from([e,...t],r){let n={};return"string"==typeof r?n.name=r:void 0!==r&&(n=r),new ol({...n,first:ll(e),middle:t.slice(0,-1).map(ll),last:ll(t[t.length-1])})}}class al extends tl{static lc_name(){return"RunnableMap"}getStepsKeys(){return Object.keys(this.steps)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.steps={};for(const[t,r]of Object.entries(e.steps))this.steps[t]=ll(r)}static from(e){return new al({steps:e})}async invoke(e,t){const r=Ns(t),n=await ks(r),i=await(n?.handleChainStart(this.toJSON(),{input:e},r.runId,void 0,void 0,void 0,r?.runName));delete r.runId;const o={};try{const n=Object.entries(this.steps).map(async([t,n])=>{o[t]=await n.invoke(e,Ps(r,{callbacks:i?.getChild(`map:key:${t}`)}))});await Ls(Promise.all(n),t?.signal)}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(o)),o}async*_transform(e,t,r){const n={...this.steps},i=$s(e,Object.keys(n).length),o=new Map(Object.entries(n).map(([e,n],o)=>{const a=n.transform(i[o],Ps(r,{callbacks:t?.getChild(`map:key:${e}`)}));return[e,a.next().then(t=>({key:e,gen:a,result:t}))]}));for(;o.size;){const e=Promise.race(o.values()),{key:t,result:n,gen:i}=await Ls(e,r?.signal);o.delete(t),n.done||(yield{[t]:n.value},o.set(t,i.next().then(e=>({key:t,gen:i,result:e}))))}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const r=Ns(t),n=new Bs({generator:this.transform(async function*(){yield e}(),r),config:r});return await n.setup,Ms.fromAsyncGenerator(n)}}class sl extends tl{constructor(e){if(super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!Or(e.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=e.func}async invoke(e,t){const[r]=this._getOptionsList(t??{},1),n=await ks(r);return Ls(this.func(Ps(r,{callbacks:n}),e),r?.signal)}async*_streamIterator(e,t){const[r]=this._getOptionsList(t??{},1),n=await this.invoke(e,t);var i;if(Yu(n))for await(const e of n)r?.signal?.throwIfAborted(),yield e;else if(null!=(i=n)&&"object"==typeof i&&"next"in i&&"function"==typeof i.next)for(;;){r?.signal?.throwIfAborted();const e=n.next();if(e.done)break;yield e.value}else yield n}static from(e){return new sl({func:e})}}class cl extends tl{static lc_name(){return"RunnableLambda"}constructor(e){if(Or(e.func))return sl.from(e.func);super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e){if(Or(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}(e.func),this.func=e.func}static from(e){return new cl({func:e})}async _invoke(e,t,r){return new Promise((n,i)=>{const o=Ps(t,{callbacks:r?.getChild(),recursionLimit:(t?.recursionLimit??25)-1});Is.runWithConfig(Cs(o),async()=>{try{let r=await this.func(e,{...o});if(r&&tl.isRunnable(r)){if(0===t?.recursionLimit)throw new Error("Recursion limit reached.");r=await r.invoke(e,{...o,recursionLimit:(o.recursionLimit??25)-1})}else if(Yu(r)){let e;for await(const n of Xu(o,r))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=this._concatOutputChunks(e,n)}catch(t){e=n}r=e}else if(Ju(r)){let e;for(const n of Qu(o,r))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=this._concatOutputChunks(e,n)}catch(t){e=n}r=e}n(r)}catch(e){i(e)}})})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async*_transform(e,t,r){let n;for await(const t of e)if(void 0===n)n=t;else try{n=this._concatOutputChunks(n,t)}catch(e){n=t}const i=Ps(r,{callbacks:t?.getChild(),recursionLimit:(r?.recursionLimit??25)-1}),o=await new Promise((e,t)=>{Is.runWithConfig(Cs(i),async()=>{try{const t=await this.func(n,{...i,config:i});e(t)}catch(e){t(e)}})});if(o&&tl.isRunnable(o)){if(0===r?.recursionLimit)throw new Error("Recursion limit reached.");const e=await o.stream(n,i);for await(const t of e)yield t}else if(Yu(o))for await(const e of Xu(i,o))r?.signal?.throwIfAborted(),yield e;else if(Ju(o))for(const e of Qu(i,o))r?.signal?.throwIfAborted(),yield e;else yield o}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const r=Ns(t),n=new Bs({generator:this.transform(async function*(){yield e}(),r),config:r});return await n.setup,Ms.fromAsyncGenerator(n)}}class ul extends tl{static lc_name(){return"RunnableWithFallbacks"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(const e of this.fallbacks)yield e}async invoke(e,t){const r=Ns(t),n=await ks(r),{runId:i,...o}=r,a=await(n?.handleChainStart(this.toJSON(),el(e,"input"),i,void 0,void 0,void 0,o?.runName)),s=Ps(o,{callbacks:a?.getChild()});return await Is.runWithConfig(s,async()=>{let t;for(const n of this.runnables()){r?.signal?.throwIfAborted();try{const t=await n.invoke(e,s);return await(a?.handleChainEnd(el(t,"output"))),t}catch(e){void 0===t&&(t=e)}}if(void 0===t)throw new Error("No error stored at end of fallback.");throw await(a?.handleChainError(t)),t})}async*_streamIterator(e,t){const r=Ns(t),n=await ks(r),{runId:i,...o}=r,a=await(n?.handleChainStart(this.toJSON(),el(e,"input"),i,void 0,void 0,void 0,o?.runName));let s,c,u;for(const t of this.runnables()){r?.signal?.throwIfAborted();const n=Ps(o,{callbacks:a?.getChild()});try{c=Xu(n,await t.stream(e,n));break}catch(e){void 0===s&&(s=e)}}if(void 0===c){const e=s??new Error("No error stored at end of fallback.");throw await(a?.handleChainError(e)),e}try{for await(const e of c){yield e;try{u=void 0===u?u:this._concatOutputChunks(u,e)}catch(e){u=void 0}}}catch(e){throw await(a?.handleChainError(e)),e}await(a?.handleChainEnd(el(u,"output")))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(e=>ks(e))),o=await Promise.all(i.map(async(t,r)=>{const i=await(t?.handleChainStart(this.toJSON(),el(e[r],"input"),n[r].runId,void 0,void 0,void 0,n[r].runName));return delete n[r].runId,i}));let a;for(const t of this.runnables()){n[0].signal?.throwIfAborted();try{const i=await t.batch(e,o.map((e,t)=>Ps(n[t],{callbacks:e?.getChild()})),r);return await Promise.all(o.map((e,t)=>e?.handleChainEnd(el(i[t],"output")))),i}catch(e){void 0===a&&(a=e)}}if(!a)throw new Error("No error stored at end of fallbacks.");throw await Promise.all(o.map(e=>e?.handleChainError(a))),a}}function ll(e){if("function"==typeof e)return new cl({func:e});if(tl.isRunnable(e))return e;if(Array.isArray(e)||"object"!=typeof e)throw new Error("Expected a Runnable, function or object.\nInstead got an unsupported type.");{const t={};for(const[r,n]of Object.entries(e))t[r]=ll(n);return new al({steps:t})}}class dl extends tl{static lc_name(){return"RunnableAssign"}constructor(e){e instanceof al&&(e={mapper:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"mapper",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mapper=e.mapper}async invoke(e,t){const r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){const n=this.mapper.getStepsKeys(),[i,o]=$s(e),a=this.mapper.transform(o,Ps(r,{callbacks:t?.getChild()})),s=a.next();for await(const e of i){if("object"!=typeof e||Array.isArray(e))throw new Error("RunnableAssign can only be used with objects as input, got "+typeof e);const t=Object.fromEntries(Object.entries(e).filter(([e])=>!n.includes(e)));Object.keys(t).length>0&&(yield t)}yield(await s).value;for await(const e of a)yield e}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const r=Ns(t),n=new Bs({generator:this.transform(async function*(){yield e}(),r),config:r});return await n.setup,Ms.fromAsyncGenerator(n)}}class fl extends tl{static lc_name(){return"RunnablePick"}constructor(e){("string"==typeof e||Array.isArray(e))&&(e={keys:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keys=e.keys}async _pick(e){if("string"==typeof this.keys)return e[this.keys];{const t=this.keys.map(t=>[t,e[t]]).filter(e=>void 0!==e[1]);return 0===t.length?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(const t of e){const e=await this._pick(t);void 0!==e&&(yield e)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const r=Ns(t),n=new Bs({generator:this.transform(async function*(){yield e}(),r),config:r});return await n.setup,Ms.fromAsyncGenerator(n)}}class pl extends rl{constructor(e){super({bound:ol.from([cl.from(async e=>{let t;if(pe(e))try{t=await Bu(this.schema,e.args)}catch(t){throw new he("Received tool input did not match expected schema",JSON.stringify(e.args))}else t=e;return t}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name}),config:e.config??{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}}var hl,ml={};function yl(){if(hl)return ml;hl=1,ml.byteLength=function(e){var t=o(e),r=t[0],n=t[1];return 3*(r+n)/4-n},ml.toByteArray=function(e){var n,i,a=o(e),s=a[0],c=a[1],u=new r(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),l=0,d=c>0?s-4:s;for(i=0;i<d;i+=4)n=t[e.charCodeAt(i)]<<18|t[e.charCodeAt(i+1)]<<12|t[e.charCodeAt(i+2)]<<6|t[e.charCodeAt(i+3)],u[l++]=n>>16&255,u[l++]=n>>8&255,u[l++]=255&n;2===c&&(n=t[e.charCodeAt(i)]<<2|t[e.charCodeAt(i+1)]>>4,u[l++]=255&n);1===c&&(n=t[e.charCodeAt(i)]<<10|t[e.charCodeAt(i+1)]<<4|t[e.charCodeAt(i+2)]>>2,u[l++]=n>>8&255,u[l++]=255&n);return u},ml.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],a=16383,c=0,u=n-i;c<u;c+=a)o.push(s(t,c,c+a>u?u:c+a));1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"="));return o.join("")};for(var e=[],t=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)e[i]=n[i],t[n.charCodeAt(i)]=i;function o(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("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function a(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function s(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(a(n));return i.join("")}return t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63,ml}var gl=w(yl()),bl=Object.defineProperty;function vl(e,t){return 1===e.length?[t.get(e.join(","))]:function(e,t){let r=Array.from({length:e.length},(e,t)=>({start:t,end:t+1}));for(;r.length>1;){let n=null;for(let i=0;i<r.length-1;i++){const o=e.slice(r[i].start,r[i+1].end),a=t.get(o.join(","));null!=a&&(null==n||a<n[0])&&(n=[a,i])}if(null==n)break;{const e=n[1];r[e]={start:r[e].start,end:r[e+1].end},r.splice(e+1,1)}}return r}(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(e=>null!=e)}var wl,_l=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;const r=e.bpe_ranks.split("\n").filter(Boolean).reduce((e,t)=>{const[r,n,...i]=t.split(" "),o=Number.parseInt(n,10);return i.forEach((t,r)=>e[t]=o+r),e},{});for(const[e,t]of Object.entries(r)){const r=gl.toByteArray(e);this.rankMap.set(r.join(","),t),this.textMap.set(t,r)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((e,[t,r])=>(e[r]=this.textEncoder.encode(t),e),{})}encode(e,t=[],r="all"){const n=new RegExp(this.patStr,"ug"),i=_l.specialTokenRegex(Object.keys(this.specialTokens)),o=[],a=new Set("all"===t?Object.keys(this.specialTokens):t),s=new Set("all"===r?Object.keys(this.specialTokens).filter(e=>!a.has(e)):r);if(s.size>0){const t=_l.specialTokenRegex([...s]),r=e.match(t);if(null!=r)throw new Error(`The text contains a special token that is not allowed: ${r[0]}`)}let c=0;for(;;){let t=null,r=c;for(;i.lastIndex=r,t=i.exec(e),null!=t&&!a.has(t[0]);)r=t.index+1;const s=t?.index??e.length;for(const t of e.substring(c,s).matchAll(n)){const e=this.textEncoder.encode(t[0]),r=this.rankMap.get(e.join(","));null==r?o.push(...vl(e,this.rankMap)):o.push(r)}if(null==t)break;let u=this.specialTokens[t[0]];o.push(u),c=t.index+t[0].length}return o}decode(e){const t=[];let r=0;for(let n=0;n<e.length;++n){const i=e[n],o=this.textMap.get(i)??this.inverseSpecialTokens[i];null!=o&&(t.push(o),r+=o.length)}const n=new Uint8Array(r);let i=0;for(const e of t)n.set(e,i),i+=e.length;return this.textDecoder.decode(n)}};wl=e=>new RegExp(e.map(e=>e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")).join("|"),"g"),((e,t,r)=>{t in e?bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(_l,"specialTokenRegex"+"",wl);class El extends tl{get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),Object.defineProperty(this,"verbose",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{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,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verbose=e.verbose??!1,this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}}class Sl extends El{get lc_namespace(){return["langchain","tools"]}constructor(e){super(e??{}),Object.defineProperty(this,"returnDirect",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"verboseParsingErrors",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"responseFormat",{enumerable:!0,configurable:!0,writable:!0,value:"content"}),Object.defineProperty(this,"defaultConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata}async invoke(e,t){let r,n=Ns(js(this.defaultConfig,t));return pe(e)?(r=e.args,n={...n,toolCall:e}):r=e,this.call(r,n)}async call(e,t,r){const n=pe(e)?e.args:e;let i;if(Du(this.schema))try{i=await Bu(this.schema,n)}catch(t){let r="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(r=`${r}\nDetails: ${t.message}`),new he(r,JSON.stringify(e))}else{const t=Lu(n,this.schema);if(!t.valid){let r="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(r=`${r}\nDetails: ${t.errors.map(e=>`${e.keywordLocation}: ${e.error}`).join("\n")}`),new he(r,JSON.stringify(e))}i=n}const o=gs(t),a=Os.configure(o.callbacks,this.callbacks,o.tags||r,this.tags,o.metadata,this.metadata,{verbose:this.verbose}),s=await(a?.handleToolStart(this.toJSON(),"string"==typeof e?e:JSON.stringify(e),o.runId,void 0,void 0,void 0,o.runName));let c,u,l,d;delete o.runId;try{c=await this._call(i,s,o)}catch(e){throw await(s?.handleToolError(e)),e}if("content_and_artifact"===this.responseFormat){if(!Array.isArray(c)||2!==c.length)throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.\nResult: ${JSON.stringify(c)}`);[u,l]=c}else u=c;pe(e)&&(d=e.id),!d&&function(e){return!!(e&&"object"==typeof e&&"toolCall"in e&&null!=e.toolCall&&"object"==typeof e.toolCall&&"id"in e.toolCall&&"string"==typeof e.toolCall.id)}(o)&&(d=o.toolCall.id);const f=function(e){const{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&(o=t,null==o||"object"!=typeof o||!("lc_direct_tool_output"in o)||!0!==o.lc_direct_tool_output)?"string"==typeof t||Array.isArray(t)&&t.every(e=>"object"==typeof e)?new ce({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new ce({status:"success",content:Al(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t;var o}({content:u,artifact:l,toolCallId:d,name:this.name,metadata:this.metadata});return await(s?.handleToolEnd(f)),f}}class Ol extends Sl{static lc_name(){return"DynamicStructuredTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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){const n=gs(t);return void 0===n.runName&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}}function Al(e){try{return JSON.stringify(e,null,2)??""}catch(t){return`${e}`}}function Tl(e){if(e.isTextMessage()){if("user"==e.role)return new de(e.content);if("assistant"==e.role)return new ue(e.content);if("system"===e.role)return new fe(e.content)}else{if(e.isActionExecutionMessage())return new ue({content:"",tool_calls:[{id:e.id,args:e.arguments,name:e.name}]});if(e.isResultMessage())return new ce({content:e.result,tool_call_id:e.actionExecutionId})}}function xl(e){var t=this;return new Ol(T(T({},e),{name:e.name,description:e.description,schema:r.convertJsonSchemaToZodSchema(JSON.parse(e.jsonSchema),!0),func:function(){return j(t,void 0,void 0,function(){return R(this,function(e){return[2,""]})})}}))}function Il(e){return"[object BaseMessageChunk]"===Object.prototype.toString.call(e)}function kl(e,t){t&&e.sendActionExecutionResult({actionExecutionId:t.id,actionName:t.name,result:"Sending a message"})}function jl(e){return j(this,arguments,void 0,function(e){var t,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w,_,E,S,O,A,T,x,I,k,j,N,P,C,L=e.result,M=e.eventStream$,$=e.actionExecution;return R(this,function(e){switch(e.label){case 0:return"string"!=typeof L?[3,1]:(!$||(null==$?void 0:$.returnDirect)?(M.sendActionExecutionResult({actionExecutionId:$.id,actionName:$.name,result:L}),M.sendTextMessage(r.randomId(),L)):M.sendActionExecutionResult({actionExecutionId:$.id,actionName:$.name,result:L}),[3,11]);case 1:if(R=L,"[object AIMessage]"!==Object.prototype.toString.call(R))return[3,2];for(kl(M,$),L.content&&M.sendTextMessage(r.randomId(),L.content),t=0,n=L.tool_calls;t<n.length;t++)a=n[t],M.sendActionExecution({actionExecutionId:a.id||r.randomId(),actionName:a.name,args:JSON.stringify(a.args)});return[3,11];case 2:if(!Il(L))return[3,3];if(kl(M,$),(null===(_=L.lc_kwargs)||void 0===_?void 0:_.content)&&M.sendTextMessage(r.randomId(),L.content),null===(E=L.lc_kwargs)||void 0===E?void 0:E.tool_calls)for(i=0,o=null===(S=L.lc_kwargs)||void 0===S?void 0:S.tool_calls;i<o.length;i++)a=o[i],M.sendActionExecution({actionExecutionId:a.id||r.randomId(),actionName:a.name,args:JSON.stringify(a.args)});return[3,11];case 3:if(!L||!("getReader"in L))return[3,10];kl(M,$),s=L.getReader(),c=null,u=void 0,l={name:null,id:null,index:null,prevIndex:null},e.label=4;case 4:e.label=5;case 5:return e.trys.push([5,7,,8]),[4,s.read()];case 6:return d=e.sent(),f=d.done,p=d.value,h=void 0,m=void 0,y=void 0,g=!1,b="",p&&p.content&&(b=Array.isArray(p.content)?null!==(A=null===(O=p.content[0])||void 0===O?void 0:O.text)&&void 0!==A?A:"":p.content),!function(e){return"[object AIMessageChunk]"===Object.prototype.toString.call(e)}(p)?Il(p)&&(v=null===(I=null===(x=p.additional_kwargs)||void 0===x?void 0:x.tool_calls)||void 0===I?void 0:I[0],h=null===(k=null==v?void 0:v.function)||void 0===k?void 0:k.name,m=null==v?void 0:v.id,y=null===(j=null==v?void 0:v.function)||void 0===j?void 0:j.arguments,g=null!=(null==v?void 0:v.function)):(v=null===(T=p.tool_call_chunks)||void 0===T?void 0:T[0],y=null==v?void 0:v.args,g=null!=v,(null==v?void 0:v.name)&&(l.name=v.name),null!=(null==v?void 0:v.index)&&(l.index=v.index,null==l.prevIndex&&(l.prevIndex=v.index)),(null==v?void 0:v.id)&&(l.id=null!=v.index?"".concat(v.id,"-idx-").concat(v.index):v.id),h=l.name,m=l.id),"message"===c&&(m||f)?(c=null,M.sendTextMessageEnd({messageId:u})):"function"!==c||g&&!f||(c=null,M.sendActionExecutionEnd({actionExecutionId:m})),f?[3,9]:(null===c&&(g&&m&&h?(c="function",M.sendActionExecutionStart({actionExecutionId:m,actionName:h,parentMessageId:null===(N=p.lc_kwargs)||void 0===N?void 0:N.id})):b&&(c="message",u=(null===(P=p.lc_kwargs)||void 0===P?void 0:P.id)||r.randomId(),M.sendTextMessageStart({messageId:u}))),"message"===c&&b?M.sendTextMessageContent({messageId:u,content:b}):"function"===c&&y&&(l.index!==l.prevIndex&&(M.sendActionExecutionEnd({actionExecutionId:m}),M.sendActionExecutionStart({actionExecutionId:m,actionName:h,parentMessageId:null===(C=p.lc_kwargs)||void 0===C?void 0:C.id}),l.prevIndex=l.index),M.sendActionExecutionArgs({actionExecutionId:m,args:y})),[3,8]);case 7:return w=e.sent(),console.error("Error reading from stream",w),[3,9];case 8:return[3,4];case 9:return[3,11];case 10:if(!$)throw new Error("Invalid return type from LangChain function.");M.sendActionExecutionResult({actionExecutionId:$.id,actionName:$.name,result:Rl(L)}),e.label=11;case 11:return M.complete(),[2]}var R})})}function Rl(e){return void 0===e?"":"string"==typeof e?e:JSON.stringify(e)}var Nl=function(){function e(e){this.options=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"LangChainAdapter"},enumerable:!1,configurable:!0}),e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l=this;return R(this,function(d){switch(d.label){case 0:return d.trys.push([0,,2,4]),t=e.eventSource,n=e.model,i=e.actions,o=e.messages,a=e.runId,s=e.threadId,c=null!=s?s:r.randomUUID(),[4,this.options.chainFn({messages:o.map(Tl),tools:i.map(xl),model:n,threadId:c,runId:a})];case 1:return u=d.sent(),t.stream(function(e){return j(l,void 0,void 0,function(){return R(this,function(t){switch(t.label){case 0:return[4,jl({result:u,eventStream$:e})];case 1:return t.sent(),[2]}})})}),[2,{threadId:c}];case 2:return[4,(0,require("@langchain/core/callbacks/promises").awaitAllCallbacks)()];case 3:return d.sent(),[7];case 4:return[2]}})})},e}(),Pl="gemini-2.5-flash",Cl=!1,Ll=function(e){function t(t){var r=this;return Cl||(null==t?void 0:t.model)||(null==t?void 0:t.apiVersion)||(console.warn("You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. "+'CopilotKit will default to apiVersion="v1" and model="'.concat(Pl,'". ')+"To silence this warning, pass model and apiVersion when constructing the adapter."),Cl=!0),r=e.call(this,{chainFn:function(e){return j(r,[e],void 0,function(e){var r,n,i,o,a,s,c=e.messages,u=e.tools,l=e.threadId;return R(this,function(e){return r=require("@langchain/google-gauth").ChatGoogle,n=require("@langchain/core/messages").AIMessage,i=c.filter(function(e){if(!(e instanceof n))return!0;var t=e;return t.content&&String(t.content).trim().length>0||t.tool_calls&&t.tool_calls.length>0}),this.model=null!==(o=null==t?void 0:t.model)&&void 0!==o?o:Pl,[2,new r({apiKey:null!==(a=null==t?void 0:t.apiKey)&&void 0!==a?a:process.env.GOOGLE_API_KEY,modelName:this.model,apiVersion:null!==(s=null==t?void 0:t.apiVersion)&&void 0!==s?s:"v1"}).bindTools(u).stream(i,{metadata:{conversation_id:l}})]})})}})||this,r.provider="google",r.model=Pl,r}return A(t,e),t}(Nl),Ml=function(){function e(e){var t;this.keepSystemRole=!1,e.openai&&(this._openai=e.openai),this.codeInterpreterEnabled=!1===e.codeInterpreterEnabled||!0,this.fileSearchEnabled=!1===e.fileSearchEnabled||!0,this.assistantId=e.assistantId,this.disableParallelToolCalls=(null==e?void 0:e.disableParallelToolCalls)||!1,this.keepSystemRole=null!==(t=null==e?void 0:e.keepSystemRole)&&void 0!==t&&t}return Object.defineProperty(e.prototype,"name",{get:function(){return"OpenAIAssistantAdapter"},enumerable:!1,configurable:!0}),e.prototype.ensureOpenAI=function(){if(!this._openai){var e=require("openai").default;this._openai=new e({})}return this._openai},e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,r,n,i,o,a,s,c,u,l,d;return R(this,function(f){switch(f.label){case 0:return t=e.messages,r=e.actions,n=e.eventSource,i=e.runId,o=e.forwardedParameters,a=null===(d=null===(l=e.extensions)||void 0===l?void 0:l.openaiAssistantAPI)||void 0===d?void 0:d.threadId,s=this.ensureOpenAI(),a?[3,2]:[4,s.beta.threads.create()];case 1:a=f.sent().id,f.label=2;case 2:return c=t.at(-1),u=void 0,c.isResultMessage()&&i?[4,this.submitToolOutputs(a,i,t,n)]:[3,4];case 3:return u=f.sent(),[3,7];case 4:return c.isTextMessage()?[4,this.submitUserMessage(a,t,r,n,o)]:[3,6];case 5:return u=f.sent(),[3,7];case 6:throw new Error("No actionable message found in the messages");case 7:return[2,{runId:u,threadId:a,extensions:T(T({},e.extensions),{openaiAssistantAPI:{threadId:a,runId:u}})}]}})})},e.prototype.submitToolOutputs=function(e,t,r,n){return j(this,void 0,void 0,function(){var i,o,a,s,c,u;return R(this,function(l){switch(l.label){case 0:return[4,(i=this.ensureOpenAI()).beta.threads.runs.retrieve(e,t)];case 1:if(!(o=l.sent()).required_action)throw new Error("No tool outputs required");if(a=o.required_action.submit_tool_outputs.tool_calls.map(function(e){return e.id}),s=r.filter(function(e){return e.isResultMessage()&&a.includes(e.actionExecutionId)}),a.length!=s.length)throw new Error("Number of function results does not match the number of tool calls");return c=s.map(function(e){return{tool_call_id:e.actionExecutionId,output:e.result}}),u=i.beta.threads.runs.submitToolOutputsStream(e,t,T({tool_outputs:c},this.disableParallelToolCalls&&{parallel_tool_calls:!1})),[4,this.streamResponse(u,n)];case 2:return l.sent(),[2,t]}})})},e.prototype.submitUserMessage=function(e,t,r,n,i){return j(this,void 0,void 0,function(){var o,a,s,c,u,l,d,f=this;return R(this,function(p){switch(p.label){case 0:if(o=this.ensureOpenAI(),t=P([],t,!0),a=t.shift(),s=a.isTextMessage()?a.content:"","user"!==(c=t.map(function(e){return U(e,{keepSystemRole:f.keepSystemRole})}).map(z).at(-1)).role)throw new Error("No user message found");return[4,o.beta.threads.messages.create(e,{role:"user",content:c.content})];case 1:return p.sent(),u=r.map(F),l=P(P(P([],u,!0),this.codeInterpreterEnabled?[{type:"code_interpreter"}]:[],!0),this.fileSearchEnabled?[{type:"file_search"}]:[],!0),d=o.beta.threads.runs.stream(e,T(T({assistant_id:this.assistantId,instructions:s,tools:l},(null==i?void 0:i.maxTokens)&&{max_completion_tokens:i.maxTokens}),this.disableParallelToolCalls&&{parallel_tool_calls:!1})),[4,this.streamResponse(d,n)];case 2:return p.sent(),[2,$l(d)]}})})},e.prototype.streamResponse=function(e,t){return j(this,void 0,void 0,function(){var r=this;return R(this,function(n){return t.stream(function(t){return j(r,void 0,void 0,function(){var r,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w,_,E;return R(this,function(S){switch(S.label){case 0:r=!1,S.label=1;case 1:S.trys.push([1,6,7,12]),o=!0,a=C(e),S.label=2;case 2:return[4,a.next()];case 3:if(s=S.sent(),p=s.done)return[3,5];switch(y=s.value,o=!1,(c=y).event){case"thread.message.created":r&&t.sendActionExecutionEnd({actionExecutionId:i}),n=c.data.id,t.sendTextMessageStart({messageId:n});break;case"thread.message.delta":"text"===(null===(g=c.data.delta.content)||void 0===g?void 0:g[0].type)&&t.sendTextMessageContent({messageId:n,content:null===(b=c.data.delta.content)||void 0===b?void 0:b[0].text.value});break;case"thread.message.completed":t.sendTextMessageEnd({messageId:n});break;case"thread.run.step.delta":u=void 0,l=void 0,d=void 0,"tool_calls"===c.data.delta.step_details.type&&"function"===(null===(v=c.data.delta.step_details.tool_calls)||void 0===v?void 0:v[0].type)&&(u=null===(w=c.data.delta.step_details.tool_calls)||void 0===w?void 0:w[0].id,l=null===(_=c.data.delta.step_details.tool_calls)||void 0===_?void 0:_[0].function.name,d=null===(E=c.data.delta.step_details.tool_calls)||void 0===E?void 0:E[0].function.arguments),l&&u?(r&&t.sendActionExecutionEnd({actionExecutionId:i}),r=!0,i=u,t.sendActionExecutionStart({actionExecutionId:i,parentMessageId:c.data.id,actionName:l})):d&&t.sendActionExecutionArgs({actionExecutionId:i,args:d})}S.label=4;case 4:return o=!0,[3,2];case 5:return[3,12];case 6:return f=S.sent(),h={error:f},[3,12];case 7:return S.trys.push([7,,10,11]),o||p||!(m=a.return)?[3,9]:[4,m.call(a)];case 8:S.sent(),S.label=9;case 9:return[3,11];case 10:if(h)throw h.error;return[7];case 11:return[7];case 12:return r&&t.sendActionExecutionEnd({actionExecutionId:i}),t.complete(),[2]}})})}),[2]})})},e}();function $l(e){return new Promise(function(t,r){var n=function(r){if("thread.run.created"===r.event){var i=r.data.id;e.off("event",n),t(i)}};e.on("event",n)})}var Dl=function(){function e(e){this.provider="unify",(null==e?void 0:e.apiKey)?this.apiKey=e.apiKey:this.apiKey="UNIFY_API_KEY",this.model=null==e?void 0:e.model,this.start=!0}return Object.defineProperty(e.prototype,"name",{get:function(){return"UnifyAdapter"},enumerable:!1,configurable:!0}),e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d=this;return R(this,function(f){switch(f.label){case 0:return t=e.actions.map(F),n=require("openai").default,i=new n({apiKey:this.apiKey,baseURL:"https://api.unify.ai/v0/"}),o=e.forwardedParameters,a=e.messages.map(function(e){return U(e)}),[4,i.chat.completions.create(T(T({model:this.model,messages:a,stream:!0},t.length>0&&{tools:t}),(null==o?void 0:o.temperature)&&{temperature:o.temperature}))];case 1:return s=f.sent(),c=null,e.eventSource.stream(function(e){return j(d,void 0,void 0,function(){var t,n,i,o,a,d,f,p,h,m,y,g,b,v;return R(this,function(w){switch(w.label){case 0:t=null,w.label=1;case 1:w.trys.push([1,6,7,12]),n=!0,i=C(s),w.label=2;case 2:return[4,i.next()];case 3:if(o=w.sent(),h=o.done)return[3,5];g=o.value,n=!1,a=g,this.start&&(c=a.model,u=r.randomId(),e.sendTextMessageStart({messageId:u}),e.sendTextMessageContent({messageId:u,content:"Model used: ".concat(c,"\n")}),e.sendTextMessageEnd({messageId:u}),this.start=!1),d=null===(b=a.choices[0].delta.tool_calls)||void 0===b?void 0:b[0],f=a.choices[0].delta.content,"message"===t&&(null==d?void 0:d.id)?(t=null,e.sendTextMessageEnd({messageId:u})):"function"!==t||void 0!==d&&!(null==d?void 0:d.id)||(t=null,e.sendActionExecutionEnd({actionExecutionId:l})),null===t&&((null==d?void 0:d.id)?(t="function",l=d.id,e.sendActionExecutionStart({actionExecutionId:l,actionName:d.function.name})):f&&(t="message",u=a.id,e.sendTextMessageStart({messageId:u}))),"message"===t&&f?e.sendTextMessageContent({messageId:u,content:f}):"function"===t&&(null===(v=null==d?void 0:d.function)||void 0===v?void 0:v.arguments)&&e.sendActionExecutionArgs({actionExecutionId:l,args:d.function.arguments}),w.label=4;case 4:return n=!0,[3,2];case 5:return[3,12];case 6:return p=w.sent(),m={error:p},[3,12];case 7:return w.trys.push([7,,10,11]),n||h||!(y=i.return)?[3,9]:[4,y.call(i)];case 8:w.sent(),w.label=9;case 9:return[3,11];case 10:if(m)throw m.error;return[7];case 11:return[7];case 12:return"message"===t?e.sendTextMessageEnd({messageId:u}):"function"===t&&e.sendActionExecutionEnd({actionExecutionId:l}),e.complete(),[2]}})})}),[2,{threadId:e.threadId||r.randomUUID()}]}})})},e}(),Bl=function(){function e(e){this.model="llama-3.3-70b-versatile",this.provider="groq",this.disableParallelToolCalls=!1,(null==e?void 0:e.groq)&&(this._groq=e.groq),(null==e?void 0:e.model)&&(this.model=e.model),this.disableParallelToolCalls=(null==e?void 0:e.disableParallelToolCalls)||!1}return Object.defineProperty(e.prototype,"groq",{get:function(){return this._groq},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"GroqAdapter"},enumerable:!1,configurable:!0}),e.prototype.ensureGroq=function(){if(!this._groq){var e=require("groq-sdk").Groq;this._groq=new e({})}return this._groq},e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d,f=this;return R(this,function(p){switch(p.label){case 0:e.threadId,t=e.model,n=void 0===t?this.model:t,i=e.messages,o=e.actions,a=e.eventSource,s=e.forwardedParameters,c=o.map(F),u=L(u=i.map(function(e){return U(e,{keepSystemRole:!0})}),c,n),l=null==s?void 0:s.toolChoice,"function"===(null==s?void 0:s.toolChoice)&&(l={type:"function",function:{name:s.toolChoiceFunctionName}}),p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.ensureGroq().chat.completions.create(T(T(T(T(T(T({model:n,stream:!0,messages:u},c.length>0&&{tools:c}),(null==s?void 0:s.maxTokens)&&{max_tokens:s.maxTokens}),(null==s?void 0:s.stop)&&{stop:s.stop}),l&&{tool_choice:l}),this.disableParallelToolCalls&&{parallel_tool_calls:!1}),(null==s?void 0:s.temperature)&&{temperature:s.temperature}))];case 2:return d=p.sent(),[3,4];case 3:throw G(p.sent(),"Groq");case 4:return a.stream(function(e){return j(f,void 0,void 0,function(){var t,r,n,i,o,a,s,c,u,l,f,p,h,m,y,g;return R(this,function(b){switch(b.label){case 0:t=null,b.label=1;case 1:b.trys.push([1,14,,15]),b.label=2;case 2:b.trys.push([2,7,8,13]),i=!0,o=C(d),b.label=3;case 3:return[4,o.next()];case 4:if(a=b.sent(),f=a.done)return[3,6];m=a.value,i=!1,c=null===(y=(s=m).choices[0].delta.tool_calls)||void 0===y?void 0:y[0],u=s.choices[0].delta.content,"message"===t&&(null==c?void 0:c.id)?(t=null,e.sendTextMessageEnd({messageId:r})):"function"!==t||void 0!==c&&!(null==c?void 0:c.id)||(t=null,e.sendActionExecutionEnd({actionExecutionId:n})),null===t&&((null==c?void 0:c.id)?(t="function",n=c.id,e.sendActionExecutionStart({actionExecutionId:n,actionName:c.function.name,parentMessageId:s.id})):u&&(t="message",r=s.id,e.sendTextMessageStart({messageId:r}))),"message"===t&&u?e.sendTextMessageContent({messageId:r,content:u}):"function"===t&&(null===(g=null==c?void 0:c.function)||void 0===g?void 0:g.arguments)&&e.sendActionExecutionArgs({actionExecutionId:n,args:c.function.arguments}),b.label=5;case 5:return i=!0,[3,3];case 6:return[3,13];case 7:return l=b.sent(),p={error:l},[3,13];case 8:return b.trys.push([8,,11,12]),i||f||!(h=o.return)?[3,10]:[4,h.call(o)];case 9:b.sent(),b.label=10;case 10:return[3,12];case 11:if(p)throw p.error;return[7];case 12:return[7];case 13:return"message"===t?e.sendTextMessageEnd({messageId:r}):"function"===t&&e.sendActionExecutionEnd({actionExecutionId:n}),[3,15];case 14:throw G(b.sent(),"Groq");case 15:return e.complete(),[2]}})})}),[2,{threadId:e.threadId||r.randomUUID()}]}})})},e}();function Fl(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}function Ul(e,t){return"string"==typeof e?{name:e,options:{}}:{options:e||{}}}class zl extends t.GraphQLError{constructor(e="Access denied! You need to be authenticated to perform this action!"){super(e,{extensions:{code:"UNAUTHENTICATED"}}),Object.setPrototypeOf(this,new.target.prototype)}}class Gl extends t.GraphQLError{constructor(e="Access denied! You don't have permission for this action!"){super(e,{extensions:{code:"UNAUTHORIZED"}}),Object.setPrototypeOf(this,new.target.prototype)}}class ql extends t.GraphQLError{constructor(e){super("Argument Validation Error",{extensions:{code:"BAD_USER_INPUT",validationErrors:e}}),Object.setPrototypeOf(this,new.target.prototype)}}class Vl extends Error{constructor(e,t,r,n,i){let o=`Cannot determine GraphQL ${e} type for `;i?o+=`argument named '${i}' of `:void 0!==n&&(o+=`parameter #${n} of `),o+=`'${r}' of '${t}' class. Is the value, that is used as its TS type or explicit type, decorated with a proper decorator or is it a proper ${e} value?`,super(o),Object.setPrototypeOf(this,new.target.prototype)}}class Wl extends Error{constructor(e){let t="Some errors occurred while generating GraphQL schema:\n";t+=e.map(e=>` ${e.message}\n`),t+="Please check the `details` property of the error to get more detailed info.",super(t),Object.setPrototypeOf(this,new.target.prototype),this.details=e}}class Hl extends Error{constructor(e,t,r,n){super(`The '${t}' field of '${e}' has conflicting default values. Default value from decorator ('${r}') is not equal to the property initializer value ('${n}').`),Object.setPrototypeOf(this,new.target.prototype)}}class Kl extends Error{constructor(e){super(`Cannot resolve type for interface ${e.name}! You need to return instance of object type class, not a plain object!`),Object.setPrototypeOf(this,new.target.prototype)}}class Zl extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class Jl extends Error{constructor(){super("Looks like you've forgot to provide `pubSub` option in `buildSchema()`. Subscriptions can't work without a proper PubSub system."),Object.setPrototypeOf(this,new.target.prototype)}}class Yl extends Error{constructor(e,t){super(`${e.name}#${t} subscription has no provided topics!`),Object.setPrototypeOf(this,new.target.prototype)}}class Ql extends Error{constructor(e,t,r,n){let i="Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for ";n?i+=`argument named '${n}' of `:void 0!==r&&(i+=`parameter #${r} of `),i+=`'${t}' of '${e}' class.`,super(i),Object.setPrototypeOf(this,new.target.prototype)}}class Xl extends Error{constructor(){super("Looks like you've forgot to provide experimental metadata API polyfill. Please read the installation instruction for more details."),Object.setPrototypeOf(this,new.target.prototype)}}class ed extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}class td extends Error{constructor(e){super(`Cannot resolve type for union ${e.name}! You need to return instance of object type class, not a plain object!`),Object.setPrototypeOf(this,new.target.prototype)}}class rd extends Error{constructor(e,t){super(`Looks like you use an incorrect version of the 'graphql' package: "${e}". Please ensure that you have installed a version that meets TypeGraphQL's requirement: "${t}".`),Object.setPrototypeOf(this,new.target.prototype)}}class nd extends Error{constructor(e,t,r){super(`Wrong nullable option set for ${e}#${t}. You cannot combine non-list type with nullable '${r}'.`),Object.setPrototypeOf(this,new.target.prototype)}}function id(e){try{return e(),!1}catch{return!0}}function od(e,t,r){return e.map(e=>e.target===t?{...e,target:r.target,resolverClassMetadata:r}:e)}function ad(e,t,r){return od(e,t,r).map(e=>e.target===t?{...e,getObjectType:id(e.getObjectType)?r.getObjectType:e.getObjectType}:e)}function sd(e){return e.map(e=>e.middlewares).reduce((e,t)=>t.concat(e),[])}const cd=[Promise,Array,Object,Function];function ud([e],t=1){return Array.isArray(e)?ud(e,t+1):{depth:t,returnType:e}}function ld({metadataKey:e,prototype:t,propertyKey:r,parameterIndex:n,argName:i,returnTypeFunc:o,typeOptions:a={}}){const s={...a};let c;!function(){if("object"!=typeof Reflect||"function"!=typeof Reflect.getMetadata)throw new Xl}();const u=Reflect.getMetadata(e,t,r);if(u&&(c="design:paramtypes"===e?u[n]:u),!o&&(!c||cd.includes(c)))throw new Ql(t.constructor.name,r,n,i);if(o){return{getType:()=>{const e=o();if(Array.isArray(e)){const{depth:t,returnType:r}=ud(e);return s.array=!0,s.arrayDepth=t,r}return e},typeOptions:s}}if(c)return{getType:()=>c,typeOptions:s};throw new Error("Ops... this should never happen :)")}function dd({prototype:e,propertyKey:t,parameterIndex:r,argName:n,returnTypeFunc:i,options:o={}}){if("symbol"==typeof t)throw new ed;const{getType:a,typeOptions:s}=ld({metadataKey:"design:paramtypes",prototype:e,propertyKey:t,parameterIndex:r,argName:n,returnTypeFunc:i,typeOptions:o});return{target:e.constructor,methodName:t,index:r,getType:a,typeOptions:s,validateSettings:o.validate,validateFn:o.validateFn}}let fd=class{constructor(){this.queries=[],this.mutations=[],this.subscriptions=[],this.fieldResolvers=[],this.objectTypes=[],this.inputTypes=[],this.argumentTypes=[],this.interfaceTypes=[],this.authorizedFields=[],this.enums=[],this.unions=[],this.middlewares=[],this.classDirectives=[],this.fieldDirectives=[],this.argumentDirectives=[],this.classExtensions=[],this.fieldExtensions=[],this.resolverClasses=[],this.fields=[],this.params=[]}collectQueryHandlerMetadata(e){this.queries.push(e)}collectMutationHandlerMetadata(e){this.mutations.push(e)}collectSubscriptionHandlerMetadata(e){this.subscriptions.push(e)}collectFieldResolverMetadata(e){this.fieldResolvers.push(e)}collectObjectMetadata(e){this.objectTypes.push(e)}collectInputMetadata(e){this.inputTypes.push(e)}collectArgsMetadata(e){this.argumentTypes.push(e)}collectInterfaceMetadata(e){this.interfaceTypes.push(e)}collectAuthorizedFieldMetadata(e){this.authorizedFields.push(e)}collectEnumMetadata(e){this.enums.push(e)}collectUnionMetadata(e){const t=Symbol(e.name);return this.unions.push({...e,symbol:t}),t}collectMiddlewareMetadata(e){this.middlewares.push(e)}collectResolverClassMetadata(e){this.resolverClasses.push(e)}collectClassFieldMetadata(e){this.fields.push(e)}collectHandlerParamMetadata(e){this.params.push(e)}collectDirectiveClassMetadata(e){this.classDirectives.push(e)}collectDirectiveFieldMetadata(e){this.fieldDirectives.push(e)}collectDirectiveArgumentMetadata(e){this.argumentDirectives.push(e)}collectExtensionsClassMetadata(e){this.classExtensions.push(e)}collectExtensionsFieldMetadata(e){this.fieldExtensions.push(e)}build(e){this.classDirectives.reverse(),this.fieldDirectives.reverse(),this.argumentDirectives.reverse(),this.classExtensions.reverse(),this.fieldExtensions.reverse(),this.buildClassMetadata(this.objectTypes),this.buildClassMetadata(this.inputTypes),this.buildClassMetadata(this.argumentTypes),this.buildClassMetadata(this.interfaceTypes),this.buildFieldResolverMetadata(this.fieldResolvers,e),this.buildResolversMetadata(this.queries),this.buildResolversMetadata(this.mutations),this.buildResolversMetadata(this.subscriptions),this.buildExtendedResolversMetadata()}clear(){this.queries=[],this.mutations=[],this.subscriptions=[],this.fieldResolvers=[],this.objectTypes=[],this.inputTypes=[],this.argumentTypes=[],this.interfaceTypes=[],this.authorizedFields=[],this.enums=[],this.unions=[],this.middlewares=[],this.classDirectives=[],this.fieldDirectives=[],this.argumentDirectives=[],this.classExtensions=[],this.fieldExtensions=[],this.resolverClasses=[],this.fields=[],this.params=[]}buildClassMetadata(e){e.forEach(e=>{if(!e.fields){const t=this.fields.filter(t=>t.target===e.target);t.forEach(e=>{e.roles=this.findFieldRoles(e.target,e.name),e.params=this.params.filter(t=>t.target===e.target&&e.name===t.methodName),e.middlewares=sd(this.middlewares.filter(t=>t.target===e.target&&t.fieldName===e.name)),e.directives=this.fieldDirectives.filter(t=>t.target===e.target&&t.fieldName===e.name).map(e=>e.directive),e.extensions=this.findExtensions(e.target,e.name)}),e.fields=t}e.directives||(e.directives=this.classDirectives.filter(t=>t.target===e.target).map(e=>e.directive)),e.extensions||(e.extensions=this.findExtensions(e.target))})}buildResolversMetadata(e){e.forEach(e=>{const t=this.resolverClasses.find(t=>t.target===e.target);e.resolverClassMetadata=t,e.params=this.params.filter(t=>t.target===e.target&&e.methodName===t.methodName),e.roles=this.findFieldRoles(e.target,e.methodName),e.middlewares=sd(this.middlewares.filter(t=>t.target===e.target&&e.methodName===t.fieldName)),e.directives=this.fieldDirectives.filter(t=>t.target===e.target&&t.fieldName===e.methodName).map(e=>e.directive),e.extensions=this.findExtensions(e.target,e.methodName)})}buildFieldResolverMetadata(e,t){this.buildResolversMetadata(e),e.forEach(e=>{if(e.roles=this.findFieldRoles(e.target,e.methodName),e.directives=this.fieldDirectives.filter(t=>t.target===e.target&&t.fieldName===e.methodName).map(e=>e.directive),e.extensions=this.findExtensions(e.target,e.methodName),e.getObjectType="external"===e.kind?this.resolverClasses.find(t=>t.target===e.target).getObjectType:()=>e.target,"external"===e.kind){const r=this.resolverClasses.find(t=>t.target===e.target).getObjectType(),n=this.objectTypes.find(e=>e.target===r)||this.interfaceTypes.find(e=>e.target===r);if(!n)throw new Error(`Unable to find type metadata for input type or object type named '${r.name}'`);const i=n.fields.find(t=>t.schemaName===e.schemaName);if(i)i.complexity=e.complexity,0===i.params.length&&(i.params=e.params),e.roles?i.roles=e.roles:i.roles&&(e.roles=i.roles);else{const i=!t.resolvers||t.resolvers.some(t=>t===e.target||Object.prototype.isPrototypeOf.call(e.target,t));if(!e.getType||!e.typeOptions)throw new Ql(e.target.name,e.methodName);if(i){const t={name:e.methodName,schemaName:e.schemaName,getType:e.getType,target:r,typeOptions:e.typeOptions,deprecationReason:e.deprecationReason,description:e.description,complexity:e.complexity,roles:e.roles,middlewares:e.middlewares,params:e.params,directives:e.directives,extensions:e.extensions};this.collectClassFieldMetadata(t),n.fields.push(t)}}}})}buildExtendedResolversMetadata(){this.resolverClasses.forEach(e=>{let t=Object.getPrototypeOf(e.target);for(;t.prototype;){this.resolverClasses.find(e=>e.target===t)&&(this.queries=od(this.queries,t,e),this.mutations=od(this.mutations,t,e),this.subscriptions=od(this.subscriptions,t,e),this.fieldResolvers=ad(this.fieldResolvers,t,e)),t=Object.getPrototypeOf(t)}})}findFieldRoles(e,t){const r=this.authorizedFields.find(r=>r.target===e&&r.fieldName===t);if(r)return r.roles}findExtensions(e,t){return(t?this.fieldExtensions:this.classExtensions).filter(r=>(r.target===e||Object.prototype.isPrototypeOf.call(r.target,e))&&(!("fieldName"in r)||r.fieldName===t)).reduce((e,t)=>({...e,...t.extensions}),{})}};function pd(){return global.TypeGraphQLMetadataStorage||(global.TypeGraphQLMetadataStorage=new fd),global.TypeGraphQLMetadataStorage}function hd(e,t,r){return(n,i,o)=>{const{options:a,returnTypeFunc:s}=Fl(t,r);pd().collectHandlerParamMetadata({kind:"arg",name:e,description:a.description,deprecationReason:a.deprecationReason,...dd({prototype:n,propertyKey:i,parameterIndex:o,returnTypeFunc:s,options:a,argName:e})})}}function md(e){return(t,r,n)=>{if("symbol"==typeof r)throw new ed;pd().collectHandlerParamMetadata({kind:"context",target:t.constructor,methodName:r,index:n,propertyName:e})}}function yd(e,t){pd().collectEnumMetadata({enumObj:e,name:t.name,description:t.description,valuesConfig:t.valuesConfig||{}})}function gd(e,t){return(r,n,i)=>{if("symbol"==typeof n)throw new ed;const{options:o,returnTypeFunc:a}=Fl(e,t),s=Boolean(i),c=Boolean(i&&i.value),{getType:u,typeOptions:l}=ld({metadataKey:c?"design:returntype":"design:type",prototype:r,propertyKey:n,returnTypeFunc:a,typeOptions:o});pd().collectClassFieldMetadata({name:n,schemaName:o.name||n,getType:u,typeOptions:l,complexity:o.complexity,target:r.constructor,description:o.description,deprecationReason:o.deprecationReason,simple:o.simple}),s&&pd().collectFieldResolverMetadata({kind:"internal",methodName:n,schemaName:o.name||n,target:r.constructor,complexity:o.complexity})}}function bd(e,t){const{name:r,options:n}=Ul(e);return e=>{pd().collectInputMetadata({name:r||e.name,target:e,description:n.description})}}function vd(e,t){const{name:r,options:n}=Ul(e),i=n.implements&&[].concat(n.implements);return e=>{pd().collectInterfaceMetadata({name:r||e.name,target:e,interfaceClasses:i,autoRegisteringDisabled:!1===n.autoRegisterImplementations,...n})}}function wd(e,t,r,n={}){if("symbol"==typeof t)throw new ed;const{getType:i,typeOptions:o}=ld({metadataKey:"design:returntype",prototype:e,propertyKey:t,returnTypeFunc:r,typeOptions:n}),a=t;return{methodName:a,schemaName:n.name||a,target:e.constructor,getReturnType:i,returnTypeOptions:o,description:n.description,deprecationReason:n.deprecationReason,complexity:n.complexity}}function _d(e,t){const{options:r,returnTypeFunc:n}=Fl(e,t);return(e,t)=>{const i=wd(e,t,n,r);pd().collectMutationHandlerMetadata(i)}}function Ed(e,t){const{name:r,options:n}=Ul(e),i=n.implements&&[].concat(n.implements);return e=>{pd().collectObjectMetadata({name:r||e.name,target:e,description:n.description,interfaceClasses:i,simpleResolvers:n.simpleResolvers})}}function Sd(e,t){const{options:r,returnTypeFunc:n}=Fl(e,t);return(e,t)=>{const i=wd(e,t,n,r);pd().collectQueryHandlerMetadata(i)}}function Od(e){return t=>{const r=e?e.prototype?()=>e:e:()=>{throw new Error(`No provided object type in '@Resolver' decorator for class '${t.name}!'`)};pd().collectResolverClassMetadata({target:t,getObjectType:r})}}function Ad({name:e,description:t,types:r,resolveType:n}){return pd().collectUnionMetadata({name:e,description:t,getClassTypes:r,resolveType:n})}function Td(e,r){return t.versionInfo.major>=17?new t.GraphQLError(e,r):new t.GraphQLError(e,null==r?void 0:r.nodes,null==r?void 0:r.source,null==r?void 0:r.positions,null==r?void 0:r.path,null==r?void 0:r.originalError,null==r?void 0:r.extensions)}const xd=["Afghanistan","Åland Islands","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia, Plurinational State of","Bonaire, Sint Eustatius and Saba","Bosnia and Herzegovina","Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cabo Verde","Cambodia","Cameroon","Canada","Cayman Islands","Central African Republic","Chad","Chile","China","Christmas Island","Cocos (Keeling) Islands","Colombia","Comoros","Congo, Republic of the","Congo, Democratic Republic of the","Cook Islands","Costa Rica","Côte d'Ivoire","Croatia","Cuba","Curaçao","Cyprus","Czechia","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Eswatini","Ethiopia","Falkland Islands (Malvinas)","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","French Southern Territories","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala","Guernsey","Guinea","Guinea-Bissau","Guyana","Haiti","Heard Island and McDonald Islands","Holy See","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran, Islamic Republic of","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kiribati","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait","Kyrgyzstan","Lao People's Democratic Republic","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macao","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mayotte","Mexico","Micronesia, Federated States of","Moldova, Republic of","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands, Kingdom of the","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Niue","Norfolk Island","North Macedonia","Northern Mariana Islands","Norway","Oman","Pakistan","Palau","Palestine, State of","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn","Poland","Portugal","Puerto Rico","Qatar","Réunion","Romania","Russian Federation","Rwanda","Saint Barthélemy","Saint Helena, Ascension and Tristan da Cunha","Saint Kitts and Nevis","Saint Lucia","Saint Martin (French part)","Saint Pierre and Miquelon","Saint Vincent and the Grenadines","Samoa","San Marino","São Tomé and Príncipe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Sint Maarten (Dutch part)","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia and the South Sandwich Islands","South Sudan","Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen","Sweden","Switzerland","Syrian Arab Republic","Taiwan, Province of China","Tajikistan","Tanzania, United Republic of","Thailand","Timor-Leste","Togo","Tokelau","Tonga","Trinidad and Tobago","Tunisia","Türkiye","Turkmenistan","Turks and Caicos Islands","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom of Great Britain and Northern Ireland","United States of America","United States Minor Outlying Islands","Uruguay","Uzbekistan","Vanuatu","Venezuela, Bolivarian Republic of","Viet Nam","Virgin Islands (British)","Virgin Islands (U.S.)","Wallis and Futuna","Western Sahara","Yemen","Zambia","Zimbabwe"];new Set(xd);xd.map(e=>`"${e}"`).join(" | ");const Id=e=>new Date(e),kd=e=>e%4==0&&e%100!=0||e%400==0,jd=e=>{e=null==e?void 0:e.toUpperCase();if(!/^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60))(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/.test(e))return!1;const t=Date.parse(e);if(t!=t)return!1;const r=e.indexOf("T"),n=e.substr(0,r),i=e.substr(r+1);return(e=>{if(!/^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))$/.test(e))return!1;const t=Number(e.substr(0,4)),r=Number(e.substr(5,2)),n=Number(e.substr(8,2));switch(r){case 2:return!(kd(t)&&n>29||!kd(t)&&n>28);case 4:case 6:case 9:case 11:if(n>30)return!1}return!0})(n)&&(e=>(e=null==e?void 0:e.toUpperCase(),/^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/.test(e)))(i)},Rd=e=>{const t=e.getTime();return t==t},Nd={name:"DateTime",description:"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.",serialize(e){if(e instanceof Date){if(Rd(e))return e;throw Td("DateTime cannot represent an invalid Date instance")}if("string"==typeof e){if(jd(e))return Id(e);throw Td(`DateTime cannot represent an invalid date-time-string ${e}.`)}if("number"!=typeof e)throw Td("DateTime cannot be serialized from a non string, non numeric or non Date type "+JSON.stringify(e));try{return new Date(e)}catch(t){throw Td("DateTime cannot represent an invalid Unix timestamp "+e)}},parseValue(e){if(e instanceof Date){if(Rd(e))return e;throw Td("DateTime cannot represent an invalid Date instance")}if("string"==typeof e){if(jd(e))return Id(e);throw Td(`DateTime cannot represent an invalid date-time-string ${e}.`)}throw Td(`DateTime cannot represent non string or Date type ${JSON.stringify(e)}`)},parseLiteral(e){if(e.kind!==t.Kind.STRING)throw Td(`DateTime cannot represent non string or Date type ${"value"in e&&e.value}`,{nodes:e});const{value:r}=e;if(jd(r))return Id(r);throw Td(`DateTime cannot represent an invalid date-time-string ${String(r)}.`,{nodes:e})},extensions:{codegenScalarType:"Date | string",jsonSchema:{type:"string",format:"date-time"}}},Pd={...Nd,name:"DateTimeISO",description:"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.This scalar is serialized to a string in ISO 8601 format and parsed from a string in ISO 8601 format.",serialize:e=>Nd.serialize(e).toISOString()},Cd=new t.GraphQLScalarType(Pd),Ld=[/^\d{5}([-]?\d{4})?$/,/^(GIR|[A-Z]\d[A-Z\d]??|[A-Z]{2}\d[A-Z\d]??)[ ]??(\d[A-Z]{2})$/,/\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b/,/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/,/^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$/,/^(V-|I-)?[0-9]{5}$/,/^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$/,/^[1-9][0-9]{3}\s?([a-zA-Z]{2})?$/,/^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$/,/^([D|d][K|k]( |-))?[1-9]{1}[0-9]{3}$/,/^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$/,/^[1-9]{1}[0-9]{3}$/,/^\d{6}$/,/^\d{4}$/,/^\d{4}([\-]\d{3})?$/,/^\d{4}$/,/^\d{4}$/,/^[1,3-9]{10}$/,/^\d{3}-\d{4}$/,/^\d{5}$/];Ld.map(e=>({type:"string",pattern:e.source}));const Md=[/^(?:ISBN(?:-10)?:? *)?((?=\d{1,5}([ -]?)\d{1,7}\2?\d{1,6}\2?\d)(?:\d\2*){9}[\dX])$/i,/^(?:ISBN(?:-13)?:? *)?(97(?:8|9)([ -]?)(?=\d{1,5}\2?\d{1,7}\2?\d{1,6}\2?\d)(?:\d\2*){9}\d)$/i];function $d(e){return e}function Dd(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Td(`JSONObject cannot represent non-object value: ${e}`,t?{nodes:t}:void 0);return e}function Bd(e,r){if(e.kind!==t.Kind.OBJECT)throw Td(`JSONObject cannot represent non-object value: ${t.print(e)}`,e?{nodes:e}:void 0);const n=Object.create(null);return e.fields.forEach(e=>{n[e.name.value]=Fd(e.value,r)}),n}function Fd(e,r){switch(e.kind){case t.Kind.STRING:case t.Kind.BOOLEAN:return e.value;case t.Kind.INT:case t.Kind.FLOAT:return parseFloat(e.value);case t.Kind.OBJECT:return Bd(e,r);case t.Kind.LIST:return e.values.map(e=>Fd(e,r));case t.Kind.NULL:return null;case t.Kind.VARIABLE:{const t=e.name.value;return r?r[t]:void 0}}}Md.map(e=>({type:"string",pattern:e.source}));const Ud="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf",zd={name:"JSON",description:"The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).",serialize:$d,parseValue:$d,parseLiteral:Fd,specifiedByURL:Ud,specifiedByUrl:Ud,extensions:{codegenScalarType:"any"}},Gd=new t.GraphQLScalarType(zd),qd="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf",Vd={name:"JSONObject",description:"The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).",serialize:Dd,parseValue:Dd,parseLiteral:Bd,specifiedByURL:qd,specifiedByUrl:qd,extensions:{codegenScalarType:"Record<string, any>",jsonSchema:{type:"object",additionalProperties:!0}}},Wd=new t.GraphQLScalarType(Vd);["YYYYMMDDXXXX","YYMMDDXXXX"].map(e=>({type:"string",length:e.length,pattern:e}));
21
+ /*! *****************************************************************************
22
+ Copyright (c) Microsoft Corporation.
23
+
24
+ Permission to use, copy, modify, and/or distribute this software for any
25
+ purpose with or without fee is hereby granted.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
28
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
30
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
+ PERFORMANCE OF THIS SOFTWARE.
34
+ ***************************************************************************** */
35
+ var Hd=function(e,t){return Hd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},Hd(e,t)};function Kd(e,t,r,n){return new(r||(r=Promise))(function(t,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?t(e.value):function(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(o,a)}s((n=n.apply(e,[])).next())})}function Zd(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function Jd(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Yd(e){return this instanceof Yd?(this.v=e,this):new Yd(e)}function Qd(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||s(e,t)})})}function s(e,t){try{(r=i[e](t)).value instanceof Yd?Promise.resolve(r.value.v).then(c,u):l(o[0][2],r)}catch(e){l(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function l(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}var Xd=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"name",{value:"RepeaterOverflowError",enumerable:!1}),"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf(r,r.constructor.prototype):r.__proto__=r.constructor.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,r.constructor),r}return function(e,t){function r(){this.constructor=e}Hd(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t}(Error);function ef(e){null!=e&&"function"==typeof e.then&&e.then(rf,rf)}!function(){function e(e){if(e<0)throw new RangeError("Capacity may not be less than 0");this._c=e,this._q=[]}Object.defineProperty(e.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),e.prototype.add=function(e){if(this.full)throw new Error("Buffer full");this._q.push(e)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function e(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}Object.defineProperty(e.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(e){for(;this._q.length>=this._c;)this._q.shift();this._q.push(e)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function e(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}Object.defineProperty(e.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(e){this._q.length<this._c&&this._q.push(e)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}();var tf=1024,rf=function(){};function nf(e){var t=e.err,r=Promise.resolve(e.execution).then(function(e){if(null!=t)throw t;return e});return e.err=void 0,e.execution=r.then(function(){},function(){}),void 0===e.pending?r:e.pending.then(function(){return r})}function of(e,t){var r=e.state>=3;return Promise.resolve(t).then(function(t){return!r&&e.state>=4?nf(e).then(function(e){return{value:e,done:!0}}):{value:t,done:r}})}function af(e,t){var r,n;if(!(e.state>=2))if(e.state=2,e.onnext(),e.onstop(),null==e.err&&(e.err=t),0!==e.pushes.length||void 0!==e.buffer&&!e.buffer.empty)try{for(var i=Jd(e.pushes),o=i.next();!o.done;o=i.next()){o.value.resolve()}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}else sf(e)}function sf(e){var t,r;if(!(e.state>=3)){e.state<2&&af(e),e.state=3,e.buffer=void 0;try{for(var n=Jd(e.nexts),i=n.next();!i.done;i=n.next()){var o=i.value,a=void 0===e.pending?nf(e):e.pending.then(function(){return nf(e)});o.resolve(of(e,a))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.pushes=[],e.nexts=[]}}function cf(e){e.state>=4||(e.state<3&&sf(e),e.state=4)}function uf(e,t){if(ef(t),e.pushes.length>=tf)throw new Xd("No more than 1024 pending calls to push are allowed on a single repeater.");if(e.state>=2)return Promise.resolve(void 0);var r,n=void 0===e.pending?Promise.resolve(t):e.pending.then(function(){return t});(n=n.catch(function(t){e.state<2&&(e.err=t),cf(e)}),e.nexts.length)?(e.nexts.shift().resolve(of(e,n)),r=e.nexts.length?Promise.resolve(e.nexts[0].value):void 0===e.buffer||e.buffer.full?new Promise(function(t){return e.onnext=t}):Promise.resolve(void 0)):void 0===e.buffer||e.buffer.full?r=new Promise(function(t){return e.pushes.push({resolve:t,value:n})}):(e.buffer.add(n),r=Promise.resolve(void 0));var i=!0,o={},a=r.catch(function(e){if(i)throw e});return o.then=function(e,t){return i=!1,Promise.prototype.then.call(r,e,t)},o.catch=function(e){return i=!1,Promise.prototype.catch.call(r,e)},o.finally=r.finally.bind(r),e.pending=n.then(function(){return a}).catch(function(t){e.err=t,cf(e)}),o}function lf(e){if(!(e.state>=1)){e.state=1;var t=uf.bind(null,e),r=function(e){var t=af.bind(null,e),r=new Promise(function(t){return e.onstop=t});return t.then=r.then.bind(r),t.catch=r.catch.bind(r),t.finally=r.finally.bind(r),t}(e);e.execution=new Promise(function(n){return n(e.executor(t,r))}),e.execution.catch(function(){return af(e)})}}var df=new WeakMap,ff=function(){function e(e,t){df.set(this,{executor:e,buffer:t,err:void 0,state:0,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:rf,onstop:rf})}return e.prototype.next=function(e){ef(e);var t=df.get(this);if(void 0===t)throw new Error("WeakMap error");if(t.nexts.length>=tf)throw new Xd("No more than 1024 pending calls to next are allowed on a single repeater.");if(t.state<=0&&lf(t),t.onnext(e),void 0!==t.buffer&&!t.buffer.empty){var r=of(t,t.buffer.remove());if(t.pushes.length){var n=t.pushes.shift();t.buffer.add(n.value),t.onnext=n.resolve}return r}if(t.pushes.length){var i=t.pushes.shift();return t.onnext=i.resolve,of(t,i.value)}return t.state>=2?(sf(t),of(t,nf(t))):new Promise(function(r){return t.nexts.push({resolve:r,value:e})})},e.prototype.return=function(e){ef(e);var t=df.get(this);if(void 0===t)throw new Error("WeakMap error");return sf(t),t.execution=Promise.resolve(t.execution).then(function(){return e}),of(t,nf(t))},e.prototype.throw=function(e){var t=df.get(this);if(void 0===t)throw new Error("WeakMap error");return t.state<=0||t.state>=2||void 0!==t.buffer&&!t.buffer.empty?(sf(t),null==t.err&&(t.err=e),of(t,nf(t))):this.next(Promise.reject(e))},e.prototype[Symbol.asyncIterator]=function(){return this},e.race=hf,e.merge=mf,e.zip=yf,e.latest=gf,e}();function pf(e,t){var r,n,i=[],o=function(e){null!=e&&"function"==typeof e[Symbol.asyncIterator]?i.push(e[Symbol.asyncIterator]()):null!=e&&"function"==typeof e[Symbol.iterator]?i.push(e[Symbol.iterator]()):i.push(function(){return Qd(this,arguments,function(){return Zd(this,function(r){switch(r.label){case 0:return t.yieldValues?[4,Yd(e)]:[3,3];case 1:return[4,r.sent()];case 2:r.sent(),r.label=3;case 3:return t.returnValues?[4,Yd(e)]:[3,5];case 4:return[2,r.sent()];case 5:return[2]}})})}())};try{for(var a=Jd(e),s=a.next();!s.done;s=a.next()){o(s.value)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return i}function hf(e){var t=this,r=pf(e,{returnValues:!0});return new ff(function(e,n){return Kd(t,0,void 0,function(){var t,i,o,a,s,c;return Zd(this,function(u){switch(u.label){case 0:if(!r.length)return n(),[2];i=!1,n.then(function(){t(),i=!0}),u.label=1;case 1:u.trys.push([1,,5,7]),a=void 0,s=0,c=function(){var i,c,u,l,d,f;return Zd(this,function(p){switch(p.label){case 0:i=s;try{for(d=void 0,c=Jd(r),u=c.next();!u.done;u=c.next())l=u.value,Promise.resolve(l.next()).then(function(e){e.done?(n(),void 0===o&&(o=e)):s===i&&(s++,t(e))},function(e){return n(e)})}catch(e){d={error:e}}finally{try{u&&!u.done&&(f=c.return)&&f.call(c)}finally{if(d)throw d.error}}return[4,new Promise(function(e){return t=e})];case 1:return void 0===(a=p.sent())?[3,3]:[4,e(a.value)];case 2:p.sent(),p.label=3;case 3:return[2]}})},u.label=2;case 2:return i?[3,4]:[5,c()];case 3:return u.sent(),[3,2];case 4:return[2,o&&o.value];case 5:return n(),[4,Promise.race(r.map(function(e){return e.return&&e.return()}))];case 6:return u.sent(),[7];case 7:return[2]}})})})}function mf(e){var t=this,r=pf(e,{yieldValues:!0});return new ff(function(e,n){return Kd(t,0,void 0,function(){var t,i,o,a=this;return Zd(this,function(s){switch(s.label){case 0:if(!r.length)return n(),[2];t=[],i=!1,n.then(function(){var e,r;i=!0;try{for(var n=Jd(t),o=n.next();!o.done;o=n.next()){(0,o.value)()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}),s.label=1;case 1:return s.trys.push([1,,3,4]),[4,Promise.all(r.map(function(r,s){return Kd(a,0,void 0,function(){var a;return Zd(this,function(c){switch(c.label){case 0:c.trys.push([0,,6,9]),c.label=1;case 1:return i?[3,5]:(Promise.resolve(r.next()).then(function(e){return t[s](e)},function(e){return n(e)}),[4,new Promise(function(e){t[s]=e})]);case 2:return void 0===(a=c.sent())?[3,4]:a.done?(o=a,[2]):[4,e(a.value)];case 3:c.sent(),c.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return r.return?[4,r.return()]:[3,8];case 7:c.sent(),c.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return s.sent(),[2,o&&o.value];case 3:return n(),[7];case 4:return[2]}})})})}function yf(e){var t=this,r=pf(e,{returnValues:!0});return new ff(function(e,n){return Kd(t,0,void 0,function(){var t,i,o,a;return Zd(this,function(s){switch(s.label){case 0:if(!r.length)return n(),[2,[]];i=!1,n.then(function(){t(),i=!0}),s.label=1;case 1:s.trys.push([1,,6,8]),s.label=2;case 2:return i?[3,5]:(Promise.all(r.map(function(e){return e.next()})).then(function(e){return t(e)},function(e){return n(e)}),[4,new Promise(function(e){return t=e})]);case 3:return void 0===(o=s.sent())?[2]:(a=o.map(function(e){return e.value}),o.some(function(e){return e.done})?[2,a]:[4,e(a)]);case 4:return s.sent(),[3,2];case 5:return[3,8];case 6:return n(),[4,Promise.all(r.map(function(e){return e.return&&e.return()}))];case 7:return s.sent(),[7];case 8:return[2]}})})})}function gf(e){var t=this,r=pf(e,{yieldValues:!0,returnValues:!0});return new ff(function(e,n){return Kd(t,0,void 0,function(){var t,i,o,a,s,c=this;return Zd(this,function(u){switch(u.label){case 0:if(!r.length)return n(),[2,[]];i=[],o=!1,n.then(function(){var e,r;t();try{for(var n=Jd(i),a=n.next();!a.done;a=n.next()){(0,a.value)()}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}o=!0}),u.label=1;case 1:return u.trys.push([1,,5,7]),Promise.all(r.map(function(e){return e.next()})).then(function(e){return t(e)},function(e){return n(e)}),[4,new Promise(function(e){return t=e})];case 2:return void 0===(a=u.sent())?[2]:(s=a.map(function(e){return e.value}),a.every(function(e){return e.done})?[2,s]:[4,e(s.slice())]);case 3:return u.sent(),[4,Promise.all(r.map(function(t,r){return Kd(c,0,void 0,function(){var c;return Zd(this,function(u){switch(u.label){case 0:if(a[r].done)return[2,a[r].value];u.label=1;case 1:return o?[3,4]:(Promise.resolve(t.next()).then(function(e){return i[r](e)},function(e){return n(e)}),[4,new Promise(function(e){return i[r]=e})]);case 2:return void 0===(c=u.sent())?[2,a[r].value]:c.done?[2,c.value]:(s[r]=c.value,[4,e(s.slice())]);case 3:return u.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,u.sent()];case 5:return n(),[4,Promise.all(r.map(function(e){return e.return&&e.return()}))];case 6:return u.sent(),[7];case 7:return[2]}})})})}class bf{constructor(){this.instances=[]}get(e){let t=this.instances.find(t=>t.type===e);return t||(t={type:e,object:new e},this.instances.push(t)),t.object}}class vf{constructor(e){this.defaultContainer=new bf,e&&"get"in e&&"function"==typeof e.get?this.container=e:"function"==typeof e&&(this.containerGetter=e)}getInstance(e,t){const r=this.containerGetter?this.containerGetter(t):this.container;return r?r.get(e,t):this.defaultContainer.get(e)}}class wf{static create(e){void 0!==e.scalarsMap&&(this.scalarsMaps=e.scalarsMap),void 0!==e.validate&&(this.validate=e.validate),void 0!==e.validateFn&&(this.validateFn=e.validateFn),void 0!==e.authChecker&&(this.authChecker=e.authChecker),void 0!==e.authMode&&(this.authMode=e.authMode),void 0!==e.pubSub&&(this.pubSub=e.pubSub),e.globalMiddlewares&&(this.globalMiddlewares=e.globalMiddlewares),void 0!==e.nullableByDefault&&(this.nullableByDefault=e.nullableByDefault),void 0!==e.disableInferringDefaultValues&&(this.disableInferringDefaultValues=e.disableInferringDefaultValues),this.container=new vf(e.container)}static reset(){this.scalarsMaps=[],this.validate=!1,this.validateFn=void 0,this.authChecker=void 0,this.authMode="error",this.pubSub=void 0,this.globalMiddlewares=[],this.container=new vf,this.nullableByDefault=!1,this.disableInferringDefaultValues=!1}}function _f(e,r,n){const i=n?e:new t.GraphQLNonNull(e);return 0===r?e:_f(new t.GraphQLList(i),r-1,n)}function Ef(e){if(e instanceof t.GraphQLScalarType)return e;const r=wf.scalarsMaps.find(t=>t.type===e);if(r)return r.scalar;switch(e){case String:return t.GraphQLString;case Boolean:return t.GraphQLBoolean;case Number:return t.GraphQLFloat;case Date:return Cd;default:return}}function Sf(e,r,n,i,o){if(!i.array&&("items"===i.nullable||"itemsAndList"===i.nullable))throw new nd(e.name,r,i.nullable);let a=n;if(i.array){const e="items"===i.nullable||"itemsAndList"===i.nullable||void 0===i.nullable&&!0===o;a=_f(a,i.arrayDepth,e)}return(!1===i.nullable||void 0===i.nullable&&!1===o||"items"===i.nullable)&&(a=new t.GraphQLNonNull(a)),a}wf.reset();const Of=[String,Boolean,Number,Date,Array,Promise];function Af(e,r){return null==r||e instanceof t.GraphQLScalarType||Of.includes(r.constructor)||r instanceof e?r:Array.isArray(r)?r.map(t=>Af(e,t)):Object.assign(new e,r)}function Tf(e,t,r,n){return async(i,o)=>{let a;if(e.prototype){const r=await t.getInstance(e,i);a=await r.check(i,n)}else a=await e(i,n);if(!a){if("null"===r)return null;if("error"===r)throw 0===n.length?new zl:new Gl}return o()}}function xf(e){return null!=e&&"function"==typeof e.then}const If=new Map;function kf(e){return pd().inputTypes.find(t=>t.target===e)}function jf(e){return pd().argumentTypes.find(t=>t.target===e)}function Rf(e,t){if(null==t)return t;if(Array.isArray(t))return t.map(t=>Rf(e,t));const r=e.getFields().reduce((e,r)=>{const n=r.fields,i=t[r.name];return void 0!==i&&(null!==i&&n?Array.isArray(i)?e[r.name]=i.map(e=>Rf(n,e)):e[r.name]=Rf(n,i):e[r.name]=Af(r.target,i)),e},{});return Af(e.target,r)}function Nf(e,t){const r=function(e){if(If.has(e))return If.get(e);const t=kf(e);if(!t)return If.set(e,null),null;const r=function e(t){let r=t.fields,n=Object.getPrototypeOf(t.target);for(;void 0!==n.prototype;){const e=kf(n);if(e){const t=new Set(r.map(e=>e.name)),n=e.fields.filter(e=>!t.has(e.name));r=[...r,...n]}n=Object.getPrototypeOf(n)}const i={target:t.target,getFields:()=>r.map(r=>{const n=r.getType(),o=kf(n);return{name:r.name,target:n,fields:n===t.target?i:o&&e(o)}})};return i}(t);return If.set(e,r),r}(e);return r?Rf(r,t):Af(e,t)}function Pf(e,t){return null==t?t:Array.isArray(t)?t.map(t=>Pf(e,t)):Nf(e,t)}const Cf=e=>null!==e&&"object"==typeof e;async function Lf(e,t,r,n,i,o,a){const s=a??o;if("function"==typeof s)return await s(e,t,r),e;if(!1===(void 0!==i?i:n)||!Cf(e))return e;const c={..."object"==typeof n?n:{},..."object"==typeof i?i:{}};!1!==c.skipMissingProperties&&(c.skipMissingProperties=!0),!0!==c.forbidUnknownValues&&(c.forbidUnknownValues=!1);const{validateOrReject:u}=await Promise.resolve().then(function(){return uO});try{return Array.isArray(e)?await Promise.all(e.filter(Cf).map(e=>u(e,c))):await u(e,c),e}catch(e){throw new ql(e)}}function Mf(e,t,r,n){const i=e.sort((e,t)=>e.index-t.index).map(e=>{switch(e.kind){case"args":return Lf(function(e,t){const r=e.getType(),n=jf(r);let i=n.fields,o=Object.getPrototypeOf(n.target);for(;void 0!==o.prototype;){const e=jf(o);e&&(i=[...i,...e.fields]),o=Object.getPrototypeOf(o)}return Af(r,i.reduce((e,r)=>{const n=t[r.name];if(void 0!==n){const t=r.getType();e[r.name]=Pf(t,n)}return e},{}))}(e,t.args),e.getType(),t,r,e.validateSettings,n,e.validateFn);case"arg":return Lf(function(e,t){const r=t[e.name];return Pf(e.getType(),r)}(e,t.args),e.getType(),t,r,e.validateSettings,n,e.validateFn);case"context":return e.propertyName?t.context[e.propertyName]:t.context;case"root":{const r=e.propertyName?t.root[e.propertyName]:t.root;return e.getType?Af(e.getType(),r):r}case"info":return t.info;case"custom":return e.resolver(t)}});return i.some(xf)?Promise.all(i):i}function $f(e,t,r,n,i){t&&i&&e.unshift(Tf(t,r,n,i))}function Df(e,t,r,n){if(0===r.length)return n();let i=-1;return async function o(a){if(a<=i)throw new Error("next() called multiple times");let s,c;if(i=a,a===r.length)s=n;else{const n=r[a];if(void 0!==n.prototype){const r=await e.getInstance(n,t);s=r.use.bind(r)}else s=n}const u=await s(t,async()=>(c=await o(a+1),c));return void 0!==u?u:c}(0)}function Bf(e){const{validate:t,validateFn:r,authChecker:n,authMode:i,globalMiddlewares:o,container:a}=wf,s=o.concat(e.middlewares);return $f(s,n,a,i,e.roles),(n,i,o,c)=>{const u={root:n,args:i,context:o,info:c},l=a.getInstance(e.target,u);return xf(l)?l.then(n=>Df(a,u,s,()=>{const i=Mf(e.params,u,t,r);return xf(i)?i.then(t=>n[e.methodName].apply(n,t)):n[e.methodName].apply(n,i)})):Df(a,u,s,()=>{const n=Mf(e.params,u,t,r),i=l;return xf(n)?n.then(t=>i[e.methodName].apply(i,t)):i[e.methodName].apply(i,n)})}}function Ff(e){if("external"===e.kind)return Bf(e);const t=e.getObjectType(),{validate:r,validateFn:n,authChecker:i,authMode:o,globalMiddlewares:a,container:s}=wf,c=a.concat(e.middlewares);return $f(c,i,s,o,e.roles),(i,o,a,u)=>{const l={root:i,args:o,context:a,info:u},d=Af(t,i);return Df(s,l,c,()=>{const t=d[e.methodName];if("function"!=typeof t)return t;const i=Mf(e.params,l,r,n);return xf(i)?i.then(e=>t.apply(d,e)):t.apply(d,i)})}}function Uf(e){const{authChecker:t,authMode:r,globalMiddlewares:n,container:i}=wf,o=n.concat(e.middlewares);return $f(o,t,i,r,e.roles),(t,r,n,a)=>Df(i,{root:t,args:r,context:n,info:a},o,()=>t[e.name])}const zf="^16.8.1";function Gf(e){const r=e.nameOrDefinition.replaceAll("\n"," ").trimStart(),{args:n}=e;if(""===r)throw new Zl("Please pass at-least one directive name or definition to the @Directive decorator");if(!r.startsWith("@"))return{kind:t.Kind.DIRECTIVE,name:{kind:t.Kind.NAME,value:r},arguments:Object.keys(n).map(e=>({kind:t.Kind.ARGUMENT,name:{kind:t.Kind.NAME,value:e},value:t.parseConstValue(n[e])}))};let i;try{i=t.parse(`type String ${r}`)}catch(t){throw new Zl(`Error parsing directive definition "${e.nameOrDefinition}"`)}const o=i.definitions.filter(e=>!!e.directives&&e.directives.length>0).map(e=>e.directives).flat();if(1!==o.length)throw new Zl(`Please pass only one directive name or definition at a time to the @Directive decorator "${e.nameOrDefinition}"`);return o[0]}function qf(e,r){if(r&&r.length)return{kind:t.Kind.OBJECT_TYPE_DEFINITION,name:{kind:t.Kind.NAME,value:e},directives:r.map(Gf)}}function Vf(e,r){if(r&&r.length)return{kind:t.Kind.INPUT_OBJECT_TYPE_DEFINITION,name:{kind:t.Kind.NAME,value:e},directives:r.map(Gf)}}function Wf(e,r,n){if(n&&n.length)return{kind:t.Kind.FIELD_DEFINITION,type:{kind:t.Kind.NAMED_TYPE,name:{kind:t.Kind.NAME,value:r.toString()}},name:{kind:t.Kind.NAME,value:e},directives:n.map(Gf)}}function Hf(e,r,n){if(n&&n.length)return{kind:t.Kind.INPUT_VALUE_DEFINITION,type:{kind:t.Kind.NAMED_TYPE,name:{kind:t.Kind.NAME,value:r.toString()}},name:{kind:t.Kind.NAME,value:e},directives:n.map(Gf)}}function Kf(e,r){if(r&&r.length)return{kind:t.Kind.INTERFACE_TYPE_DEFINITION,name:{kind:t.Kind.NAME,value:e},directives:r.map(Gf)}}function Zf(e){const t=e.getFields();return Object.keys(t).reduce((e,r)=>{const n=t[r];return e[r]={type:n.type,args:n.args.reduce((e,{name:t,...r})=>(e[t]=r,e),{}),astNode:n.astNode,resolve:n.resolve,description:n.description,deprecationReason:n.deprecationReason,extensions:n.extensions},e},{})}class Jf{static generateFromMetadata(e){this.checkForErrors(e),wf.create(e),pd().build(e),this.buildTypesInfo(e.resolvers);const r=e.orphanedTypes??[],n=new t.GraphQLSchema({query:this.buildRootQueryType(e.resolvers),mutation:this.buildRootMutationType(e.resolvers),subscription:this.buildRootSubscriptionType(e.resolvers),directives:e.directives}),i=new t.GraphQLSchema({...n.toConfig(),types:this.buildOtherTypes(r)});if(wf.reset(),this.usedInterfaceTypes=new Set,!e.skipCheck){const{errors:e}=t.graphqlSync({schema:i,source:t.getIntrospectionQuery()});if(e)throw new Wl(e)}return i}static checkForErrors(e){if(function(){if(!ra.satisfies(b.version,zf))throw new rd(b.version,zf)}(),0!==pd().authorizedFields.length&&void 0===e.authChecker)throw new Error("You need to provide `authChecker` function for `@Authorized` decorator usage!")}static getDefaultValue(e,t,r,n){const{disableInferringDefaultValues:i}=wf;if(i)return t.defaultValue;const o=e[r];if(void 0!==t.defaultValue&&void 0!==o&&t.defaultValue!==o)throw new Hl(n,r,t.defaultValue,o);return void 0!==t.defaultValue?t.defaultValue:o}static buildTypesInfo(e){this.unionTypesInfo=pd().unions.map(e=>{const r=[];return{unionSymbol:e.symbol,type:new t.GraphQLUnionType({name:e.name,description:e.description,types:()=>(r.push(...e.getClassTypes().map(e=>this.objectTypesInfo.find(t=>t.target===e))),r.map(e=>e.type)),resolveType:e.resolveType?this.getResolveTypeFunction(e.resolveType,r):t=>{const n=e.getClassTypes().find(e=>t instanceof e);if(!n)throw new td(e);const i=r.find(e=>e.target===n);return i?.type.name}})}}),this.enumTypesInfo=pd().enums.map(e=>{const r=function(e){const t=Object.keys(e).filter(e=>Number.isNaN(parseInt(e,10))),r=t.reduce((t,r)=>(t[r]=e[r],t),{});return r}(e.enumObj);return{enumObj:e.enumObj,type:new t.GraphQLEnumType({name:e.name,description:e.description,values:Object.keys(r).reduce((t,n)=>{const i=e.valuesConfig[n]||{};return t[n]={value:r[n],description:i.description,deprecationReason:i.deprecationReason},t},{})})}}),this.objectTypesInfo=pd().objectTypes.map(r=>{const n=Object.getPrototypeOf(r.target),i=void 0!==n.prototype,o=()=>{const e=this.objectTypesInfo.find(e=>e.target===n)??this.interfaceTypesInfo.find(e=>e.target===n);return e?e.type:void 0},a=r.interfaceClasses||[];return{metadata:r,target:r.target,type:new t.GraphQLObjectType({name:r.name,description:r.description,astNode:qf(r.name,r.directives),extensions:r.extensions,interfaces:()=>{let e=a.map(e=>{const t=this.interfaceTypesInfo.find(t=>t.target===e);if(!t)throw new Error(`Cannot find interface type metadata for class '${e.name}' provided in 'implements' option for '${r.target.name}' object type class. Please make sure that class is annotated with an '@InterfaceType()' decorator.`);return t.type});if(i){const t=o();if(t){const r=t.getInterfaces();e=Array.from(new Set(e.concat(r)))}}return e},fields:()=>{const t=[];if(r.interfaceClasses){pd().interfaceTypes.filter(e=>r.interfaceClasses.includes(e.target)).forEach(e=>{t.push(...e.fields||[])})}t.push(...r.fields);let n=t.reduce((t,n)=>{const{fieldResolvers:i}=pd(),o=i.filter(t=>"internal"===t.kind||e.includes(t.target)).find(e=>e.getObjectType()===n.target&&e.methodName===n.name),a=this.getGraphQLOutputType(n.target,n.name,n.getType(),n.typeOptions),s=void 0!==n.simple?!0===n.simple:void 0!==r.simpleResolvers&&!0===r.simpleResolvers;return t[n.schemaName]={type:a,args:this.generateHandlerArgs(n.target,n.name,n.params),resolve:o?Ff(o):s?void 0:Uf(n),description:n.description,deprecationReason:n.deprecationReason,astNode:Wf(n.name,a,n.directives),extensions:{complexity:n.complexity,...n.extensions,...o?.extensions}},t},{});if(i){const e=o();if(e){n={...Zf(e),...n}}}return n}})}}),this.interfaceTypesInfo=pd().interfaceTypes.map(e=>{const r=Object.getPrototypeOf(e.target),n=void 0!==r.prototype,i=()=>{const e=this.interfaceTypesInfo.find(e=>e.target===r);return e?e.type:void 0},o=pd().objectTypes.filter(t=>t.interfaceClasses&&t.interfaceClasses.includes(e.target)).map(e=>e.target),a=this.objectTypesInfo.filter(e=>o.includes(e.target));return{metadata:e,target:e.target,type:new t.GraphQLInterfaceType({name:e.name,description:e.description,astNode:Kf(e.name,e.directives),interfaces:()=>{let t=(e.interfaceClasses||[]).map(e=>this.interfaceTypesInfo.find(t=>t.target===e).type);if(n){const e=i();if(e){const r=e.getInterfaces();t=Array.from(new Set(t.concat(r)))}}return t},fields:()=>{const t=[];if(e.interfaceClasses){pd().interfaceTypes.filter(t=>e.interfaceClasses.includes(t.target)).forEach(e=>{t.push(...e.fields||[])})}t.push(...e.fields);let r=t.reduce((e,t)=>{const r=pd().fieldResolvers.find(e=>e.getObjectType()===t.target&&e.methodName===t.name),n=this.getGraphQLOutputType(t.target,t.name,t.getType(),t.typeOptions);return e[t.schemaName]={type:n,args:this.generateHandlerArgs(t.target,t.name,t.params),resolve:r?Ff(r):Uf(t),description:t.description,deprecationReason:t.deprecationReason,astNode:Wf(t.name,n,t.directives),extensions:{complexity:t.complexity,...t.extensions}},e},{});if(n){const e=i();if(e){r={...Zf(e),...r}}}return r},resolveType:e.resolveType?this.getResolveTypeFunction(e.resolveType,a):t=>{const r=o.find(e=>t instanceof e);if(!r)throw new Kl(e);const n=a.find(e=>e.target===r);return n?.type.name}})}}),this.inputTypesInfo=pd().inputTypes.map(e=>{const r=Object.getPrototypeOf(e.target),n=()=>{const e=this.inputTypesInfo.find(e=>e.target===r);return e?e.type:void 0},i=new e.target;return{target:e.target,type:new t.GraphQLInputObjectType({name:e.name,description:e.description,extensions:e.extensions,fields:()=>{let t=e.fields.reduce((t,r)=>{const n=this.getDefaultValue(i,r.typeOptions,r.name,e.name),o=this.getGraphQLInputType(r.target,r.name,r.getType(),{...r.typeOptions,defaultValue:n});return t[r.name]={description:r.description,type:o,defaultValue:n,astNode:Hf(r.name,o,r.directives),extensions:r.extensions,deprecationReason:r.deprecationReason},t},{});if(void 0!==r.prototype){const e=n();if(e){const r=function(e){const t=e.getFields();return Object.keys(t).reduce((e,r)=>{const n=t[r];return e[r]={type:n.type,astNode:n.astNode,description:n.description,defaultValue:n.defaultValue},e},{})}(e);t={...r,...t}}}return t},astNode:Vf(e.name,e.directives)})}})}static buildRootQueryType(e){const r=this.filterHandlersByResolvers(pd().queries,e);return new t.GraphQLObjectType({name:"Query",fields:this.generateHandlerFields(r)})}static buildRootMutationType(e){const r=this.filterHandlersByResolvers(pd().mutations,e);if(0!==r.length)return new t.GraphQLObjectType({name:"Mutation",fields:this.generateHandlerFields(r)})}static buildRootSubscriptionType(e){const r=this.filterHandlersByResolvers(pd().subscriptions,e);if(0!==r.length)return new t.GraphQLObjectType({name:"Subscription",fields:this.generateSubscriptionsFields(r)})}static buildOtherTypes(e){const t=this.objectTypesInfo.filter(e=>e.metadata.interfaceClasses?.some(e=>{const t=this.interfaceTypesInfo.find(t=>t.target===e);return!!t&&(!t.metadata.autoRegisteringDisabled&&!!this.usedInterfaceTypes.has(e))}));return[...this.filterTypesInfoByOrphanedTypesAndExtractType(this.objectTypesInfo,e),...this.filterTypesInfoByOrphanedTypesAndExtractType(this.interfaceTypesInfo,e),...this.filterTypesInfoByOrphanedTypesAndExtractType(this.inputTypesInfo,e),...t.map(e=>e.type)]}static generateHandlerFields(e){return e.reduce((e,t)=>{const r=this.getGraphQLOutputType(t.target,t.methodName,t.getReturnType(),t.returnTypeOptions);return e[t.schemaName]={type:r,args:this.generateHandlerArgs(t.target,t.methodName,t.params),resolve:Bf(t),description:t.description,deprecationReason:t.deprecationReason,astNode:Wf(t.schemaName,r,t.directives),extensions:{complexity:t.complexity,...t.extensions}},e},{})}static generateSubscriptionsFields(e){if(!e.length)return{};const{pubSub:t,container:r}=wf;if(!t)throw new Jl;const n=this.generateHandlerFields(e);return e.reduce((e,n)=>{let i;return i=n.subscribe?(e,t,r,i)=>{const o={source:e,args:t,context:r,info:i};return n.subscribe(o)}:(e,r,i,o)=>{const a={source:e,args:r,context:i,info:o};let s;if("function"==typeof n.topics){s=(0,n.topics)(a)}else s=n.topics;const c=n.topicId?.(a);let u;if(Array.isArray(s)){if(0===s.length)throw new Yl(n.target,n.methodName);u=ff.merge([...s.map(e=>t.subscribe(e,c))])}else u=t.subscribe(s,c);return n.filter?function(e,t,r,n,i,o,a,s,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return i(n(r(t(e))));case 6:return o(i(n(r(t(e)))));case 7:return a(o(i(n(r(t(e))))));case 8:return s(a(o(i(n(r(t(e)))))));case 9:return c(s(a(o(i(n(r(t(e))))))));default:let u=arguments[0];for(let e=1;e<arguments.length;e++)u=arguments[e](u);return u}}(u,function(e){return t=>new ff(async(r,n)=>{const i=t[Symbol.asyncIterator]();let o;for(n.then(()=>{i.return?.()});!1===(o=await i.next()).done;)await e(o.value)&&await r(o.value);n()})}(e=>{const t={payload:e,args:r,context:i,info:o};return n.filter(t)})):u},e[n.schemaName].subscribe=function(e,t,r){const{authChecker:n,authMode:i}=wf;return n&&r?(o,a,s,c)=>{const u={root:o,args:a,context:s,info:c};return Tf(n,t,i,r)(u,async()=>e(o,a,s,c))}:e}(i,r,n.roles),e},n)}static generateHandlerArgs(e,t,r){return r.reduce((r,n)=>{if("arg"===n.kind){const i=this.getGraphQLInputType(e,t,n.getType(),n.typeOptions,n.index,n.name),o=pd().argumentDirectives.filter(r=>r.target===e&&r.fieldName===t&&r.parameterIndex===n.index).map(e=>e.directive);r[n.name]={description:n.description,type:i,defaultValue:n.typeOptions.defaultValue,deprecationReason:n.deprecationReason,astNode:Hf(n.name,i,o)}}else if("args"===n.kind){const i=pd().argumentTypes.find(e=>e.target===n.getType());if(!i)throw new Error(`The value used as a type of '@Args' for '${t}' of '${e.name}' is not a class decorated with '@ArgsType' decorator!`);const o=[i.target];for(let e=i.target;void 0!==e.prototype;e=Object.getPrototypeOf(e))o.push(e);for(const e of o.reverse()){const t=pd().argumentTypes.find(t=>t.target===e);t&&this.mapArgFields(t,r)}}return r},{})}static mapArgFields(e,t={}){const r=new e.target;e.fields.forEach(n=>{const i=this.getDefaultValue(r,n.typeOptions,n.name,e.name),o=this.getGraphQLInputType(n.target,n.name,n.getType(),{...n.typeOptions,defaultValue:i});t[n.schemaName]={description:n.description,type:o,defaultValue:i,astNode:Hf(n.name,o,n.directives),extensions:n.extensions,deprecationReason:n.deprecationReason}})}static getGraphQLOutputType(e,t,r,n={}){let i;if(i=Ef(r),!i){const e=this.objectTypesInfo.find(e=>e.target===r);e&&(i=e.type)}if(!i){const e=this.interfaceTypesInfo.find(e=>e.target===r);e&&(this.usedInterfaceTypes.add(e.target),i=e.type)}if(!i){const e=this.enumTypesInfo.find(e=>e.enumObj===r);e&&(i=e.type)}if(!i){const e=this.unionTypesInfo.find(e=>e.unionSymbol===r);e&&(i=e.type)}if(!i)throw new Vl("output",e.name,t);const{nullableByDefault:o}=wf;return Sf(e,t,i,n,o)}static getGraphQLInputType(e,t,r,n={},i,o){let a;if(a=Ef(r),!a){const e=this.inputTypesInfo.find(e=>e.target===r);e&&(a=e.type)}if(!a){const e=this.enumTypesInfo.find(e=>e.enumObj===r);e&&(a=e.type)}if(!a)throw new Vl("input",e.name,t,i,o);const{nullableByDefault:s}=wf;return Sf(e,t,a,n,s)}static getResolveTypeFunction(e,t){return async(...r)=>{const n=await e(...r);return n&&"string"!=typeof n?t.find(e=>e.target===n)?.type.name:n??void 0}}static filterHandlersByResolvers(e,t){return e.filter(e=>t.includes(e.target))}static filterTypesInfoByOrphanedTypesAndExtractType(e,t){return e.filter(e=>t.includes(e.target)).map(e=>e.type)}}Jf.objectTypesInfo=[],Jf.inputTypesInfo=[],Jf.interfaceTypesInfo=[],Jf.enumTypesInfo=[],Jf.unionTypesInfo=[],Jf.usedInterfaceTypes=new Set;const Yf={sortedSchema:!0};function Qf(e,r,o=Yf){const a=function(e,r){const n=r.sortedSchema?t.lexicographicSortSchema(e):e;return"# -----------------------------------------------\n# !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!!\n# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!\n# -----------------------------------------------\n\n"+t.printSchema(n)}(r,o);!function(e,t){try{i.writeFileSync(e,t)}catch(r){if("ENOENT"!==r.code)throw r;i.mkdirSync(n.dirname(e),{recursive:!0}),i.writeFileSync(e,t)}}(e,a)}function Xf(e){const t=function(e){if(0===e.resolvers.length)throw new Error("Empty `resolvers` array property found in `buildSchema` options!");return e.resolvers}(e),r=Jf.generateFromMetadata({...e,resolvers:t});if(e.emitSchemaFile){const{schemaFileName:t,printSchemaOptions:i}=function(e){const t=n.resolve(process.cwd(),"schema.graphql");return{schemaFileName:"string"==typeof e.emitSchemaFile?e.emitSchemaFile:"object"==typeof e.emitSchemaFile&&e.emitSchemaFile.path||t,printSchemaOptions:"object"==typeof e.emitSchemaFile?{...Yf,...e.emitSchemaFile}:Yf}}(e);Qf(t,r,i)}return r}var ep,tp,rp;!function(e){e.assistant="assistant",e.developer="developer",e.system="system",e.tool="tool",e.user="user"}(ep||(ep={})),function(e){e.Chat="Chat",e.Task="Task",e.TextareaCompletion="TextareaCompletion",e.TextareaPopover="TextareaPopover",e.Suggestion="Suggestion"}(tp||(tp={})),function(e){e.disabled="disabled",e.enabled="enabled",e.remote="remote"}(rp||(rp={})),yd(ep,{name:"MessageRole",description:"The role of the message"}),yd(tp,{name:"CopilotRequestType",description:"The type of Copilot request"}),yd(rp,{name:"ActionInputAvailability",description:"The availability of the frontend action"});var np,ip=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return A(t,e),x([gd(function(){return op},{nullable:!0}),k("design:type",op)],t.prototype,"textMessage",void 0),x([gd(function(){return ap},{nullable:!0}),k("design:type",ap)],t.prototype,"actionExecutionMessage",void 0),x([gd(function(){return sp},{nullable:!0}),k("design:type",sp)],t.prototype,"resultMessage",void 0),x([gd(function(){return cp},{nullable:!0}),k("design:type",cp)],t.prototype,"agentStateMessage",void 0),x([gd(function(){return up},{nullable:!0}),k("design:type",up)],t.prototype,"imageMessage",void 0),t=x([bd()],t)}(function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"id",void 0),x([gd(function(){return Date}),k("design:type",Date)],e.prototype,"createdAt",void 0),e=x([bd()],e)}()),op=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"content",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),e=x([bd()],e)}(),ap=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"arguments",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),x([gd(function(){return String},{nullable:!0,deprecationReason:"This field will be removed in a future version"}),k("design:type",String)],e.prototype,"scope",void 0),e=x([bd()],e)}(),sp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"actionExecutionId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"actionName",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"result",void 0),e=x([bd()],e)}(),cp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"agentName",void 0),x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"state",void 0),x([gd(function(){return Boolean}),k("design:type",Boolean)],e.prototype,"running",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"nodeName",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return Boolean}),k("design:type",Boolean)],e.prototype,"active",void 0),e=x([bd()],e)}(),up=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"format",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"bytes",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),e=x([bd()],e)}(),lp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"description",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"jsonSchema",void 0),x([gd(function(){return rp},{nullable:!0}),k("design:type",String)],e.prototype,"available",void 0),e=x([bd()],e)}(),dp=function(){function e(){}return x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"toDeprecate_fullContext",void 0),x([gd(function(){return[lp]}),k("design:type",Array)],e.prototype,"actions",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"url",void 0),e=x([bd()],e)}(),fp=function(){function e(){this.allowList=[],this.denyList=[]}return x([gd(function(){return[String]},{nullable:!0}),k("design:type",Array)],e.prototype,"allowList",void 0),x([gd(function(){return[String]},{nullable:!0}),k("design:type",Array)],e.prototype,"denyList",void 0),e=x([bd()],e)}(),pp=function(){function e(){}return x([gd(function(){return fp},{nullable:!1}),k("design:type",fp)],e.prototype,"inputValidationRules",void 0),e=x([bd()],e)}(),hp=function(){function e(){}return x([gd(function(){return pp},{nullable:!0}),k("design:type",pp)],e.prototype,"guardrails",void 0),e=x([bd()],e)}(),mp=function(){function e(){}return x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"model",void 0),x([gd(function(){return Number},{nullable:!0}),k("design:type",Number)],e.prototype,"maxTokens",void 0),x([gd(function(){return[String]},{nullable:!0}),k("design:type",Array)],e.prototype,"stop",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"toolChoice",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"toolChoiceFunctionName",void 0),x([gd(function(){return Number},{nullable:!0}),k("design:type",Number)],e.prototype,"temperature",void 0),e=x([bd()],e)}(),yp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"agentName",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"nodeName",void 0),e=x([bd()],e)}(),gp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"agentName",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"state",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"config",void 0),e=x([bd()],e)}(),bp=function(){function e(){}return x([gd(function(){return vp},{nullable:!0}),k("design:type",vp)],e.prototype,"openaiAssistantAPI",void 0),e=x([bd()],e)}(),vp=function(){function e(){}return x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"threadId",void 0),e=x([bd()],e)}();!function(e){e.Pending="pending",e.Success="success",e.Failed="failed"}(np||(np={})),yd(np,{name:"MessageStatusCode"});var wp,_p=function(){function e(){}return x([gd(function(){return np}),k("design:type",String)],e.prototype,"code",void 0),e=x([Ed()],e)}(),Ep=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=np.Pending,t}return A(t,e),t=x([Ed()],t)}(_p),Sp=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=np.Success,t}return A(t,e),t=x([Ed()],t)}(_p),Op=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=np.Failed,t}return A(t,e),x([gd(function(){return String}),k("design:type",String)],t.prototype,"reason",void 0),t=x([Ed()],t)}(_p),Ap=Ad({name:"MessageStatus",types:function(){return[Ep,Sp,Op]}});!function(e){e.Pending="pending",e.Success="success",e.Failed="failed"}(wp||(wp={})),yd(wp,{name:"ResponseStatusCode"});var Tp,xp=function(){function e(){}return x([gd(function(){return wp}),k("design:type",String)],e.prototype,"code",void 0),e=x([vd({resolveType:function(e){return e.code===wp.Success?kp:e.code===wp.Failed?Rp:e.code===wp.Pending?Ip:void 0}}),Ed()],e),e}(),Ip=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=wp.Pending,t}return A(t,e),t=x([Ed({implements:xp})],t)}(xp),kp=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=wp.Success,t}return A(t,e),t=x([Ed({implements:xp})],t)}(xp);!function(e){e.GUARDRAILS_VALIDATION_FAILED="GUARDRAILS_VALIDATION_FAILED",e.MESSAGE_STREAM_INTERRUPTED="MESSAGE_STREAM_INTERRUPTED",e.UNKNOWN_ERROR="UNKNOWN_ERROR"}(Tp||(Tp={})),yd(Tp,{name:"FailedResponseStatusReason"});var jp,Rp=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.code=wp.Failed,t.details=null,t}return A(t,e),x([gd(function(){return Tp}),k("design:type",String)],t.prototype,"reason",void 0),x([gd(function(){return Gd},{nullable:!0}),k("design:type",Object)],t.prototype,"details",void 0),t=x([Ed({implements:xp})],t)}(xp),Np=Ad({name:"ResponseStatus",types:function(){return[Ip,kp,Rp]}}),Pp=function(){function e(){}return x([gd(function(){return Cp},{nullable:!0}),k("design:type",Cp)],e.prototype,"openaiAssistantAPI",void 0),e=x([Ed()],e)}(),Cp=function(){function e(){}return x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"threadId",void 0),e=x([Ed()],e)}(),Lp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"id",void 0),x([gd(function(){return Date}),k("design:type",Date)],e.prototype,"createdAt",void 0),x([gd(function(){return Ap}),k("design:type",Object)],e.prototype,"status",void 0),e=x([vd({resolveType:function(e){return e.hasOwnProperty("content")?Mp:e.hasOwnProperty("name")?$p:e.hasOwnProperty("result")?Dp:e.hasOwnProperty("state")?Bp:e.hasOwnProperty("format")&&e.hasOwnProperty("bytes")?Fp:void 0}})],e),e}(),Mp=function(){function e(){}return x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),x([gd(function(){return[String]}),k("design:type",Array)],e.prototype,"content",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),e=x([Ed({implements:Lp})],e)}(),$p=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String},{nullable:!0,deprecationReason:"This field will be removed in a future version"}),k("design:type",String)],e.prototype,"scope",void 0),x([gd(function(){return[String]}),k("design:type",Array)],e.prototype,"arguments",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),e=x([Ed({implements:Lp})],e)}(),Dp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"actionExecutionId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"actionName",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"result",void 0),e=x([Ed({implements:Lp})],e)}(),Bp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"agentName",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"nodeName",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return Boolean}),k("design:type",Boolean)],e.prototype,"active",void 0),x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"state",void 0),x([gd(function(){return Boolean}),k("design:type",Boolean)],e.prototype,"running",void 0),e=x([Ed({implements:Lp})],e)}(),Fp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"format",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"bytes",void 0),x([gd(function(){return ep}),k("design:type",String)],e.prototype,"role",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"parentMessageId",void 0),e=x([Ed({implements:Lp})],e)}(),Up=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return Np}),k("design:type",Object)],e.prototype,"status",void 0),x([gd({nullable:!0}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return[Lp]}),k("design:type",Array)],e.prototype,"messages",void 0),x([gd(function(){return Pp},{nullable:!0}),k("design:type",Pp)],e.prototype,"extensions",void 0),x([gd(function(){return[Vp]},{nullable:!0}),k("design:type",Array)],e.prototype,"metaEvents",void 0),e=x([Ed()],e)}();!function(e){e.LangGraphInterruptEvent="LangGraphInterruptEvent",e.CopilotKitLangGraphInterruptEvent="CopilotKitLangGraphInterruptEvent"}(jp||(jp={})),yd(jp,{name:"MetaEventName",description:"Meta event types"});var zp,Gp,qp,Vp=function(){function e(){this.type="MetaEvent"}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"type",void 0),x([gd(function(){return jp}),k("design:type",String)],e.prototype,"name",void 0),e=x([vd({resolveType:function(e){return e.name===jp.LangGraphInterruptEvent?Hp:e.name===jp.CopilotKitLangGraphInterruptEvent?Kp:void 0}}),vd()],e),e}(),Wp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"value",void 0),x([gd(function(){return[Lp]}),k("design:type",Array)],e.prototype,"messages",void 0),e=x([Ed()],e)}(),Hp=function(){function e(){this.name=jp.LangGraphInterruptEvent}return x([gd(function(){return jp}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"value",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"response",void 0),e=x([Ed({implements:Vp})],e)}(),Kp=function(){function e(){this.name=jp.CopilotKitLangGraphInterruptEvent}return x([gd(function(){return jp}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return Wp}),k("design:type",Wp)],e.prototype,"data",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"response",void 0),e=x([Ed({implements:Vp})],e)}(),Zp=function(){function e(){}return x([gd(function(){return jp}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"value",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"response",void 0),x([gd(function(){return[ip]},{nullable:!0}),k("design:type",Array)],e.prototype,"messages",void 0),e=x([bd()],e)}(),Jp=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"description",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"value",void 0),e=x([bd()],e)}(),Yp=function(){function e(){}return x([gd(function(){return tp},{nullable:!0}),k("design:type",String)],e.prototype,"requestType",void 0),e=x([bd()],e)}(),Qp=function(){function e(){}return x([gd(function(){return Yp},{nullable:!1}),k("design:type",Yp)],e.prototype,"metadata",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return String},{nullable:!0}),k("design:type",String)],e.prototype,"runId",void 0),x([gd(function(){return[ip]}),k("design:type",Array)],e.prototype,"messages",void 0),x([gd(function(){return dp}),k("design:type",dp)],e.prototype,"frontend",void 0),x([gd(function(){return hp},{nullable:!0}),k("design:type",hp)],e.prototype,"cloud",void 0),x([gd(function(){return mp},{nullable:!0}),k("design:type",mp)],e.prototype,"forwardedParameters",void 0),x([gd(function(){return yp},{nullable:!0}),k("design:type",yp)],e.prototype,"agentSession",void 0),x([gd(function(){return gp},{nullable:!0}),k("design:type",gp)],e.prototype,"agentState",void 0),x([gd(function(){return[gp]},{nullable:!0}),k("design:type",Array)],e.prototype,"agentStates",void 0),x([gd(function(){return bp},{nullable:!0}),k("design:type",bp)],e.prototype,"extensions",void 0),x([gd(function(){return[Zp]},{nullable:!0}),k("design:type",Array)],e.prototype,"metaEvents",void 0),x([gd(function(){return[Jp]},{nullable:!0}),k("design:type",Array)],e.prototype,"context",void 0),e=x([bd()],e)}(),Xp=function(){function e(e){var t,n,i;null!==(t=e.id)&&void 0!==t||(e.id=r.randomId()),null!==(n=e.status)&&void 0!==n||(e.status={code:np.Success}),null!==(i=e.createdAt)&&void 0!==i||(e.createdAt=new Date),Object.assign(this,e)}return e.prototype.isTextMessage=function(){return"TextMessage"===this.type},e.prototype.isActionExecutionMessage=function(){return"ActionExecutionMessage"===this.type},e.prototype.isResultMessage=function(){return"ResultMessage"===this.type},e.prototype.isAgentStateMessage=function(){return"AgentStateMessage"===this.type},e.prototype.isImageMessage=function(){return"ImageMessage"===this.type},e}(),eh=ep,th=function(e){function t(t){var r=e.call(this,t)||this;return r.type="TextMessage",r.type="TextMessage",r}return A(t,e),t}(Xp),rh=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="ActionExecutionMessage",t}return A(t,e),t}(Xp),nh=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="ResultMessage",t}return A(t,e),t.encodeResult=function(e,t){var r=t?"string"==typeof t?{code:"ERROR",message:t}:t instanceof Error?{code:"ERROR",message:t.message}:t:void 0;return r?JSON.stringify({error:r,result:e||""}):void 0===e?"":"string"==typeof e?e:JSON.stringify(e)},t.decodeResult=function(e){if(!e)return{result:""};try{var t=JSON.parse(e);return t&&"object"==typeof t?"error"in t?{error:t.error,result:t.result||""}:{result:JSON.stringify(t)}:{result:e}}catch(t){return{result:e}}},t.prototype.hasError=function(){try{return!!t.decodeResult(this.result).error}catch(e){return!1}},t.prototype.getError=function(){try{return t.decodeResult(this.result).error}catch(e){return}},t}(Xp),ih=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="AgentStateMessage",t}return A(t,e),t}(Xp),oh=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="ImageMessage",t}return A(t,e),t}(Xp);!function(e){e.TextMessageStart="TextMessageStart",e.TextMessageContent="TextMessageContent",e.TextMessageEnd="TextMessageEnd",e.ActionExecutionStart="ActionExecutionStart",e.ActionExecutionArgs="ActionExecutionArgs",e.ActionExecutionEnd="ActionExecutionEnd",e.ActionExecutionResult="ActionExecutionResult",e.AgentStateMessage="AgentStateMessage",e.MetaEvent="MetaEvent",e.RunError="RunError"}(zp||(zp={})),function(e){e.LangGraphInterruptEvent="LangGraphInterruptEvent",e.LangGraphInterruptResumeEvent="LangGraphInterruptResumeEvent",e.CopilotKitLangGraphInterruptEvent="CopilotKitLangGraphInterruptEvent"}(Gp||(Gp={})),function(e){function t(){return e.call(this)||this}A(t,e),t.prototype.sendTextMessageStart=function(e){var t=e.messageId,r=e.parentMessageId;this.next({type:zp.TextMessageStart,messageId:t,parentMessageId:r})},t.prototype.sendTextMessageContent=function(e){var t=e.messageId,r=e.content;this.next({type:zp.TextMessageContent,content:r,messageId:t})},t.prototype.sendTextMessageEnd=function(e){var t=e.messageId;this.next({type:zp.TextMessageEnd,messageId:t})},t.prototype.sendTextMessage=function(e,t){this.sendTextMessageStart({messageId:e}),this.sendTextMessageContent({messageId:e,content:t}),this.sendTextMessageEnd({messageId:e})},t.prototype.sendActionExecutionStart=function(e){var t=e.actionExecutionId,r=e.actionName,n=e.parentMessageId;this.next({type:zp.ActionExecutionStart,actionExecutionId:t,actionName:r,parentMessageId:n})},t.prototype.sendActionExecutionArgs=function(e){var t=e.actionExecutionId,r=e.args;this.next({type:zp.ActionExecutionArgs,args:r,actionExecutionId:t})},t.prototype.sendActionExecutionEnd=function(e){var t=e.actionExecutionId;this.next({type:zp.ActionExecutionEnd,actionExecutionId:t})},t.prototype.sendActionExecution=function(e){var t=e.actionExecutionId,r=e.actionName,n=e.args,i=e.parentMessageId;this.sendActionExecutionStart({actionExecutionId:t,actionName:r,parentMessageId:i}),this.sendActionExecutionArgs({actionExecutionId:t,args:n}),this.sendActionExecutionEnd({actionExecutionId:t})},t.prototype.sendActionExecutionResult=function(e){var t=e.actionExecutionId,r=e.actionName,n=e.result,i=e.error;this.next({type:zp.ActionExecutionResult,actionName:r,actionExecutionId:t,result:nh.encodeResult(n,i)})},t.prototype.sendAgentStateMessage=function(e){var t=e.threadId,r=e.agentName,n=e.nodeName,i=e.runId,o=e.active,a=e.role,s=e.state,c=e.running;this.next({type:zp.AgentStateMessage,threadId:t,agentName:r,nodeName:n,runId:i,active:o,role:a,state:s,running:c})}}(a.ReplaySubject),function(e){e[e.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",e[e.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",e[e.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(qp||(qp={}));var ah=function(){function e(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return e.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},e.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.findTransformMetadatas=function(e,t,r){return this.findMetadatas(this._transformMetadatas,e,t).filter(function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?r===qp.CLASS_TO_CLASS||r===qp.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||r===qp.CLASS_TO_PLAIN))})},e.prototype.findExcludeMetadata=function(e,t){return this.findMetadata(this._excludeMetadatas,e,t)},e.prototype.findExposeMetadata=function(e,t){return this.findMetadata(this._exposeMetadatas,e,t)},e.prototype.findExposeMetadataByCustomName=function(e,t){return this.getExposedMetadatas(e).find(function(e){return e.options&&e.options.name===t})},e.prototype.findTypeMetadata=function(e,t){return this.findMetadata(this._typeMetadatas,e,t)},e.prototype.getStrategy=function(e){var t=this._excludeMetadatas.get(e),r=t&&t.get(void 0),n=this._exposeMetadatas.get(e),i=n&&n.get(void 0);return r&&i||!r&&!i?"none":r?"excludeAll":"exposeAll"},e.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},e.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},e.prototype.getExposedProperties=function(e,t){return this.getExposedMetadatas(e).filter(function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===qp.CLASS_TO_CLASS||t===qp.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===qp.CLASS_TO_PLAIN))}).map(function(e){return e.propertyName})},e.prototype.getExcludedProperties=function(e,t){return this.getExcludedMetadatas(e).filter(function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===qp.CLASS_TO_CLASS||t===qp.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===qp.CLASS_TO_PLAIN))}).map(function(e){return e.propertyName})},e.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},e.prototype.getMetadata=function(e,t){var r,n=e.get(t);n&&(r=Array.from(n.values()).filter(function(e){return void 0!==e.propertyName}));for(var i=[],o=0,a=this.getAncestors(t);o<a.length;o++){var s=a[o],c=e.get(s);if(c){var u=Array.from(c.values()).filter(function(e){return void 0!==e.propertyName});i.push.apply(i,u)}}return i.concat(r||[])},e.prototype.findMetadata=function(e,t,r){var n=e.get(t);if(n){var i=n.get(r);if(i)return i}for(var o=0,a=this.getAncestors(t);o<a.length;o++){var s=a[o],c=e.get(s);if(c){var u=c.get(r);if(u)return u}}},e.prototype.findMetadatas=function(e,t,r){var n,i=e.get(t);i&&(n=i.get(r));for(var o=[],a=0,s=this.getAncestors(t);a<s.length;a++){var c=s[a],u=e.get(c);u&&u.has(r)&&o.push.apply(o,u.get(r))}return o.slice().reverse().concat((n||[]).slice().reverse())},e.prototype.getAncestors=function(e){if(!e)return[];if(!this._ancestorsMap.has(e)){for(var t=[],r=Object.getPrototypeOf(e.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))t.push(r);this._ancestorsMap.set(e,t)}return this._ancestorsMap.get(e)},e}(),sh=new ah;var ch=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};var uh=function(){function e(e,t){this.transformationType=e,this.options=t,this.recursionStack=new Set}return e.prototype.transform=function(e,t,r,n,i,o){var a,s=this;if(void 0===o&&(o=0),Array.isArray(t)||t instanceof Set){var c=n&&this.transformationType===qp.PLAIN_TO_CLASS?function(e){var t=new e;return t instanceof Set||"push"in t?t:[]}(n):[];return t.forEach(function(t,n){var i=e?e[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(t))s.transformationType===qp.CLASS_TO_CLASS&&(c instanceof Set?c.add(t):c.push(t));else{var a=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===qp.PLAIN_TO_CLASS){a=r.options.discriminator.subTypes.find(function(e){return e.name===t[r.options.discriminator.property]});var u={newObject:c,object:t,property:void 0},l=r.typeFunction(u);a=void 0===a?l:a.value,r.options.keepDiscriminatorProperty||delete t[r.options.discriminator.property]}s.transformationType===qp.CLASS_TO_CLASS&&(a=t.constructor),s.transformationType===qp.CLASS_TO_PLAIN&&(t[r.options.discriminator.property]=r.options.discriminator.subTypes.find(function(e){return e.value===t.constructor}).name)}else a=r;var d=s.transform(i,t,a,void 0,t instanceof Map,o+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(r!==String||i){if(r!==Number||i){if(r!==Boolean||i){if((r===Date||t instanceof Date)&&!i)return t instanceof Date?new Date(t.valueOf()):null==t?t:new Date(t);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||t instanceof Buffer)&&!i)return null==t?t:Buffer.from(t);if(null===(a=t)||"object"!=typeof a||"function"!=typeof a.then||i){if(i||null===t||"object"!=typeof t||"function"!=typeof t.then){if("object"==typeof t&&null!==t){r||t.constructor===Object||(Array.isArray(t)||t.constructor!==Array)&&(r=t.constructor),!r&&e&&(r=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(t);var u=this.getKeys(r,t,i),l=e||{};e||this.transformationType!==qp.PLAIN_TO_CLASS&&this.transformationType!==qp.CLASS_TO_CLASS||(l=i?new Map:r?new r:{});for(var d=function(n){if("__proto__"===n||"constructor"===n)return"continue";var a=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===qp.PLAIN_TO_CLASS)(u=sh.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===qp.CLASS_TO_PLAIN||f.transformationType===qp.CLASS_TO_CLASS){var u;(u=sh.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var d=void 0;d=f.transformationType===qp.PLAIN_TO_CLASS?t[a]:t instanceof Map?t.get(a):t[a]instanceof Function?t[a]():t[a];var p=void 0,h=d instanceof Map;if(r&&i)p=r;else if(r){var m=sh.findTypeMetadata(r,c);if(m){var y={newObject:l,object:t,property:c},g=m.typeFunction?m.typeFunction(y):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?t[a]instanceof Array?p=m:(f.transformationType===qp.PLAIN_TO_CLASS&&(p=void 0===(p=m.options.discriminator.subTypes.find(function(e){if(d&&d instanceof Object&&m.options.discriminator.property in d)return e.name===d[m.options.discriminator.property]}))?g:p.value,m.options.keepDiscriminatorProperty||d&&d instanceof Object&&m.options.discriminator.property in d&&delete d[m.options.discriminator.property]),f.transformationType===qp.CLASS_TO_CLASS&&(p=d.constructor),f.transformationType===qp.CLASS_TO_PLAIN&&d&&(d[m.options.discriminator.property]=m.options.discriminator.subTypes.find(function(e){return e.value===d.constructor}).name)):p=g,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter(function(e){return e.target===r&&!!e.properties[c]}).forEach(function(e){return p=e.properties[c]});else if(f.options.enableImplicitConversion&&f.transformationType===qp.PLAIN_TO_CLASS){var b=Reflect.getMetadata("design:type",r.prototype,c);b&&(p=b)}}var v=Array.isArray(t[a])?f.getReflectedType(r,c):void 0,w=e?e[a]:void 0;if(l.constructor.prototype){var _=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===qp.PLAIN_TO_CLASS||f.transformationType===qp.CLASS_TO_CLASS)&&(_&&!_.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(d)){if(f.transformationType===qp.CLASS_TO_CLASS){S=d;(void 0!==(S=f.applyCustomTransformations(S,r,n,t,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,S):l[s]=S)}}else{var E=f.transformationType===qp.PLAIN_TO_CLASS?s:n,S=void 0;f.transformationType===qp.CLASS_TO_PLAIN?(S=t[E],S=f.applyCustomTransformations(S,r,E,t,f.transformationType),S=t[E]===S?d:S,S=f.transform(w,S,p,v,h,o+1)):void 0===d&&f.options.exposeDefaultValues?S=l[s]:(S=f.transform(w,d,p,v,h,o+1),S=f.applyCustomTransformations(S,r,E,t,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,S):l[s]=S)}},f=this,p=0,h=u;p<h.length;p++){d(h[p])}return this.options.enableCircularCheck&&this.recursionStack.delete(t),l}return t}return t}return new Promise(function(e,n){t.then(function(t){return e(s.transform(void 0,t,r,void 0,void 0,o+1))},n)})}return null==t?t:Boolean(t)}return null==t?t:Number(t)}return null==t?t:String(t)},e.prototype.applyCustomTransformations=function(e,t,r,n,i){var o=this,a=sh.findTransformMetadatas(t,r,this.transformationType);return void 0!==this.options.version&&(a=a.filter(function(e){return!e.options||o.checkVersion(e.options.since,e.options.until)})),(a=this.options.groups&&this.options.groups.length?a.filter(function(e){return!e.options||o.checkGroups(e.options.groups)}):a.filter(function(e){return!e.options||!e.options.groups||!e.options.groups.length})).forEach(function(t){e=t.transformFn({value:e,key:r,obj:n,type:i,options:o.options})}),e},e.prototype.isCircular=function(e){return this.recursionStack.has(e)},e.prototype.getReflectedType=function(e,t){if(e){var r=sh.findTypeMetadata(e,t);return r?r.reflectedType:void 0}},e.prototype.getKeys=function(e,t,r){var n=this,i=sh.getStrategy(e);"none"===i&&(i=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===i||r)&&(o=t instanceof Map?Array.from(t.keys()):Object.keys(t)),r)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&e){var a=sh.getExposedProperties(e,this.transformationType),s=sh.getExcludedProperties(e,this.transformationType);o=ch(ch([],a,!0),s,!0)}if(!this.options.ignoreDecorators&&e){a=sh.getExposedProperties(e,this.transformationType);this.transformationType===qp.PLAIN_TO_CLASS&&(a=a.map(function(t){var r=sh.findExposeMetadata(e,t);return r&&r.options&&r.options.name?r.options.name:t})),o=this.options.excludeExtraneousValues?a:o.concat(a);var c=sh.getExcludedProperties(e,this.transformationType);c.length>0&&(o=o.filter(function(e){return!c.includes(e)})),void 0!==this.options.version&&(o=o.filter(function(t){var r=sh.findExposeMetadata(e,t);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)})),o=this.options.groups&&this.options.groups.length?o.filter(function(t){var r=sh.findExposeMetadata(e,t);return!r||!r.options||n.checkGroups(r.options.groups)}):o.filter(function(t){var r=sh.findExposeMetadata(e,t);return!(r&&r.options&&r.options.groups&&r.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter(function(e){return n.options.excludePrefixes.every(function(t){return e.substr(0,t.length)!==t})})),o=o.filter(function(e,t,r){return r.indexOf(e)===t}),o},e.prototype.checkVersion=function(e,t){var r=!0;return r&&e&&(r=this.options.version>=e),r&&t&&(r=this.options.version<t),r},e.prototype.checkGroups=function(e){return!e||this.options.groups.some(function(t){return e.includes(t)})},e}(),lh={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},dh=function(){return dh=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},dh.apply(this,arguments)},fh=new(function(){function e(){}return e.prototype.instanceToPlain=function(e,t){return new uh(qp.CLASS_TO_PLAIN,dh(dh({},lh),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToPlainFromExist=function(e,t,r){return new uh(qp.CLASS_TO_PLAIN,dh(dh({},lh),r)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.plainToInstance=function(e,t,r){return new uh(qp.PLAIN_TO_CLASS,dh(dh({},lh),r)).transform(void 0,t,e,void 0,void 0,void 0)},e.prototype.plainToClassFromExist=function(e,t,r){return new uh(qp.PLAIN_TO_CLASS,dh(dh({},lh),r)).transform(e,t,void 0,void 0,void 0,void 0)},e.prototype.instanceToInstance=function(e,t){return new uh(qp.CLASS_TO_CLASS,dh(dh({},lh),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToClassFromExist=function(e,t,r){return new uh(qp.CLASS_TO_CLASS,dh(dh({},lh),r)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.serialize=function(e,t){return JSON.stringify(this.instanceToPlain(e,t))},e.prototype.deserialize=function(e,t,r){var n=JSON.parse(t);return this.plainToInstance(e,n,r)},e.prototype.deserializeArray=function(e,t,r){var n=JSON.parse(t);return this.plainToInstance(e,n,r)},e}());function ph(e,t,r){return fh.plainToInstance(e,t,r)}var hh=function(e){function t(t){var r=t.guardrailsReason,n=e.call(this)||this;return n.reason=Tp.GUARDRAILS_VALIDATION_FAILED,n.details={guardrailsReason:r},n}return A(t,e),t}(Rp),mh=function(e){function t(t){var r=t.messageId,n=e.call(this)||this;return n.reason=Tp.MESSAGE_STREAM_INTERRUPTED,n.details={messageId:r,description:"Check the message for mode details"},n}return A(t,e),t}(Rp),yh=function(e){function t(t){var r=t.description,n=t.originalError,i=e.call(this)||this;return i.reason=Tp.UNKNOWN_ERROR,i.details={description:r,originalError:n},i}return A(t,e),t}(Rp);function gh(e){if("assistant"!==e.role)throw new Error("Cannot extract agent name from message with role ".concat(e.role));return e.agentName||"unknown"}function bh(e){return"assistant"===e.role&&"agentName"in e&&"state"in e}function vh(e){return("assistant"===e.role||"user"===e.role)&&void 0!==e.image&&!(void 0===e.image.format||void 0===e.image.bytes)}function wh(e){if("string"==typeof e||void 0===e)return e||"";if(Array.isArray(e))return e.map(function(e){return"text"===(null==e?void 0:e.type)?e.text:"binary"===(null==e?void 0:e.type)?e.data||e.url||e.filename||"[binary:".concat(e.mimeType,"]"):""}).filter(Boolean).join("\n");if(e&&"object"==typeof e)try{return JSON.stringify(e)}catch(e){console.warn("Failed to serialize message content",e)}return String(null!=e?e:"")}function _h(e){if("developer"!==e.role&&"system"!==e.role&&"assistant"!==e.role&&"user"!==e.role)throw new Error("Cannot convert message with role ".concat(e.role," to TextMessage"));var t;return t="developer"===e.role?eh.developer:"system"===e.role?eh.system:"assistant"===e.role?eh.assistant:eh.user,new th({id:e.id,content:wh(e.content),role:t})}function Eh(e,t){if("function"!==e.type)throw new Error("Unsupported tool call type: ".concat(e.type));var r;if("string"==typeof e.function.arguments)try{r=JSON.parse(e.function.arguments)}catch(t){console.warn("Failed to parse tool call arguments for ".concat(e.function.name,":"),t),r={}}else"object"==typeof e.function.arguments&&null!==e.function.arguments?r=e.function.arguments:(console.warn("Invalid tool call arguments type for ".concat(e.function.name,":"),typeof e.function.arguments),r={});return new rh({id:e.id,name:e.function.name,arguments:r,parentMessageId:t})}function Sh(e,t){if("tool"!==e.role)throw new Error("Cannot convert message with role ".concat(e.role," to ResultMessage"));if(!e.toolCallId)throw new Error("Tool message must have a toolCallId");var r,n=t[e.toolCallId]||"unknown",i=e.content||"";if("string"==typeof i)r=i;else if("object"==typeof i&&null!==i)try{r=JSON.stringify(i)}catch(e){console.warn("Failed to stringify tool result for ".concat(n,":"),e),r=String(i)}else r=String(i);return new nh({id:e.id,result:r,actionExecutionId:e.toolCallId,actionName:e.toolName||n})}function Oh(e){if(!vh(e))throw new Error("Cannot convert message to ImageMessage: missing format or bytes");var t;if(t="assistant"===e.role?eh.assistant:eh.user,"assistant"!==e.role&&"user"!==e.role)throw new Error("Cannot convert message with role ".concat(e.role," to ImageMessage"));return new oh({id:e.id,format:e.image.format,bytes:e.image.bytes,role:t})}var Ah,Th=function(){function e(e){var t;this._runner=null!==(t=null==e?void 0:e.runner)&&void 0!==t?t:new u.InMemoryAgentRunner,this.hashedLgcKey=(null==e?void 0:e.langsmithApiKey)?c.createHash("sha256").update(e.langsmithApiKey).digest("hex"):void 0}return e.prototype.run=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n={hashedLgcKey:this.hashedLgcKey},i=!1;return Rh.capture("oss.runtime.agent_execution_stream_started",{hashedLgcKey:this.hashedLgcKey}),(e=this._runner).run.apply(e,t).pipe(a.tap(function(e){var t,r=e.rawEvent;if(null==r?void 0:r.data){var i=r.data;(null===(t=null==i?void 0:i.output)||void 0===t?void 0:t.model)&&(n.model=i.output.model,n.provider=i.output.model)}if(null==r?void 0:r.metadata){var o=r.metadata;(null==o?void 0:o.langgraph_host)&&(n.langGraphHost=o.langgraph_host),(null==o?void 0:o.langgraph_version)&&(n.langGraphVersion=o.langgraph_version)}}),a.catchError(function(e){throw i=!0,Rh.capture("oss.runtime.agent_execution_stream_errored",T(T({},n),{error:e instanceof Error?e.message:String(e)})),e}),a.finalize(function(){i||Rh.capture("oss.runtime.agent_execution_stream_ended",n)}))},e.prototype.connect=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(e=this._runner).connect.apply(e,t)},e.prototype.isRunning=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(e=this._runner).isRunning.apply(e,t)},e.prototype.stop=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(e=this._runner).stop.apply(e,t)},e}();function xh(e){var t,r=[],n="schema"in(e||{})?e.schema:e,i=(null===(t=null==n?void 0:n.parameters)||void 0===t?void 0:t.jsonSchema)||(null==n?void 0:n.parameters),o=null==i?void 0:i.properties,a=new Set((null==i?void 0:i.required)||[]);if(!o)return r;for(var s in o)if(Object.prototype.hasOwnProperty.call(o,s)){var c=o[s],u=c.type||"string",l=c.description||"";if("array"===u&&c.items){var d=c.items.type||"object";if("object"===d&&c.items.properties){var f=Object.keys(c.items.properties).join(", ");l=l+(l?" ":"")+"Array of objects with properties: ".concat(f)}else u="array<".concat(d,">")}if(c.enum&&Array.isArray(c.enum)){var p=c.enum.join(" | ");l=l+(l?" ":"")+"Allowed values: ".concat(p)}if("object"===u&&c.properties){var h=Object.keys(c.properties).join(", ");l=l+(l?" ":"")+"Object with properties: ".concat(h)}r.push({name:s,type:u,description:l,required:a.has(s)})}return r}!function(e){e.CopilotKit="copilotKit",e.LangGraphPlatform="langgraph-platform"}(Ah||(Ah={}));var Ih=function(){function e(e){var t,n,i;this.mcpToolsCache=new Map;var o=null!==(t=null==e?void 0:e.agents)&&void 0!==t?t:{},a=this.assignEndpointsToAgents(null!==(n=null==e?void 0:e.remoteEndpoints)&&void 0!==n?n:[]),s=null!==(i=null==e?void 0:e.runner)&&void 0!==i?i:new u.InMemoryAgentRunner,c=r.isTelemetryDisabled()?s:new Th({runner:s});this.runtimeArgs={agents:T(T({},a),o),runner:c,beforeRequestMiddleware:this.createOnBeforeRequestHandler(e).bind(this),afterRequestMiddleware:this.createOnAfterRequestHandler(e).bind(this)},this.params=e,this.observability=null==e?void 0:e.observability_c}return Object.defineProperty(e.prototype,"instance",{get:function(){return this._instance||(this._instance=new u.CopilotRuntime(this.runtimeArgs)),this._instance},enumerable:!1,configurable:!0}),e.prototype.assignEndpointsToAgents=function(e){if(e.some(function(e){return kh(e)==Ah.LangGraphPlatform}))throw new r.CopilotKitMisuseError({message:'LangGraphPlatformEndpoint in remoteEndpoints is deprecated. Please use the "agents" option instead with LangGraphAgent from "@copilotkit/runtime/langgraph". Example: agents: { myAgent: new LangGraphAgent({ deploymentUrl: "...", graphId: "..." }) }'});return{}},e.prototype.handleServiceAdapter=function(e){var t,n=this;this.runtimeArgs.agents=Promise.resolve(null!==(t=this.runtimeArgs.agents)&&void 0!==t?t:{}).then(function(t){return j(n,void 0,void 0,function(){var n,i,o,a,s,c,u;return R(this,function(d){switch(d.label){case 0:if(n=t,i=!Object.keys(t).length,o=Boolean(e),a=!["EmptyAdapter"].includes(e.name),i&&(!o||!a))throw new r.CopilotKitMisuseError({message:"No default agent provided. Please provide a default agent in the runtime config."});return i&&(n.default=new l.BuiltInAgent({model:"".concat(e.provider,"/").concat(e.model)})),(s=null===(u=this.params)||void 0===u?void 0:u.actions)?[4,this.getToolsFromMCP()]:[3,2];case 1:c=d.sent(),n=this.assignToolsToAgents(t,P(P([],this.getToolsFromActions(s),!0),c,!0)),d.label=2;case 2:return[2,n]}})})})},e.prototype.getToolsFromActions=function(e){return("function"==typeof e?e({properties:{},url:void 0}):e).map(function(e){var t=r.getZodParameters(e.parameters||[]);return{name:e.name,description:e.description||"",parameters:t,execute:function(){return Promise.resolve()}}})},e.prototype.assignToolsToAgents=function(e,t){var r,n;if(!(null==t?void 0:t.length))return e;for(var i=T({},e),o=0,a=Object.entries(i);o<a.length;o++){var s=a[o],c=s[0],u=s[1],l=null!==(r=Reflect.get(u,"config"))&&void 0!==r?r:{},d=null!==(n=l.tools)&&void 0!==n?n:[],f=T(T({},l),{tools:P(P([],d,!0),t,!0)});Reflect.set(u,"config",f),i[c]=u}return i},e.prototype.createOnBeforeRequestHandler=function(e){var t=this;return function(n){return j(t,void 0,void 0,function(){var t,i,o,a,s,c,u,l,d,f,p,h,m,y;return R(this,function(g){switch(g.label){case 0:return t=n.request,i=t.headers.get("x-copilotcloud-public-api-key"),[4,r.readBody(t)];case 1:return o=g.sent(),a=o.forwardedProps,s=process.env.COPILOT_CLOUD_BASE_URL||"https://api.cloud.copilotkit.ai",Rh.capture("oss.runtime.copilot_request_created",T(T({"cloud.guardrails.enabled":void 0!==(null===(f=null==a?void 0:a.cloud)||void 0===f?void 0:f.guardrails),requestType:null!==(h=null===(p=null==a?void 0:a.metadata)||void 0===p?void 0:p.requestType)&&void 0!==h?h:"unknown","cloud.api_key_provided":!!i},i?{"cloud.public_api_key":i}:{}),{"cloud.base_url":s})),[4,null===(m=null==e?void 0:e.beforeRequestMiddleware)||void 0===m?void 0:m.call(e,n)];case 2:return c=g.sent(),(null===(y=null==e?void 0:e.middleware)||void 0===y?void 0:y.onBeforeRequest)&&(u=n.request,n.runtime,n.path,l=function(e){var t=[];e=Array.isArray(e)?e:[e];for(var r={},n=0,i=e;n<i.length;n++){var o=i[n];if(bh(o)){var a=gh(o),s="state"in o&&o.state?o.state:{};t.push(new ih({id:o.id,agentName:a,state:s,role:eh.assistant})),"generativeUI"in o&&o.generativeUI}else if(vh(o))t.push(Oh(o));else if("assistant"===o.role&&o.toolCalls){t.push(_h(o));for(var c=function(e){r[e.id]=e.function.name;var n=Eh(e,o.id);"generativeUI"in o&&o.generativeUI,t.push(n)},u=0,l=o.toolCalls;u<l.length;u++)c(l[u])}else if("developer"!==o.role&&"system"!==o.role&&"assistant"!==o.role&&"user"!==o.role){if("tool"!==o.role)throw new Error('Unknown message role: "'.concat(o.role,'" in message with id: ').concat(o.id));t.push(Sh(o,r))}else t.push(_h(o))}return t}(o.messages).reduce(function(e,t){return"role"in t&&"user"===t.role?e.inputMessages.push(t):e.outputMessages.push(t),e},{inputMessages:[],outputMessages:[]}),d=l.inputMessages,l.outputMessages,e.middleware.onBeforeRequest({threadId:o.threadId,runId:o.runId,inputMessages:d,properties:o.forwardedProps,url:u.url})),[2,c]}})})}},e.prototype.createOnAfterRequestHandler=function(e){var t=this;return function(r){return j(t,void 0,void 0,function(){var t,n;return R(this,function(i){return null===(t=null==e?void 0:e.afterRequestMiddleware)||void 0===t||t.call(e,r),(null===(n=null==e?void 0:e.middleware)||void 0===n?void 0:n.onAfterRequest)&&e.middleware.onAfterRequest({}),[2]})})}},e.prototype.logObservabilityBeforeRequest=function(e){return j(this,void 0,void 0,function(){var t;return R(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.observability.hooks.handleRequest(e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),console.error("Error logging LLM request:",t),[3,3];case 3:return[2]}})})},e.prototype.logObservabilityAfterRequest=function(e,t,r,n,i){var o=this;try{e.then(function(e){var i={threadId:t.threadId,runId:t.runId,model:t.model,output:o.observability.progressive?r:e,latency:Date.now()-n,timestamp:Date.now(),provider:t.provider,isFinalResponse:!0,agentName:t.agentName,nodeName:t.nodeName};try{o.observability.hooks.handleResponse(i)}catch(e){console.error("Error logging LLM response:",e)}}).catch(function(e){console.error("Failed to get output messages for logging:",e)})}catch(e){console.error("Error setting up logging for LLM response:",e)}},e.prototype.getToolsFromMCP=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w,_,E,S,O;return R(this,function(A){switch(A.label){case 0:if(t=null!==(g=null===(y=this.params)||void 0===y?void 0:y.mcpServers)&&void 0!==g?g:[],n=null===(b=this.params)||void 0===b?void 0:b.createMCPClient,i=null!==(E=null!==(w=null===(v=null==e?void 0:e.properties)||void 0===v?void 0:v.mcpServers)&&void 0!==w?w:null===(_=null==e?void 0:e.properties)||void 0===_?void 0:_.mcpEndpoints)&&void 0!==E?E:[],!((null!==(S=null==t?void 0:t.length)&&void 0!==S?S:0)>0||(null!==(O=null==i?void 0:i.length)&&void 0!==O?O:0)>0))return[2,[]];if(!n)throw new r.CopilotKitMisuseError({message:"MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."});o=function(){for(var e=new Map,r=0,n=t;r<n.length;r++){(null==(s=n[r])?void 0:s.endpoint)&&e.set(s.endpoint,s)}for(var o=0,a=i;o<a.length;o++){var s;(null==(s=a[o])?void 0:s.endpoint)&&e.set(s.endpoint,s)}return Array.from(e.values())}(),a=[],s=function(e){var t,i,o,s,u;return R(this,function(l){switch(l.label){case 0:if(t=e.endpoint,i=c.mcpToolsCache.get(t))return a.push.apply(a,i),[2,"continue"];l.label=1;case 1:return l.trys.push([1,4,,5]),[4,n(e)];case 2:return[4,l.sent().tools()];case 3:return o=l.sent(),s=Object.entries(o).map(function(e){var n=e[0],i=e[1],o=xh(i),a=r.getZodParameters(o);return{name:n,description:i.description||"MCP tool: ".concat(n," (from ").concat(t,")"),parameters:a,execute:function(){return Promise.resolve()}}}),c.mcpToolsCache.set(t,s),a.push.apply(a,s),[3,5];case 4:return u=l.sent(),console.error("MCP: Failed to fetch tools from endpoint ".concat(t,". Skipping. Error:"),u),c.mcpToolsCache.set(t,[]),[3,5];case 5:return[2]}})},c=this,u=0,l=o,A.label=1;case 1:return u<l.length?(d=l[u],[5,s(d)]):[3,4];case 2:A.sent(),A.label=3;case 3:return u++,[3,1];case 4:for(f=new Map,p=0,h=a;p<h.length;p++)m=h[p],f.set(m.name,m);return[2,Array.from(f.values())]}})})},e}();function kh(e){return e.type?e.type:"deploymentUrl"in e&&"agents"in e?Ah.LangGraphPlatform:Ah.CopilotKit}var jh=require("../../package.json"),Rh=new r.TelemetryClient({packageName:jh.name,packageVersion:jh.version});function Nh(e){var t,r,n,i,o,a,s,u=e.runtime,l=null!==(r=null===(t=u.params)||void 0===t?void 0:t.remoteEndpoints)&&void 0!==r?r:[],d=l.reduce(function(e,t){var r=T({},e),n=kh(t);if(r.endpointTypes.includes(n)||(r=T(T({},r),{endpointTypes:P(P([],r.endpointTypes,!0),[n],!1)})),n===Ah.LangGraphPlatform){var i=t;r=T(T({},r),{agentsAmount:i.agents.length,hashedKey:i.langsmithApiKey?c.createHash("sha256").update(i.langsmithApiKey).digest("hex"):null})}return r},{endpointTypes:[],agentsAmount:null,hashedKey:null}),f=null===(n=e.cloud)||void 0===n?void 0:n.publicApiKey,p=!!f&&f.trim().length>0;return T(T({actionsAmount:null!==(a=null===(o=null===(i=u.params)||void 0===i?void 0:i.actions)||void 0===o?void 0:o.length)&&void 0!==a?a:0,endpointsAmount:l.length,endpointTypes:d.endpointTypes,agentsAmount:Object.keys(u.instance.agents).length,hashedLgcKey:d.hashedKey,"cloud.api_key_provided":p},p?{"cloud.public_api_key":f}:{}),(null===(s=e.cloud)||void 0===s?void 0:s.baseUrl)?{"cloud.base_url":e.cloud.baseUrl}:{})}var Ph,Ch,Lh,Mh=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"id",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"name",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"description",void 0),e=x([Ed()],e)}(),$h=function(){function e(){}return x([gd(function(){return[Mh]}),k("design:type",Array)],e.prototype,"agents",void 0),e=x([Ed()],e)}();!function(e){e.OnChainStart="on_chain_start",e.OnChainStream="on_chain_stream",e.OnChainEnd="on_chain_end",e.OnChatModelStart="on_chat_model_start",e.OnChatModelStream="on_chat_model_stream",e.OnChatModelEnd="on_chat_model_end",e.OnToolStart="on_tool_start",e.OnToolEnd="on_tool_end",e.OnCopilotKitStateSync="on_copilotkit_state_sync",e.OnCopilotKitEmitMessage="on_copilotkit_emit_message",e.OnCopilotKitEmitToolCall="on_copilotkit_emit_tool_call",e.OnCustomEvent="on_custom_event",e.OnInterrupt="on_interrupt",e.OnCopilotKitInterrupt="on_copilotkit_interrupt",e.OnCopilotKitError="on_copilotkit_error"}(Ph||(Ph={})),function(e){e.LangGraphInterruptEvent="LangGraphInterruptEvent",e.CopilotKitLangGraphInterruptEvent="CopilotKitLangGraphInterruptEvent"}(Ch||(Ch={})),function(e){e.CopilotKitManuallyEmitMessage="copilotkit_manually_emit_message",e.CopilotKitManuallyEmitToolCall="copilotkit_manually_emit_tool_call",e.CopilotKitManuallyEmitIntermediateState="copilotkit_manually_emit_intermediate_state",e.CopilotKitExit="copilotkit_exit"}(Lh||(Lh={}));var Dh=function(){function e(){}return e.prototype.hello=function(){return j(this,void 0,void 0,function(){return R(this,function(e){return[2,"Hello World"]})})},e.prototype.availableAgents=function(e){return j(this,void 0,void 0,function(){var t,r;return R(this,function(n){return(t=e.logger.child({component:"CopilotResolver.availableAgents"})).debug("Processing"),r=[],t.debug("Event source created, creating response"),[2,{agents:r.map(function(e){e.endpoint;var t=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["endpoint"]);return t})}]})})},e.prototype.generateCopilotResponse=function(e,n,i){return j(this,void 0,void 0,function(){var o,c,u,l,d,f,p,h,m,y,g,b,v,w,_,E,S,O,A,x,I,k,N,P,C=this;return R(this,function(L){if(Rh.capture("oss.runtime.copilot_request_created",T(T({"cloud.guardrails.enabled":void 0!==(null===(I=n.cloud)||void 0===I?void 0:I.guardrails),requestType:n.metadata.requestType,"cloud.api_key_provided":!!e.request.headers.get("x-copilotcloud-public-api-key")},e.request.headers.get("x-copilotcloud-public-api-key")?{"cloud.public_api_key":e.request.headers.get("x-copilotcloud-public-api-key")}:{}),e._copilotkit.baseUrl?{"cloud.base_url":e._copilotkit.baseUrl}:{"cloud.base_url":"https://api.cloud.copilotkit.ai"})),(o=e.logger.child({component:"CopilotResolver.generateCopilotResponse"})).debug({data:n},"Generating Copilot response"),i&&(o.debug("Properties provided, merging with context properties"),e.properties=T(T({},e.properties),i)),e._copilotkit.runtime,e._copilotkit.serviceAdapter,c=null,(l=e.request.headers.get("x-copilotcloud-public-api-key"))&&(c=l),n.cloud){if((o=o.child({cloud:!0})).debug("Cloud configuration provided, checking for public API key in headers"),!c)throw o.error("Public API key not found in headers"),new t.GraphQLError("X-CopilotCloud-Public-API-Key header is required");u=process.env.COPILOT_CLOUD_BASE_URL?process.env.COPILOT_CLOUD_BASE_URL:(null===(k=e._copilotkit.cloud)||void 0===k?void 0:k.baseUrl)?null===(N=e._copilotkit.cloud)||void 0===N?void 0:N.baseUrl:"https://api.cloud.copilotkit.ai",o=o.child({copilotCloudBaseUrl:u})}return o.debug("Setting up subjects"),d=new a.ReplaySubject,f=new a.ReplaySubject,p=new a.ReplaySubject,h=[],new Promise(function(e,t){m=e,y=t}),c&&(e.properties.copilotCloudPublicApiKey=c),o.debug("Processing"),b=g.eventSource,v=g.threadId,w=void 0===v?r.randomId():v,_=g.runId,E=g.serverSideActions,S=g.actionInputsWithoutAgents,O=g.extensions,o.debug("Event source created, creating response"),A=b.processRuntimeEvents({serverSideActions:E,guardrailsResult$:(null===(P=n.cloud)||void 0===P?void 0:P.guardrails)?p:null,actionInputsWithoutAgents:S.filter(function(e){return!E.find(function(t){return t.name==e.name})}),threadId:w}).pipe(a.shareReplay(),a.finalize(function(){o.debug("Event stream finalized")})),x={threadId:w,runId:_,status:a.firstValueFrom(d),extensions:O,metaEvents:new s.Repeater(function(e,t){return j(C,void 0,void 0,function(){var r,n=this;return R(this,function(i){return r=A.subscribe({next:function(t){return j(n,void 0,void 0,function(){return R(this,function(r){if(t.type!=zp.MetaEvent)return[2];switch(t.name){case Ph.OnInterrupt:e(ph(Hp,{type:t.type,name:Gp.LangGraphInterruptEvent,value:t.value}));break;case Gp.LangGraphInterruptEvent:e(ph(Hp,{type:t.type,name:t.name,value:t.value}));break;case Gp.CopilotKitLangGraphInterruptEvent:e(ph(Kp,{type:t.type,name:t.name,data:{value:t.data.value,messages:t.data.messages.map(function(e){if("TextMessage"===e.type||"content"in e&&"role"in e)return ph(th,{id:e.id,createdAt:new Date,content:[e.content],role:e.role,status:new Sp});if("arguments"in e)return ph(rh,{name:e.name,id:e.id,arguments:[JSON.stringify(e.arguments)],createdAt:new Date,status:new Sp});throw new Error("Unknown message in metaEvents copilot resolver")})}}))}return[2]})})},error:function(e){var n,i;(null===(n=null==e?void 0:e.name)||void 0===n?void 0:n.includes("CopilotKit"))||(null===(i=null==e?void 0:e.extensions)||void 0===i?void 0:i.visibility)?d.next(new yh({description:e.message||"Agent error occurred"})):d.next(new yh({description:"An unknown error has occurred in the event stream"})),null==r||r.unsubscribe(),t()},complete:function(){return j(n,void 0,void 0,function(){return R(this,function(e){return o.debug("Meta events stream completed"),d.next(new kp),null==r||r.unsubscribe(),t(),[2]})})}}),[2]})})}),messages:new s.Repeater(function(e,t){return j(C,void 0,void 0,function(){var i,l,g=this;return R(this,function(b){return o.debug("Messages repeater created"),(null===(l=n.cloud)||void 0===l?void 0:l.guardrails)&&((o=o.child({guardrails:!0})).debug("Guardrails is enabled, validating input"),function(e){j(void 0,[e],void 0,function(e){var t,r,n,i,o,a,s,c,u=e.baseUrl,l=e.copilotCloudPublicApiKey,d=e.data,f=e.onResult,p=e.onError;return R(this,function(e){switch(e.label){case 0:return d.messages.length&&(null===(c=d.messages[d.messages.length-1].textMessage)||void 0===c?void 0:c.role)===ep.user?(t=d.messages.filter(function(e){return void 0!==e.textMessage&&(e.textMessage.role===ep.user||e.textMessage.role===ep.assistant)}).map(function(e){return{role:e.textMessage.role,content:e.textMessage.content}}),r=t[t.length-1],n=t.slice(0,-1),i={input:r.content,validTopics:d.cloud.guardrails.inputValidationRules.allowList,invalidTopics:d.cloud.guardrails.inputValidationRules.denyList,messages:n},[4,fetch("".concat(u,"/guardrails/validate"),{method:"POST",headers:{"Content-Type":"application/json","X-CopilotCloud-Public-API-Key":l},body:JSON.stringify(i)})]):[3,5];case 1:return(o=e.sent()).ok?[4,o.json()]:[3,3];case 2:return a=e.sent(),f(a),[3,5];case 3:return s=p,[4,o.json()];case 4:s.apply(void 0,[e.sent()]),e.label=5;case 5:return[2]}})})}({baseUrl:u,copilotCloudPublicApiKey:c,data:n,onResult:function(e){o.debug({status:e.status},"Guardrails validation done"),p.next(e),"denied"===e.status&&(d.next(new hh({guardrailsReason:e.reason})),f.next({reason:"Interrupted due to Guardrails validation failure. Reason: ".concat(e.reason)}),h=[ph(th,{id:r.randomId(),createdAt:new Date,content:e.reason,role:ep.assistant})],m(h))},onError:function(e){o.error({err:e},"Error in guardrails validation"),d.next(new yh({description:"An unknown error has occurred in the guardrails validation"})),f.next({reason:"Interrupted due to unknown error in guardrails validation"}),y(e)}})),o.debug("Event stream created, subscribing to event stream"),i=A.subscribe({next:function(t){return j(g,void 0,void 0,function(){var n,i,c,u,l,p=this;return R(this,function(m){switch(t.type){case zp.MetaEvent:break;case zp.TextMessageStart:n=A.pipe(a.skipWhile(function(e){return e!==t}),a.takeWhile(function(e){return!(e.type===zp.TextMessageEnd&&e.messageId==t.messageId)}),a.filter(function(e){return e.type==zp.TextMessageContent&&e.messageId==t.messageId})),i=new a.Subject,c=t.messageId,e({id:c,parentMessageId:t.parentMessageId,status:a.firstValueFrom(i),createdAt:new Date,role:ep.assistant,content:new s.Repeater(function(e,t){return j(p,void 0,void 0,function(){var r,s,u=this;return R(this,function(l){return o.debug("Text message content repeater created"),r=[],f.pipe(a.shareReplay(),a.take(1),a.tap(function(e){var r=e.reason,n=e.messageId;o.debug({reason:r,messageId:n},"Text streaming interrupted"),i.next(ph(Op,{reason:r})),d.next(new mh({messageId:n})),t(),null==s||s.unsubscribe()})).subscribe(),o.debug("Subscribing to text message content stream"),s=n.subscribe({next:function(t){return j(u,void 0,void 0,function(){return R(this,function(n){switch(n.label){case 0:return t.type!=zp.TextMessageContent?[3,2]:[4,e(t.content)];case 1:n.sent(),r.push(t.content),n.label=2;case 2:return[2]}})})},error:function(e){o.error({err:e},"Error in text message content stream"),f.next({reason:"Error streaming message content",messageId:c}),t(),null==s||s.unsubscribe()},complete:function(){o.debug("Text message content stream completed"),i.next(new Sp),t(),null==s||s.unsubscribe(),h.push(ph(th,{id:c,createdAt:new Date,content:r.join(""),role:ep.assistant}))}}),[2]})})})});break;case zp.ActionExecutionStart:o.debug("Action execution start event received"),u=A.pipe(a.skipWhile(function(e){return e!==t}),a.takeWhile(function(e){return!(e.type===zp.ActionExecutionEnd&&e.actionExecutionId==t.actionExecutionId)}),a.filter(function(e){return e.type==zp.ActionExecutionArgs&&e.actionExecutionId==t.actionExecutionId})),l=new a.Subject,e({id:t.actionExecutionId,parentMessageId:t.parentMessageId,status:a.firstValueFrom(l),createdAt:new Date,name:t.actionName,arguments:new s.Repeater(function(e,r){return j(p,void 0,void 0,function(){var n,i,a=this;return R(this,function(s){return o.debug("Action execution argument stream created"),n=[],i=u.subscribe({next:function(t){return j(a,void 0,void 0,function(){return R(this,function(r){switch(r.label){case 0:return t.type!=zp.ActionExecutionArgs?[3,2]:[4,e(t.args)];case 1:r.sent(),n.push(t.args),r.label=2;case 2:return[2]}})})},error:function(e){o.error({err:e},"Error in action execution argument stream"),l.next(ph(Op,{reason:"An unknown error has occurred in the action execution argument stream"})),r(),null==i||i.unsubscribe()},complete:function(){o.debug("Action execution argument stream completed"),l.next(new Sp),r(),null==i||i.unsubscribe(),h.push(ph(rh,{id:t.actionExecutionId,createdAt:new Date,name:t.actionName,arguments:n.join("")}))}}),[2]})})})});break;case zp.ActionExecutionResult:o.debug({result:t.result},"Action execution result event received"),e({id:"result-"+t.actionExecutionId,status:new Sp,createdAt:new Date,actionExecutionId:t.actionExecutionId,actionName:t.actionName,result:t.result}),h.push(ph(nh,{id:"result-"+t.actionExecutionId,createdAt:new Date,actionExecutionId:t.actionExecutionId,actionName:t.actionName,result:t.result}));break;case zp.AgentStateMessage:o.debug({event:t},"Agent message event received"),e({id:r.randomId(),status:new Sp,threadId:t.threadId,agentName:t.agentName,nodeName:t.nodeName,runId:t.runId,active:t.active,state:t.state,running:t.running,role:ep.assistant,createdAt:new Date}),h.push(ph(ih,{id:r.randomId(),threadId:t.threadId,agentName:t.agentName,nodeName:t.nodeName,runId:t.runId,active:t.active,state:t.state,running:t.running,role:ep.assistant,createdAt:new Date}))}return[2]})})},error:function(e){var n,o,a,s,c,u;if(e instanceof r.CopilotKitError||e instanceof r.CopilotKitLowLevelError||e instanceof Error&&e.name&&e.name.includes("CopilotKit")||(null===(n=null==e?void 0:e.extensions)||void 0===n?void 0:n.visibility))return d.next(new yh({description:e.message||"Agent error occurred",originalError:{code:e.code||(null===(o=e.extensions)||void 0===o?void 0:o.code),statusCode:e.statusCode||(null===(a=e.extensions)||void 0===a?void 0:a.statusCode),severity:e.severity||(null===(s=e.extensions)||void 0===s?void 0:s.severity),visibility:e.visibility||(null===(c=e.extensions)||void 0===c?void 0:c.visibility),originalErrorType:e.originalErrorType||(null===(u=e.extensions)||void 0===u?void 0:u.originalErrorType),extensions:e.extensions}})),null==i||i.unsubscribe(),y(e),void t();d.next(new yh({description:"An unknown error has occurred in the event stream"})),null==i||i.unsubscribe(),t(),y(e)},complete:function(){return j(g,void 0,void 0,function(){var e;return R(this,function(r){switch(r.label){case 0:return o.debug("Event stream completed"),(null===(e=n.cloud)||void 0===e?void 0:e.guardrails)?(o.debug("Guardrails is enabled, waiting for guardrails result"),[4,a.firstValueFrom(p)]):[3,2];case 1:r.sent(),r.label=2;case 2:return d.next(new kp),null==i||i.unsubscribe(),t(),m(h),[2]}})})}}),[2]})})})},[2,x]})})},x([Sd(function(){return String}),k("design:type",Function),k("design:paramtypes",[]),k("design:returntype",Promise)],e.prototype,"hello",null),x([Sd(function(){return $h}),I(0,md()),k("design:type",Function),k("design:paramtypes",[Object]),k("design:returntype",Promise)],e.prototype,"availableAgents",null),x([_d(function(){return Up}),I(0,md()),I(1,hd("data")),I(2,hd("properties",function(){return Wd},{nullable:!0})),k("design:type",Function),k("design:paramtypes",[Object,Qp,Object]),k("design:returntype",Promise)],e.prototype,"generateCopilotResponse",null),e=x([Od(function(){return Up})],e)}();function Bh(e){return Fh(e,[])}function Fh(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(e instanceof Error)return"AggregateError"===e.name?Uh(e)+"\n"+zh(e.errors,t):Uh(e);if(t.includes(e))return"[Circular]";const r=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:Fh(t,r)}else if(Array.isArray(e))return zh(e,r);return function(e,t){const r=Object.entries(e);if(0===r.length)return"{}";if(t.length>3)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const n=r.map(([e,r])=>e+": "+Fh(r,t));return"{ "+n.join(", ")+" }"}(e,r)}(e,t);default:return String(e)}}function Uh(e){return(e.name="GraphQLError")?e.toString():`${e.name}: ${e.message};\n ${e.stack}`}function zh(e,t){if(0===e.length)return"[]";if(t.length>3)return"[Array]";const r=e.length,n=[];for(let i=0;i<r;++i)n.push(Fh(e[i],t));return"["+n.join(", ")+"]"}const Gh=new t.GraphQLDirective({name:"defer",description:"Directs the executor to defer this fragment when the `if` argument is true or undefined.",locations:[t.DirectiveLocation.FRAGMENT_SPREAD,t.DirectiveLocation.INLINE_FRAGMENT],args:{if:{type:new t.GraphQLNonNull(t.GraphQLBoolean),description:"Deferred when true or undefined.",defaultValue:!0},label:{type:t.GraphQLString,description:"Unique name"}}}),qh=new t.GraphQLDirective({name:"stream",description:"Directs the executor to stream plural fields when the `if` argument is true or undefined.",locations:[t.DirectiveLocation.FIELD],args:{if:{type:new t.GraphQLNonNull(t.GraphQLBoolean),description:"Stream when true or undefined.",defaultValue:!0},label:{type:t.GraphQLString,description:"Unique name"},initialCount:{defaultValue:0,type:t.GraphQLInt,description:"Number of items to return immediately"}}});function Vh(e){const r=Object.create(null);return{Directive(n){if(n.name.value===Gh.name||n.name.value===qh.name){const i=n.arguments?.find(e=>"label"===e.name.value),o=i?.value;if(!o)return;o.kind!==t.Kind.STRING?e.reportError(s.createGraphQLError(`Directive "${n.name.value}"'s label argument must be a static string.`,{nodes:n})):r[o.value]?e.reportError(s.createGraphQLError("Defer/Stream directive label argument must be unique.",{nodes:[r[o.value],n]})):r[o.value]=n}}}}function Wh(e){return{Directive(t){const r=e.getSchema().getMutationType(),n=e.getSchema().getSubscriptionType(),i=e.getParentType();i&&t.name.value===Gh.name&&(r&&i===r&&e.reportError(s.createGraphQLError(`Defer directive cannot be used on root mutation type "${i.name}".`,{nodes:t})),n&&i===n&&e.reportError(s.createGraphQLError(`Defer directive cannot be used on root subscription type "${i.name}".`,{nodes:t}))),i&&t.name.value===qh.name&&(r&&i===r&&e.reportError(s.createGraphQLError(`Stream directive cannot be used on root mutation type "${i.name}".`,{nodes:t})),n&&i===n&&e.reportError(s.createGraphQLError(`Stream directive cannot be used on root subscription type "${i.name}".`,{nodes:t})))}}}const Hh=48,Kh=57;function Zh(e){return!Number.isNaN(e)&&Hh<=e&&e<=Kh}function Jh(e){switch(e.kind){case t.Kind.OBJECT:return{...e,fields:(r=e.fields,r.map(e=>({...e,value:Jh(e.value)})).sort((e,t)=>function(e,t){let r=0,n=0;for(;r<e.length&&n<t.length;){let i=e.charCodeAt(r),o=t.charCodeAt(n);if(Zh(i)&&Zh(o)){let a=0;do{++r,a=10*a+i-Hh,i=e.charCodeAt(r)}while(Zh(i)&&a>0);let s=0;do{++n,s=10*s+o-Hh,o=t.charCodeAt(n)}while(Zh(o)&&s>0);if(a<s)return-1;if(a>s)return 1}else{if(i<o)return-1;if(i>o)return 1;++r,++n}}return e.length-t.length}(e.name.value,t.name.value)))};case t.Kind.LIST:return{...e,values:e.values.map(Jh)};case t.Kind.INT:case t.Kind.FLOAT:case t.Kind.STRING:case t.Kind.BOOLEAN:case t.Kind.NULL:case t.Kind.ENUM:case t.Kind.VARIABLE:return e}var r}function Yh(e){return Array.isArray(e)?e.map(([e,t])=>`subfields "${e}" conflict because `+Yh(t)).join(" and "):e}function Qh(e){const t=new um,r=new Map;return{SelectionSet(n){const i=function(e,t,r,n,i){const o=[],[a,s]=am(e,t,n,i);if(function(e,t,r,n,i){for(const[o,a]of Object.entries(i))if(a.length>1)for(let i=0;i<a.length;i++)for(let s=i+1;s<a.length;s++){const c=rm(e,r,n,!1,o,a[i],a[s]);c&&t.push(c)}}(e,o,t,r,a),0!==s.length)for(let n=0;n<s.length;n++){Xh(e,o,t,r,!1,a,s[n]);for(let i=n+1;i<s.length;i++)em(e,o,t,r,!1,s[n],s[i])}return o}(e,r,t,e.getParentType(),n);for(const[[t,r],n,o]of i){const i=Yh(r);e.reportError(s.createGraphQLError(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:n.concat(o)}))}}}}function Xh(e,t,r,n,i,o,a){const s=e.getFragment(a);if(!s)return;const[c,u]=sm(e,r,s);if(o!==c){tm(e,t,r,n,i,o,c);for(const s of u)n.has(s,a,i)||(n.add(s,a,i),Xh(e,t,r,n,i,o,s))}}function em(e,t,r,n,i,o,a){if(o===a)return;if(n.has(o,a,i))return;n.add(o,a,i);const s=e.getFragment(o),c=e.getFragment(a);if(!s||!c)return;const[u,l]=sm(e,r,s),[d,f]=sm(e,r,c);tm(e,t,r,n,i,u,d);for(const a of f)em(e,t,r,n,i,o,a);for(const o of l)em(e,t,r,n,i,o,a)}function tm(e,t,r,n,i,o,a){for(const[s,c]of Object.entries(o)){const o=a[s];if(o)for(const a of c)for(const c of o){const o=rm(e,r,n,i,s,a,c);o&&t.push(o)}}}function rm(e,r,n,i,o,a,s){const[c,u,l]=a,[d,f,p]=s,h=i||c!==d&&t.isObjectType(c)&&t.isObjectType(d);if(!h){const e=u.name.value,t=f.name.value;if(e!==t)return[[o,`"${e}" and "${t}" are different fields`],[u],[f]];if(nm(u)!==nm(f))return[[o,"they have differing arguments"],[u],[f]]}if(!function(e,t){const r=im(e),n=im(t);if(!r&&!n)return!0;if(r&&n)return nm(r)===nm(n);return!1}(u.directives??[],f.directives??[]))return[[o,"they have differing stream directives"],[u],[f]];const m=l?.type,y=p?.type;if(m&&y&&om(m,y))return[[o,`they return conflicting types "${Bh(m)}" and "${Bh(y)}"`],[u],[f]];const g=u.selectionSet,b=f.selectionSet;if(g&&b){const i=function(e,t,r,n,i,o,a,s){const c=[],[u,l]=am(e,t,i,o),[d,f]=am(e,t,a,s);tm(e,c,t,r,n,u,d);for(const i of f)Xh(e,c,t,r,n,u,i);for(const i of l)Xh(e,c,t,r,n,d,i);for(const i of l)for(const o of f)em(e,c,t,r,n,i,o);return c}(e,r,n,h,t.getNamedType(m),g,t.getNamedType(y),b);return function(e,t,r,n){if(e.length>0)return[[t,e.map(([e])=>e)],[r,...e.map(([,e])=>e).flat()],[n,...e.map(([,,e])=>e).flat()]];return}(i,o,u,f)}}function nm(e){const r=e.arguments??[],n={kind:t.Kind.OBJECT,fields:r.map(e=>({kind:t.Kind.OBJECT_FIELD,name:e.name,value:e.value}))};return t.print(Jh(n))}function im(e){return e.find(e=>"stream"===e.name.value)}function om(e,r){return t.isListType(e)?!t.isListType(r)||om(e.ofType,r.ofType):!!t.isListType(r)||(t.isNonNullType(e)?!t.isNonNullType(r)||om(e.ofType,r.ofType):!!t.isNonNullType(r)||!(!t.isLeafType(e)&&!t.isLeafType(r))&&e!==r)}function am(e,t,r,n){const i=t.get(n);if(i)return i;const o=Object.create(null),a=new Set;cm(e,r,n,o,a);const s=[o,[...a]];return t.set(n,s),s}function sm(e,r,n){const i=r.get(n.selectionSet);if(i)return i;const o=t.typeFromAST(e.getSchema(),n.typeCondition);return am(e,r,o,n.selectionSet)}function cm(e,r,n,i,o){for(const a of n.selections)switch(a.kind){case t.Kind.FIELD:{const e=a.name.value;let n;(t.isObjectType(r)||t.isInterfaceType(r))&&(n=r.getFields()[e]);const o=a.alias?a.alias.value:e;i[o]||=[],i[o].push([r,a,n]);break}case t.Kind.FRAGMENT_SPREAD:o.add(a.name.value);break;case t.Kind.INLINE_FRAGMENT:{const n=a.typeCondition,s=n?t.typeFromAST(e.getSchema(),n):r;cm(e,s,a.selectionSet,i,o);break}}}class um{_data;constructor(){this._data=new Map}has(e,t,r){const[n,i]=e<t?[e,t]:[t,e],o=this._data.get(n)?.get(i);return void 0!==o&&(!!r||r===o)}add(e,t,r){const[n,i]=e<t?[e,t]:[t,e],o=this._data.get(n);void 0===o?this._data.set(n,new Map([[i,r]])):o.set(i,r)}}function lm(e){return{Directive(r){const n=e.getFieldDef(),i=e.getParentType();n&&i&&r.name.value===qh.name&&!(t.isListType(n.type)||t.isWrappingType(n.type)&&t.isListType(n.type.ofType))&&e.reportError(s.createGraphQLError(`Stream directive cannot be used on non-list field "${n.name}" on type "${i.name}".`,{nodes:r}))}}}var dm,fm,pm,hm={exports:{}};var mm,ym=function(){if(pm)return hm.exports;pm=1;const e=function(){if(fm)return dm;function e(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}return fm=1,dm=function(t,r,n){var i=n&&n.stringify||e;if("object"==typeof t&&null!==t){var o=r.length+1;if(1===o)return t;var a=new Array(o);a[0]=i(t);for(var s=1;s<o;s++)a[s]=i(r[s]);return a.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",l=0,d=-1,f=t&&t.length||0,p=0;p<f;){if(37===t.charCodeAt(p)&&p+1<f){switch(d=d>-1?d:0,t.charCodeAt(p+1)){case 100:case 102:if(l>=c)break;if(null==r[l])break;d<p&&(u+=t.slice(d,p)),u+=Number(r[l]),d=p+2,p++;break;case 105:if(l>=c)break;if(null==r[l])break;d<p&&(u+=t.slice(d,p)),u+=Math.floor(Number(r[l])),d=p+2,p++;break;case 79:case 111:case 106:if(l>=c)break;if(void 0===r[l])break;d<p&&(u+=t.slice(d,p));var h=typeof r[l];if("string"===h){u+="'"+r[l]+"'",d=p+2,p++;break}if("function"===h){u+=r[l].name||"<anonymous>",d=p+2,p++;break}u+=i(r[l]),d=p+2,p++;break;case 115:if(l>=c)break;d<p&&(u+=t.slice(d,p)),u+=String(r[l]),d=p+2,p++;break;case 37:d<p&&(u+=t.slice(d,p)),u+="%",d=p+2,p++,l--}++l}++p}return-1===d?t:(d<f&&(u+=t.slice(d)),u)},dm}();hm.exports=c;const t=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:h,mapHttpResponse:h,wrapRequestSerializer:m,wrapResponseSerializer:m,wrapErrorSerializer:m,req:h,res:h,err:f,errWithCause:f};function n(e,t){return"silent"===e?1/0:t.levels.values[e]}const i=Symbol("pino.logFuncs"),o=Symbol("pino.hierarchy"),a={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function s(e,t){const r={logger:t,parent:e[o]};t[o]=r}function c(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const o=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const f=e.serializers||{},h=function(e,t){if(Array.isArray(e))return e.filter(function(e){return"!stdSerializers.err"!==e});return!0===e&&Object.keys(t)}(e.browser.serialize,f);let m=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(m=!1);const g=Object.keys(e.customLevels||{}),b=["error","fatal","warn","info","debug","trace"].concat(g);"function"==typeof o&&b.forEach(function(e){o[e]=o}),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const v=e.level||"info",w=Object.create(o);w.log||(w.log=y),function(e,r,n){const o={};r.forEach(e=>{o[e]=n[e]?n[e]:t[e]||t[a[e]||"log"]||y}),e[i]=o}(w,b,o),s({},w),Object.defineProperty(w,"levelVal",{get:function(){return n(this.level,this)}}),Object.defineProperty(w,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,u(this,_,w,"error"),u(this,_,w,"fatal"),u(this,_,w,"warn"),u(this,_,w,"info"),u(this,_,w,"debug"),u(this,_,w,"trace"),g.forEach(e=>{u(this,_,w,e)})}});const _={transmit:r,serialize:h,asObject:e.browser.asObject,asObjectBindingsOnly:e.browser.asObjectBindingsOnly,formatters:e.browser.formatters,reportCaller:e.browser.reportCaller,levels:b,timestamp:p(e),messageKey:e.messageKey||"msg",onChild:e.onChild||y};function E(t,n,i){if(!n)throw new Error("missing bindings for child Pino");i=i||{},h&&n.serializers&&(i.serializers=n.serializers);const o=i.serializers;if(h&&o){var a=Object.assign({},f,o),c=!0===e.browser.serialize?Object.keys(a):h;delete n.serializers,l([n],c,a,this._stdErrSerialize)}function u(e){this._childLevel=1+(0|e._childLevel),this.bindings=n,a&&(this.serializers=a,this._serialize=c),r&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}u.prototype=this;const p=new u(this);return s(this,p),p.child=function(...e){return E.call(this,t,...e)},p.level=i.level||this.level,t.onChild(p),p}return w.levels=function(e){const t=e.customLevels||{},r=Object.assign({},c.levels.values,t),n=Object.assign({},c.levels.labels,function(e){const t={};return Object.keys(e).forEach(function(r){t[e[r]]=r}),t}(t));return{values:r,labels:n}}(e),w.level=v,w.isLevelEnabled=function(e){return!!this.levels.values[e]&&this.levels.values[e]>=this.levels.values[this.level]},w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=f,w._serialize=h,w._stdErrSerialize=m,w.child=function(...e){return E.call(this,_,...e)},r&&(w._logEvent=d()),w}function u(r,a,s,c){if(Object.defineProperty(r,c,{value:n(r.level,s)>n(c,s)?y:s[i][c],writable:!0,enumerable:!0,configurable:!0}),r[c]===y){if(!a.transmit)return;const e=n(a.transmit.level||r.level,s);if(n(c,s)<e)return}r[c]=function(r,o,a,s){return c=r[i][s],function(){const i=o.timestamp(),u=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var p=0;p<u.length;p++)u[p]=arguments[p];var h=!1;if(o.serialize&&(l(u,this._serialize,this.serializers,this._stdErrSerialize),h=!0),o.asObject||o.formatters){const t=function(t,r,n,i,o){const{level:a,log:s=e=>e}=o.formatters||{},c=n.slice();let u=c[0];const l={};let d=1+(0|t._childLevel);if(d<1&&(d=1),i&&(l.time=i),a){const e=a(r,t.levels.values[r]);Object.assign(l,e)}else l.level=t.levels.values[r];if(o.asObjectBindingsOnly){if(null!==u&&"object"==typeof u)for(;d--&&"object"==typeof c[0];)Object.assign(l,c.shift());return[s(l),...c]}if(null!==u&&"object"==typeof u){for(;d--&&"object"==typeof c[0];)Object.assign(l,c.shift());u=c.length?e(c.shift(),c):void 0}else"string"==typeof u&&(u=e(c.shift(),c));return void 0!==u&&(l[o.messageKey]=u),[s(l)]}(this,s,u,i,o);if(o.reportCaller&&t&&t.length>0&&t[0]&&"object"==typeof t[0])try{const e=v();e&&(t[0].caller=e)}catch(e){}c.call(f,...t)}else{if(o.reportCaller)try{const e=v();e&&u.push(e)}catch(e){}c.apply(f,u)}if(o.transmit){const e=n(o.transmit.level||r._level,a),t=n(s,a);if(t<e)return;!function(e,t,r,n=!1){const i=t.send,o=t.ts,a=t.methodLevel,s=t.methodValue,c=t.val,u=e._logEvent.bindings;n||l(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=o,e._logEvent.messages=r.filter(function(e){return-1===u.indexOf(e)}),e._logEvent.level.label=a,e._logEvent.level.value=s,i(a,e._logEvent,c),e._logEvent=d(u)}(this,{ts:i,methodLevel:s,methodValue:t,transmitValue:a.levels.values[o.transmit.level||r._level],send:o.transmit.send,val:n(r._level,a)},u,h)}};var c}(r,a,s,c);const u=function(e){const t=[];e.bindings&&t.push(e.bindings);let r=e[o];for(;r.parent;)r=r.parent,r.logger.bindings&&t.push(r.logger.bindings);return t.reverse()}(r);0!==u.length&&(r[c]=function(e,t){return function(){return t.apply(this,[...e,...arguments])}}(u,r[c]))}function l(e,t,r,n){for(const i in e)if(n&&e[i]instanceof Error)e[i]=c.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i])&&t)for(const n in e[i])t.indexOf(n)>-1&&n in r&&(e[i][n]=r[n](e[i][n]))}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function f(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}function p(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?g:b}function h(){return{}}function m(e){return e}function y(){}function g(){return!1}function b(){return Date.now()}function v(){const e=(new Error).stack;if(!e)return null;const t=e.split("\n");for(let e=1;e<t.length;e++){const r=t[e].trim();if(/(^at\s+)?(createWrap|LOG|set\s*\(|asObject|Object\.apply|Function\.apply)/.test(r))continue;if(-1!==r.indexOf("browser.js"))continue;if(-1!==r.indexOf("node:internal"))continue;if(-1!==r.indexOf("node_modules"))continue;let n=r.match(/\((.*?):(\d+):(\d+)\)/);if(n||(n=r.match(/at\s+(.*?):(\d+):(\d+)/)),n){return n[1]+":"+n[2]+":"+n[3]}}return null}return c.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},c.stdSerializers=r,c.stdTimeFunctions=Object.assign({},{nullTime:g,epochTime:b,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),hm.exports.default=c,hm.exports.pino=c,hm.exports}(),gm=w(ym),bm={exports:{}},vm={};function wm(){if(mm)return vm;function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}mm=1,Object.defineProperty(vm,"__esModule",{value:!0});var t=e(d);const{env:r={},argv:n=[],platform:i=""}="undefined"==typeof process?{}:process,o="NO_COLOR"in r||n.includes("--no-color"),a="FORCE_COLOR"in r||n.includes("--color"),s="win32"===i,c="dumb"===r.TERM,u=t&&t.isatty&&t.isatty(1)&&r.TERM&&!c,l=!o&&(a||s&&!c||u||"CI"in r&&("GITHUB_ACTIONS"in r||"GITLAB_CI"in r||"CIRCLECI"in r)),f=(e,t,r,n,i=t.substring(0,e)+n,o=t.substring(e+r.length),a=o.indexOf(r))=>i+(a<0?o:f(a,o,r,n)),p=(e,t,r=e,n=e.length+1)=>i=>i||""!==i&&void 0!==i?((e,t,r,n,i)=>e<0?r+t+n:r+f(e,t,n,i)+n)((""+i).indexOf(t,n),i,e,t,r):"",h=(e,t,r)=>p(`[${e}m`,`[${t}m`,r),m={reset:h(0,0),bold:h(1,22,""),dim:h(2,22,""),italic:h(3,23),underline:h(4,24),inverse:h(7,27),hidden:h(8,28),strikethrough:h(9,29),black:h(30,39),red:h(31,39),green:h(32,39),yellow:h(33,39),blue:h(34,39),magenta:h(35,39),cyan:h(36,39),white:h(37,39),gray:h(90,39),bgBlack:h(40,49),bgRed:h(41,49),bgGreen:h(42,49),bgYellow:h(43,49),bgBlue:h(44,49),bgMagenta:h(45,49),bgCyan:h(46,49),bgWhite:h(47,49),blackBright:h(90,39),redBright:h(91,39),greenBright:h(92,39),yellowBright:h(93,39),blueBright:h(94,39),magentaBright:h(95,39),cyanBright:h(96,39),whiteBright:h(97,39),bgBlackBright:h(100,49),bgRedBright:h(101,49),bgGreenBright:h(102,49),bgYellowBright:h(103,49),bgBlueBright:h(104,49),bgMagentaBright:h(105,49),bgCyanBright:h(106,49),bgWhiteBright:h(107,49)},y=({useColor:e=l}={})=>e?m:Object.keys(m).reduce((e,t)=>({...e,[t]:String}),{}),{reset:g,bold:b,dim:v,italic:w,underline:_,inverse:E,hidden:S,strikethrough:O,black:A,red:T,green:x,yellow:I,blue:k,magenta:j,cyan:R,white:N,gray:P,bgBlack:C,bgRed:L,bgGreen:M,bgYellow:$,bgBlue:D,bgMagenta:B,bgCyan:F,bgWhite:U,blackBright:z,redBright:G,greenBright:q,yellowBright:V,blueBright:W,magentaBright:H,cyanBright:K,whiteBright:Z,bgBlackBright:J,bgRedBright:Y,bgGreenBright:Q,bgYellowBright:X,bgBlueBright:ee,bgMagentaBright:te,bgCyanBright:re,bgWhiteBright:ne}=y();return vm.bgBlack=C,vm.bgBlackBright=J,vm.bgBlue=D,vm.bgBlueBright=ee,vm.bgCyan=F,vm.bgCyanBright=re,vm.bgGreen=M,vm.bgGreenBright=Q,vm.bgMagenta=B,vm.bgMagentaBright=te,vm.bgRed=L,vm.bgRedBright=Y,vm.bgWhite=U,vm.bgWhiteBright=ne,vm.bgYellow=$,vm.bgYellowBright=X,vm.black=A,vm.blackBright=z,vm.blue=k,vm.blueBright=W,vm.bold=b,vm.createColors=y,vm.cyan=R,vm.cyanBright=K,vm.dim=v,vm.gray=P,vm.green=x,vm.greenBright=q,vm.hidden=S,vm.inverse=E,vm.isColorSupported=l,vm.italic=w,vm.magenta=j,vm.magentaBright=H,vm.red=T,vm.redBright=G,vm.reset=g,vm.strikethrough=O,vm.underline=_,vm.white=N,vm.whiteBright=Z,vm.yellow=I,vm.yellowBright=V,vm}var _m,Em,Sm,Om,Am,Tm={exports:{}};function xm(){if(Sm)return Tm.exports;Sm=1;var e=(Em||(Em=1,_m=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n;function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),i=e[e.length-1];return"function"==typeof n&&n!==i&&Object.keys(i).forEach(function(e){n[e]=i[e]}),n}}),_m);function t(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function r(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}return Tm.exports=e(t),Tm.exports.strict=e(r),t.proto=t(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return t(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return r(this)},configurable:!0})}),Tm.exports}function Im(){if(Am)return Om;Am=1;var e=xm(),t=function(){},r=v.Bare?queueMicrotask:process.nextTick.bind(process),n=function(i,o,a){if("function"==typeof o)return n(i,null,o);o||(o={}),a=e(a||t);var s=i._writableState,c=i._readableState,u=o.readable||!1!==o.readable&&i.readable,l=o.writable||!1!==o.writable&&i.writable,d=!1,f=function(){i.writable||p()},p=function(){l=!1,u||a.call(i)},h=function(){u=!1,l||a.call(i)},m=function(e){a.call(i,e?new Error("exited with error code: "+e):null)},y=function(e){a.call(i,e)},g=function(){r(b)},b=function(){if(!d)return(!u||c&&c.ended&&!c.destroyed)&&(!l||s&&s.ended&&!s.destroyed)?void 0:a.call(i,new Error("premature close"))},v=function(){i.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(i)?l&&!s&&(i.on("end",f),i.on("close",f)):(i.on("complete",p),i.on("abort",g),i.req?v():i.on("request",v)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(i)&&i.on("exit",m),i.on("end",h),i.on("finish",p),!1!==o.error&&i.on("error",y),i.on("close",g),function(){d=!0,i.removeListener("complete",p),i.removeListener("abort",g),i.removeListener("request",v),i.req&&i.req.removeListener("finish",p),i.removeListener("end",f),i.removeListener("close",f),i.removeListener("finish",p),i.removeListener("exit",m),i.removeListener("end",h),i.removeListener("error",y),i.removeListener("close",g)}};return Om=n}var km,jm,Rm=_(Object.freeze({__proto__:null,default:{}}));function Nm(){if(jm)return km;jm=1;var e,t=xm(),r=Im();try{e=Rm}catch(e){}var n=function(){},i="undefined"!=typeof process&&/^v?\.0/.test(process.version),o=function(e){return"function"==typeof e},a=function(a,s,c,u){u=t(u);var l=!1;a.on("close",function(){l=!0}),r(a,{readable:s,writable:c},function(e){if(e)return u(e);l=!0,u()});var d=!1;return function(t){if(!l&&!d)return d=!0,function(t){return!!i&&!!e&&(t instanceof(e.ReadStream||n)||t instanceof(e.WriteStream||n))&&o(t.close)}(a)?a.close(n):function(e){return e.setHeader&&o(e.abort)}(a)?a.abort():o(a.destroy)?a.destroy():void u(t||new Error("stream was destroyed"))}},s=function(e){e()},c=function(e,t){return e.pipe(t)};return km=function(){var e,t=Array.prototype.slice.call(arguments),r=o(t[t.length-1]||n)&&t.pop()||n;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var i=t.map(function(n,o){var c=o<t.length-1;return a(n,c,o>0,function(t){e||(e=t),t&&i.forEach(s),c||(i.forEach(s),r(e))})});return t.reduce(c)},km}var Pm,Cm,Lm,Mm,$m={exports:{}},Dm={exports:{}},Bm={},Fm={};function Um(){return Pm||(Pm=1,Fm.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,c=(1<<s)-1,u=c>>1,l=-7,d=r?i-1:0,f=r?-1:1,p=e[t+d];for(d+=f,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+e[t+d],d+=f,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+d],d+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=u}return(p?-1:1)*a*Math.pow(2,o-n)},Fm.write=function(e,t,r,n,i,o){var a,s,c,u=8*o-i-1,l=(1<<u)-1,d=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,h=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=l?(s=0,a=l):a+d>=1?(s=(t*c-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+p]=255&s,p+=h,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;e[r+p]=255&a,p+=h,a/=256,u-=8);e[r+p-h]|=128*m}),Fm}
36
+ /*!
37
+ * The buffer module from node.js, for the browser.
38
+ *
39
+ * @author Feross Aboukhadijeh <https://feross.org>
40
+ * @license MIT
41
+ */function zm(){return Cm||(Cm=1,function(e){const t=yl(),r=Um(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},e.INSPECT_MAX_BYTES=50;const i=2147483647;function o(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return s(e,t,r)}function s(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|p(e,t);let n=o(r);const i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(H(e,Uint8Array)){const t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return l(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return d(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(H(e,SharedArrayBuffer)||e&&H(e.buffer,SharedArrayBuffer)))return d(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);const i=function(e){if(a.isBuffer(e)){const t=0|f(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||K(e.length)?o(0):l(e);if("Buffer"===e.type&&Array.isArray(e.data))return l(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return c(e),o(e<0?0:0|f(e))}function l(e){const t=e.length<0?0:0|f(e.length),r=o(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,a.prototype),n}function f(e){if(e>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function p(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(i)return n?-1:q(e).length;t=(""+t).toLowerCase(),i=!0}}function h(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return O(this,t,r);case"ascii":return T(this,t,r);case"latin1":case"binary":return x(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),K(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:g(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,i){let o,a=1,s=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){let n=-1;for(o=r;o<s;o++)if(u(e,o)===u(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+c>s&&(r=s-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(e,o+n)!==u(t,n)){r=!1;break}if(r)return o}return-1}function b(e,t,r,n){r=Number(r)||0;const i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=t.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(t.substr(2*a,2),16);if(K(n))return a;e[r+a]=n}return a}function v(e,t,r,n){return W(q(t,e.length-r),e,r,n)}function w(e,t,r,n){return W(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function _(e,t,r,n){return W(V(t),e,r,n)}function E(e,t,r,n){return W(function(e,t){let r,n,i;const o=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function S(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function O(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i<r;){const t=e[i];let o=null,a=t>239?4:t>223?3:t>191?2:1;if(i+a<=r){let r,n,s,c;switch(a){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[i+1],n=e[i+2],s=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=A));return r}(n)}e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(e,t,r){return s(e,t,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)}(e,t,r)},a.allocUnsafe=function(e){return u(e)},a.allocUnsafeSlow=function(e){return u(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(H(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=a.allocUnsafe(t);let i=0;for(r=0;r<e.length;++r){let t=e[r];if(H(t,Uint8Array))i+t.length>n.length?(a.isBuffer(t)||(t=a.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!a.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},a.byteLength=p,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)m(this,t,t+1);return this},a.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},a.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},a.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):h.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(e,t,r,n,i){if(H(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const c=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r);for(let e=0;e<c;++e)if(u[e]!==l[e]){o=u[e],s=l[e];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function T(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function x(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function I(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=Z[e[n]];return i}function k(e,t,r){const n=e.slice(t,r);let i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}function j(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function N(e,t,r,n,i){F(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,r}function P(e,t,r,n,i){F(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a>>=8,e[r+2]=a,a>>=8,e[r+1]=a,a>>=8,e[r]=a,r+8}function C(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,n,i,o){return t=+t,n>>>=0,o||C(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function M(e,t,n,i,o){return t=+t,n>>>=0,o||C(e,0,n,8),r.write(e,t,n,i,52,8),n+8}a.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=J(function(e){U(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||z(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),a.prototype.readBigUInt64BE=J(function(e){U(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||z(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=J(function(e){U(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||z(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),a.prototype.readBigInt64BE=J(function(e){U(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||z(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)}),a.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){R(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){R(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigUInt64LE=J(function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=J(function(e,t=0){return P(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,e,t,r,n-1,-n)}let i=0,o=1,a=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/o|0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,e,t,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/o|0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigInt64LE=J(function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=J(function(e,t=0){return P(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);const i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{const o=a.isBuffer(e)?e:a.from(e,n),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=o[i%s]}return this};const $={};function D(e,t,r){$[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function B(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function F(e,t,r,n,i,o){if(e>r||e<t){const r="bigint"==typeof t?"n":"";let n;throw n=0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new $.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){U(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||z(t,e.length-(r+1))}(n,i,o)}function U(e,t){if("number"!=typeof e)throw new $.ERR_INVALID_ARG_TYPE(t,"number",e)}function z(e,t,r){if(Math.floor(e)!==e)throw U(e,r),new $.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new $.ERR_BUFFER_OUT_OF_BOUNDS;throw new $.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}D("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),D("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=B(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=B(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function J(e){return"undefined"==typeof BigInt?Y:e}function Y(){throw new Error("BigInt not supported")}}(Bm)),Bm}function Gm(){if(Mm)return Lm;Mm=1;class e extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got "+typeof e);let t="";for(let r=0;r<e.length;r++)t+=` ${e[r].stack}\n`;super(t),this.name="AggregateError",this.errors=e}}return Lm={AggregateError:e,ArrayIsArray:e=>Array.isArray(e),ArrayPrototypeIncludes:(e,t)=>e.includes(t),ArrayPrototypeIndexOf:(e,t)=>e.indexOf(t),ArrayPrototypeJoin:(e,t)=>e.join(t),ArrayPrototypeMap:(e,t)=>e.map(t),ArrayPrototypePop:(e,t)=>e.pop(t),ArrayPrototypePush:(e,t)=>e.push(t),ArrayPrototypeSlice:(e,t,r)=>e.slice(t,r),Error:Error,FunctionPrototypeCall:(e,t,...r)=>e.call(t,...r),FunctionPrototypeSymbolHasInstance:(e,t)=>Function.prototype[Symbol.hasInstance].call(e,t),MathFloor:Math.floor,Number:Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(e,t)=>Object.defineProperties(e,t),ObjectDefineProperty:(e,t,r)=>Object.defineProperty(e,t,r),ObjectGetOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e,t),ObjectKeys:e=>Object.keys(e),ObjectSetPrototypeOf:(e,t)=>Object.setPrototypeOf(e,t),Promise:Promise,PromisePrototypeCatch:(e,t)=>e.catch(t),PromisePrototypeThen:(e,t,r)=>e.then(t,r),PromiseReject:e=>Promise.reject(e),PromiseResolve:e=>Promise.resolve(e),ReflectApply:Reflect.apply,RegExpPrototypeTest:(e,t)=>e.test(t),SafeSet:Set,String:String,StringPrototypeSlice:(e,t,r)=>e.slice(t,r),StringPrototypeToLowerCase:e=>e.toLowerCase(),StringPrototypeToUpperCase:e=>e.toUpperCase(),StringPrototypeTrim:e=>e.trim(),Symbol:Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet:(e,t,r)=>e.set(t,r),Boolean:Boolean,Uint8Array:Uint8Array},Lm}var qm,Vm,Wm,Hm,Km={exports:{}};function Zm(){return Vm||(Vm=1,qm={format:(e,...t)=>e.replace(/%([sdifj])/g,function(...[e,r]){const n=t.shift();if("f"===r)return n.toFixed(6);if("j"===r)return JSON.stringify(n);if("s"===r&&"object"==typeof n){return`${n.constructor!==Object?n.constructor.name:""} {}`.trim()}return n.toString()}),inspect(e){switch(typeof e){case"string":if(e.includes("'")){if(!e.includes('"'))return`"${e}"`;if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}}}),qm}function Jm(){if(Hm)return Wm;Hm=1;const{format:e,inspect:t}=Zm(),{AggregateError:r}=Gm(),n=globalThis.AggregateError||r,i=Symbol("kIsNodeError"),o=["string","function","number","object","Function","Object","boolean","bigint","symbol"],a=/^([A-Z][a-z0-9]*)+$/,s={};function c(e,t){if(!e)throw new s.ERR_INTERNAL_ASSERTION(t)}function u(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function l(t,r,n){n||(n=Error);class o extends n{constructor(...n){super(function(t,r,n){if("function"==typeof r)return c(r.length<=n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${r.length}).`),r(...n);const i=(r.match(/%[dfijoOs]/g)||[]).length;return c(i===n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${i}).`),0===n.length?r:e(r,...n)}(t,r,n))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(o.prototype,{name:{value:n.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),o.prototype.code=t,o.prototype[i]=!0,s[t]=o}function d(e){const t="__node_internal_"+e.name;return Object.defineProperty(e,"name",{value:t}),e}class f extends Error{constructor(e="The operation was aborted",t=void 0){if(void 0!==t&&"object"!=typeof t)throw new s.ERR_INVALID_ARG_TYPE("options","Object",t);super(e,t),this.code="ABORT_ERR",this.name="AbortError"}}return l("ERR_ASSERTION","%s",Error),l("ERR_INVALID_ARG_TYPE",(e,r,n)=>{c("string"==typeof e,"'name' must be a string"),Array.isArray(r)||(r=[r]);let i="The ";e.endsWith(" argument")?i+=`${e} `:i+=`"${e}" ${e.includes(".")?"property":"argument"} `,i+="must be ";const s=[],u=[],l=[];for(const e of r)c("string"==typeof e,"All expected entries have to be of type string"),o.includes(e)?s.push(e.toLowerCase()):a.test(e)?u.push(e):(c("object"!==e,'The value "object" should be written as "Object"'),l.push(e));if(u.length>0){const e=s.indexOf("object");-1!==e&&(s.splice(s,e,1),u.push("Object"))}if(s.length>0){switch(s.length){case 1:i+=`of type ${s[0]}`;break;case 2:i+=`one of type ${s[0]} or ${s[1]}`;break;default:{const e=s.pop();i+=`one of type ${s.join(", ")}, or ${e}`}}(u.length>0||l.length>0)&&(i+=" or ")}if(u.length>0){switch(u.length){case 1:i+=`an instance of ${u[0]}`;break;case 2:i+=`an instance of ${u[0]} or ${u[1]}`;break;default:{const e=u.pop();i+=`an instance of ${u.join(", ")}, or ${e}`}}l.length>0&&(i+=" or ")}switch(l.length){case 0:break;case 1:l[0].toLowerCase()!==l[0]&&(i+="an "),i+=`${l[0]}`;break;case 2:i+=`one of ${l[0]} or ${l[1]}`;break;default:{const e=l.pop();i+=`one of ${l.join(", ")}, or ${e}`}}if(null==n)i+=`. Received ${n}`;else if("function"==typeof n&&n.name)i+=`. Received function ${n.name}`;else if("object"==typeof n){var d;if(null!==(d=n.constructor)&&void 0!==d&&d.name)i+=`. Received an instance of ${n.constructor.name}`;else{i+=`. Received ${t(n,{depth:-1})}`}}else{let e=t(n,{colors:!1});e.length>25&&(e=`${e.slice(0,25)}...`),i+=`. Received type ${typeof n} (${e})`}return i},TypeError),l("ERR_INVALID_ARG_VALUE",(e,r,n="is invalid")=>{let i=t(r);i.length>128&&(i=i.slice(0,128)+"...");return`The ${e.includes(".")?"property":"argument"} '${e}' ${n}. Received ${i}`},TypeError),l("ERR_INVALID_RETURN_VALUE",(e,t,r)=>{var n;return`Expected ${e} to be returned from the "${t}" function but got ${null!=r&&null!==(n=r.constructor)&&void 0!==n&&n.name?`instance of ${r.constructor.name}`:"type "+typeof r}.`},TypeError),l("ERR_MISSING_ARGS",(...e)=>{let t;c(e.length>0,"At least one arg needs to be specified");const r=e.length;switch(e=(Array.isArray(e)?e:[e]).map(e=>`"${e}"`).join(" or "),r){case 1:t+=`The ${e[0]} argument`;break;case 2:t+=`The ${e[0]} and ${e[1]} arguments`;break;default:{const r=e.pop();t+=`The ${e.join(", ")}, and ${r} arguments`}}return`${t} must be specified`},TypeError),l("ERR_OUT_OF_RANGE",(e,r,n)=>{let i;if(c(r,'Missing "range" argument'),Number.isInteger(n)&&Math.abs(n)>2**32)i=u(String(n));else if("bigint"==typeof n){i=String(n);const e=BigInt(2)**BigInt(32);(n>e||n<-e)&&(i=u(i)),i+="n"}else i=t(n);return`The value of "${e}" is out of range. It must be ${r}. Received ${i}`},RangeError),l("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),l("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),l("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),l("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),l("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),l("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),l("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),l("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),l("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),l("ERR_STREAM_WRITE_AFTER_END","write after end",Error),l("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Wm={AbortError:f,aggregateTwoErrors:d(function(e,t){if(e&&t&&e!==t){if(Array.isArray(t.errors))return t.errors.push(e),t;const r=new n([t,e],t.message);return r.code=t.code,r}return e||t}),hideStackFrames:d,codes:s}}var Ym,Qm={exports:{}};function Xm(){if(Ym)return Qm.exports;Ym=1;const{AbortController:e,AbortSignal:t}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;return Qm.exports=e,Qm.exports.AbortSignal=t,Qm.exports.default=e,Qm.exports}var ey,ty,ry={exports:{}};function ny(){if(ey)return ry.exports;ey=1;var e,t="object"==typeof Reflect?Reflect:null,r=t&&"function"==typeof t.apply?t.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}ry.exports=i,ry.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}h(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&h(e,"error",t,r)}(e,i,{once:!0})})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var i,o,c,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),c=o[t]),void 0===c)c=o[t]=r,++e._eventsCount;else if("function"==typeof c?c=o[t]=n?[r,c]:[c,r]:n?c.unshift(r):c.push(r),(i=s(e))>0&&c.length>i&&!c.warned){c.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=c.length,u=l,console&&console.warn&&console.warn(u)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=u.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function h(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)})}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var u=c.length,l=p(c,u);for(n=0;n<u;++n)r(l[n],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},ry.exports}function iy(){return ty||(ty=1,function(e){const t=zm(),{format:r,inspect:n}=Zm(),{codes:{ERR_INVALID_ARG_TYPE:i}}=Jm(),{kResistStopPropagation:o,AggregateError:a,SymbolDispose:s}=Gm(),c=globalThis.AbortSignal||Xm().AbortSignal,u=globalThis.AbortController||Xm().AbortController,l=Object.getPrototypeOf(async function(){}).constructor,d=globalThis.Blob||t.Blob,f=void 0!==d?function(e){return e instanceof d}:function(e){return!1},p=(e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new i(t,"AbortSignal",e)};e.exports={AggregateError:a,kEmptyObject:Object.freeze({}),once(e){let t=!1;return function(...r){t||(t=!0,e.apply(this,r))}},createDeferredPromise:function(){let e,t;return{promise:new Promise((r,n)=>{e=r,t=n}),resolve:e,reject:t}},promisify:e=>new Promise((t,r)=>{e((e,...n)=>e?r(e):t(...n))}),debuglog:()=>function(){},format:r,inspect:n,types:{isAsyncFunction:e=>e instanceof l,isArrayBufferView:e=>ArrayBuffer.isView(e)},isBlob:f,deprecate:(e,t)=>e,addAbortListener:ny().addAbortListener||function(e,t){if(void 0===e)throw new i("signal","AbortSignal",e);let r;return p(e,"signal"),((e,t)=>{if("function"!=typeof e)throw new i(t,"Function",e)})(t,"listener"),e.aborted?queueMicrotask(()=>t()):(e.addEventListener("abort",t,{__proto__:null,once:!0,[o]:!0}),r=()=>{e.removeEventListener("abort",t)}),{__proto__:null,[s](){var e;null===(e=r)||void 0===e||e()}}},AbortSignalAny:c.any||function(e){if(1===e.length)return e[0];const t=new u,r=()=>t.abort();return e.forEach(e=>{p(e,"signals"),e.addEventListener("abort",r,{once:!0})}),t.signal.addEventListener("abort",()=>{e.forEach(e=>e.removeEventListener("abort",r))},{once:!0}),t.signal}},e.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}(Km)),Km.exports}var oy,ay,sy={};function cy(){if(ay)return oy;ay=1;const{ArrayIsArray:e,ArrayPrototypeIncludes:t,ArrayPrototypeJoin:r,ArrayPrototypeMap:n,NumberIsInteger:i,NumberIsNaN:o,NumberMAX_SAFE_INTEGER:a,NumberMIN_SAFE_INTEGER:s,NumberParseInt:c,ObjectPrototypeHasOwnProperty:u,RegExpPrototypeExec:l,String:d,StringPrototypeToUpperCase:f,StringPrototypeTrim:p}=Gm(),{hideStackFrames:h,codes:{ERR_SOCKET_BAD_PORT:m,ERR_INVALID_ARG_TYPE:y,ERR_INVALID_ARG_VALUE:g,ERR_OUT_OF_RANGE:b,ERR_UNKNOWN_SIGNAL:v}}=Jm(),{normalizeEncoding:w}=iy(),{isAsyncFunction:_,isArrayBufferView:E}=iy().types,S={};const O=/^[0-7]+$/;const A=h((e,t,r=s,n=a)=>{if("number"!=typeof e)throw new y(t,"number",e);if(!i(e))throw new b(t,"an integer",e);if(e<r||e>n)throw new b(t,`>= ${r} && <= ${n}`,e)}),T=h((e,t,r=-2147483648,n=2147483647)=>{if("number"!=typeof e)throw new y(t,"number",e);if(!i(e))throw new b(t,"an integer",e);if(e<r||e>n)throw new b(t,`>= ${r} && <= ${n}`,e)}),x=h((e,t,r=!1)=>{if("number"!=typeof e)throw new y(t,"number",e);if(!i(e))throw new b(t,"an integer",e);const n=r?1:0,o=4294967295;if(e<n||e>o)throw new b(t,`>= ${n} && <= ${o}`,e)});function I(e,t){if("string"!=typeof e)throw new y(t,"string",e)}const k=h((e,i,o)=>{if(!t(o,e)){const t=r(n(o,e=>"string"==typeof e?`'${e}'`:d(e)),", ");throw new g(i,e,"must be one of: "+t)}});function j(e,t){if("boolean"!=typeof e)throw new y(t,"boolean",e)}function R(e,t,r){return null!=e&&u(e,t)?e[t]:r}const N=h((t,r,n=null)=>{const i=R(n,"allowArray",!1),o=R(n,"allowFunction",!1);if(!R(n,"nullable",!1)&&null===t||!i&&e(t)||"object"!=typeof t&&(!o||"function"!=typeof t))throw new y(r,"Object",t)}),P=h((e,t)=>{if(null!=e&&"object"!=typeof e&&"function"!=typeof e)throw new y(t,"a dictionary",e)}),C=h((t,r,n=0)=>{if(!e(t))throw new y(r,"Array",t);if(t.length<n){throw new g(r,t,`must be longer than ${n}`)}});const L=h((e,t="buffer")=>{if(!E(e))throw new y(t,["Buffer","TypedArray","DataView"],e)});const M=h((e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new y(t,"AbortSignal",e)}),$=h((e,t)=>{if("function"!=typeof e)throw new y(t,"Function",e)}),D=h((e,t)=>{if("function"!=typeof e||_(e))throw new y(t,"Function",e)}),B=h((e,t)=>{if(void 0!==e)throw new y(t,"undefined",e)});const F=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function U(e,t){if(void 0===e||!l(F,e))throw new g(t,e,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}return oy={isInt32:function(e){return e===(0|e)},isUint32:function(e){return e===e>>>0},parseFileMode:function(e,t,r){if(void 0===e&&(e=r),"string"==typeof e){if(null===l(O,e))throw new g(t,e,"must be a 32-bit unsigned integer or an octal string");e=c(e,8)}return x(e,t),e},validateArray:C,validateStringArray:function(e,t){C(e,t);for(let r=0;r<e.length;r++)I(e[r],`${t}[${r}]`)},validateBooleanArray:function(e,t){C(e,t);for(let r=0;r<e.length;r++)j(e[r],`${t}[${r}]`)},validateAbortSignalArray:function(e,t){C(e,t);for(let r=0;r<e.length;r++){const n=e[r],i=`${t}[${r}]`;if(null==n)throw new y(i,"AbortSignal",n);M(n,i)}},validateBoolean:j,validateBuffer:L,validateDictionary:P,validateEncoding:function(e,t){const r=w(t),n=e.length;if("hex"===r&&n%2!=0)throw new g("encoding",t,`is invalid for data of length ${n}`)},validateFunction:$,validateInt32:T,validateInteger:A,validateNumber:function(e,t,r=void 0,n){if("number"!=typeof e)throw new y(t,"number",e);if(null!=r&&e<r||null!=n&&e>n||(null!=r||null!=n)&&o(e))throw new b(t,`${null!=r?`>= ${r}`:""}${null!=r&&null!=n?" && ":""}${null!=n?`<= ${n}`:""}`,e)},validateObject:N,validateOneOf:k,validatePlainFunction:D,validatePort:function(e,t="Port",r=!0){if("number"!=typeof e&&"string"!=typeof e||"string"==typeof e&&0===p(e).length||+e!==+e>>>0||e>65535||0===e&&!r)throw new m(t,e,r);return 0|e},validateSignalName:function(e,t="signal"){if(I(e,t),void 0===S[e]){if(void 0!==S[f(e)])throw new v(e+" (signals must use all capital letters)");throw new v(e)}},validateString:I,validateUint32:x,validateUndefined:B,validateUnion:function(e,n,i){if(!t(i,e))throw new y(n,`('${r(i,"|")}')`,e)},validateAbortSignal:M,validateLinkHeaderValue:function(t){if("string"==typeof t)return U(t,"hints"),t;if(e(t)){const e=t.length;let r="";if(0===e)return r;for(let n=0;n<e;n++){const i=t[n];U(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new g("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}},oy}var uy,ly,dy,fy,py,hy,my,yy,gy={exports:{}},by={exports:{}};function vy(){if(uy)return by.exports;uy=1;var e,t,r=by.exports={};function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:n}catch(t){e=n}try{t="function"==typeof clearTimeout?clearTimeout:i}catch(e){t=i}}();var a,s=[],c=!1,u=-1;function l(){c&&a&&(c=!1,a.length?s=a.concat(s):u=-1,s.length&&d())}function d(){if(!c){var e=o(l);c=!0;for(var r=s.length;r;){for(a=s,s=[];++u<r;)a&&a[u].run();u=-1,r=s.length}a=null,c=!1,function(e){if(t===clearTimeout)return clearTimeout(e);if((t===i||!t)&&clearTimeout)return t=clearTimeout,clearTimeout(e);try{return t(e)}catch(r){try{return t.call(null,e)}catch(r){return t.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}return r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];s.push(new f(e,t)),1!==s.length||c||o(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0},by.exports}function wy(){if(dy)return ly;dy=1;const{SymbolAsyncIterator:e,SymbolIterator:t,SymbolFor:r}=Gm(),n=r("nodejs.stream.destroyed"),i=r("nodejs.stream.errored"),o=r("nodejs.stream.readable"),a=r("nodejs.stream.writable"),s=r("nodejs.stream.disturbed"),c=r("nodejs.webstream.isClosedPromise"),u=r("nodejs.webstream.controllerErrorFunction");function l(e,t=!1){var r;return!(!e||"function"!=typeof e.pipe||"function"!=typeof e.on||t&&("function"!=typeof e.pause||"function"!=typeof e.resume)||e._writableState&&!1===(null===(r=e._readableState)||void 0===r?void 0:r.readable)||e._writableState&&!e._readableState)}function d(e){var t;return!(!e||"function"!=typeof e.write||"function"!=typeof e.on||e._readableState&&!1===(null===(t=e._writableState)||void 0===t?void 0:t.writable))}function f(e){return e&&(e._readableState||e._writableState||"function"==typeof e.write&&"function"==typeof e.on||"function"==typeof e.pipe&&"function"==typeof e.on)}function p(e){return!(!e||f(e)||"function"!=typeof e.pipeThrough||"function"!=typeof e.getReader||"function"!=typeof e.cancel)}function h(e){return!(!e||f(e)||"function"!=typeof e.getWriter||"function"!=typeof e.abort)}function m(e){return!(!e||f(e)||"object"!=typeof e.readable||"object"!=typeof e.writable)}function y(e){if(!f(e))return null;const t=e._writableState,r=e._readableState,i=t||r;return!!(e.destroyed||e[n]||null!=i&&i.destroyed)}function g(e){if(!d(e))return null;if(!0===e.writableEnded)return!0;const t=e._writableState;return(null==t||!t.errored)&&("boolean"!=typeof(null==t?void 0:t.ended)?null:t.ended)}function b(e,t){if(!l(e))return null;const r=e._readableState;return(null==r||!r.errored)&&("boolean"!=typeof(null==r?void 0:r.endEmitted)?null:!!(r.endEmitted||!1===t&&!0===r.ended&&0===r.length))}function v(e){return e&&null!=e[o]?e[o]:"boolean"!=typeof(null==e?void 0:e.readable)?null:!y(e)&&(l(e)&&e.readable&&!b(e))}function w(e){return e&&null!=e[a]?e[a]:"boolean"!=typeof(null==e?void 0:e.writable)?null:!y(e)&&(d(e)&&e.writable&&!g(e))}function _(e){return"boolean"==typeof e._closed&&"boolean"==typeof e._defaultKeepAlive&&"boolean"==typeof e._removedConnection&&"boolean"==typeof e._removedContLen}function E(e){return"boolean"==typeof e._sent100&&_(e)}return ly={isDestroyed:y,kIsDestroyed:n,isDisturbed:function(e){var t;return!(!e||!(null!==(t=e[s])&&void 0!==t?t:e.readableDidRead||e.readableAborted))},kIsDisturbed:s,isErrored:function(e){var t,r,n,o,a,s,c,u,l,d;return!(!e||!(null!==(t=null!==(r=null!==(n=null!==(o=null!==(a=null!==(s=e[i])&&void 0!==s?s:e.readableErrored)&&void 0!==a?a:e.writableErrored)&&void 0!==o?o:null===(c=e._readableState)||void 0===c?void 0:c.errorEmitted)&&void 0!==n?n:null===(u=e._writableState)||void 0===u?void 0:u.errorEmitted)&&void 0!==r?r:null===(l=e._readableState)||void 0===l?void 0:l.errored)&&void 0!==t?t:null===(d=e._writableState)||void 0===d?void 0:d.errored))},kIsErrored:i,isReadable:v,kIsReadable:o,kIsClosedPromise:c,kControllerErrorFunction:u,kIsWritable:a,isClosed:function(e){if(!f(e))return null;if("boolean"==typeof e.closed)return e.closed;const t=e._writableState,r=e._readableState;return"boolean"==typeof(null==t?void 0:t.closed)||"boolean"==typeof(null==r?void 0:r.closed)?(null==t?void 0:t.closed)||(null==r?void 0:r.closed):"boolean"==typeof e._closed&&_(e)?e._closed:null},isDuplexNodeStream:function(e){return!(!e||"function"!=typeof e.pipe||!e._readableState||"function"!=typeof e.on||"function"!=typeof e.write)},isFinished:function(e,t){return f(e)?!!y(e)||(!1===(null==t?void 0:t.readable)||!v(e))&&(!1===(null==t?void 0:t.writable)||!w(e)):null},isIterable:function(r,n){return null!=r&&(!0===n?"function"==typeof r[e]:!1===n?"function"==typeof r[t]:"function"==typeof r[e]||"function"==typeof r[t])},isReadableNodeStream:l,isReadableStream:p,isReadableEnded:function(e){if(!l(e))return null;if(!0===e.readableEnded)return!0;const t=e._readableState;return!(!t||t.errored)&&("boolean"!=typeof(null==t?void 0:t.ended)?null:t.ended)},isReadableFinished:b,isReadableErrored:function(e){var t,r;return f(e)?e.readableErrored?e.readableErrored:null!==(t=null===(r=e._readableState)||void 0===r?void 0:r.errored)&&void 0!==t?t:null:null},isNodeStream:f,isWebStream:function(e){return p(e)||h(e)||m(e)},isWritable:w,isWritableNodeStream:d,isWritableStream:h,isWritableEnded:g,isWritableFinished:function(e,t){if(!d(e))return null;if(!0===e.writableFinished)return!0;const r=e._writableState;return(null==r||!r.errored)&&("boolean"!=typeof(null==r?void 0:r.finished)?null:!!(r.finished||!1===t&&!0===r.ended&&0===r.length))},isWritableErrored:function(e){var t,r;return f(e)?e.writableErrored?e.writableErrored:null!==(t=null===(r=e._writableState)||void 0===r?void 0:r.errored)&&void 0!==t?t:null:null},isServerRequest:function(e){var t;return"boolean"==typeof e._consuming&&"boolean"==typeof e._dumped&&void 0===(null===(t=e.req)||void 0===t?void 0:t.upgradeOrConnect)},isServerResponse:E,willEmitClose:function(e){if(!f(e))return null;const t=e._writableState,r=e._readableState,n=t||r;return!n&&E(e)||!!(n&&n.autoDestroy&&n.emitClose&&!1===n.closed)},isTransformStream:m},ly}function _y(){if(fy)return gy.exports;fy=1;const e=vy(),{AbortError:t,codes:r}=Jm(),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_PREMATURE_CLOSE:i}=r,{kEmptyObject:o,once:a}=iy(),{validateAbortSignal:s,validateFunction:c,validateObject:u,validateBoolean:l}=cy(),{Promise:d,PromisePrototypeThen:f,SymbolDispose:p}=Gm(),{isClosed:h,isReadable:m,isReadableNodeStream:y,isReadableStream:g,isReadableFinished:b,isReadableErrored:v,isWritable:w,isWritableNodeStream:_,isWritableStream:E,isWritableFinished:S,isWritableErrored:O,isNodeStream:A,willEmitClose:T,kIsClosedPromise:x}=wy();let I;const k=()=>{};function j(r,l,d){var j,R;if(2===arguments.length?(d=l,l=o):null==l?l=o:u(l,"options"),c(d,"callback"),s(l.signal,"options.signal"),d=a(d),g(r)||E(r))return function(r,n,i){let o=!1,s=k;if(n.signal)if(s=()=>{o=!0,i.call(r,new t(void 0,{cause:n.signal.reason}))},n.signal.aborted)e.nextTick(s);else{I=I||iy().addAbortListener;const e=I(n.signal,s),t=i;i=a((...n)=>{e[p](),t.apply(r,n)})}const c=(...t)=>{o||e.nextTick(()=>i.apply(r,t))};return f(r[x].promise,c,c),k}(r,l,d);if(!A(r))throw new n("stream",["ReadableStream","WritableStream","Stream"],r);const N=null!==(j=l.readable)&&void 0!==j?j:y(r),P=null!==(R=l.writable)&&void 0!==R?R:_(r),C=r._writableState,L=r._readableState,M=()=>{r.writable||B()};let $=T(r)&&y(r)===N&&_(r)===P,D=S(r,!1);const B=()=>{D=!0,r.destroyed&&($=!1),(!$||r.readable&&!N)&&(N&&!F||d.call(r))};let F=b(r,!1);const U=()=>{F=!0,r.destroyed&&($=!1),(!$||r.writable&&!P)&&(P&&!D||d.call(r))},z=e=>{d.call(r,e)};let G=h(r);const q=()=>{G=!0;const e=O(r)||v(r);return e&&"boolean"!=typeof e?d.call(r,e):N&&!F&&y(r,!0)&&!b(r,!1)?d.call(r,new i):!P||D||S(r,!1)?void d.call(r):d.call(r,new i)},V=()=>{G=!0;const e=O(r)||v(r);if(e&&"boolean"!=typeof e)return d.call(r,e);d.call(r)},W=()=>{r.req.on("finish",B)};!function(e){return e.setHeader&&"function"==typeof e.abort}(r)?P&&!C&&(r.on("end",M),r.on("close",M)):(r.on("complete",B),$||r.on("abort",q),r.req?W():r.on("request",W)),$||"boolean"!=typeof r.aborted||r.on("aborted",q),r.on("end",U),r.on("finish",B),!1!==l.error&&r.on("error",z),r.on("close",q),G?e.nextTick(q):null!=C&&C.errorEmitted||null!=L&&L.errorEmitted?$||e.nextTick(V):(N||$&&!m(r)||!D&&!1!==w(r))&&(P||$&&!w(r)||!F&&!1!==m(r))?L&&r.req&&r.aborted&&e.nextTick(V):e.nextTick(V);const H=()=>{d=k,r.removeListener("aborted",q),r.removeListener("complete",B),r.removeListener("abort",q),r.removeListener("request",W),r.req&&r.req.removeListener("finish",B),r.removeListener("end",M),r.removeListener("close",M),r.removeListener("finish",B),r.removeListener("end",U),r.removeListener("error",z),r.removeListener("close",q)};if(l.signal&&!G){const n=()=>{const e=d;H(),e.call(r,new t(void 0,{cause:l.signal.reason}))};if(l.signal.aborted)e.nextTick(n);else{I=I||iy().addAbortListener;const e=I(l.signal,n),t=d;d=a((...n)=>{e[p](),t.apply(r,n)})}}return H}return gy.exports=j,gy.exports.finished=function(e,t){var r;let n=!1;return null===t&&(t=o),null!==(r=t)&&void 0!==r&&r.cleanup&&(l(t.cleanup,"cleanup"),n=t.cleanup),new d((r,i)=>{const o=j(e,t,e=>{n&&o(),e?i(e):r()})})},gy.exports}function Ey(){if(hy)return py;hy=1;const e=vy(),{aggregateTwoErrors:t,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:n}=Jm(),{Symbol:i}=Gm(),{kIsDestroyed:o,isDestroyed:a,isFinished:s,isServerRequest:c}=wy(),u=i("kDestroy"),l=i("kConstruct");function d(e,t,r){e&&(e.stack,t&&!t.errored&&(t.errored=e),r&&!r.errored&&(r.errored=e))}function f(t,r,n){let i=!1;function o(r){if(i)return;i=!0;const o=t._readableState,a=t._writableState;d(r,a,o),a&&(a.closed=!0),o&&(o.closed=!0),"function"==typeof n&&n(r),r?e.nextTick(p,t,r):e.nextTick(h,t)}try{t._destroy(r||null,o)}catch(r){o(r)}}function p(e,t){m(e,t),h(e)}function h(e){const t=e._readableState,r=e._writableState;r&&(r.closeEmitted=!0),t&&(t.closeEmitted=!0),(null!=r&&r.emitClose||null!=t&&t.emitClose)&&e.emit("close")}function m(e,t){const r=e._readableState,n=e._writableState;null!=n&&n.errorEmitted||null!=r&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),e.emit("error",t))}function y(t,r,n){const i=t._readableState,o=t._writableState;if(null!=o&&o.destroyed||null!=i&&i.destroyed)return this;null!=i&&i.autoDestroy||null!=o&&o.autoDestroy?t.destroy(r):r&&(r.stack,o&&!o.errored&&(o.errored=r),i&&!i.errored&&(i.errored=r),n?e.nextTick(m,t,r):m(t,r))}function g(t){let n=!1;function i(i){if(n)return void y(t,null!=i?i:new r);n=!0;const o=t._readableState,a=t._writableState,s=a||o;o&&(o.constructed=!0),a&&(a.constructed=!0),s.destroyed?t.emit(u,i):i?y(t,i,!0):e.nextTick(b,t)}try{t._construct(t=>{e.nextTick(i,t)})}catch(t){e.nextTick(i,t)}}function b(e){e.emit(l)}function v(e){return(null==e?void 0:e.setHeader)&&"function"==typeof e.abort}function w(e){e.emit("close")}function _(t,r){t.emit("error",r),e.nextTick(w,t)}return py={construct:function(t,r){if("function"!=typeof t._construct)return;const n=t._readableState,i=t._writableState;n&&(n.constructed=!1),i&&(i.constructed=!1),t.once(l,r),t.listenerCount(l)>1||e.nextTick(g,t)},destroyer:function(t,r){t&&!a(t)&&(r||s(t)||(r=new n),c(t)?(t.socket=null,t.destroy(r)):v(t)?t.abort():v(t.req)?t.req.abort():"function"==typeof t.destroy?t.destroy(r):"function"==typeof t.close?t.close():r?e.nextTick(_,t,r):e.nextTick(w,t),t.destroyed||(t[o]=!0))},destroy:function(e,r){const n=this._readableState,i=this._writableState,o=i||n;return null!=i&&i.destroyed||null!=n&&n.destroyed?("function"==typeof r&&r(),this):(d(e,i,n),i&&(i.destroyed=!0),n&&(n.destroyed=!0),o.constructed?f(this,e,r):this.once(u,function(n){f(this,t(n,e),r)}),this)},undestroy:function(){const e=this._readableState,t=this._writableState;e&&(e.constructed=!0,e.closed=!1,e.closeEmitted=!1,e.destroyed=!1,e.errored=null,e.errorEmitted=!1,e.reading=!1,e.ended=!1===e.readable,e.endEmitted=!1===e.readable),t&&(t.constructed=!0,t.destroyed=!1,t.closed=!1,t.closeEmitted=!1,t.errored=null,t.errorEmitted=!1,t.finalCalled=!1,t.prefinished=!1,t.ended=!1===t.writable,t.ending=!1===t.writable,t.finished=!1===t.writable)},errorOrDestroy:y},py}function Sy(){if(yy)return my;yy=1;const{ArrayIsArray:e,ObjectSetPrototypeOf:t}=Gm(),{EventEmitter:r}=ny();function n(e){r.call(this,e)}function i(t,r,n){if("function"==typeof t.prependListener)return t.prependListener(r,n);t._events&&t._events[r]?e(t._events[r])?t._events[r].unshift(n):t._events[r]=[n,t._events[r]]:t.on(r,n)}return t(n.prototype,r.prototype),t(n,r),n.prototype.pipe=function(e,t){const n=this;function o(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function a(){n.readable&&n.resume&&n.resume()}n.on("data",o),e.on("drain",a),e._isStdio||t&&!1===t.end||(n.on("end",c),n.on("close",u));let s=!1;function c(){s||(s=!0,e.end())}function u(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){d(),0===r.listenerCount(this,"error")&&this.emit("error",e)}function d(){n.removeListener("data",o),e.removeListener("drain",a),n.removeListener("end",c),n.removeListener("close",u),n.removeListener("error",l),e.removeListener("error",l),n.removeListener("end",d),n.removeListener("close",d),e.removeListener("close",d)}return i(n,"error",l),i(e,"error",l),n.on("end",d),n.on("close",d),e.on("close",d),e.emit("pipe",n),e},my={Stream:n,prependListener:i}}var Oy,Ay,Ty,xy,Iy,ky={exports:{}};function jy(){return Oy||(Oy=1,function(e){const{SymbolDispose:t}=Gm(),{AbortError:r,codes:n}=Jm(),{isNodeStream:i,isWebStream:o,kControllerErrorFunction:a}=wy(),s=_y(),{ERR_INVALID_ARG_TYPE:c}=n;let u;e.exports.addAbortSignal=function(t,r){if(((e,t)=>{if("object"!=typeof e||!("aborted"in e))throw new c(t,"AbortSignal",e)})(t,"signal"),!i(r)&&!o(r))throw new c("stream",["ReadableStream","WritableStream","Stream"],r);return e.exports.addAbortSignalNoValidate(t,r)},e.exports.addAbortSignalNoValidate=function(e,n){if("object"!=typeof e||!("aborted"in e))return n;const o=i(n)?()=>{n.destroy(new r(void 0,{cause:e.reason}))}:()=>{n[a](new r(void 0,{cause:e.reason}))};if(e.aborted)o();else{u=u||iy().addAbortListener;const r=u(e,o);s(n,r[t])}return n}}(ky)),ky.exports}function Ry(){if(Ty)return Ay;Ty=1;const{StringPrototypeSlice:e,SymbolIterator:t,TypedArrayPrototypeSet:r,Uint8Array:n}=Gm(),{Buffer:i}=zm(),{inspect:o}=iy();return Ay=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}unshift(e){const t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}shift(){if(0===this.length)return;const e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(0===this.length)return"";let t=this.head,r=""+t.data;for(;null!==(t=t.next);)r+=e+t.data;return r}concat(e){if(0===this.length)return i.alloc(0);const t=i.allocUnsafe(e>>>0);let n=this.head,o=0;for(;n;)r(t,n.data,o),o+=n.data.length,n=n.next;return t}consume(e,t){const r=this.head.data;if(e<r.length){const t=r.slice(0,e);return this.head.data=r.slice(e),t}return e===r.length?this.shift():t?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[t](){for(let e=this.head;e;e=e.next)yield e.data}_getString(t){let r="",n=this.head,i=0;do{const o=n.data;if(!(t>o.length)){t===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=e(o,0,t),this.head=n,n.data=e(o,t));break}r+=o,t-=o.length,++i}while(null!==(n=n.next));return this.length-=i,r}_getBuffer(e){const t=i.allocUnsafe(e),o=e;let a=this.head,s=0;do{const i=a.data;if(!(e>i.length)){e===i.length?(r(t,i,o-e),++s,a.next?this.head=a.next:this.head=this.tail=null):(r(t,new n(i.buffer,i.byteOffset,e),o-e),this.head=a,a.data=i.slice(e));break}r(t,i,o-e),e-=i.length,++s}while(null!==(a=a.next));return this.length-=s,t}[Symbol.for("nodejs.util.inspect.custom")](e,t){return o(this,{...t,depth:0,customInspect:!1})}},Ay}function Ny(){if(Iy)return xy;Iy=1;const{MathFloor:e,NumberIsInteger:t}=Gm(),{validateInteger:r}=cy(),{ERR_INVALID_ARG_VALUE:n}=Jm().codes;let i=16384,o=16;function a(e){return e?o:i}return xy={getHighWaterMark:function(r,i,o,s){const c=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(i,s,o);if(null!=c){if(!t(c)||c<0){throw new n(s?`options.${o}`:"options.highWaterMark",c)}return e(c)}return a(r.objectMode)},getDefaultHighWaterMark:a,setDefaultHighWaterMark:function(e,t){r(t,"value",0),e?o=t:i=t}},xy}var Py,Cy,Ly,My,$y,Dy,By,Fy,Uy,zy,Gy,qy,Vy,Wy,Hy,Ky,Zy,Jy,Yy,Qy,Xy,eg,tg,rg,ng,ig,og,ag,sg,cg,ug,lg,dg,fg,pg,hg={},mg={exports:{}};function yg(){if(Cy)return hg;Cy=1;var e=(Py||(Py=1,function(e,t){var r=zm(),n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(mg,mg.exports)),mg.exports).Buffer,t=e.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(r){var n;switch(this.encoding=function(r){var n=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(r);if("string"!=typeof n&&(e.isEncoding===t||!t(r)))throw new Error("Unknown encoding: "+r);return n||r}(r),this.encoding){case"utf16le":this.text=o,this.end=a,n=4;break;case"utf8":this.fillLast=i,n=4;break;case"base64":this.text=s,this.end=c,n=3;break;default:return this.write=u,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(n)}function n(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function i(e){var t=this.lastTotal-this.lastNeed,r=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function o(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function a(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function s(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function u(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}return hg.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var o=n(t[i]);if(o>=0)return o>0&&(e.lastNeed=o-1),o;if(--i<r||-2===o)return 0;if(o=n(t[i]),o>=0)return o>0&&(e.lastNeed=o-2),o;if(--i<r||-2===o)return 0;if(o=n(t[i]),o>=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},hg}function gg(){if(My)return Ly;My=1;const e=vy(),{PromisePrototypeThen:t,SymbolAsyncIterator:r,SymbolIterator:n}=Gm(),{Buffer:i}=zm(),{ERR_INVALID_ARG_TYPE:o,ERR_STREAM_NULL_VALUES:a}=Jm().codes;return Ly=function(s,c,u){let l,d;if("string"==typeof c||c instanceof i)return new s({objectMode:!0,...u,read(){this.push(c),this.push(null)}});if(c&&c[r])d=!0,l=c[r]();else{if(!c||!c[n])throw new o("iterable",["Iterable"],c);d=!1,l=c[n]()}const f=new s({objectMode:!0,highWaterMark:1,...u});let p=!1;return f._read=function(){p||(p=!0,async function(){for(;;){try{const{value:e,done:t}=d?await l.next():l.next();if(t)f.push(null);else{const t=e&&"function"==typeof e.then?await e:e;if(null===t)throw p=!1,new a;if(f.push(t))continue;p=!1}}catch(e){f.destroy(e)}break}}())},f._destroy=function(r,n){t(async function(e){const t=null!=e,r="function"==typeof l.throw;if(t&&r){const{value:t,done:r}=await l.throw(e);if(await t,r)return}if("function"==typeof l.return){const{value:e}=await l.return();await e}}(r),()=>e.nextTick(n,r),t=>e.nextTick(n,t||r))},f},Ly}function bg(){if(Dy)return $y;Dy=1;const e=vy(),{ArrayPrototypeIndexOf:t,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:o,ObjectKeys:a,ObjectSetPrototypeOf:s,Promise:c,SafeSet:u,SymbolAsyncDispose:l,SymbolAsyncIterator:d,Symbol:f}=Gm();$y=q,q.ReadableState=G;const{EventEmitter:p}=ny(),{Stream:h,prependListener:m}=Sy(),{Buffer:y}=zm(),{addAbortSignal:g}=jy(),b=_y();let v=iy().debuglog("stream",e=>{v=e});const w=Ry(),_=Ey(),{getHighWaterMark:E,getDefaultHighWaterMark:S}=Ny(),{aggregateTwoErrors:O,codes:{ERR_INVALID_ARG_TYPE:A,ERR_METHOD_NOT_IMPLEMENTED:T,ERR_OUT_OF_RANGE:x,ERR_STREAM_PUSH_AFTER_EOF:I,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:k},AbortError:j}=Jm(),{validateObject:R}=cy(),N=f("kPaused"),{StringDecoder:P}=yg(),C=gg();s(q.prototype,h.prototype),s(q,h);const L=()=>{},{errorOrDestroy:M}=_,$=1,D=16,B=32,F=2048,U=4096;function z(e){return{enumerable:!1,get(){return 0!==(this.state&e)},set(t){t?this.state|=e:this.state&=~e}}}function G(e,t,r){"boolean"!=typeof r&&(r=t instanceof _g()),this.state=F|U|D|B,e&&e.objectMode&&(this.state|=$),r&&e&&e.readableObjectMode&&(this.state|=$),this.highWaterMark=e?E(this,e,"readableHighWaterMark",r):S(!1),this.buffer=new w,this.length=0,this.pipes=[],this.flowing=null,this[N]=null,e&&!1===e.emitClose&&(this.state&=~F),e&&!1===e.autoDestroy&&(this.state&=~U),this.errored=null,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,e&&e.encoding&&(this.decoder=new P(e.encoding),this.encoding=e.encoding)}function q(e){if(!(this instanceof q))return new q(e);const t=this instanceof _g();this._readableState=new G(e,this,t),e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&!t&&g(e.signal,this)),h.call(this,e),_.construct(this,()=>{this._readableState.needReadable&&J(this,this._readableState)})}function V(e,t,r,n){v("readableAddChunk",t);const i=e._readableState;let o;if(0===(i.state&$)&&("string"==typeof t?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?t=y.from(t,r).toString(i.encoding):(t=y.from(t,r),r=""))):t instanceof y?r="":h._isUint8Array(t)?(t=h._uint8ArrayToBuffer(t),r=""):null!=t&&(o=new A("chunk",["string","Buffer","Uint8Array"],t))),o)M(e,o);else if(null===t)i.state&=-9,function(e,t){if(v("onEofChunk"),t.ended)return;if(t.decoder){const e=t.decoder.end();e&&e.length&&(t.buffer.push(e),t.length+=t.objectMode?1:e.length)}t.ended=!0,t.sync?K(e):(t.needReadable=!1,t.emittedReadable=!0,Z(e))}(e,i);else if(0!==(i.state&$)||t&&t.length>0)if(n)if(4&i.state)M(e,new k);else{if(i.destroyed||i.errored)return!1;W(e,i,t,!0)}else if(i.ended)M(e,new I);else{if(i.destroyed||i.errored)return!1;i.state&=-9,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?W(e,i,t,!1):J(e,i)):W(e,i,t,!1)}else n||(i.state&=-9,J(e,i));return!i.ended&&(i.length<i.highWaterMark||0===i.length)}function W(e,t,r,n){t.flowing&&0===t.length&&!t.sync&&e.listenerCount("data")>0?(65536&t.state?t.awaitDrainWriters.clear():t.awaitDrainWriters=null,t.dataEmitted=!0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),64&t.state&&K(e)),J(e,t)}o(G.prototype,{objectMode:z($),ended:z(2),endEmitted:z(4),reading:z(8),constructed:z(D),sync:z(B),needReadable:z(64),emittedReadable:z(128),readableListening:z(256),resumeScheduled:z(512),errorEmitted:z(1024),emitClose:z(F),autoDestroy:z(U),destroyed:z(8192),closed:z(16384),closeEmitted:z(32768),multiAwaitDrain:z(65536),readingMore:z(1<<17),dataEmitted:z(1<<18)}),q.prototype.destroy=_.destroy,q.prototype._undestroy=_.undestroy,q.prototype._destroy=function(e,t){t(e)},q.prototype[p.captureRejectionSymbol]=function(e){this.destroy(e)},q.prototype[l]=function(){let e;return this.destroyed||(e=this.readableEnded?null:new j,this.destroy(e)),new c((t,r)=>b(this,n=>n&&n!==e?r(n):t(null)))},q.prototype.push=function(e,t){return V(this,e,t,!1)},q.prototype.unshift=function(e,t){return V(this,e,t,!0)},q.prototype.isPaused=function(){const e=this._readableState;return!0===e[N]||!1===e.flowing},q.prototype.setEncoding=function(e){const t=new P(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;const r=this._readableState.buffer;let n="";for(const e of r)n+=t.write(e);return r.clear(),""!==n&&r.push(n),this._readableState.length=n.length,this};function H(e,t){return e<=0||0===t.length&&t.ended?0:0!==(t.state&$)?1:n(e)?t.flowing&&t.length?t.buffer.first().length:t.length:e<=t.length?e:t.ended?t.length:0}function K(t){const r=t._readableState;v("emitReadable",r.needReadable,r.emittedReadable),r.needReadable=!1,r.emittedReadable||(v("emitReadable",r.flowing),r.emittedReadable=!0,e.nextTick(Z,t))}function Z(e){const t=e._readableState;v("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||t.errored||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,te(e)}function J(t,r){!r.readingMore&&r.constructed&&(r.readingMore=!0,e.nextTick(Y,t,r))}function Y(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){const r=t.length;if(v("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function Q(e){const t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!1===t[N]?t.flowing=!0:e.listenerCount("data")>0?e.resume():t.readableListening||(t.flowing=null)}function X(e){v("readable nexttick read 0"),e.read(0)}function ee(e,t){v("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),te(e),t.flowing&&!t.reading&&e.read(0)}function te(e){const t=e._readableState;for(v("flow",t.flowing);t.flowing&&null!==e.read(););}function re(e,t){"function"!=typeof e.read&&(e=q.wrap(e,{objectMode:!0}));const r=async function*(e,t){let r,n=L;function i(t){this===e?(n(),n=L):n=t}e.on("readable",i);const o=b(e,{writable:!1},e=>{r=e?O(r,e):null,n(),n=L});try{for(;;){const t=e.destroyed?null:e.read();if(null!==t)yield t;else{if(r)throw r;if(null===r)return;await new c(i)}}}catch(e){throw r=O(r,e),r}finally{!r&&!1===(null==t?void 0:t.destroyOnReturn)||void 0!==r&&!e._readableState.autoDestroy?(e.off("readable",i),o()):_.destroyer(e,null)}}(e,t);return r.stream=e,r}function ne(e,t){if(0===t.length)return null;let r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function ie(t){const r=t._readableState;v("endReadable",r.endEmitted),r.endEmitted||(r.ended=!0,e.nextTick(oe,r,t))}function oe(t,r){if(v("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,r.emit("end"),r.writable&&!1===r.allowHalfOpen)e.nextTick(ae,r);else if(t.autoDestroy){const e=r._writableState;(!e||e.autoDestroy&&(e.finished||!1===e.writable))&&r.destroy()}}function ae(e){e.writable&&!e.writableEnded&&!e.destroyed&&e.end()}let se;function ce(){return void 0===se&&(se={}),se}return q.prototype.read=function(e){v("read",e),void 0===e?e=NaN:r(e)||(e=i(e,10));const t=this._readableState,n=e;if(e>t.highWaterMark&&(t.highWaterMark=function(e){if(e>1073741824)throw new x("size","<= 1GiB",e);return e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,++e}(e)),0!==e&&(t.state&=-129),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return v("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?ie(this):K(this),null;if(0===(e=H(e,t))&&t.ended)return 0===t.length&&ie(this),null;let o,a=!!(64&t.state);if(v("need readable",a),(0===t.length||t.length-e<t.highWaterMark)&&(a=!0,v("length less than watermark",a)),t.ended||t.reading||t.destroyed||t.errored||!t.constructed)a=!1,v("reading, ended or constructing",a);else if(a){v("do read"),t.state|=8|B,0===t.length&&(t.state|=64);try{this._read(t.highWaterMark)}catch(e){M(this,e)}t.state&=~B,t.reading||(e=H(n,t))}return o=e>0?ne(e,t):null,null===o?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.multiAwaitDrain?t.awaitDrainWriters.clear():t.awaitDrainWriters=null),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&ie(this)),null===o||t.errorEmitted||t.closeEmitted||(t.dataEmitted=!0,this.emit("data",o)),o},q.prototype._read=function(e){throw new T("_read()")},q.prototype.pipe=function(t,r){const n=this,i=this._readableState;1===i.pipes.length&&(i.multiAwaitDrain||(i.multiAwaitDrain=!0,i.awaitDrainWriters=new u(i.awaitDrainWriters?[i.awaitDrainWriters]:[]))),i.pipes.push(t),v("pipe count=%d opts=%j",i.pipes.length,r);const o=(!r||!1!==r.end)&&t!==e.stdout&&t!==e.stderr?s:g;function a(e,r){v("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,function(){v("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),c&&t.removeListener("drain",c);t.removeListener("error",p),t.removeListener("unpipe",a),n.removeListener("end",s),n.removeListener("end",g),n.removeListener("data",f),l=!0,c&&i.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&c()}())}function s(){v("onend"),t.end()}let c;i.endEmitted?e.nextTick(o):n.once("end",o),t.on("unpipe",a);let l=!1;function d(){l||(1===i.pipes.length&&i.pipes[0]===t?(v("false write response, pause",0),i.awaitDrainWriters=t,i.multiAwaitDrain=!1):i.pipes.length>1&&i.pipes.includes(t)&&(v("false write response, pause",i.awaitDrainWriters.size),i.awaitDrainWriters.add(t)),n.pause()),c||(c=function(e,t){return function(){const r=e._readableState;r.awaitDrainWriters===t?(v("pipeOnDrain",1),r.awaitDrainWriters=null):r.multiAwaitDrain&&(v("pipeOnDrain",r.awaitDrainWriters.size),r.awaitDrainWriters.delete(t)),r.awaitDrainWriters&&0!==r.awaitDrainWriters.size||!e.listenerCount("data")||e.resume()}}(n,t),t.on("drain",c))}function f(e){v("ondata");const r=t.write(e);v("dest.write",r),!1===r&&d()}function p(e){if(v("onerror",e),g(),t.removeListener("error",p),0===t.listenerCount("error")){const r=t._writableState||t._readableState;r&&!r.errorEmitted?M(t,e):t.emit("error",e)}}function h(){t.removeListener("finish",y),g()}function y(){v("onfinish"),t.removeListener("close",h),g()}function g(){v("unpipe"),n.unpipe(t)}return n.on("data",f),m(t,"error",p),t.once("close",h),t.once("finish",y),t.emit("pipe",n),!0===t.writableNeedDrain?d():i.flowing||(v("pipe resume"),n.resume()),t},q.prototype.unpipe=function(e){const r=this._readableState;if(0===r.pipes.length)return this;if(!e){const e=r.pipes;r.pipes=[],this.pause();for(let t=0;t<e.length;t++)e[t].emit("unpipe",this,{hasUnpiped:!1});return this}const n=t(r.pipes,e);return-1===n||(r.pipes.splice(n,1),0===r.pipes.length&&this.pause(),e.emit("unpipe",this,{hasUnpiped:!1})),this},q.prototype.on=function(t,r){const n=h.prototype.on.call(this,t,r),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,v("on readable",i.length,i.reading),i.length?K(this):i.reading||e.nextTick(X,this))),n},q.prototype.addListener=q.prototype.on,q.prototype.removeListener=function(t,r){const n=h.prototype.removeListener.call(this,t,r);return"readable"===t&&e.nextTick(Q,this),n},q.prototype.off=q.prototype.removeListener,q.prototype.removeAllListeners=function(t){const r=h.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(Q,this),r},q.prototype.resume=function(){const t=this._readableState;return t.flowing||(v("resume"),t.flowing=!t.readableListening,function(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(ee,t,r))}(this,t)),t[N]=!1,this},q.prototype.pause=function(){return v("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(v("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[N]=!0,this},q.prototype.wrap=function(e){let t=!1;e.on("data",r=>{!this.push(r)&&e.pause&&(t=!0,e.pause())}),e.on("end",()=>{this.push(null)}),e.on("error",e=>{M(this,e)}),e.on("close",()=>{this.destroy()}),e.on("destroy",()=>{this.destroy()}),this._read=()=>{t&&e.resume&&(t=!1,e.resume())};const r=a(e);for(let t=1;t<r.length;t++){const n=r[t];void 0===this[n]&&"function"==typeof e[n]&&(this[n]=e[n].bind(e))}return this},q.prototype[d]=function(){return re(this)},q.prototype.iterator=function(e){return void 0!==e&&R(e,"options"),re(this,e)},o(q.prototype,{readable:{__proto__:null,get(){const e=this._readableState;return!(!e||!1===e.readable||e.destroyed||e.errorEmitted||e.endEmitted)},set(e){this._readableState&&(this._readableState.readable=!!e)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._readableState.readable||!this._readableState.destroyed&&!this._readableState.errored||this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.objectMode}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return!!this._readableState&&this._readableState.closed}},destroyed:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.destroyed},set(e){this._readableState&&(this._readableState.destroyed=e)}},readableEnded:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.endEmitted}}}),o(G.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return!1!==this[N]},set(e){this[N]=!!e}}}),q._fromList=ne,q.from=function(e,t){return C(q,e,t)},q.fromWeb=function(e,t){return ce().newStreamReadableFromReadableStream(e,t)},q.toWeb=function(e,t){return ce().newReadableStreamFromStreamReadable(e,t)},q.wrap=function(e,t){var r,n;return new q({objectMode:null===(r=null!==(n=e.readableObjectMode)&&void 0!==n?n:e.objectMode)||void 0===r||r,...t,destroy(t,r){_.destroyer(e,t),r(t)}}).wrap(e)},$y}function vg(){if(Fy)return By;Fy=1;const e=vy(),{ArrayPrototypeSlice:t,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:o,ObjectSetPrototypeOf:a,StringPrototypeToLowerCase:s,Symbol:c,SymbolHasInstance:u}=Gm();By=R,R.WritableState=k;const{EventEmitter:l}=ny(),d=Sy().Stream,{Buffer:f}=zm(),p=Ey(),{addAbortSignal:h}=jy(),{getHighWaterMark:m,getDefaultHighWaterMark:y}=Ny(),{ERR_INVALID_ARG_TYPE:g,ERR_METHOD_NOT_IMPLEMENTED:b,ERR_MULTIPLE_CALLBACK:v,ERR_STREAM_CANNOT_PIPE:w,ERR_STREAM_DESTROYED:_,ERR_STREAM_ALREADY_FINISHED:E,ERR_STREAM_NULL_VALUES:S,ERR_STREAM_WRITE_AFTER_END:O,ERR_UNKNOWN_ENCODING:A}=Jm().codes,{errorOrDestroy:T}=p;function x(){}a(R.prototype,d.prototype),a(R,d);const I=c("kOnFinished");function k(e,t,r){"boolean"!=typeof r&&(r=t instanceof _g()),this.objectMode=!(!e||!e.objectMode),r&&(this.objectMode=this.objectMode||!(!e||!e.writableObjectMode)),this.highWaterMark=e?m(this,e,"writableHighWaterMark",r):y(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const n=!(!e||!1!==e.decodeStrings);this.decodeStrings=!n,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=L.bind(void 0,t),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,j(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!e||!1!==e.emitClose,this.autoDestroy=!e||!1!==e.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[I]=[]}function j(e){e.buffered=[],e.bufferedIndex=0,e.allBuffers=!0,e.allNoop=!0}function R(e){const t=this instanceof _g();if(!t&&!n(R,this))return new R(e);this._writableState=new k(e,this,t),e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&h(e.signal,this)),d.call(this,e),p.construct(this,()=>{const e=this._writableState;e.writing||B(this,e),z(this,e)})}function N(t,r,n,i){const o=t._writableState;if("function"==typeof n)i=n,n=o.defaultEncoding;else{if(n){if("buffer"!==n&&!f.isEncoding(n))throw new A(n)}else n=o.defaultEncoding;"function"!=typeof i&&(i=x)}if(null===r)throw new S;if(!o.objectMode)if("string"==typeof r)!1!==o.decodeStrings&&(r=f.from(r,n),n="buffer");else if(r instanceof f)n="buffer";else{if(!d._isUint8Array(r))throw new g("chunk",["string","Buffer","Uint8Array"],r);r=d._uint8ArrayToBuffer(r),n="buffer"}let a;return o.ending?a=new O:o.destroyed&&(a=new _("write")),a?(e.nextTick(i,a),T(t,a,!0),a):(o.pendingcb++,function(e,t,r,n,i){const o=t.objectMode?1:r.length;t.length+=o;const a=t.length<t.highWaterMark;a||(t.needDrain=!0);t.writing||t.corked||t.errored||!t.constructed?(t.buffered.push({chunk:r,encoding:n,callback:i}),t.allBuffers&&"buffer"!==n&&(t.allBuffers=!1),t.allNoop&&i!==x&&(t.allNoop=!1)):(t.writelen=o,t.writecb=i,t.writing=!0,t.sync=!0,e._write(r,n,t.onwrite),t.sync=!1);return a&&!t.errored&&!t.destroyed}(t,o,r,n,i))}function P(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new _("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function C(e,t,r,n){--t.pendingcb,n(r),D(t),T(e,r)}function L(t,r){const n=t._writableState,i=n.sync,o=n.writecb;"function"==typeof o?(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,r?(r.stack,n.errored||(n.errored=r),t._readableState&&!t._readableState.errored&&(t._readableState.errored=r),i?e.nextTick(C,t,n,r,o):C(t,n,r,o)):(n.buffered.length>n.bufferedIndex&&B(t,n),i?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===o?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:o,stream:t,state:n},e.nextTick(M,n.afterWriteTickInfo)):$(t,n,1,o))):T(t,new v)}function M({stream:e,state:t,count:r,cb:n}){return t.afterWriteTickInfo=null,$(e,t,r,n)}function $(e,t,r,n){for(!t.ending&&!e.destroyed&&0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"));r-- >0;)t.pendingcb--,n();t.destroyed&&D(t),z(e,t)}function D(e){if(e.writing)return;for(let r=e.bufferedIndex;r<e.buffered.length;++r){var t;const{chunk:n,callback:i}=e.buffered[r],o=e.objectMode?1:n.length;e.length-=o,i(null!==(t=e.errored)&&void 0!==t?t:new _("write"))}const r=e[I].splice(0);for(let t=0;t<r.length;t++){var n;r[t](null!==(n=e.errored)&&void 0!==n?n:new _("end"))}j(e)}function B(e,r){if(r.corked||r.bufferProcessing||r.destroyed||!r.constructed)return;const{buffered:n,bufferedIndex:i,objectMode:o}=r,a=n.length-i;if(!a)return;let s=i;if(r.bufferProcessing=!0,a>1&&e._writev){r.pendingcb-=a-1;const i=r.allNoop?x:e=>{for(let t=s;t<n.length;++t)n[t].callback(e)},o=r.allNoop&&0===s?n:t(n,s);o.allBuffers=r.allBuffers,P(e,r,!0,r.length,o,"",i),j(r)}else{do{const{chunk:t,encoding:i,callback:a}=n[s];n[s++]=null;P(e,r,!1,o?1:t.length,t,i,a)}while(s<n.length&&!r.writing);s===n.length?j(r):s>256?(n.splice(0,s),r.bufferedIndex=0):r.bufferedIndex=s}r.bufferProcessing=!1}function F(e){return e.ending&&!e.destroyed&&e.constructed&&0===e.length&&!e.errored&&0===e.buffered.length&&!e.finished&&!e.writing&&!e.errorEmitted&&!e.closeEmitted}function U(t,r){r.prefinished||r.finalCalled||("function"!=typeof t._final||r.destroyed?(r.prefinished=!0,t.emit("prefinish")):(r.finalCalled=!0,function(t,r){let n=!1;function i(i){if(n)T(t,null!=i?i:v());else if(n=!0,r.pendingcb--,i){const e=r[I].splice(0);for(let t=0;t<e.length;t++)e[t](i);T(t,i,r.sync)}else F(r)&&(r.prefinished=!0,t.emit("prefinish"),r.pendingcb++,e.nextTick(G,t,r))}r.sync=!0,r.pendingcb++;try{t._final(i)}catch(e){i(e)}r.sync=!1}(t,r)))}function z(t,r,n){F(r)&&(U(t,r),0===r.pendingcb&&(n?(r.pendingcb++,e.nextTick((e,t)=>{F(t)?G(e,t):t.pendingcb--},t,r)):F(r)&&(r.pendingcb++,G(t,r))))}function G(e,t){t.pendingcb--,t.finished=!0;const r=t[I].splice(0);for(let e=0;e<r.length;e++)r[e]();if(e.emit("finish"),t.autoDestroy){const t=e._readableState;(!t||t.autoDestroy&&(t.endEmitted||!1===t.readable))&&e.destroy()}}k.prototype.getBuffer=function(){return t(this.buffered,this.bufferedIndex)},i(k.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}}),i(R,u,{__proto__:null,value:function(e){return!!n(this,e)||this===R&&(e&&e._writableState instanceof k)}}),R.prototype.pipe=function(){T(this,new w)},R.prototype.write=function(e,t,r){return!0===N(this,e,t,r)},R.prototype.cork=function(){this._writableState.corked++},R.prototype.uncork=function(){const e=this._writableState;e.corked&&(e.corked--,e.writing||B(this,e))},R.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=s(e)),!f.isEncoding(e))throw new A(e);return this._writableState.defaultEncoding=e,this},R.prototype._write=function(e,t,r){if(!this._writev)throw new b("_write()");this._writev([{chunk:e,encoding:t}],r)},R.prototype._writev=null,R.prototype.end=function(t,n,i){const o=this._writableState;let a;if("function"==typeof t?(i=t,t=null,n=null):"function"==typeof n&&(i=n,n=null),null!=t){const e=N(this,t,n);e instanceof r&&(a=e)}return o.corked&&(o.corked=1,this.uncork()),a||(o.errored||o.ending?o.finished?a=new E("end"):o.destroyed&&(a=new _("end")):(o.ending=!0,z(this,o,!0),o.ended=!0)),"function"==typeof i&&(a||o.finished?e.nextTick(i,a):o[I].push(i)),this},o(R.prototype,{closed:{__proto__:null,get(){return!!this._writableState&&this._writableState.closed}},destroyed:{__proto__:null,get(){return!!this._writableState&&this._writableState.destroyed},set(e){this._writableState&&(this._writableState.destroyed=e)}},writable:{__proto__:null,get(){const e=this._writableState;return!(!e||!1===e.writable||e.destroyed||e.errored||e.ending||e.ended)},set(e){this._writableState&&(this._writableState.writable=!!e)}},writableFinished:{__proto__:null,get(){return!!this._writableState&&this._writableState.finished}},writableObjectMode:{__proto__:null,get(){return!!this._writableState&&this._writableState.objectMode}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return!!this._writableState&&this._writableState.ending}},writableNeedDrain:{__proto__:null,get(){const e=this._writableState;return!!e&&(!e.destroyed&&!e.ending&&e.needDrain)}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._writableState.writable||!this._writableState.destroyed&&!this._writableState.errored||this._writableState.finished)}}});const q=p.destroy;let V;function W(){return void 0===V&&(V={}),V}return R.prototype.destroy=function(t,r){const n=this._writableState;return!n.destroyed&&(n.bufferedIndex<n.buffered.length||n[I].length)&&e.nextTick(D,n),q.call(this,t,r),this},R.prototype._undestroy=p.undestroy,R.prototype._destroy=function(e,t){t(e)},R.prototype[l.captureRejectionSymbol]=function(e){this.destroy(e)},R.fromWeb=function(e,t){return W().newStreamWritableFromWritableStream(e,t)},R.toWeb=function(e){return W().newWritableStreamFromStreamWritable(e)},By}function wg(){if(zy)return Uy;zy=1;const e=vy(),t=zm(),{isReadable:r,isWritable:n,isIterable:i,isNodeStream:o,isReadableNodeStream:a,isWritableNodeStream:s,isDuplexNodeStream:c,isReadableStream:u,isWritableStream:l}=wy(),d=_y(),{AbortError:f,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:h}}=Jm(),{destroyer:m}=Ey(),y=_g(),g=bg(),b=vg(),{createDeferredPromise:v}=iy(),w=gg(),_=globalThis.Blob||t.Blob,E=void 0!==_?function(e){return e instanceof _}:function(e){return!1},S=globalThis.AbortController||Xm().AbortController,{FunctionPrototypeCall:O}=Gm();class A extends y{constructor(e){super(e),!1===(null==e?void 0:e.readable)&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===(null==e?void 0:e.writable)&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}function T(e){const t=e.readable&&"function"!=typeof e.readable.read?g.wrap(e.readable):e.readable,i=e.writable;let o,a,s,c,u,l=!!r(t),p=!!n(i);function h(e){const t=c;c=null,t?t(e):e&&u.destroy(e)}return u=new A({readableObjectMode:!(null==t||!t.readableObjectMode),writableObjectMode:!(null==i||!i.writableObjectMode),readable:l,writable:p}),p&&(d(i,e=>{p=!1,e&&m(t,e),h(e)}),u._write=function(e,t,r){i.write(e,t)?r():o=r},u._final=function(e){i.end(),a=e},i.on("drain",function(){if(o){const e=o;o=null,e()}}),i.on("finish",function(){if(a){const e=a;a=null,e()}})),l&&(d(t,e=>{l=!1,e&&m(t,e),h(e)}),t.on("readable",function(){if(s){const e=s;s=null,e()}}),t.on("end",function(){u.push(null)}),u._read=function(){for(;;){const e=t.read();if(null===e)return void(s=u._read);if(!u.push(e))return}}),u._destroy=function(e,r){e||null===c||(e=new f),s=null,o=null,a=null,null===c?r(e):(c=r,m(i,e),m(t,e))},u}return Uy=function t(r,n){if(c(r))return r;if(a(r))return T({readable:r});if(s(r))return T({writable:r});if(o(r))return T({writable:!1,readable:!1});if(u(r))return T({readable:g.fromWeb(r)});if(l(r))return T({writable:b.fromWeb(r)});if("function"==typeof r){const{value:t,write:o,final:a,destroy:s}=function(t){let{promise:r,resolve:n}=v();const i=new S,o=i.signal,a=t(async function*(){for(;;){const t=r;r=null;const{chunk:i,done:a,cb:s}=await t;if(e.nextTick(s),a)return;if(o.aborted)throw new f(void 0,{cause:o.reason});({promise:r,resolve:n}=v()),yield i}}(),{signal:o});return{value:a,write(e,t,r){const i=n;n=null,i({chunk:e,done:!1,cb:r})},final(e){const t=n;n=null,t({done:!0,cb:e})},destroy(e,t){i.abort(),t(e)}}}(r);if(i(t))return w(A,t,{objectMode:!0,write:o,final:a,destroy:s});const c=null==t?void 0:t.then;if("function"==typeof c){let r;const n=O(c,t,e=>{if(null!=e)throw new h("nully","body",e)},e=>{m(r,e)});return r=new A({objectMode:!0,readable:!1,write:o,final(t){a(async()=>{try{await n,e.nextTick(t,null)}catch(r){e.nextTick(t,r)}})},destroy:s})}throw new h("Iterable, AsyncIterable or AsyncFunction",n,t)}if(E(r))return t(r.arrayBuffer());if(i(r))return w(A,r,{objectMode:!0,writable:!1});if(u(null==r?void 0:r.readable)&&l(null==r?void 0:r.writable))return A.fromWeb(r);if("object"==typeof(null==r?void 0:r.writable)||"object"==typeof(null==r?void 0:r.readable)){return T({readable:null!=r&&r.readable?a(null==r?void 0:r.readable)?null==r?void 0:r.readable:t(r.readable):void 0,writable:null!=r&&r.writable?s(null==r?void 0:r.writable)?null==r?void 0:r.writable:t(r.writable):void 0})}const d=null==r?void 0:r.then;if("function"==typeof d){let e;return O(d,r,t=>{null!=t&&e.push(t),e.push(null)},t=>{m(e,t)}),e=new A({objectMode:!0,writable:!1,read(){}})}throw new p(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],r)},Uy}function _g(){if(qy)return Gy;qy=1;const{ObjectDefineProperties:e,ObjectGetOwnPropertyDescriptor:t,ObjectKeys:r,ObjectSetPrototypeOf:n}=Gm();Gy=a;const i=bg(),o=vg();n(a.prototype,i.prototype),n(a,i);{const e=r(o.prototype);for(let t=0;t<e.length;t++){const r=e[t];a.prototype[r]||(a.prototype[r]=o.prototype[r])}}function a(e){if(!(this instanceof a))return new a(e);i.call(this,e),o.call(this,e),e?(this.allowHalfOpen=!1!==e.allowHalfOpen,!1===e.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===e.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}let s,c;function u(){return void 0===s&&(s={}),s}return e(a.prototype,{writable:{__proto__:null,...t(o.prototype,"writable")},writableHighWaterMark:{__proto__:null,...t(o.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...t(o.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...t(o.prototype,"writableBuffer")},writableLength:{__proto__:null,...t(o.prototype,"writableLength")},writableFinished:{__proto__:null,...t(o.prototype,"writableFinished")},writableCorked:{__proto__:null,...t(o.prototype,"writableCorked")},writableEnded:{__proto__:null,...t(o.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...t(o.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set(e){this._readableState&&this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}}),a.fromWeb=function(e,t){return u().newStreamDuplexFromReadableWritablePair(e,t)},a.toWeb=function(e){return u().newReadableWritablePairFromDuplex(e)},a.from=function(e){return c||(c=wg()),c(e,"body")},Gy}function Eg(){if(Wy)return Vy;Wy=1;const{ObjectSetPrototypeOf:e,Symbol:t}=Gm();Vy=a;const{ERR_METHOD_NOT_IMPLEMENTED:r}=Jm().codes,n=_g(),{getHighWaterMark:i}=Ny();e(a.prototype,n.prototype),e(a,n);const o=t("kCallback");function a(e){if(!(this instanceof a))return new a(e);const t=e?i(this,e,"readableHighWaterMark",!0):null;0===t&&(e={...e,highWaterMark:null,readableHighWaterMark:t,writableHighWaterMark:e.writableHighWaterMark||0}),n.call(this,e),this._readableState.sync=!1,this[o]=null,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",c)}function s(e){"function"!=typeof this._flush||this.destroyed?(this.push(null),e&&e()):this._flush((t,r)=>{t?e?e(t):this.destroy(t):(null!=r&&this.push(r),this.push(null),e&&e())})}function c(){this._final!==s&&s.call(this)}return a.prototype._final=s,a.prototype._transform=function(e,t,n){throw new r("_transform()")},a.prototype._write=function(e,t,r){const n=this._readableState,i=this._writableState,a=n.length;this._transform(e,t,(e,t)=>{e?r(e):(null!=t&&this.push(t),i.ended||a===n.length||n.length<n.highWaterMark?r():this[o]=r)})},a.prototype._read=function(){if(this[o]){const e=this[o];this[o]=null,e()}},Vy}function Sg(){if(Ky)return Hy;Ky=1;const{ObjectSetPrototypeOf:e}=Gm();Hy=r;const t=Eg();function r(e){if(!(this instanceof r))return new r(e);t.call(this,e)}return e(r.prototype,t.prototype),e(r,t),r.prototype._transform=function(e,t,r){r(null,e)},Hy}function Og(){if(Jy)return Zy;Jy=1;const e=vy(),{ArrayIsArray:t,Promise:r,SymbolAsyncIterator:n,SymbolDispose:i}=Gm(),o=_y(),{once:a}=iy(),s=Ey(),c=_g(),{aggregateTwoErrors:u,codes:{ERR_INVALID_ARG_TYPE:l,ERR_INVALID_RETURN_VALUE:d,ERR_MISSING_ARGS:f,ERR_STREAM_DESTROYED:p,ERR_STREAM_PREMATURE_CLOSE:h},AbortError:m}=Jm(),{validateFunction:y,validateAbortSignal:g}=cy(),{isIterable:b,isReadable:v,isReadableNodeStream:w,isNodeStream:_,isTransformStream:E,isWebStream:S,isReadableStream:O,isReadableFinished:A}=wy(),T=globalThis.AbortController||Xm().AbortController;let x,I,k;function j(e,t,r){let n=!1;e.on("close",()=>{n=!0});return{destroy:t=>{n||(n=!0,s.destroyer(e,t||new p("pipe")))},cleanup:o(e,{readable:t,writable:r},e=>{n=!e})}}function R(e){if(b(e))return e;if(w(e))return async function*(e){I||(I=bg());yield*I.prototype[n].call(e)}(e);throw new l("val",["Readable","Iterable","AsyncIterable"],e)}async function N(e,t,n,{end:i}){let a,s=null;const c=e=>{if(e&&(a=e),s){const e=s;s=null,e()}},l=()=>new r((e,t)=>{a?t(a):s=()=>{a?t(a):e()}});t.on("drain",c);const d=o(t,{readable:!1},c);try{t.writableNeedDrain&&await l();for await(const r of e)t.write(r)||await l();i&&(t.end(),await l()),n()}catch(e){n(a!==e?u(a,e):e)}finally{d(),t.off("drain",c)}}async function P(e,t,r,{end:n}){E(t)&&(t=t.writable);const i=t.getWriter();try{for await(const t of e)await i.ready,i.write(t).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(e){try{await i.abort(e),r(e)}catch(e){r(e)}}}function C(r,n,o){if(1===r.length&&t(r[0])&&(r=r[0]),r.length<2)throw new f("streams");const a=new T,s=a.signal,u=null==o?void 0:o.signal,p=[];function h(){B(new m)}let y,A,I;g(u,"options.signal"),k=k||iy().addAbortListener,u&&(y=k(u,h));const C=[];let M,$=0;function D(e){B(e,0===--$)}function B(t,r){var o;if(!t||A&&"ERR_STREAM_PREMATURE_CLOSE"!==A.code||(A=t),A||r){for(;C.length;)C.shift()(A);null===(o=y)||void 0===o||o[i](),a.abort(),r&&(A||p.forEach(e=>e()),e.nextTick(n,A,I))}}for(let z=0;z<r.length;z++){const G=r[z],q=z<r.length-1,V=z>0,W=q||!1!==(null==o?void 0:o.end),H=z===r.length-1;if(_(G)){if(W){const{destroy:Z,cleanup:J}=j(G,q,V);C.push(Z),v(G)&&H&&p.push(J)}function K(e){e&&"AbortError"!==e.name&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code&&D(e)}G.on("error",K),v(G)&&H&&p.push(()=>{G.removeListener("error",K)})}if(0===z)if("function"==typeof G){if(M=G({signal:s}),!b(M))throw new d("Iterable, AsyncIterable or Stream","source",M)}else M=b(G)||w(G)||E(G)?G:c.from(G);else if("function"==typeof G){var F;if(E(M))M=R(null===(F=M)||void 0===F?void 0:F.readable);else M=R(M);if(M=G(M,{signal:s}),q){if(!b(M,!0))throw new d("AsyncIterable",`transform[${z-1}]`,M)}else{var U;x||(x=Sg());const Y=new x({objectMode:!0}),Q=null===(U=M)||void 0===U?void 0:U.then;if("function"==typeof Q)$++,Q.call(M,t=>{I=t,null!=t&&Y.write(t),W&&Y.end(),e.nextTick(D)},t=>{Y.destroy(t),e.nextTick(D,t)});else if(b(M,!0))$++,N(M,Y,D,{end:W});else{if(!O(M)&&!E(M))throw new d("AsyncIterable or Promise","destination",M);{const te=M.readable||M;$++,N(te,Y,D,{end:W})}}M=Y;const{destroy:X,cleanup:ee}=j(M,!1,!0);C.push(X),H&&p.push(ee)}}else if(_(G)){if(w(M)){$+=2;const re=L(M,G,D,{end:W});v(G)&&H&&p.push(re)}else if(E(M)||O(M)){const ne=M.readable||M;$++,N(ne,G,D,{end:W})}else{if(!b(M))throw new l("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],M);$++,N(M,G,D,{end:W})}M=G}else if(S(G)){if(w(M))$++,P(R(M),G,D,{end:W});else if(O(M)||b(M))$++,P(M,G,D,{end:W});else{if(!E(M))throw new l("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],M);$++,P(M.readable,G,D,{end:W})}M=G}else M=c.from(G)}return(null!=s&&s.aborted||null!=u&&u.aborted)&&e.nextTick(h),M}function L(t,r,n,{end:i}){let a=!1;if(r.on("close",()=>{a||n(new h)}),t.pipe(r,{end:!1}),i){function s(){a=!0,r.end()}A(t)?e.nextTick(s):t.once("end",s)}else n();return o(t,{readable:!0,writable:!1},e=>{const r=t._readableState;e&&"ERR_STREAM_PREMATURE_CLOSE"===e.code&&r&&r.ended&&!r.errored&&!r.errorEmitted?t.once("end",n).once("error",n):n(e)}),o(r,{readable:!1,writable:!0},n)}return Zy={pipelineImpl:C,pipeline:function(...e){return C(e,a(function(e){return y(e[e.length-1],"streams[stream.length - 1]"),e.pop()}(e)))}}}function Ag(){if(Qy)return Yy;Qy=1;const{pipeline:e}=Og(),t=_g(),{destroyer:r}=Ey(),{isNodeStream:n,isReadable:i,isWritable:o,isWebStream:a,isTransformStream:s,isWritableStream:c,isReadableStream:u}=wy(),{AbortError:l,codes:{ERR_INVALID_ARG_VALUE:d,ERR_MISSING_ARGS:f}}=Jm(),p=_y();return Yy=function(...h){if(0===h.length)throw new f("streams");if(1===h.length)return t.from(h[0]);const m=[...h];if("function"==typeof h[0]&&(h[0]=t.from(h[0])),"function"==typeof h[h.length-1]){const e=h.length-1;h[e]=t.from(h[e])}for(let e=0;e<h.length;++e)if(n(h[e])||a(h[e])){if(e<h.length-1&&!(i(h[e])||u(h[e])||s(h[e])))throw new d(`streams[${e}]`,m[e],"must be readable");if(e>0&&!(o(h[e])||c(h[e])||s(h[e])))throw new d(`streams[${e}]`,m[e],"must be writable")}let y,g,b,v,w;const _=h[0],E=e(h,function(e){const t=v;v=null,t?t(e):e?w.destroy(e):O||S||w.destroy()}),S=!!(o(_)||c(_)||s(_)),O=!!(i(E)||u(E)||s(E));if(w=new t({writableObjectMode:!(null==_||!_.writableObjectMode),readableObjectMode:!(null==E||!E.readableObjectMode),writable:S,readable:O}),S){if(n(_))w._write=function(e,t,r){_.write(e,t)?r():y=r},w._final=function(e){_.end(),g=e},_.on("drain",function(){if(y){const e=y;y=null,e()}});else if(a(_)){const e=(s(_)?_.writable:_).getWriter();w._write=async function(t,r,n){try{await e.ready,e.write(t).catch(()=>{}),n()}catch(e){n(e)}},w._final=async function(t){try{await e.ready,e.close().catch(()=>{}),g=t}catch(e){t(e)}}}const e=s(E)?E.readable:E;p(e,()=>{if(g){const e=g;g=null,e()}})}if(O)if(n(E))E.on("readable",function(){if(b){const e=b;b=null,e()}}),E.on("end",function(){w.push(null)}),w._read=function(){for(;;){const e=E.read();if(null===e)return void(b=w._read);if(!w.push(e))return}};else if(a(E)){const e=(s(E)?E.readable:E).getReader();w._read=async function(){for(;;)try{const{value:t,done:r}=await e.read();if(!w.push(t))return;if(r)return void w.push(null)}catch{return}}}return w._destroy=function(e,t){e||null===v||(e=new l),b=null,y=null,g=null,null===v?t(e):(v=t,n(E)&&r(E,e))},w},Yy}function Tg(){if(tg)return eg;tg=1;const{ArrayPrototypePop:e,Promise:t}=Gm(),{isIterable:r,isNodeStream:n,isWebStream:i}=wy(),{pipelineImpl:o}=Og(),{finished:a}=_y();return xg(),eg={finished:a,pipeline:function(...a){return new t((t,s)=>{let c,u;const l=a[a.length-1];if(l&&"object"==typeof l&&!n(l)&&!r(l)&&!i(l)){const t=e(a);c=t.signal,u=t.end}o(a,(e,r)=>{e?s(e):t(r)},{signal:c,end:u})})}},eg}function xg(){if(rg)return Dm.exports;rg=1;const{Buffer:e}=zm(),{ObjectDefineProperty:t,ObjectKeys:r,ReflectApply:n}=Gm(),{promisify:{custom:i}}=iy(),{streamReturningOperators:o,promiseReturningOperators:a}=function(){if(Xy)return sy;Xy=1;const e=globalThis.AbortController||Xm().AbortController,{codes:{ERR_INVALID_ARG_VALUE:t,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:i},AbortError:o}=Jm(),{validateAbortSignal:a,validateInteger:s,validateObject:c}=cy(),u=Gm().Symbol("kWeak"),l=Gm().Symbol("kResistStopPropagation"),{finished:d}=_y(),f=Ag(),{addAbortSignalNoValidate:p}=jy(),{isWritable:h,isNodeStream:m}=wy(),{deprecate:y}=iy(),{ArrayPrototypePush:g,Boolean:b,MathFloor:v,Number:w,NumberIsNaN:_,Promise:E,PromiseReject:S,PromiseResolve:O,PromisePrototypeThen:A,Symbol:T}=Gm(),x=T("kEmpty"),I=T("kEof");function k(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);null!=t&&c(t,"options"),null!=(null==t?void 0:t.signal)&&a(t.signal,"options.signal");let n=1;null!=(null==t?void 0:t.concurrency)&&(n=v(t.concurrency));let i=n-1;return null!=(null==t?void 0:t.highWaterMark)&&(i=v(t.highWaterMark)),s(n,"options.concurrency",1),s(i,"options.highWaterMark",0),i+=n,async function*(){const r=iy().AbortSignalAny([null==t?void 0:t.signal].filter(b)),a=this,s=[],c={signal:r};let u,l,d=!1,f=0;function p(){d=!0,h()}function h(){f-=1,m()}function m(){l&&!d&&f<n&&s.length<i&&(l(),l=null)}!async function(){try{for await(let t of a){if(d)return;if(r.aborted)throw new o;try{if(t=e(t,c),t===x)continue;t=O(t)}catch(e){t=S(e)}f+=1,A(t,h,p),s.push(t),u&&(u(),u=null),!d&&(s.length>=i||f>=n)&&await new E(e=>{l=e})}s.push(I)}catch(e){const t=S(e);A(t,h,p),s.push(t)}finally{d=!0,u&&(u(),u=null)}}();try{for(;;){for(;s.length>0;){const e=await s[0];if(e===I)return;if(r.aborted)throw new o;e!==x&&(yield e),s.shift(),m()}await new E(e=>{u=e})}}finally{d=!0,l&&(l(),l=null)}}.call(this)}async function j(e,t=void 0){for await(const r of R.call(this,e,t))return!0;return!1}function R(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);return k.call(this,async function(t,r){return await e(t,r)?t:x},t)}class N extends n{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function P(e){if(e=w(e),_(e))return 0;if(e<0)throw new i("number",">= 0",e);return e}return sy.streamReturningOperators={asIndexedPairs:y(function(e=void 0){return null!=e&&c(e,"options"),null!=(null==e?void 0:e.signal)&&a(e.signal,"options.signal"),async function*(){let t=0;for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new o({cause:e.signal.reason});yield[t++,n]}}.call(this)},"readable.asIndexedPairs will be removed in a future version."),drop:function(e,t=void 0){return null!=t&&c(t,"options"),null!=(null==t?void 0:t.signal)&&a(t.signal,"options.signal"),e=P(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new o;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new o;e--<=0&&(yield r)}}.call(this)},filter:R,flatMap:function(e,t){const r=k.call(this,e,t);return async function*(){for await(const e of r)yield*e}.call(this)},map:k,take:function(e,t=void 0){return null!=t&&c(t,"options"),null!=(null==t?void 0:t.signal)&&a(t.signal,"options.signal"),e=P(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new o;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new o;if(e-- >0&&(yield r),e<=0)return}}.call(this)},compose:function(e,r){if(null!=r&&c(r,"options"),null!=(null==r?void 0:r.signal)&&a(r.signal,"options.signal"),m(e)&&!h(e))throw new t("stream",e,"must be writable");const n=f(this,e);return null!=r&&r.signal&&p(r.signal,n),n}},sy.promiseReturningOperators={every:async function(e,t=void 0){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);return!await j.call(this,async(...t)=>!await e(...t),t)},forEach:async function(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);for await(const r of k.call(this,async function(t,r){return await e(t,r),x},t));},reduce:async function(t,n,i){var s;if("function"!=typeof t)throw new r("reducer",["Function","AsyncFunction"],t);null!=i&&c(i,"options"),null!=(null==i?void 0:i.signal)&&a(i.signal,"options.signal");let f=arguments.length>1;if(null!=i&&null!==(s=i.signal)&&void 0!==s&&s.aborted){const e=new o(void 0,{cause:i.signal.reason});throw this.once("error",()=>{}),await d(this.destroy(e)),e}const p=new e,h=p.signal;if(null!=i&&i.signal){const e={once:!0,[u]:this,[l]:!0};i.signal.addEventListener("abort",()=>p.abort(),e)}let m=!1;try{for await(const e of this){var y;if(m=!0,null!=i&&null!==(y=i.signal)&&void 0!==y&&y.aborted)throw new o;f?n=await t(n,e,{signal:h}):(n=e,f=!0)}if(!m&&!f)throw new N}finally{p.abort()}return n},toArray:async function(e){null!=e&&c(e,"options"),null!=(null==e?void 0:e.signal)&&a(e.signal,"options.signal");const t=[];for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new o(void 0,{cause:e.signal.reason});g(t,n)}return t},some:j,find:async function(e,t){for await(const r of R.call(this,e,t))return r}},sy}(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:s}}=Jm(),c=Ag(),{setDefaultHighWaterMark:u,getDefaultHighWaterMark:l}=Ny(),{pipeline:d}=Og(),{destroyer:f}=Ey(),p=_y(),h=Tg(),m=wy(),y=Dm.exports=Sy().Stream;y.isDestroyed=m.isDestroyed,y.isDisturbed=m.isDisturbed,y.isErrored=m.isErrored,y.isReadable=m.isReadable,y.isWritable=m.isWritable,y.Readable=bg();for(const b of r(o)){const v=o[b];function w(...e){if(new.target)throw s();return y.Readable.from(n(v,this,e))}t(w,"name",{__proto__:null,value:v.name}),t(w,"length",{__proto__:null,value:v.length}),t(y.Readable.prototype,b,{__proto__:null,value:w,enumerable:!1,configurable:!0,writable:!0})}for(const _ of r(a)){const E=a[_];function S(...e){if(new.target)throw s();return n(E,this,e)}t(S,"name",{__proto__:null,value:E.name}),t(S,"length",{__proto__:null,value:E.length}),t(y.Readable.prototype,_,{__proto__:null,value:S,enumerable:!1,configurable:!0,writable:!0})}y.Writable=vg(),y.Duplex=_g(),y.Transform=Eg(),y.PassThrough=Sg(),y.pipeline=d;const{addAbortSignal:g}=jy();return y.addAbortSignal=g,y.finished=p,y.destroy=f,y.compose=c,y.setDefaultHighWaterMark=u,y.getDefaultHighWaterMark=l,t(y,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:()=>h}),t(d,i,{__proto__:null,enumerable:!0,get:()=>h.pipeline}),t(p,i,{__proto__:null,enumerable:!0,get:()=>h.finished}),y.Stream=y,y._isUint8Array=function(e){return e instanceof Uint8Array},y._uint8ArrayToBuffer=function(t){return e.from(t.buffer,t.byteOffset,t.byteLength)},Dm.exports}function Ig(){if(sg)return ag;sg=1;const e=Symbol.for("pino.metadata"),t=function(){if(og)return ig;og=1;const{Transform:e}=f,{StringDecoder:t}=yg(),r=Symbol("last"),n=Symbol("decoder");function i(e,t,i){let o;if(this.overflow){if(o=this[n].write(e).split(this.matcher),1===o.length)return i();o.shift(),this.overflow=!1}else this[r]+=this[n].write(e),o=this[r].split(this.matcher);this[r]=o.pop();for(let e=0;e<o.length;e++)try{a(this,this.mapper(o[e]))}catch(e){return i(e)}this.overflow=this[r].length>this.maxLength,!this.overflow||this.skipOverflow?i():i(new Error("maximum buffer reached"))}function o(e){if(this[r]+=this[n].end(),this[r])try{a(this,this.mapper(this[r]))}catch(t){return e(t)}e()}function a(e,t){void 0!==t&&e.push(t)}function s(e){return e}return ig=function(a,c,u){switch(a=a||/\r?\n/,c=c||s,u=u||{},arguments.length){case 1:"function"==typeof a?(c=a,a=/\r?\n/):"object"!=typeof a||a instanceof RegExp||a[Symbol.split]||(u=a,a=/\r?\n/);break;case 2:"function"==typeof a?(u=c,c=a,a=/\r?\n/):"object"==typeof c&&(u=c,c=s)}(u=Object.assign({},u)).autoDestroy=!0,u.transform=i,u.flush=o,u.readableObjectMode=!0;const l=new e(u);return l[r]="",l[n]=new t("utf8"),l.matcher=a,l.mapper=c,l.maxLength=u.maxLength,l.skipOverflow=u.skipOverflow||!1,l.overflow=!1,l._destroy=function(e,t){this._writableState.errorEmitted=!1,t(e)},l},ig}(),{Duplex:r}=f,{parentPort:n,workerData:i}=p;function o(e,t){process.nextTick(t,e)}return ag=function(a,s={}){const c=!0===s.expectPinoConfig&&!0===i?.workerData?.pinoWillSendConfig,u="lines"===s.parse,l="function"==typeof s.parseLine?s.parseLine:JSON.parse,d=s.close||o,f=t(function(t){let r;try{r=l(t)}catch(e){return void this.emit("unknown",t,e)}if(null!==r)return"object"!=typeof r&&(r={data:r,time:Date.now()}),f[e]&&(f.lastTime=r.time,f.lastLevel=r.level,f.lastObj=r),u?t:r;this.emit("unknown",t,"Null value ignored")},{autoDestroy:!0});if(f._destroy=function(e,t){const r=d(e,t);r&&"function"==typeof r.then&&r.then(t,t)},!0===s.expectPinoConfig&&!0!==i?.workerData?.pinoWillSendConfig&&setImmediate(()=>{f.emit("error",new Error("This transport is not compatible with the current version of pino. Please upgrade pino to the latest version."))}),!1!==s.metadata&&(f[e]=!0,f.lastTime=0,f.lastLevel=0,f.lastObj=null),c){let e={};const t=function(){let e,t;const r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r}();return n.on("message",function r(i){"PINO_CONFIG"===i.code&&(e=i.config,t.resolve(),n.off("message",r))}),Object.defineProperties(f,{levels:{get:()=>e.levels},messageKey:{get:()=>e.messageKey},errorKey:{get:()=>e.errorKey}}),t.then(p)}return p();function p(){let e=a(f);if(e&&"function"==typeof e.catch)e.catch(e=>{f.destroy(e)}),e=null;else if(s.enablePipelining&&e)return r.from({writable:f,readable:e});return f}},ag}function kg(){return ug?cg:(ug=1,cg={DATE_FORMAT:"yyyy-mm-dd HH:MM:ss.l o",DATE_FORMAT_SIMPLE:"HH:MM:ss.l",ERROR_LIKE_KEYS:["err","error"],MESSAGE_KEY:"msg",LEVEL_KEY:"level",LEVEL_LABEL:"levelLabel",TIMESTAMP_KEY:"time",LEVELS:{default:"USERLVL",60:"FATAL",50:"ERROR",40:"WARN",30:"INFO",20:"DEBUG",10:"TRACE"},LEVEL_NAMES:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},LOGGER_KEYS:["pid","hostname","name","level","time","timestamp","caller"]})}function jg(){if(dg)return lg;dg=1,lg=function(r,n,i){const o=r?n||e:Object.assign({},e,n),a=r?i||t:Object.assign({},t,i);return function(e){let t="default";return t=Number.isInteger(+e)?Object.prototype.hasOwnProperty.call(o,e)?e:t:Object.prototype.hasOwnProperty.call(a,e.toLowerCase())?a[e.toLowerCase()]:t,[o[t],t]}};const{LEVELS:e,LEVEL_NAMES:t}=kg();return lg}function Rg(){if(pg)return fg;pg=1;const e=e=>e,t={default:e,60:e,50:e,40:e,30:e,20:e,10:e,message:e,greyMessage:e},{createColors:r}=wm(),n=jg(),i=r({useColor:!0}),{white:o,bgRed:a,red:s,yellow:c,green:u,blue:l,gray:d,cyan:f}=i,p={default:o,60:a,50:s,40:c,30:u,20:l,10:d,message:f,greyMessage:d};function h(e){return function(t,r,{customLevels:i,customLevelNames:o}={}){const[a,s]=n(e,i,o)(t);return Object.prototype.hasOwnProperty.call(r,s)?r[s](a):r.default(a)}}function m(e,t){const r=function(e){return e.reduce(function(e,[t,r]){return e[t]="function"==typeof i[r]?i[r]:o,e},{default:o,message:f,greyMessage:d})}(e),n=t?r:Object.assign({},p,r),a=h(t),s=function(e,t){return a(e,n,t)};return s.colors=i,s.message=s.message||n.message,s.greyMessage=s.greyMessage||n.greyMessage,s}return fg=function(e=!1,n,o){return e&&void 0!==n?m(n,o):e?function(e){const t=h(e),r=function(e,r){return t(e,p,r)};return r.message=p.message,r.greyMessage=p.greyMessage,r.colors=i,r}(o):function(e){const n=h(e),i=function(e,r){return n(e,t,r)};return i.message=t.message,i.greyMessage=t.greyMessage,i.colors=r({useColor:!1}),i}(o)}}var Ng,Pg,Cg,Lg,Mg,$g,Dg,Bg,Fg,Ug,zg,Gg,qg,Vg,Wg,Hg,Kg,Zg,Jg,Yg,Qg,Xg,eb,tb,rb,nb,ib,ob,ab,sb,cb,ub,lb,db,fb,pb,hb,mb,yb,gb,bb,vb,wb,_b,Eb,Sb,Ob,Ab,Tb,xb,Ib,kb,jb,Rb,Nb,Pb,Cb,Lb,Mb,$b,Db,Bb,Fb,Ub,zb,Gb,qb,Vb,Wb,Hb,Kb,Zb,Jb,Yb,Qb,Xb,ev,tv,rv,nv,iv,ov,av,sv,cv,uv,lv,dv,fv,pv,hv={},mv={};function yv(){return Pg||(Pg=1,Ng=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var i=Object.getOwnPropertySymbols(e);if(1!==i.length||i[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}),Ng}function gv(){if(Lg)return Cg;Lg=1;var e=yv();return Cg=function(){return e()&&!!Symbol.toStringTag}}function bv(){return $g?Mg:($g=1,Mg=Object)}function vv(){return Bg?Dg:(Bg=1,Dg=Error)}function wv(){return Ug?Fg:(Ug=1,Fg=EvalError)}function _v(){return Gg?zg:(Gg=1,zg=RangeError)}function Ev(){return Vg?qg:(Vg=1,qg=ReferenceError)}function Sv(){return Hg?Wg:(Hg=1,Wg=SyntaxError)}function Ov(){return Zg?Kg:(Zg=1,Kg=TypeError)}function Av(){return Yg?Jg:(Yg=1,Jg=URIError)}function Tv(){return Xg?Qg:(Xg=1,Qg=Math.abs)}function xv(){return tb?eb:(tb=1,eb=Math.floor)}function Iv(){return nb?rb:(nb=1,rb=Math.max)}function kv(){return ob?ib:(ob=1,ib=Math.min)}function jv(){return sb?ab:(sb=1,ab=Math.pow)}function Rv(){return ub?cb:(ub=1,cb=Math.round)}function Nv(){return db?lb:(db=1,lb=Number.isNaN||function(e){return e!=e})}function Pv(){if(pb)return fb;pb=1;var e=Nv();return fb=function(t){return e(t)||0===t?t:t<0?-1:1}}function Cv(){return mb?hb:(mb=1,hb=Object.getOwnPropertyDescriptor)}function Lv(){if(gb)return yb;gb=1;var e=Cv();if(e)try{e([],"length")}catch(t){e=null}return yb=e}function Mv(){if(vb)return bb;vb=1;var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return bb=e}function $v(){if(_b)return wb;_b=1;var e="undefined"!=typeof Symbol&&Symbol,t=yv();return wb=function(){return"function"==typeof e&&("function"==typeof Symbol&&("symbol"==typeof e("foo")&&("symbol"==typeof Symbol("bar")&&t())))}}function Dv(){return Sb?Eb:(Sb=1,Eb="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null)}function Bv(){return Ab?Ob:(Ab=1,Ob=bv().getPrototypeOf||null)}function Fv(){if(kb)return Ib;kb=1;var e=function(){if(xb)return Tb;xb=1;var e=Object.prototype.toString,t=Math.max,r=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var i=0;i<t.length;i+=1)r[i+e.length]=t[i];return r};return Tb=function(n){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(e){for(var t=[],r=1,n=0;r<e.length;r+=1,n+=1)t[n]=e[r];return t}(arguments),s=t(0,i.length-a.length),c=[],u=0;u<s;u++)c[u]="$"+u;if(o=Function("binder","return function ("+function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r}(c,",")+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof o){var e=i.apply(this,r(a,arguments));return Object(e)===e?e:this}return i.apply(n,r(a,arguments))}),i.prototype){var l=function(){};l.prototype=i.prototype,o.prototype=new l,l.prototype=null}return o},Tb}();return Ib=Function.prototype.bind||e}function Uv(){return Rb?jb:(Rb=1,jb=Function.prototype.call)}function zv(){return Pb?Nb:(Pb=1,Nb=Function.prototype.apply)}function Gv(){if($b)return Mb;$b=1;var e=Fv(),t=zv(),r=Uv(),n=Lb?Cb:(Lb=1,Cb="undefined"!=typeof Reflect&&Reflect&&Reflect.apply);return Mb=n||e.call(r,t)}function qv(){if(Bb)return Db;Bb=1;var e=Fv(),t=Ov(),r=Uv(),n=Gv();return Db=function(i){if(i.length<1||"function"!=typeof i[0])throw new t("a function is required");return n(e,r,i)}}function Vv(){if(Ub)return Fb;Ub=1;var e,t=qv(),r=Lv();try{e=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var n=!!e&&r&&r(Object.prototype,"__proto__"),i=Object,o=i.getPrototypeOf;return Fb=n&&"function"==typeof n.get?t([n.get]):"function"==typeof o&&function(e){return o(null==e?e:i(e))},Fb}function Wv(){if(Gb)return zb;Gb=1;var e=Dv(),t=Bv(),r=Vv();return zb=e?function(t){return e(t)}:t?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return t(e)}:r?function(e){return r(e)}:null}function Hv(){if(Vb)return qb;Vb=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=Fv();return qb=r.call(e,t)}function Kv(){if(Hb)return Wb;var e;Hb=1;var t=bv(),r=vv(),n=wv(),i=_v(),o=Ev(),a=Sv(),s=Ov(),c=Av(),u=Tv(),l=xv(),d=Iv(),f=kv(),p=jv(),h=Rv(),m=Pv(),y=Function,g=function(e){try{return y('"use strict"; return ('+e+").constructor;")()}catch(e){}},b=Lv(),v=Mv(),w=function(){throw new s},_=b?function(){try{return w}catch(e){try{return b(arguments,"callee").get}catch(e){return w}}}():w,E=$v()(),S=Wv(),O=Bv(),A=Dv(),T=zv(),x=Uv(),I={},k="undefined"!=typeof Uint8Array&&S?S(Uint8Array):e,j={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?e:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?e:ArrayBuffer,"%ArrayIteratorPrototype%":E&&S?S([][Symbol.iterator]()):e,"%AsyncFromSyncIteratorPrototype%":e,"%AsyncFunction%":I,"%AsyncGenerator%":I,"%AsyncGeneratorFunction%":I,"%AsyncIteratorPrototype%":I,"%Atomics%":"undefined"==typeof Atomics?e:Atomics,"%BigInt%":"undefined"==typeof BigInt?e:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?e:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?e:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?e:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":"undefined"==typeof Float16Array?e:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?e:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?e:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?e:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":I,"%Int8Array%":"undefined"==typeof Int8Array?e:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?e:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?e:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":E&&S?S(S([][Symbol.iterator]())):e,"%JSON%":"object"==typeof JSON?JSON:e,"%Map%":"undefined"==typeof Map?e:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&E&&S?S((new Map)[Symbol.iterator]()):e,"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?e:Promise,"%Proxy%":"undefined"==typeof Proxy?e:Proxy,"%RangeError%":i,"%ReferenceError%":o,"%Reflect%":"undefined"==typeof Reflect?e:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?e:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&E&&S?S((new Set)[Symbol.iterator]()):e,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?e:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":E&&S?S(""[Symbol.iterator]()):e,"%Symbol%":E?Symbol:e,"%SyntaxError%":a,"%ThrowTypeError%":_,"%TypedArray%":k,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?e:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?e:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?e:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?e:Uint32Array,"%URIError%":c,"%WeakMap%":"undefined"==typeof WeakMap?e:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?e:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?e:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":T,"%Object.defineProperty%":v,"%Object.getPrototypeOf%":O,"%Math.abs%":u,"%Math.floor%":l,"%Math.max%":d,"%Math.min%":f,"%Math.pow%":p,"%Math.round%":h,"%Math.sign%":m,"%Reflect.getPrototypeOf%":A};if(S)try{null.error}catch(e){var R=S(S(e));j["%Error.prototype%"]=R}var N=function e(t){var r;if("%AsyncFunction%"===t)r=g("async function () {}");else if("%GeneratorFunction%"===t)r=g("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=g("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&S&&(r=S(i.prototype))}return j[t]=r,r},P={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=Fv(),L=Hv(),M=C.call(x,Array.prototype.concat),$=C.call(T,Array.prototype.splice),D=C.call(x,String.prototype.replace),B=C.call(x,String.prototype.slice),F=C.call(x,RegExp.prototype.exec),U=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,z=/\\(\\)?/g,G=function(e,t){var r,n=e;if(L(P,n)&&(n="%"+(r=P[n])[0]+"%"),L(j,n)){var i=j[n];if(i===I&&(i=N(n)),void 0===i&&!t)throw new s("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new a("intrinsic "+e+" does not exist!")};return Wb=function(e,t){if("string"!=typeof e||0===e.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new s('"allowMissing" argument must be a boolean');if(null===F(/^%?[^%]*%?$/,e))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=B(e,0,1),r=B(e,-1);if("%"===t&&"%"!==r)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new a("invalid intrinsic syntax, expected opening `%`");var n=[];return D(e,U,function(e,t,r,i){n[n.length]=r?D(i,z,"$1"):t||e}),n}(e),n=r.length>0?r[0]:"",i=G("%"+n+"%",t),o=i.name,c=i.value,u=!1,l=i.alias;l&&(n=l[0],$(r,M([0,1],l)));for(var d=1,f=!0;d<r.length;d+=1){var p=r[d],h=B(p,0,1),m=B(p,-1);if(('"'===h||"'"===h||"`"===h||'"'===m||"'"===m||"`"===m)&&h!==m)throw new a("property names with quotes must have matching quotes");if("constructor"!==p&&f||(u=!0),L(j,o="%"+(n+="."+p)+"%"))c=j[o];else if(null!=c){if(!(p in c)){if(!t)throw new s("base intrinsic for "+e+" exists, but the property is not available.");return}if(b&&d+1>=r.length){var y=b(c,p);c=(f=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:c[p]}else f=L(c,p),c=c[p];f&&!u&&(j[o]=c)}}return c},Wb}function Zv(){if(Zb)return Kb;Zb=1;var e=Kv(),t=qv(),r=t([e("%String.prototype.indexOf%")]);return Kb=function(n,i){var o=e(n,!!i);return"function"==typeof o&&r(n,".prototype.")>-1?t([o]):o}}function Jv(){if(Yb)return Jb;Yb=1;var e=gv()(),t=Zv()("Object.prototype.toString"),r=function(r){return!(e&&r&&"object"==typeof r&&Symbol.toStringTag in r)&&"[object Arguments]"===t(r)},n=function(e){return!!r(e)||null!==e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==t(e)&&"callee"in e&&"[object Function]"===t(e.callee)},i=function(){return r(arguments)}();return r.isLegacyArguments=n,Jb=i?r:n}function Yv(){if(Xb)return Qb;Xb=1;var e,t=Zv(),r=gv()(),n=Hv(),i=Lv();if(r){var o=t("RegExp.prototype.exec"),a={},s=function(){throw a},c={toString:s,valueOf:s};"symbol"==typeof Symbol.toPrimitive&&(c[Symbol.toPrimitive]=s),e=function(e){if(!e||"object"!=typeof e)return!1;var t=i(e,"lastIndex");if(!(t&&n(t,"value")))return!1;try{o(e,c)}catch(e){return e===a}}}else{var u=t("Object.prototype.toString");e=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===u(e)}}return Qb=e}function Qv(){if(tv)return ev;tv=1;var e=Zv(),t=Yv(),r=e("RegExp.prototype.exec"),n=Ov();return ev=function(e){if(!t(e))throw new n("`regex` must be a RegExp");return function(t){return null!==r(e,t)}},ev}function Xv(){if(nv)return rv;nv=1;const e=function*(){}.constructor;return rv=()=>e}function ew(){if(ov)return iv;ov=1;var e=Zv(),t=Qv()(/^\s*(?:function)?\*/),r=gv()(),n=Wv(),i=e("Object.prototype.toString"),o=e("Function.prototype.toString"),a=Xv();return iv=function(e){if("function"!=typeof e)return!1;if(t(o(e)))return!0;if(!r)return"[object GeneratorFunction]"===i(e);if(!n)return!1;var s=a();return s&&n(e)===s.prototype}}function tw(){if(sv)return av;sv=1;var e,t,r=Function.prototype.toString,n="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof n&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw t}}),t={},n(function(){throw 42},null,e)}catch(e){e!==t&&(n=null)}else n=null;var i=/^\s*class\b/,o=function(e){try{var t=r.call(e);return i.test(t)}catch(e){return!1}},a=function(e){try{return!o(e)&&(r.call(e),!0)}catch(e){return!1}},s=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,u=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var d=document.all;s.call(d)===s.call(document.all)&&(l=function(e){if((u||!e)&&(void 0===e||"object"==typeof e))try{var t=s.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}return av=n?function(r){if(l(r))return!0;if(!r)return!1;if("function"!=typeof r&&"object"!=typeof r)return!1;try{n(r,null,e)}catch(e){if(e!==t)return!1}return!o(r)&&a(r)}:function(e){if(l(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(c)return a(e);if(o(e))return!1;var t=s.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&a(e)},av}function rw(){if(uv)return cv;uv=1;var e=tw(),t=Object.prototype.toString,r=Object.prototype.hasOwnProperty;return cv=function(n,i,o){if(!e(i))throw new TypeError("iterator must be a function");var a,s;arguments.length>=3&&(a=o),s=n,"[object Array]"===t.call(s)?function(e,t,n){for(var i=0,o=e.length;i<o;i++)r.call(e,i)&&(null==n?t(e[i],i,e):t.call(n,e[i],i,e))}(n,i,a):"string"==typeof n?function(e,t,r){for(var n=0,i=e.length;n<i;n++)null==r?t(e.charAt(n),n,e):t.call(r,e.charAt(n),n,e)}(n,i,a):function(e,t,n){for(var i in e)r.call(e,i)&&(null==n?t(e[i],i,e):t.call(n,e[i],i,e))}(n,i,a)},cv}function nw(){return dv?lv:(dv=1,lv=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"])}function iw(){if(pv)return fv;pv=1;var e=nw(),t="undefined"==typeof globalThis?v:globalThis;return fv=function(){for(var r=[],n=0;n<e.length;n++)"function"==typeof t[e[n]]&&(r[r.length]=e[n]);return r},fv}var ow,aw,sw,cw,uw,lw,dw,fw,pw,hw,mw,yw,gw,bw,vw,ww,_w={exports:{}};function Ew(){if(aw)return ow;aw=1;var e=Mv(),t=Sv(),r=Ov(),n=Lv();return ow=function(i,o,a){if(!i||"object"!=typeof i&&"function"!=typeof i)throw new r("`obj` must be an object or a function`");if("string"!=typeof o&&"symbol"!=typeof o)throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new r("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,l=arguments.length>6&&arguments[6],d=!!n&&n(i,o);if(e)e(i,o,{configurable:null===u&&d?d.configurable:!u,enumerable:null===s&&d?d.enumerable:!s,value:a,writable:null===c&&d?d.writable:!c});else{if(!l&&(s||c||u))throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");i[o]=a}},ow}function Sw(){if(cw)return sw;cw=1;var e=Mv(),t=function(){return!!e};return t.hasArrayLengthDefineBug=function(){if(!e)return null;try{return 1!==e([],"length",{value:1}).length}catch(e){return!0}},sw=t}function Ow(){if(lw)return uw;lw=1;var e=Kv(),t=Ew(),r=Sw()(),n=Lv(),i=Ov(),o=e("%Math.floor%");return uw=function(e,a){if("function"!=typeof e)throw new i("`fn` is not a function");if("number"!=typeof a||a<0||a>4294967295||o(a)!==a)throw new i("`length` must be a positive 32-bit integer");var s=arguments.length>2&&!!arguments[2],c=!0,u=!0;if("length"in e&&n){var l=n(e,"length");l&&!l.configurable&&(c=!1),l&&!l.writable&&(u=!1)}return(c||u||!s)&&(r?t(e,"length",a,!0,!0):t(e,"length",a)),e},uw}function Aw(){if(fw)return dw;fw=1;var e=Fv(),t=zv(),r=Gv();return dw=function(){return r(e,t,arguments)},dw}function Tw(){return pw||(pw=1,function(e){var t=Ow(),r=Mv(),n=qv(),i=Aw();e.exports=function(e){var r=n(arguments),i=e.length-(arguments.length-1);return t(r,1+(i>0?i:0),!0)},r?r(e.exports,"apply",{value:i}):e.exports.apply=i}(_w)),_w.exports}function xw(){if(mw)return hw;mw=1;var e=rw(),t=iw(),r=Tw(),n=Zv(),i=Lv(),o=Wv(),a=n("Object.prototype.toString"),s=gv()(),c="undefined"==typeof globalThis?v:globalThis,u=t(),l=n("String.prototype.slice"),d=n("Array.prototype.indexOf",!0)||function(e,t){for(var r=0;r<e.length;r+=1)if(e[r]===t)return r;return-1},f={__proto__:null};e(u,s&&i&&o?function(e){var t=new c[e];if(Symbol.toStringTag in t&&o){var n=o(t),a=i(n,Symbol.toStringTag);if(!a&&n){var s=o(n);a=i(s,Symbol.toStringTag)}f["$"+e]=r(a.get)}}:function(e){var t=new c[e],n=t.slice||t.set;n&&(f["$"+e]=r(n))});return hw=function(t){if(!t||"object"!=typeof t)return!1;if(!s){var r=l(a(t),8,-1);return d(u,r)>-1?r:"Object"===r&&function(t){var r=!1;return e(f,function(e,n){if(!r)try{e(t),r=l(n,1)}catch(e){}}),r}(t)}return i?function(t){var r=!1;return e(f,function(e,n){if(!r)try{"$"+e(t)===n&&(r=l(n,1))}catch(e){}}),r}(t):null},hw}function Iw(){if(gw)return yw;gw=1;var e=xw();return yw=function(t){return!!e(t)},yw}var kw,jw,Rw={exports:{}};function Nw(){return jw||(jw=1,function(e){var t=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++)r[t[n]]=Object.getOwnPropertyDescriptor(e,t[n]);return r},r=/%[sdj%]/g;e.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var i=arguments,o=i.length,s=String(e).replace(r,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(e){return"[Circular]"}default:return e}}),c=i[n];n<o;c=i[++n])h(c)||!v(c)?s+=" "+c:s+=" "+a(c);return s},e.deprecate=function(t,r){if("undefined"!=typeof process&&!0===process.noDeprecation)return t;if("undefined"==typeof process)return function(){return e.deprecate(t,r).apply(this,arguments)};var n=!1;return function(){if(!n){if(process.throwDeprecation)throw new Error(r);process.traceDeprecation?console.trace(r):console.error(r),n=!0}return t.apply(this,arguments)}};var n={},i=/^$/;if(process.env.NODE_DEBUG){var o=process.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}function a(t,r){var n={seen:[],stylize:c};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&e._extend(n,r),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),u(n,t,n.depth)}function s(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(e,t){return e}function u(t,r,n){if(t.customInspect&&r&&E(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return y(i)||(i=u(t,i,n)),i}var o=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(y(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(m(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(h(t))return e.stylize("null","null")}(t,r);if(o)return o;var a=Object.keys(r),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),_(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(E(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(b(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(w(r))return t.stylize(Date.prototype.toString.call(r),"date");if(_(r))return l(r)}var v,S="",O=!1,A=["{","}"];(f(r)&&(O=!0,A=["[","]"]),E(r))&&(S=" [Function"+(r.name?": "+r.name:"")+"]");return b(r)&&(S=" "+RegExp.prototype.toString.call(r)),w(r)&&(S=" "+Date.prototype.toUTCString.call(r)),_(r)&&(S=" "+l(r)),0!==a.length||O&&0!=r.length?n<0?b(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),v=O?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a<s;++a)T(t,String(a))?o.push(d(e,t,r,n,String(a),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(d(e,t,r,n,i,!0))}),o}(t,r,n,s,a):a.map(function(e){return d(t,r,n,s,e,O)}),t.seen.pop(),function(e,t,r){var n=e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(n>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(v,S,A)):A[0]+S+A[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,r,n,i,o){var a,s,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),T(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(s=h(r)?u(e,c.value,null):u(e,c.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").slice(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),g(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function f(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function h(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function g(e){return void 0===e}function b(e){return v(e)&&"[object RegExp]"===S(e)}function v(e){return"object"==typeof e&&null!==e}function w(e){return v(e)&&"[object Date]"===S(e)}function _(e){return v(e)&&("[object Error]"===S(e)||e instanceof Error)}function E(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!n[t])if(i.test(t)){var r=process.pid;n[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else n[t]=function(){};return n[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=(bw||(bw=1,function(e){var t=Jv(),r=ew(),n=xw(),i=Iw();function o(e){return e.call.bind(e)}var a="undefined"!=typeof BigInt,s="undefined"!=typeof Symbol,c=o(Object.prototype.toString),u=o(Number.prototype.valueOf),l=o(String.prototype.valueOf),d=o(Boolean.prototype.valueOf);if(a)var f=o(BigInt.prototype.valueOf);if(s)var p=o(Symbol.prototype.valueOf);function h(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function m(e){return"[object Map]"===c(e)}function y(e){return"[object Set]"===c(e)}function g(e){return"[object WeakMap]"===c(e)}function b(e){return"[object WeakSet]"===c(e)}function v(e){return"[object ArrayBuffer]"===c(e)}function w(e){return"undefined"!=typeof ArrayBuffer&&(v.working?v(e):e instanceof ArrayBuffer)}function _(e){return"[object DataView]"===c(e)}function E(e){return"undefined"!=typeof DataView&&(_.working?_(e):e instanceof DataView)}e.isArgumentsObject=t,e.isGeneratorFunction=r,e.isTypedArray=i,e.isPromise=function(e){return"undefined"!=typeof Promise&&e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch},e.isArrayBufferView=function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):i(e)||E(e)},e.isUint8Array=function(e){return"Uint8Array"===n(e)},e.isUint8ClampedArray=function(e){return"Uint8ClampedArray"===n(e)},e.isUint16Array=function(e){return"Uint16Array"===n(e)},e.isUint32Array=function(e){return"Uint32Array"===n(e)},e.isInt8Array=function(e){return"Int8Array"===n(e)},e.isInt16Array=function(e){return"Int16Array"===n(e)},e.isInt32Array=function(e){return"Int32Array"===n(e)},e.isFloat32Array=function(e){return"Float32Array"===n(e)},e.isFloat64Array=function(e){return"Float64Array"===n(e)},e.isBigInt64Array=function(e){return"BigInt64Array"===n(e)},e.isBigUint64Array=function(e){return"BigUint64Array"===n(e)},m.working="undefined"!=typeof Map&&m(new Map),e.isMap=function(e){return"undefined"!=typeof Map&&(m.working?m(e):e instanceof Map)},y.working="undefined"!=typeof Set&&y(new Set),e.isSet=function(e){return"undefined"!=typeof Set&&(y.working?y(e):e instanceof Set)},g.working="undefined"!=typeof WeakMap&&g(new WeakMap),e.isWeakMap=function(e){return"undefined"!=typeof WeakMap&&(g.working?g(e):e instanceof WeakMap)},b.working="undefined"!=typeof WeakSet&&b(new WeakSet),e.isWeakSet=function(e){return b(e)},v.working="undefined"!=typeof ArrayBuffer&&v(new ArrayBuffer),e.isArrayBuffer=w,_.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&_(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=E;var S="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(e){return"[object SharedArrayBuffer]"===c(e)}function A(e){return void 0!==S&&(void 0===O.working&&(O.working=O(new S)),O.working?O(e):e instanceof S)}function T(e){return h(e,u)}function x(e){return h(e,l)}function I(e){return h(e,d)}function k(e){return a&&h(e,f)}function j(e){return s&&h(e,p)}e.isSharedArrayBuffer=A,e.isAsyncFunction=function(e){return"[object AsyncFunction]"===c(e)},e.isMapIterator=function(e){return"[object Map Iterator]"===c(e)},e.isSetIterator=function(e){return"[object Set Iterator]"===c(e)},e.isGeneratorObject=function(e){return"[object Generator]"===c(e)},e.isWebAssemblyCompiledModule=function(e){return"[object WebAssembly.Module]"===c(e)},e.isNumberObject=T,e.isStringObject=x,e.isBooleanObject=I,e.isBigIntObject=k,e.isSymbolObject=j,e.isBoxedPrimitive=function(e){return T(e)||x(e)||I(e)||k(e)||j(e)},e.isAnyArrayBuffer=function(e){return"undefined"!=typeof Uint8Array&&(w(e)||A(e))},["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})})}(mv)),mv),e.isArray=f,e.isBoolean=p,e.isNull=h,e.isNullOrUndefined=function(e){return null==e},e.isNumber=m,e.isString=y,e.isSymbol=function(e){return"symbol"==typeof e},e.isUndefined=g,e.isRegExp=b,e.types.isRegExp=b,e.isObject=v,e.isDate=w,e.types.isDate=w,e.isError=_,e.types.isNativeError=_,e.isFunction=E,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=ww?vw:(ww=1,vw=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8});var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.log=function(){console.log("%s - %s",function(){var e=new Date,t=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":");return[e.getDate(),A[e.getMonth()],t].join(" ")}(),e.format.apply(e,arguments))},e.inherits=(kw||(kw=1,"function"==typeof Object.create?Rw.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Rw.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),Rw.exports),e._extend=function(e,t){if(!t||!v(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function I(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}e.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(x&&e[x]){var r;if("function"!=typeof(r=e[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,x,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var t,r,n=new Promise(function(e,n){t=e,r=n}),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push(function(e,n){e?r(e):t(n)});try{e.apply(this,i)}catch(e){r(e)}return n}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),x&&Object.defineProperty(r,x,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,t(e))},e.promisify.custom=x,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var t=[],r=0;r<arguments.length;r++)t.push(arguments[r]);var n=t.pop();if("function"!=typeof n)throw new TypeError("The last argument must be of type Function");var i=this,o=function(){return n.apply(i,arguments)};e.apply(this,t).then(function(e){process.nextTick(o.bind(null,null,e))},function(e){process.nextTick(I.bind(null,e,o))})}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,t(e)),r}}(hv)),hv}var Pw,Cw={exports:{}};var Lw,Mw,$w,Dw,Bw,Fw,Uw,zw,Gw,qw,Vw,Ww,Hw,Kw,Zw,Jw,Yw,Qw,Xw,e_,t_,r_,n_,i_,o_,a_,s_,c_,u_,l_,d_,f_,p_,h_,m_,y_,g_,b_,v_,w_,__,E_,S_,O_,A_,T_,x_,I_,k_,j_,R_,N_,P_,C_,L_={exports:{}},M_={};function $_(){if(Lw)return M_;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}function r(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var i,o=n(t);if(r){var a=n(this).constructor;i=Reflect.construct(o,arguments,a)}else i=o.apply(this,arguments);return function(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(this,i)}}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}Lw=1;var i,o,a={};function s(e,n,i){i||(i=Error);var o=function(i){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&t(e,r)}(s,i);var o,a=r(s);function s(t,r,i){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),o=a.call(this,function(e,t,r){return"string"==typeof n?n:n(e,t,r)}(t,r,i)),o.code=e,o}return o=s,Object.defineProperty(o,"prototype",{writable:!1}),o}(i);a[e]=o}function c(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(e){return String(e)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}return s("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),s("ERR_INVALID_ARG_TYPE",function(t,r,n){var o,a,s;if(void 0===i&&(i=Y_()),i("string"==typeof t,"'name' must be a string"),"string"==typeof r&&(a="not ",r.substr(0,a.length)===a)?(o="must not be",r=r.replace(/^not /,"")):o="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(t," argument"))s="The ".concat(t," ").concat(o," ").concat(c(r,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(t,".")?"property":"argument";s='The "'.concat(t,'" ').concat(u," ").concat(o," ").concat(c(r,"type"))}return s+=". Received type ".concat(e(n))},TypeError),s("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===o&&(o=Nw());var n=o.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError),s("ERR_INVALID_RETURN_VALUE",function(t,r,n){var i;return i=n&&n.constructor&&n.constructor.name?"instance of ".concat(n.constructor.name):"type ".concat(e(n)),"Expected ".concat(t,' to be returned from the "').concat(r,'"')+" function but got ".concat(i,".")},TypeError),s("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];void 0===i&&(i=Y_()),i(t.length>0,"At least one arg needs to be specified");var n="The ",o=t.length;switch(t=t.map(function(e){return'"'.concat(e,'"')}),o){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,o-1).join(", "),n+=", and ".concat(t[o-1]," arguments")}return"".concat(n," must be specified")},TypeError),M_.codes=a,M_}function D_(){if($w)return Mw;function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach(function(e){r(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function r(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e){var t=function(e,t){if("object"!==f(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!==f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"===f(t)?t:String(t)}function o(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)},s(e)}function c(e,t,r){return c=u()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i},c.apply(null,arguments)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}$w=1;var p=Nw().inspect,h=$_().codes.ERR_INVALID_ARG_TYPE;function m(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}var y="",g="",b="",v="",w={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function _(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(t){r[t]=e[t]}),Object.defineProperty(r,"message",{value:e.message}),r}function E(e){return p(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function S(e,t,r){var n="",i="",o=0,a="",s=!1,c=E(e),u=c.split("\n"),l=E(t).split("\n"),d=0,p="";if("strictEqual"===r&&"object"===f(e)&&"object"===f(t)&&null!==e&&null!==t&&(r="strictEqualObject"),1===u.length&&1===l.length&&u[0]!==l[0]){var h=u[0].length+l[0].length;if(h<=10){if(!("object"===f(e)&&null!==e||"object"===f(t)&&null!==t||0===e&&0===t))return"".concat(w[r],"\n\n")+"".concat(u[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r){if(h<(process.stderr&&process.stderr.isTTY?process.stderr.columns:80)){for(;u[0][d]===l[0][d];)d++;d>2&&(p="\n ".concat(function(e,t){if(t=Math.floor(t),0==e.length||0==t)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+e.substring(0,r-e.length)}(" ",d),"^"),d=0)}}}for(var _=u[u.length-1],S=l[l.length-1];_===S&&(d++<2?a="\n ".concat(_).concat(a):n=_,u.pop(),l.pop(),0!==u.length&&0!==l.length);)_=u[u.length-1],S=l[l.length-1];var O=Math.max(u.length,l.length);if(0===O){var A=c.split("\n");if(A.length>30)for(A[26]="".concat(y,"...").concat(v);A.length>27;)A.pop();return"".concat(w.notIdentical,"\n\n").concat(A.join("\n"),"\n")}d>3&&(a="\n".concat(y,"...").concat(v).concat(a),s=!0),""!==n&&(a="\n ".concat(n).concat(a),n="");var T=0,x=w[r]+"\n".concat(g,"+ actual").concat(v," ").concat(b,"- expected").concat(v),I=" ".concat(y,"...").concat(v," Lines skipped");for(d=0;d<O;d++){var k=d-o;if(u.length<d+1)k>1&&d>2&&(k>4?(i+="\n".concat(y,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(l[d-2]),T++),i+="\n ".concat(l[d-1]),T++),o=d,n+="\n".concat(b,"-").concat(v," ").concat(l[d]),T++;else if(l.length<d+1)k>1&&d>2&&(k>4?(i+="\n".concat(y,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(u[d-2]),T++),i+="\n ".concat(u[d-1]),T++),o=d,i+="\n".concat(g,"+").concat(v," ").concat(u[d]),T++;else{var j=l[d],R=u[d],N=R!==j&&(!m(R,",")||R.slice(0,-1)!==j);N&&m(j,",")&&j.slice(0,-1)===R&&(N=!1,R+=","),N?(k>1&&d>2&&(k>4?(i+="\n".concat(y,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(u[d-2]),T++),i+="\n ".concat(u[d-1]),T++),o=d,i+="\n".concat(g,"+").concat(v," ").concat(R),n+="\n".concat(b,"-").concat(v," ").concat(j),T+=2):(i+=n,n="",1!==k&&0!==d||(i+="\n ".concat(R),T++))}if(T>20&&d<O-2)return"".concat(x).concat(I,"\n").concat(i,"\n").concat(y,"...").concat(v).concat(n,"\n")+"".concat(y,"...").concat(v)}return"".concat(x).concat(s?I:"","\n").concat(i).concat(n).concat(a).concat(p)}var O=function(e,r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(m,e);var i,s,c=(i=m,s=u(),function(){var e,t=d(i);if(s){var r=d(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return o(this,e)});function m(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,m),"object"!==f(e)||null===e)throw new h("options","Object",e);var r=e.message,n=e.operator,i=e.stackStartFn,s=e.actual,u=e.expected,l=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)t=c.call(this,String(r));else if(process.stderr&&process.stderr.isTTY&&(process.stderr&&process.stderr.getColorDepth&&1!==process.stderr.getColorDepth()?(y="",g="",v="",b=""):(y="",g="",v="",b="")),"object"===f(s)&&null!==s&&"object"===f(u)&&null!==u&&"stack"in s&&s instanceof Error&&"stack"in u&&u instanceof Error&&(s=_(s),u=_(u)),"deepStrictEqual"===n||"strictEqual"===n)t=c.call(this,S(s,u,n));else if("notDeepStrictEqual"===n||"notStrictEqual"===n){var d=w[n],p=E(s).split("\n");if("notStrictEqual"===n&&"object"===f(s)&&null!==s&&(d=w.notStrictEqualObject),p.length>30)for(p[26]="".concat(y,"...").concat(v);p.length>27;)p.pop();t=1===p.length?c.call(this,"".concat(d," ").concat(p[0])):c.call(this,"".concat(d,"\n\n").concat(p.join("\n"),"\n"))}else{var O=E(s),A="",T=w[n];"notDeepEqual"===n||"notEqual"===n?(O="".concat(w[n],"\n\n").concat(O)).length>1024&&(O="".concat(O.slice(0,1021),"...")):(A="".concat(E(u)),O.length>512&&(O="".concat(O.slice(0,509),"...")),A.length>512&&(A="".concat(A.slice(0,509),"...")),"deepEqual"===n||"equal"===n?O="".concat(T,"\n\n").concat(O,"\n\nshould equal\n\n"):A=" ".concat(n," ").concat(A)),t=c.call(this,"".concat(O).concat(A))}return Error.stackTraceLimit=l,t.generatedMessage=!r,Object.defineProperty(a(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),t.code="ERR_ASSERTION",t.actual=s,t.expected=u,t.operator=n,Error.captureStackTrace&&Error.captureStackTrace(a(t),i),t.stack,t.name="AssertionError",o(t)}return n(m,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:r,value:function(e,r){return p(this,t(t({},r),{},{customInspect:!1,depth:0}))}}]),m}(s(Error),p.custom);return Mw=O}function B_(){if(Bw)return Dw;Bw=1;var e=Object.prototype.toString;return Dw=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n},Dw}function F_(){if(Uw)return Fw;var e;if(Uw=1,!Object.keys){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=B_(),i=Object.prototype.propertyIsEnumerable,o=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(e){var t=e.constructor;return t&&t.prototype===e},u={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!u["$"+e]&&t.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{c(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();e=function(e){var i=null!==e&&"object"==typeof e,u="[object Function]"===r.call(e),d=n(e),f=i&&"[object String]"===r.call(e),p=[];if(!i&&!u&&!d)throw new TypeError("Object.keys called on a non-object");var h=a&&u;if(f&&e.length>0&&!t.call(e,0))for(var m=0;m<e.length;++m)p.push(String(m));if(d&&e.length>0)for(var y=0;y<e.length;++y)p.push(String(y));else for(var g in e)h&&"prototype"===g||!t.call(e,g)||p.push(String(g));if(o)for(var b=function(e){if("undefined"==typeof window||!l)return c(e);try{return c(e)}catch(e){return!1}}(e),v=0;v<s.length;++v)b&&"constructor"===s[v]||!t.call(e,s[v])||p.push(s[v]);return p}}return Fw=e}function U_(){if(Gw)return zw;Gw=1;var e=Array.prototype.slice,t=B_(),r=Object.keys,n=r?function(e){return r(e)}:F_(),i=Object.keys;return n.shim=function(){if(Object.keys){var r=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);r||(Object.keys=function(r){return t(r)?i(e.call(r)):i(r)})}else Object.keys=n;return Object.keys||n},zw=n}function z_(){if(Hw)return Ww;Hw=1;var e=function(){if(Vw)return qw;Vw=1;var e=U_(),t=yv()(),r=Zv(),n=bv(),i=r("Array.prototype.push"),o=r("Object.prototype.propertyIsEnumerable"),a=t?n.getOwnPropertySymbols:null;return qw=function(r,s){if(null==r)throw new TypeError("target must be an object");var c=n(r);if(1===arguments.length)return c;for(var u=1;u<arguments.length;++u){var l=n(arguments[u]),d=e(l),f=t&&(n.getOwnPropertySymbols||a);if(f)for(var p=f(l),h=0;h<p.length;++h){var m=p[h];o(l,m)&&i(d,m)}for(var y=0;y<d.length;++y){var g=d[y];if(o(l,g)){var b=l[g];c[g]=b}}}return c},qw}();return Ww=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return e!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}return!1}()?e:Object.assign:e},Ww}function G_(){if(Zw)return Kw;Zw=1;var e=function(e){return e!=e};return Kw=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}}function q_(){if(Yw)return Jw;Yw=1;var e=G_();return Jw=function(){return"function"==typeof Object.is?Object.is:e}}function V_(){if(t_)return e_;t_=1;var e=U_(),t="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),r=Object.prototype.toString,n=Array.prototype.concat,i=Ew(),o=Sw()(),a=function(e,t,n,a){if(t in e)if(!0===a){if(e[t]===n)return}else if("function"!=typeof(s=a)||"[object Function]"!==r.call(s)||!a())return;var s;o?i(e,t,n,!0):i(e,t,n)},s=function(r,i){var o=arguments.length>2?arguments[2]:{},s=e(i);t&&(s=n.call(s,Object.getOwnPropertySymbols(i)));for(var c=0;c<s.length;c+=1)a(r,s[c],i[s[c]],o[s[c]])};return s.supportsDescriptors=!!o,e_=s}function W_(){if(o_)return i_;o_=1;var e=V_(),t=Tw(),r=G_(),n=q_(),i=function(){if(n_)return r_;n_=1;var e=q_(),t=V_();return r_=function(){var r=e();return t(Object,{is:r},{is:function(){return Object.is!==r}}),r},r_}(),o=t(n(),Object);return e(o,{getPolyfill:n,implementation:r,shim:i}),i_=o}function H_(){return s_||(s_=1,a_=function(e){return e!=e}),a_}function K_(){if(u_)return c_;u_=1;var e=H_();return c_=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:e}}function Z_(){if(d_)return l_;d_=1;var e=V_(),t=K_();return l_=function(){var r=t();return e(Number,{isNaN:r},{isNaN:function(){return Number.isNaN!==r}}),r},l_}function J_(){if(m_)return h_;function e(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t);else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}m_=1;var n=void 0!==/a/g.flags,i=function(e){var t=[];return e.forEach(function(e){return t.push(e)}),t},o=function(e){var t=[];return e.forEach(function(e,r){return t.push([r,e])}),t},a=Object.is?Object.is:W_(),s=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},c=Number.isNaN?Number.isNaN:function(){if(p_)return f_;p_=1;var e=Tw(),t=V_(),r=H_(),n=K_(),i=Z_(),o=e(n(),Number);return t(o,{getPolyfill:n,implementation:r,shim:i}),f_=o}();function u(e){return e.call.bind(e)}var l=u(Object.prototype.hasOwnProperty),d=u(Object.prototype.propertyIsEnumerable),f=u(Object.prototype.toString),p=Nw().types,h=p.isAnyArrayBuffer,m=p.isArrayBufferView,y=p.isDate,g=p.isMap,b=p.isRegExp,v=p.isSet,w=p.isNativeError,_=p.isBoxedPrimitive,E=p.isNumberObject,S=p.isStringObject,O=p.isBooleanObject,A=p.isBigIntObject,T=p.isSymbolObject,x=p.isFloat32Array,I=p.isFloat64Array;function k(e){if(0===e.length||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return 10===e.length&&e>=Math.pow(2,32)}function j(e){return Object.keys(e).filter(k).concat(s(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}
42
+ /*!
43
+ * The buffer module from node.js, for the browser.
44
+ *
45
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
46
+ * @license MIT
47
+ */function R(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}function N(e,t,i,o){if(e===t)return 0!==e||(!i||a(e,t));if(i){if("object"!==r(e))return"number"==typeof e&&c(e)&&c(t);if("object"!==r(t)||null===e||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(null===e||"object"!==r(e))return(null===t||"object"!==r(t))&&e==t;if(null===t||"object"!==r(t))return!1}var s,u,l,d,p=f(e);if(p!==f(t))return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var k=j(e),N=j(t);return k.length===N.length&&C(e,t,i,o,1,k)}if("[object Object]"===p&&(!g(e)&&g(t)||!v(e)&&v(t)))return!1;if(y(e)){if(!y(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(b(e)){if(!b(t)||(l=e,d=t,!(n?l.source===d.source&&l.flags===d.flags:RegExp.prototype.toString.call(l)===RegExp.prototype.toString.call(d))))return!1}else if(w(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else{if(m(e)){if(i||!x(e)&&!I(e)){if(!function(e,t){return e.byteLength===t.byteLength&&0===R(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}(e,t))return!1}else if(!function(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e,t))return!1;var P=j(e),L=j(t);return P.length===L.length&&C(e,t,i,o,0,P)}if(v(e))return!(!v(t)||e.size!==t.size)&&C(e,t,i,o,2);if(g(e))return!(!g(t)||e.size!==t.size)&&C(e,t,i,o,3);if(h(e)){if(u=t,(s=e).byteLength!==u.byteLength||0!==R(new Uint8Array(s),new Uint8Array(u)))return!1}else if(_(e)&&!function(e,t){return E(e)?E(t)&&a(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):S(e)?S(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):O(e)?O(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):A(e)?A(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):T(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}(e,t))return!1}return C(e,t,i,o,0)}function P(e,t){return t.filter(function(t){return d(e,t)})}function C(t,n,a,c,u,f){if(5===arguments.length){f=Object.keys(t);var p=Object.keys(n);if(f.length!==p.length)return!1}for(var h=0;h<f.length;h++)if(!l(n,f[h]))return!1;if(a&&5===arguments.length){var m=s(t);if(0!==m.length){var y=0;for(h=0;h<m.length;h++){var g=m[h];if(d(t,g)){if(!d(n,g))return!1;f.push(g),y++}else if(d(n,g))return!1}var b=s(n);if(m.length!==b.length&&P(n,b).length!==y)return!1}else{var v=s(n);if(0!==v.length&&0!==P(n,v).length)return!1}}if(0===f.length&&(0===u||1===u&&0===t.length||0===t.size))return!0;if(void 0===c)c={val1:new Map,val2:new Map,position:0};else{var w=c.val1.get(t);if(void 0!==w){var _=c.val2.get(n);if(void 0!==_)return w===_}c.position++}c.val1.set(t,c.position),c.val2.set(n,c.position);var E=function(t,n,a,s,c,u){var d=0;if(2===u){if(!function(e,t,n,o){for(var a=null,s=i(e),c=0;c<s.length;c++){var u=s[c];if("object"===r(u)&&null!==u)null===a&&(a=new Set),a.add(u);else if(!t.has(u)){if(n)return!1;if(!$(e,t,u))return!1;null===a&&(a=new Set),a.add(u)}}if(null!==a){for(var l=i(t),d=0;d<l.length;d++){var f=l[d];if("object"===r(f)&&null!==f){if(!L(a,f,n,o))return!1}else if(!n&&!e.has(f)&&!L(a,f,n,o))return!1}return 0===a.size}return!0}(t,n,a,c))return!1}else if(3===u){if(!function(t,n,i,a){for(var s=null,c=o(t),u=0;u<c.length;u++){var l=e(c[u],2),d=l[0],f=l[1];if("object"===r(d)&&null!==d)null===s&&(s=new Set),s.add(d);else{var p=n.get(d);if(void 0===p&&!n.has(d)||!N(f,p,i,a)){if(i)return!1;if(!D(t,n,d,f,a))return!1;null===s&&(s=new Set),s.add(d)}}}if(null!==s){for(var h=o(n),m=0;m<h.length;m++){var y=e(h[m],2),g=y[0],b=y[1];if("object"===r(g)&&null!==g){if(!B(s,t,g,b,i,a))return!1}else if(!(i||t.has(g)&&N(t.get(g),b,!1,a)||B(s,t,g,b,!1,a)))return!1}return 0===s.size}return!0}(t,n,a,c))return!1}else if(1===u)for(;d<t.length;d++){if(!l(t,d)){if(l(n,d))return!1;for(var f=Object.keys(t);d<f.length;d++){var p=f[d];if(!l(n,p)||!N(t[p],n[p],a,c))return!1}return f.length===Object.keys(n).length}if(!l(n,d)||!N(t[d],n[d],a,c))return!1}for(d=0;d<s.length;d++){var h=s[d];if(!N(t[h],n[h],a,c))return!1}return!0}(t,n,a,f,c,u);return c.val1.delete(t),c.val2.delete(n),E}function L(e,t,r,n){for(var o=i(e),a=0;a<o.length;a++){var s=o[a];if(N(t,s,r,n))return e.delete(s),!0}return!1}function M(e){switch(r(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(c(e))return!1}return!0}function $(e,t,r){var n=M(r);return null!=n?n:t.has(n)&&!e.has(n)}function D(e,t,r,n,i){var o=M(r);if(null!=o)return o;var a=t.get(o);return!(void 0===a&&!t.has(o)||!N(n,a,!1,i))&&(!e.has(o)&&N(n,a,!1,i))}function B(e,t,r,n,o,a){for(var s=i(e),c=0;c<s.length;c++){var u=s[c];if(N(r,u,o,a)&&N(n,t.get(u),o,a))return e.delete(u),!0}return!1}return h_={isDeepEqual:function(e,t){return N(e,t,false)},isDeepStrictEqual:function(e,t){return N(e,t,true)}}}function Y_(){if(y_)return L_.exports;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}y_=1;var r,n,i=$_().codes,o=i.ERR_AMBIGUOUS_ARGUMENT,a=i.ERR_INVALID_ARG_TYPE,s=i.ERR_INVALID_ARG_VALUE,c=i.ERR_INVALID_RETURN_VALUE,u=i.ERR_MISSING_ARGS,l=D_(),d=Nw().inspect,f=Nw().types,p=f.isPromise,h=f.isRegExp,m=z_()(),y=q_()(),g=function(){if(Xw)return Qw;Xw=1;var e=Kv(),t=Tw(),r=t(e("String.prototype.indexOf"));return Qw=function(n,i){var o=e(n,!!i);return"function"==typeof o&&r(n,".prototype.")>-1?t(o):o}}()("RegExp.prototype.test");function b(){var e=J_();r=e.isDeepEqual,n=e.isDeepStrictEqual}var v=!1,w=L_.exports=O,_={};function E(e){if(e.message instanceof Error)throw e.message;throw new l(e)}function S(e,t,r,n){if(!r){var i=!1;if(0===t)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new l({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function O(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];S.apply(void 0,[O,t.length].concat(t))}w.fail=function e(t,r,n,i,o){var a,s=arguments.length;if(0===s)a="Failed";else if(1===s)n=t,t=void 0;else{if(!1===v)v=!0,(process.emitWarning?process.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094");2===s&&(i="!=")}if(n instanceof Error)throw n;var c={actual:t,expected:r,operator:void 0===i?"fail":i,stackStartFn:o||e};void 0!==n&&(c.message=n);var u=new l(c);throw a&&(u.message=a,u.generatedMessage=!0),u},w.AssertionError=l,w.ok=O,w.equal=function e(t,r,n){if(arguments.length<2)throw new u("actual","expected");t!=r&&E({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})},w.notEqual=function e(t,r,n){if(arguments.length<2)throw new u("actual","expected");t==r&&E({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})},w.deepEqual=function e(t,n,i){if(arguments.length<2)throw new u("actual","expected");void 0===r&&b(),r(t,n)||E({actual:t,expected:n,message:i,operator:"deepEqual",stackStartFn:e})},w.notDeepEqual=function e(t,n,i){if(arguments.length<2)throw new u("actual","expected");void 0===r&&b(),r(t,n)&&E({actual:t,expected:n,message:i,operator:"notDeepEqual",stackStartFn:e})},w.deepStrictEqual=function e(t,i,o){if(arguments.length<2)throw new u("actual","expected");void 0===r&&b(),n(t,i)||E({actual:t,expected:i,message:o,operator:"deepStrictEqual",stackStartFn:e})},w.notDeepStrictEqual=function e(t,i,o){if(arguments.length<2)throw new u("actual","expected");void 0===r&&b();n(t,i)&&E({actual:t,expected:i,message:o,operator:"notDeepStrictEqual",stackStartFn:e})},w.strictEqual=function e(t,r,n){if(arguments.length<2)throw new u("actual","expected");y(t,r)||E({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})},w.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new u("actual","expected");y(t,r)&&E({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var A=t(function e(t,r,n){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r.forEach(function(e){e in t&&(void 0!==n&&"string"==typeof n[e]&&h(t[e])&&g(t[e],n[e])?i[e]=n[e]:i[e]=t[e])})});function T(t,i,o,c){if("function"!=typeof i){if(h(i))return g(i,t);if(2===arguments.length)throw new a("expected",["Function","RegExp"],i);if("object"!==e(t)||null===t){var u=new l({actual:t,expected:i,message:o,operator:"deepStrictEqual",stackStartFn:c});throw u.operator=c.name,u}var d=Object.keys(i);if(i instanceof Error)d.push("name","message");else if(0===d.length)throw new s("error",i,"may not be an empty object");return void 0===r&&b(),d.forEach(function(e){"string"==typeof t[e]&&h(i[e])&&g(i[e],t[e])||function(e,t,r,i,o,a){if(!(r in e)||!n(e[r],t[r])){if(!i){var s=new A(e,o),c=new A(t,o,e),u=new l({actual:s,expected:c,operator:"deepStrictEqual",stackStartFn:a});throw u.actual=e,u.expected=t,u.operator=a.name,u}E({actual:e,expected:t,message:i,operator:a.name,stackStartFn:a})}}(t,i,e,o,d,c)}),!0}return void 0!==i.prototype&&t instanceof i||!Error.isPrototypeOf(i)&&!0===i.call({},t)}function x(e){if("function"!=typeof e)throw new a("fn","Function",e);try{e()}catch(e){return e}return _}function I(t){return p(t)||null!==t&&"object"===e(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function k(e){return Promise.resolve().then(function(){var t;if("function"==typeof e){if(!I(t=e()))throw new c("instance of Promise","promiseFn",t)}else{if(!I(e))throw new a("promiseFn",["Function","Promise"],e);t=e}return Promise.resolve().then(function(){return t}).then(function(){return _}).catch(function(e){return e})})}function j(t,r,n,i){if("string"==typeof n){if(4===arguments.length)throw new a("error",["Object","Error","Function","RegExp"],n);if("object"===e(r)&&null!==r){if(r.message===n)throw new o("error/message",'The error message "'.concat(r.message,'" is identical to the message.'))}else if(r===n)throw new o("error/message",'The error "'.concat(r,'" is identical to the message.'));i=n,n=void 0}else if(null!=n&&"object"!==e(n)&&"function"!=typeof n)throw new a("error",["Object","Error","Function","RegExp"],n);if(r===_){var s="";n&&n.name&&(s+=" (".concat(n.name,")")),s+=i?": ".concat(i):".";var c="rejects"===t.name?"rejection":"exception";E({actual:void 0,expected:n,operator:t.name,message:"Missing expected ".concat(c).concat(s),stackStartFn:t})}if(n&&!T(r,n,i,t))throw r}function R(e,t,r,n){if(t!==_){if("string"==typeof r&&(n=r,r=void 0),!r||T(t,r)){var i=n?": ".concat(n):".",o="doesNotReject"===e.name?"rejection":"exception";E({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}function N(t,r,n,i,o){if(!h(r))throw new a("regexp","RegExp",r);var s="match"===o;if("string"!=typeof t||g(r,t)!==s){if(n instanceof Error)throw n;var c=!n;n=n||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(e(t)," (").concat(d(t),")"):(s?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(d(r),". Input:\n\n").concat(d(t),"\n"));var u=new l({actual:t,expected:r,message:n,operator:o,stackStartFn:i});throw u.generatedMessage=c,u}}function P(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];S.apply(void 0,[P,t.length].concat(t))}return w.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];j.apply(void 0,[e,x(t)].concat(n))},w.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return k(t).then(function(t){return j.apply(void 0,[e,t].concat(n))})},w.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];R.apply(void 0,[e,x(t)].concat(n))},w.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return k(t).then(function(t){return R.apply(void 0,[e,t].concat(n))})},w.ifError=function t(r){if(null!=r){var n="ifError got unwanted exception: ";"object"===e(r)&&"string"==typeof r.message?0===r.message.length&&r.constructor?n+=r.constructor.name:n+=r.message:n+=d(r);var i=new l({actual:r,expected:null,operator:"ifError",message:n,stackStartFn:t}),o=r.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=i.stack.split("\n"),c=0;c<a.length;c++){var u=s.indexOf(a[c]);if(-1!==u){s=s.slice(0,u);break}}i.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw i}},w.match=function e(t,r,n){N(t,r,n,e,"match")},w.doesNotMatch=function e(t,r,n){N(t,r,n,e,"doesNotMatch")},w.strict=m(P,w,{equal:w.strictEqual,deepEqual:w.deepStrictEqual,notEqual:w.notStrictEqual,notDeepEqual:w.notDeepStrictEqual}),w.strict.strict=w.strict,L_.exports}function Q_(){if(b_)return g_;b_=1;const e=h,t=ny(),r=Nw().inherits,n=m,i=function(){if(Pw)return Cw.exports;if(Pw=1,"undefined"!=typeof SharedArrayBuffer&&"undefined"!=typeof Atomics){const e=new Int32Array(new SharedArrayBuffer(4));function t(t){if(!1==(t>0&&t<1/0)){if("number"!=typeof t&&"bigint"!=typeof t)throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait(e,0,0,Number(t))}Cw.exports=t}else{function r(e){if(!1==(e>0&&e<1/0)){if("number"!=typeof e&&"bigint"!=typeof e)throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}}Cw.exports=r}return Cw.exports}(),o=Y_(),a=100,s=Buffer.allocUnsafe(0),c="buffer",u="utf8",[l,d]=(process.versions.node||"0.0").split(".").map(Number),f=l>=22&&d>=7;function p(t,r){function i(e,n){if(e)return r._reopening=!1,r._writing=!1,r._opening=!1,void(r.sync?process.nextTick(()=>{r.listenerCount("error")>0&&r.emit("error",e)}):r.emit("error",e));const i=r._reopening;r.fd=n,r.file=t,r._reopening=!1,r._opening=!1,r._writing=!1,r.sync?process.nextTick(()=>r.emit("ready")):r.emit("ready"),r.destroyed||(!r._writing&&r._len>r.minLength||r._flushPending?r._actualWrite():i&&process.nextTick(()=>r.emit("drain")))}r._opening=!0,r._writing=!0,r._asyncDrainScheduled=!1;const o=r.append?"a":"w",a=r.mode;if(r.sync)try{r.mkdir&&e.mkdirSync(n.dirname(t),{recursive:!0});i(null,e.openSync(t,o,a))}catch(e){throw i(e),e}else r.mkdir?e.mkdir(n.dirname(t),{recursive:!0},r=>{if(r)return i(r);e.open(t,o,a,i)}):e.open(t,o,a,i)}function y(t){if(!(this instanceof y))return new y(t);let r,n,{fd:o,dest:l,minLength:d,maxLength:f,maxWrite:h,periodicFlush:m,sync:v,append:E=!0,mkdir:j,retryEAGAIN:R,fsync:N,contentMode:P,mode:C}=t||{};if(o=o||l,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(d||0,16387),this.file=null,this.destroyed=!1,this.minLength=d||0,this.maxLength=f||0,this.maxWrite=h||16384,this._periodicFlush=m||0,this._periodicFlushTimer=void 0,this.sync=v||!1,this.writable=!0,this._fsync=N||!1,this.append=E||!1,this.mode=C,this.retryEAGAIN=R||(()=>!0),this.mkdir=j||!1,P===c)this._writingBuf=s,this.write=_,this.flush=O,this.flushSync=T,this._actualWrite=I,r=()=>e.writeSync(this.fd,this._writingBuf),n=()=>e.write(this.fd,this._writingBuf,this.release);else{if(void 0!==P&&P!==u)throw new Error(`SonicBoom supports "${u}" and "${c}", but passed ${P}`);this._writingBuf="",this.write=w,this.flush=S,this.flushSync=A,this._actualWrite=x,r=()=>e.writeSync(this.fd,this._writingBuf,"utf8"),n=()=>e.write(this.fd,this._writingBuf,"utf8",this.release)}if("number"==typeof o)this.fd=o,process.nextTick(()=>this.emit("ready"));else{if("string"!=typeof o)throw new Error("SonicBoom supports only file descriptors and files");p(o,this)}if(this.minLength>=this.maxWrite)throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(t,o)=>{if(t){if("EAGAIN"!==t.code&&"EBUSY"!==t.code||!this.retryEAGAIN(t,this._writingBuf.length,this._len-this._writingBuf.length))this._writing=!1,this.emit("error",t);else if(this.sync)try{i(a),this.release(void 0,0)}catch(t){this.release(t)}else setTimeout(n,a);return}this.emit("write",o);const s=g(this._writingBuf,this._len,o);if(this._len=s.len,this._writingBuf=s.writingBuf,this._writingBuf.length){if(!this.sync)return void n();try{do{const e=r(),t=g(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(t){return void this.release(t)}}this._fsync&&e.fsyncSync(this.fd);const c=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):c>this.minLength?this._actualWrite():this._ending?c>0?this._actualWrite():(this._writing=!1,k(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(b,this)):this.emit("drain"))},this.on("newListener",function(e){"drain"===e&&(this._asyncDrainScheduled=!1)}),0!==this._periodicFlush&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function g(e,t,r){return"string"==typeof e&&Buffer.byteLength(e)!==r&&(r=Buffer.from(e).subarray(0,r).toString().length),t=Math.max(t-r,0),{writingBuf:e=e.slice(r),len:t}}function b(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"))}function v(e,t){return 0===e.length?s:1===e.length?e[0]:Buffer.concat(e,t)}function w(e){if(this.destroyed)throw new Error("SonicBoom destroyed");const t=this._len+e.length,r=this._bufs;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(0===r.length||r[r.length-1].length+e.length>this.maxWrite?r.push(""+e):r[r.length-1]+=e,this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function _(e){if(this.destroyed)throw new Error("SonicBoom destroyed");const t=this._len+e.length,r=this._bufs,n=this._lens;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(0===r.length||n[n.length-1]+e.length>this.maxWrite?(r.push([e]),n.push(e.length)):(r[r.length-1].push(e),n[n.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function E(t){this._flushPending=!0;const r=()=>{if(this._fsync)this._flushPending=!1,t();else try{e.fsync(this.fd,e=>{this._flushPending=!1,t(e)})}catch(e){t(e)}this.off("error",n)},n=e=>{this._flushPending=!1,t(e),this.off("drain",r)};this.once("drain",r),this.once("error",n)}function S(e){if(null!=e&&"function"!=typeof e)throw new Error("flush cb must be a function");if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e)return void e(t);throw t}this.minLength<=0?e?.():(e&&E.call(this,e),this._writing||(0===this._bufs.length&&this._bufs.push(""),this._actualWrite()))}function O(e){if(null!=e&&"function"!=typeof e)throw new Error("flush cb must be a function");if(this.destroyed){const t=new Error("SonicBoom destroyed");if(e)return void e(t);throw t}this.minLength<=0?e?.():(e&&E.call(this,e),this._writing||(0===this._bufs.length&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite()))}function A(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf="");let t="";for(;this._bufs.length||t;){t.length<=0&&(t=this._bufs[0]);try{const r=e.writeSync(this.fd,t,"utf8"),n=g(t,this._len,r);t=n.writingBuf,this._len=n.len,t.length<=0&&this._bufs.shift()}catch(e){if(("EAGAIN"===e.code||"EBUSY"===e.code)&&!this.retryEAGAIN(e,t.length,this._len-t.length))throw e;i(a)}}try{e.fsyncSync(this.fd)}catch{}}function T(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=s);let t=s;for(;this._bufs.length||t.length;){t.length<=0&&(t=v(this._bufs[0],this._lens[0]));try{const r=e.writeSync(this.fd,t);t=t.subarray(r),this._len=Math.max(this._len-r,0),t.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(e){if(("EAGAIN"===e.code||"EBUSY"===e.code)&&!this.retryEAGAIN(e,t.length,this._len-t.length))throw e;i(a)}}}function x(){const t=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf||this._bufs.shift()||"",this.sync)try{t(null,e.writeSync(this.fd,this._writingBuf,"utf8"))}catch(e){t(e)}else e.write(this.fd,this._writingBuf,"utf8",t)}function I(){const t=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:v(this._bufs.shift(),this._lens.shift()),this.sync)try{t(null,e.writeSync(this.fd,this._writingBuf))}catch(e){t(e)}else f&&(this._writingBuf=Buffer.from(this._writingBuf)),e.write(this.fd,this._writingBuf,t)}function k(t){if(-1!==t.fd){void 0!==t._periodicFlushTimer&&clearInterval(t._periodicFlushTimer),t.destroyed=!0,t._bufs=[],t._lens=[],o("number"==typeof t.fd,"sonic.fd must be a number, got "+typeof t.fd);try{e.fsync(t.fd,function(){1!==t.fd&&2!==t.fd?e.close(t.fd,r):r()})}catch{}}else t.once("ready",k.bind(null,t));function r(e){e?t.emit("error",e):(t._ending&&!t._writing&&t.emit("finish"),t.emit("close"))}}return r(y,t),y.prototype.reopen=function(t){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening)return void this.once("ready",()=>{this.reopen(t)});if(this._ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(t&&(this.file=t),this._reopening=!0,this._writing)return;const r=this.fd;this.once("ready",()=>{r!==this.fd&&e.close(r,e=>{if(e)return this.emit("error",e)})}),p(this.file,this)},y.prototype.end=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");this._opening?this.once("ready",()=>{this.end()}):this._ending||(this._ending=!0,this._writing||(this._len>0&&this.fd>=0?this._actualWrite():k(this)))},y.prototype.destroy=function(){this.destroyed||k(this)},y.SonicBoom=y,y.default=y,g_=y}function X_(){return w_?v_:(w_=1,v_=function(){})}function eE(){if(E_)return __;E_=1;const e={exit:[],beforeExit:[]},t={exit:function(){i("exit")},beforeExit:function(){i("beforeExit")}};let r;function n(n){e[n].length>0||(process.removeListener(n,t[n]),0===e.exit.length&&0===e.beforeExit.length&&(r=void 0))}function i(t){for(const r of e[t]){const e=r.deref(),n=r.fn;void 0!==e&&n(e,t)}e[t]=[]}function o(t){for(const r of["exit","beforeExit"]){const i=e[r].indexOf(t);e[r].splice(i,i+1),n(r)}}function a(n,i,a){if(void 0===i)throw new Error("the object can't be undefined");!function(r){e[r].length>0||process.on(r,t[r])}(n);const s=new WeakRef(i);s.fn=a,void 0===r&&(r=new FinalizationRegistry(o)),r.register(i,s),e[n].push(s)}return __={register:function(e,t){a("exit",e,t)},registerBeforeExit:function(e,t){a("beforeExit",e,t)},unregister:function(t){if(void 0!==r){r.unregister(t);for(const r of["exit","beforeExit"])e[r]=e[r].filter(e=>{const r=e.deref();return r&&r!==t}),n(r)}}},__}function tE(){if(O_)return S_;O_=1,S_=function(i){const o=new t(i);o.on("error",a),process.env.NODE_V8_COVERAGE||i.sync||!e||function(e){if(v.WeakRef&&v.WeakMap&&v.FinalizationRegistry){const t=eE();t.register(e,n),e.on("close",function(){t.unregister(e)})}}(o);return o;function a(e){if("EPIPE"===e.code)return o.write=r,o.end=r,o.flushSync=r,void(o.destroy=r);o.removeListener("error",a)}};const{isMainThread:e}=p,t=Q_(),r=X_();function n(e,t){e.destroyed||("beforeExit"===t?(e.flush(),e.on("drain",function(){e.end()})):e.flushSync())}return S_}function rE(){if(T_)return A_;return T_=1,A_=function(e){return e instanceof Date&&!Number.isNaN(e.getTime())},A_}function nE(){if(I_)return x_;I_=1,x_=function(t){let r=new Date(t);if(e(r))return r;return r=new Date(+t),r};const e=rE();return x_}function iE(){if(j_)return k_;return j_=1,k_=function(e){const t=[];let r=!1,n="";for(let i=0;i<e.length;i++){const o=e.charAt(i);"\\"!==o?r?(r=!1,n+=o):"."!==o?n+=o:(t.push(n),n=""):r=!0}n.length&&t.push(n);return t},k_}function oE(){if(N_)return R_;N_=1,R_=function(t,r){const n=Array.isArray(r)?r:e(r);for(const e of n){if(!Object.prototype.hasOwnProperty.call(t,e))return;t=t[e]}return t};const e=iE();return R_}function aE(){if(C_)return P_;C_=1,P_=function(r,n){const i=t(n),o=i.pop();null!==(r=e(r,i))&&"object"==typeof r&&Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]};const e=oE(),t=iE();return P_}var sE,cE,uE,lE={};function dE(){if(sE)return lE;sE=1,Object.defineProperty(lE,"__esModule",{value:!0});var e=Function.prototype.toString,t=Object.create,r=Object.prototype.toString,n=function(){function e(){this._keys=[],this._values=[]}return e.prototype.has=function(e){return!!~this._keys.indexOf(e)},e.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},e.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},e}();var i="undefined"!=typeof WeakMap?function(){return new WeakMap}:function(){return new n};function o(r){if(!r)return t(null);var n=r.constructor;if(n===Object)return r===Object.prototype?{}:t(r);if(n&&~e.call(n).indexOf("[native code]"))try{return new n}catch(e){}return t(r)}var a="g"===/test/g.flags?function(e){return e.flags}:function(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t};function s(e){var t=r.call(e);return t.substring(8,t.length-1)}var c="undefined"!=typeof Symbol?function(e){return e[Symbol.toStringTag]||s(e)}:s,u=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,p=Object.prototype,h=p.hasOwnProperty,m=p.propertyIsEnumerable,y="function"==typeof f;var g=y?function(e){return d(e).concat(f(e))}:d;function b(e,t,r){for(var n=g(e),i=0,o=n.length,a=void 0,s=void 0;i<o;++i)if("callee"!==(a=n[i])&&"caller"!==a)if(s=l(e,a)){s.get||s.set||(s.value=r.copier(s.value,r));try{u(t,a,s)}catch(e){t[a]=s.value}}else t[a]=r.copier(e[a],r);return t}function v(e,t){return e.slice(0)}function w(e,t){var r=new t.Constructor;return t.cache.set(e,r),e.forEach(function(e,n){r.set(n,t.copier(e,t))}),r}var _=y?function(e,t){var r=o(t.prototype);for(var n in t.cache.set(e,r),e)h.call(e,n)&&(r[n]=t.copier(e[n],t));for(var i=f(e),a=0,s=i.length,c=void 0;a<s;++a)c=i[a],m.call(e,c)&&(r[c]=t.copier(e[c],t));return r}:function(e,t){var r=o(t.prototype);for(var n in t.cache.set(e,r),e)h.call(e,n)&&(r[n]=t.copier(e[n],t));return r};function E(e,t){return new t.Constructor(e.valueOf())}function S(e,t){return e}function O(e,t){var r=new t.Constructor;return t.cache.set(e,r),e.forEach(function(e){r.add(t.copier(e,t))}),r}var A=Array.isArray,T=Object.assign,x=Object.getPrototypeOf||function(e){return e.__proto__},I={array:function(e,t){var r=new t.Constructor;t.cache.set(e,r);for(var n=0,i=e.length;n<i;++n)r[n]=t.copier(e[n],t);return r},arrayBuffer:v,blob:function(e,t){return e.slice(0,e.size,e.type)},dataView:function(e,t){return new t.Constructor(v(e.buffer))},date:function(e,t){return new t.Constructor(e.getTime())},error:S,map:w,object:_,regExp:function(e,t){var r=new t.Constructor(e.source,a(e));return r.lastIndex=e.lastIndex,r},set:O},k=T({},I,{array:function(e,t){var r=new t.Constructor;return t.cache.set(e,r),b(e,r,t)},map:function(e,t){return b(e,w(e,t),t)},object:function(e,t){var r=o(t.prototype);return t.cache.set(e,r),b(e,r,t)},set:function(e,t){return b(e,O(e,t),t)}});function j(e){var t=function(e){return{Arguments:e.object,Array:e.array,ArrayBuffer:e.arrayBuffer,Blob:e.blob,Boolean:E,DataView:e.dataView,Date:e.date,Error:e.error,Float32Array:e.arrayBuffer,Float64Array:e.arrayBuffer,Int8Array:e.arrayBuffer,Int16Array:e.arrayBuffer,Int32Array:e.arrayBuffer,Map:e.map,Number:E,Object:e.object,Promise:S,RegExp:e.regExp,Set:e.set,String:E,WeakMap:S,WeakSet:S,Uint8Array:e.arrayBuffer,Uint8ClampedArray:e.arrayBuffer,Uint16Array:e.arrayBuffer,Uint32Array:e.arrayBuffer,Uint64Array:e.arrayBuffer}}(T({},I,e)),r=t.Array,n=t.Object;function o(e,i){if(i.prototype=i.Constructor=void 0,!e||"object"!=typeof e)return e;if(i.cache.has(e))return i.cache.get(e);if(i.prototype=x(e),i.Constructor=i.prototype&&i.prototype.constructor,!i.Constructor||i.Constructor===Object)return n(e,i);if(A(e))return r(e,i);var o=t[c(e)];return o?o(e,i):"function"==typeof e.then?e:n(e,i)}return function(e){return o(e,{Constructor:void 0,cache:i(),copier:o,prototype:void 0})}}function R(e){return j(T({},k,e))}var N=R({}),P=j({});return lE.copyStrict=N,lE.createCopier=j,lE.createStrictCopier=R,lE.default=P,lE}function fE(){if(uE)return cE;uE=1,cE=function({log:e,context:n}){const{ignoreKeys:i,includeKeys:o}=n,a=t(e);if(o){const e={};return o.forEach(t=>{e[t]=a[t]}),e}return i.forEach(e=>{r(a,e)}),a};const{createCopier:e}=dE(),t=e({}),r=aE();return cE}var pE,hE,mE,yE,gE,bE,vE,wE,_E,EE,SE,OE,AE,TE,xE,IE,kE,jE,RE,NE,PE,CE,LE,ME,$E,DE,BE,FE,UE,zE,GE,qE,VE,WE={exports:{}};function HE(){return pE||(pE=1,function(e,t){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}!function(n){var i,o,a,s=arguments,c=(i=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,o=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,a=/[^-+\dA-Z]/g,function(e,t,r,n){if(1!==s.length||"string"!==p(e)||/\d/.test(e)||(t=e,e=void 0),(e=e||0===e?e:new Date)instanceof Date||(e=new Date(e)),isNaN(e))throw TypeError("Invalid date");var h=(t=String(c.masks[t]||t||c.masks.default)).slice(0,4);"UTC:"!==h&&"GMT:"!==h||(t=t.slice(4),r=!0,"GMT:"===h&&(n=!0));var m=function(){return r?"getUTC":"get"},y=function(){return e[m()+"Date"]()},g=function(){return e[m()+"Day"]()},b=function(){return e[m()+"Month"]()},v=function(){return e[m()+"FullYear"]()},w=function(){return e[m()+"Hours"]()},_=function(){return e[m()+"Minutes"]()},E=function(){return e[m()+"Seconds"]()},S=function(){return e[m()+"Milliseconds"]()},O=function(){return r?0:e.getTimezoneOffset()},A=function(){return d(e)},T={d:function(){return y()},dd:function(){return u(y())},ddd:function(){return c.i18n.dayNames[g()]},DDD:function(){return l({y:v(),m:b(),d:y(),_:m(),dayName:c.i18n.dayNames[g()],short:!0})},dddd:function(){return c.i18n.dayNames[g()+7]},DDDD:function(){return l({y:v(),m:b(),d:y(),_:m(),dayName:c.i18n.dayNames[g()+7]})},m:function(){return b()+1},mm:function(){return u(b()+1)},mmm:function(){return c.i18n.monthNames[b()]},mmmm:function(){return c.i18n.monthNames[b()+12]},yy:function(){return String(v()).slice(2)},yyyy:function(){return u(v(),4)},h:function(){return w()%12||12},hh:function(){return u(w()%12||12)},H:function(){return w()},HH:function(){return u(w())},M:function(){return _()},MM:function(){return u(_())},s:function(){return E()},ss:function(){return u(E())},l:function(){return u(S(),3)},L:function(){return u(Math.floor(S()/10))},t:function(){return w()<12?c.i18n.timeNames[0]:c.i18n.timeNames[1]},tt:function(){return w()<12?c.i18n.timeNames[2]:c.i18n.timeNames[3]},T:function(){return w()<12?c.i18n.timeNames[4]:c.i18n.timeNames[5]},TT:function(){return w()<12?c.i18n.timeNames[6]:c.i18n.timeNames[7]},Z:function(){return n?"GMT":r?"UTC":(String(e).match(o)||[""]).pop().replace(a,"").replace(/GMT\+0000/g,"UTC")},o:function(){return(O()>0?"-":"+")+u(100*Math.floor(Math.abs(O())/60)+Math.abs(O())%60,4)},p:function(){return(O()>0?"-":"+")+u(Math.floor(Math.abs(O())/60),2)+":"+u(Math.floor(Math.abs(O())%60),2)},S:function(){return["th","st","nd","rd"][y()%10>3?0:(y()%100-y()%10!=10)*y()%10]},W:function(){return A()},WW:function(){return u(A())},N:function(){return f(e)}};return t.replace(i,function(e){return e in T?T[e]():e.slice(1,e.length-1)})});c.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",paddedShortDate:"mm/dd/yyyy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},c.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],timeNames:["a","p","am","pm","A","P","AM","PM"]};var u=function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e},l=function(e){var t=e.y,r=e.m,n=e.d,i=e._,o=e.dayName,a=e.short,s=void 0!==a&&a,c=new Date,u=new Date;u.setDate(u[i+"Date"]()-1);var l=new Date;l.setDate(l[i+"Date"]()+1);return c[i+"FullYear"]()===t&&c[i+"Month"]()===r&&c[i+"Date"]()===n?s?"Tdy":"Today":u[i+"FullYear"]()===t&&u[i+"Month"]()===r&&u[i+"Date"]()===n?s?"Ysd":"Yesterday":l[i+"FullYear"]()===t&&l[i+"Month"]()===r&&l[i+"Date"]()===n?s?"Tmw":"Tomorrow":o},d=function(e){var t=new Date(e.getFullYear(),e.getMonth(),e.getDate());t.setDate(t.getDate()-(t.getDay()+6)%7+3);var r=new Date(t.getFullYear(),0,4);r.setDate(r.getDate()-(r.getDay()+6)%7+3);var n=t.getTimezoneOffset()-r.getTimezoneOffset();t.setHours(t.getHours()-n);var i=(t-r)/6048e5;return 1+Math.floor(i)},f=function(e){var t=e.getDay();return 0===t&&(t=7),t},p=function(e){return null===e?"null":void 0===e?"undefined":"object"!==r(e)?r(e):Array.isArray(e)?"array":{}.toString.call(e).slice(8,-1).toLowerCase()};"object"===r(t)?e.exports=c:n.dateFormat=c}(void 0)}(WE,WE.exports)),WE.exports}function KE(){if(mE)return hE;mE=1,hE=function(o,a=!1){if(!1===a)return o;const s=n(o);if(!i(s))return o;if(!0===a)return r(s,t);const c=a.toUpperCase();if("SYS:STANDARD"===c)return r(s,e);const u=c.substr(0,4);if("SYS:"===u||"UTC:"===u)return r(s,"UTC:"===u?a:a.slice(4));return r(s,`UTC:${a}`)};const{DATE_FORMAT:e,DATE_FORMAT_SIMPLE:t}=kg(),r=HE(),n=nE(),i=rE();return hE}function ZE(){if(gE)return yE;return gE=1,yE=function(e){if(!e)return{};return"string"==typeof e?e.split(",").reduce((e,t,r)=>{const[n,i=r]=t.split(":");return e[n.toLowerCase()]=i,e},{}):"[object Object]"===Object.prototype.toString.call(e)?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}},yE}function JE(){if(vE)return bE;return vE=1,bE=function(e){if(!e)return{};return"string"==typeof e?e.split(",").reduce((e,t,r)=>{const[n,i=r]=t.split(":");return e[i]=n.toUpperCase(),e},{default:"USERLVL"}):"[object Object]"===Object.prototype.toString.call(e)?Object.keys(e).reduce((t,r)=>(t[e[r]]=r.toUpperCase(),t),{default:"USERLVL"}):{}},bE}function YE(){if(_E)return wE;_E=1,wE=function(t,r){return t=t.replace(/{if (.*?)}(.*?){end}/g,function(t,n,i){const o=e(r,n);return o&&i.includes(n)?i.replace(new RegExp("{"+n+"}","g"),o):""}),(t=(t=t.replace(/{if (.*?)}/g,"")).replace(/{end}/g,"")).replace(/\s+/g," ").trim()};const e=oE();return wE}function QE(){if(SE)return EE;return SE=1,EE=function(e){return"[object Object]"===Object.prototype.toString.apply(e)}}function XE(){if(AE)return OE;return AE=1,OE=function({input:e,ident:t=" ",eol:r="\n"}){const n=e.split(/\r?\n/);for(let e=1;e<n.length;e+=1)n[e]=t+n[e];return n.join(r)},OE}function eS(){if(xE)return TE;xE=1,TE=function(o){const a=o.crlf?"\r\n":"\n",{customPrettifiers:s,errorLikeObjectKeys:c,hideObject:u,levelFirst:l,levelKey:d,levelLabel:f,messageFormat:p,messageKey:h,minimumLevel:m,singleLine:y,timestampKey:g,translateTime:b}=o,v=o.errorProps.split(","),w="boolean"==typeof o.useOnlyCustomProps?o.useOnlyCustomProps:"true"===o.useOnlyCustomProps,_=r(o.customLevels),E=n(o.customLevels),S=i(w,_,E);let O;if(o.customColors)if("string"==typeof o.customColors)O=o.customColors.split(",").reduce((t,r)=>{const[n,i]=r.split(":"),a=(w?o.customLevels:void 0!==E[n])?E[n]:e[n],s=void 0!==a?a:n;return t.push([s,i]),t},[]);else{if("object"!=typeof o.customColors)throw new Error("options.customColors must be of type string or object.");O=Object.keys(o.customColors).reduce((t,r)=>{const[n,i]=[r,o.customColors[r]],a=(w?o.customLevels:void 0!==E[n])?E[n]:e[n],s=void 0!==a?a:n;return t.push([s,i]),t},[])}const A={customLevels:_,customLevelNames:E};!0!==w||o.customLevels||(A.customLevels=void 0,A.customLevelNames=void 0);const T=void 0!==o.include?new Set(o.include.split(",")):void 0,x=!T&&o.ignore?new Set(o.ignore.split(",")):void 0,I=t(o.colorize,O,w),k=o.colorizeObjects?I:t(!1,[],!1);return{EOL:a,IDENT:" ",colorizer:I,customColors:O,customLevelNames:E,customLevels:_,customPrettifiers:s,customProperties:A,errorLikeObjectKeys:c,errorProps:v,getLevelLabelData:S,hideObject:u,ignoreKeys:x,includeKeys:T,levelFirst:l,levelKey:d,levelLabel:f,messageFormat:p,messageKey:h,minimumLevel:m,objectColorizer:k,singleLine:y,timestampKey:g,translateTime:b,useOnlyCustomProps:w}};const{LEVEL_NAMES:e}=kg(),t=Rg(),r=JE(),n=ZE(),i=jg();return TE}function tS(){if(kE)return IE;kE=1,IE=o,o.default=o,o.stable=u,o.stableStringify=u;var e="[...]",t="[Circular]",r=[],n=[];function i(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function o(e,t,o,a){var c;void 0===a&&(a=i()),s(e,"",0,[],void 0,0,a);try{c=0===n.length?JSON.stringify(e,t,o):JSON.stringify(e,d(t),o)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return c}function a(e,t,i,o){var a=Object.getOwnPropertyDescriptor(o,i);void 0!==a.get?a.configurable?(Object.defineProperty(o,i,{value:e}),r.push([o,i,t,a])):n.push([t,i,e]):(o[i]=e,r.push([o,i,t]))}function s(r,n,i,o,c,u,l){var d;if(u+=1,"object"==typeof r&&null!==r){for(d=0;d<o.length;d++)if(o[d]===r)return void a(t,r,n,c);if(void 0!==l.depthLimit&&u>l.depthLimit)return void a(e,r,n,c);if(void 0!==l.edgesLimit&&i+1>l.edgesLimit)return void a(e,r,n,c);if(o.push(r),Array.isArray(r))for(d=0;d<r.length;d++)s(r[d],d,d,o,r,u,l);else{var f=Object.keys(r);for(d=0;d<f.length;d++){var p=f[d];s(r[p],p,d,o,r,u,l)}}o.pop()}}function c(e,t){return e<t?-1:e>t?1:0}function u(e,t,o,a){void 0===a&&(a=i());var s,c=l(e,"",0,[],void 0,0,a)||e;try{s=0===n.length?JSON.stringify(c,t,o):JSON.stringify(c,d(t),o)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return s}function l(n,i,o,s,u,d,f){var p;if(d+=1,"object"==typeof n&&null!==n){for(p=0;p<s.length;p++)if(s[p]===n)return void a(t,n,i,u);try{if("function"==typeof n.toJSON)return}catch(e){return}if(void 0!==f.depthLimit&&d>f.depthLimit)return void a(e,n,i,u);if(void 0!==f.edgesLimit&&o+1>f.edgesLimit)return void a(e,n,i,u);if(s.push(n),Array.isArray(n))for(p=0;p<n.length;p++)l(n[p],p,p,s,n,d,f);else{var h={},m=Object.keys(n).sort(c);for(p=0;p<m.length;p++){var y=m[p];l(n[y],y,p,s,n,d,f),h[y]=n[y]}if(void 0===u)return h;r.push([u,i,n]),u[i]=h}s.pop()}}function d(e){return e=void 0!==e?e:function(e,t){return t},function(t,r){if(n.length>0)for(var i=0;i<n.length;i++){var o=n[i];if(o[1]===t&&o[0]===r){r=o[2],n.splice(i,1);break}}return e.call(this,t,r)}}return IE}function rS(){if(RE)return jE;RE=1,jE=function({keyName:t,lines:r,eol:n,ident:i}){let o="";const a=e({input:r,ident:i,eol:n}),s=`${i}${t}: ${a}${n}`.split(n);for(let e=0;e<s.length;e+=1){0!==e&&(o+=n);const t=s[e];if(/^\s*"stack"/.test(t)){const e=/^(\s*"stack":)\s*(".*"),?$/.exec(t);if(e&&3===e.length){const r=/^\s*/.exec(t)[0].length+4,i=" ".repeat(r),a=e[2];o+=e[1]+n+i+JSON.parse(a).replace(/\n/g,n+i)}else o+=t}else o+=t}return o};const e=XE();return jE}function nS(){if(PE)return NE;PE=1,NE=function({log:i,excludeLoggerKeys:o=!0,skipKeys:a=[],context:s}){const{EOL:c,IDENT:u,customPrettifiers:l,errorLikeObjectKeys:d,objectColorizer:f,singleLine:p,colorizer:h}=s,m=[].concat(a);!0===o&&Array.prototype.push.apply(m,e);let y="";const{plain:g,errors:b}=Object.entries(i).reduce(({plain:e,errors:t},[r,n])=>{if(!1===m.includes(r)){const o="function"==typeof l[r]?l[r](n,r,i,{colors:h.colors}):n;d.includes(r)?t[r]=o:e[r]=o}return{plain:e,errors:t}},{plain:{},errors:{}});p?(Object.keys(g).length>0&&(y+=f.greyMessage(t(g))),y+=c,y=y.replace(/\\\\/gi,"\\")):Object.entries(g).forEach(([e,n])=>{let i="function"==typeof l[e]?n:t(n,null,2);if(void 0===i)return;i=i.replace(/\\\\/gi,"\\");const o=r({input:i,ident:u,eol:c});y+=`${u}${e}:${o.startsWith(c)?"":" "}${o}${c}`});return Object.entries(b).forEach(([e,r])=>{const i="function"==typeof l[e]?r:t(r,null,2);void 0!==i&&(y+=n({keyName:e,lines:i,eol:c,ident:u}))}),y};const{LOGGER_KEYS:e}=kg(),t=tS(),r=XE(),n=rS();return NE}function iS(){if(LE)return CE;LE=1,CE=function({log:i,context:o}){const{EOL:a,IDENT:s,errorProps:c,messageKey:u}=o,l=i.stack,d=r({input:l,ident:s,eol:a});let f=`${s}${d}${a}`;if(c.length>0){const r=e.concat(u,"type","stack");let l;l="*"===c[0]?Object.keys(i).filter(e=>!1===r.includes(e)):c.filter(e=>!1===r.includes(e));for(let e=0;e<l.length;e+=1){const r=l[e];if(r in i!=!1){if(t(i[r])){f=`${f}${s}${r}: {${a}${n({log:i[r],excludeLoggerKeys:!1,context:{...o,IDENT:s+s}})}${s}}${a}`;continue}f=`${f}${s}${r}: ${i[r]}${a}`}}}return f};const{LOGGER_KEYS:e}=kg(),t=QE(),r=XE(),n=nS();return CE}function oS(){if($E)return ME;$E=1,ME=function({log:t,context:r}){const{colorizer:n,customLevels:i,customLevelNames:o,levelKey:a,getLevelLabelData:s}=r,c=r.customPrettifiers?.level,u=e(t,a);if(void 0===u)return;const l=n(u,{customLevels:i,customLevelNames:o});if(c){const[e]=s(u);return c(u,a,t,{label:e,labelColorized:l,colors:n.colors})}return l};const e=oE();return ME}function aS(){if(BE)return DE;BE=1,DE=function({log:n,context:i}){const{colorizer:o,customLevels:a,levelKey:s,levelLabel:c,messageFormat:u,messageKey:l,useOnlyCustomProps:d}=i;if(u&&"string"==typeof u){const i=r(u,n),l=String(i).replace(/{([^{}]+)}/g,function(r,i){let o;if(i===c&&void 0!==(o=t(n,s))){return(d?void 0===a:void 0===a[o])?e[o]:a[o]}return t(n,i)||""});return o.message(l)}if(u&&"function"==typeof u){const e=u(n,l,c,{colors:o.colors});return o.message(e)}return l in n==!1||"string"!=typeof n[l]&&"number"!=typeof n[l]&&"boolean"!=typeof n[l]?void 0:o.message(n[l])};const{LEVELS:e}=kg(),t=oE(),r=YE();return DE}function sS(){if(UE)return FE;return UE=1,FE=function({log:e,context:t}){const{customPrettifiers:r,colorizer:n}=t;let i="";if(e.name||e.pid||e.hostname){if(i+="(",e.name&&(i+=r.name?r.name(e.name,"name",e,{colors:n.colors}):e.name),e.pid){const t=r.pid?r.pid(e.pid,"pid",e,{colors:n.colors}):e.pid;e.name&&e.pid?i+="/"+t:i+=t}if(e.hostname){i+=`${"("===i?"on":" on"} ${r.hostname?r.hostname(e.hostname,"hostname",e,{colors:n.colors}):e.hostname}`}i+=")"}if(e.caller){i+=`${""===i?"":" "}<${r.caller?r.caller(e.caller,"caller",e,{colors:n.colors}):e.caller}>`}return""===i?void 0:i}}function cS(){if(GE)return zE;GE=1,zE=function({log:t,context:r}){const{timestampKey:n,translateTime:i}=r,o=r.customPrettifiers?.time;let a=null;n in t?a=t[n]:"timestamp"in t&&(a=t.timestamp);if(null===a)return;const s=i?e(a,i):a;return o?o(s):`[${s}]`};const e=KE();return zE}var uS,lS,dS,fS,pS={exports:{}};function hS(){if(dS)return lS;dS=1,lS=function(e){let p;if(t(e))p=e;else{const r=f(e);if(r.err||!t(r.value))return e+this.EOL;p=r.value}if(this.minimumLevel){let e,t;e=this.useOnlyCustomProps?this.customLevels:void 0!==this.customLevelNames[this.minimumLevel],t=e?this.customLevelNames[this.minimumLevel]:d[this.minimumLevel],t||(t="string"==typeof this.minimumLevel?d[this.minimumLevel]:d[u[this.minimumLevel].toLowerCase()]);if(p[void 0===this.levelKey?l:this.levelKey]<t)return}const h=i({log:p,context:this.context});(this.ignoreKeys||this.includeKeys)&&(p=c({log:p,context:this.context}));const m=n({log:p,context:{...this.context,...this.context.customProperties}}),y=o({log:p,context:this.context}),g=s({log:p,context:this.context});let b="";this.levelFirst&&m&&(b=`${m}`);g&&""===b?b=`${g}`:g&&(b=`${b} ${g}`);!this.levelFirst&&m&&(b=b.length>0?`${b} ${m}`:m);y&&(b=b.length>0?`${b} ${y}:`:y);!1===b.endsWith(":")&&""!==b&&(b+=":");void 0!==h&&(b=b.length>0?`${b} ${h}`:h);b.length>0&&!this.singleLine&&(b+=this.EOL);if("Error"===p.type&&"string"==typeof p.stack){const e=r({log:p,context:this.context});this.singleLine&&(b+=this.EOL),b+=e}else if(!1===this.hideObject){const e=[this.messageKey,this.levelKey,this.timestampKey].filter(e=>"string"==typeof p[e]||"number"==typeof p[e]||"boolean"==typeof p[e]),t=a({log:p,skipKeys:e,context:this.context});this.singleLine&&!/^\s$/.test(t)&&(b+=" "),b+=t}return b};const e=function(){if(uS)return pS.exports;uS=1;const e="undefined"!=typeof Buffer,t=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,r=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function n(n,o,a){null==a&&null!==o&&"object"==typeof o&&(a=o,o=void 0),e&&Buffer.isBuffer(n)&&(n=n.toString()),n&&65279===n.charCodeAt(0)&&(n=n.slice(1));const s=JSON.parse(n,o);if(null===s||"object"!=typeof s)return s;const c=a&&a.protoAction||"error",u=a&&a.constructorAction||"error";if("ignore"===c&&"ignore"===u)return s;if("ignore"!==c&&"ignore"!==u){if(!1===t.test(n)&&!1===r.test(n))return s}else if("ignore"!==c&&"ignore"===u){if(!1===t.test(n))return s}else if(!1===r.test(n))return s;return i(s,{protoAction:c,constructorAction:u,safe:a&&a.safe})}function i(e,{protoAction:t="error",constructorAction:r="error",safe:n}={}){let i=[e];for(;i.length;){const e=i;i=[];for(const o of e){if("ignore"!==t&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(!0===n)return null;if("error"===t)throw new SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if("ignore"!==r&&Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(!0===n)return null;if("error"===r)throw new SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(const e in o){const t=o[e];t&&"object"==typeof t&&i.push(t)}}}return e}function o(e,t,r){const i=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return n(e,t,r)}finally{Error.stackTraceLimit=i}}return pS.exports=o,pS.exports.default=o,pS.exports.parse=o,pS.exports.safeParse=function(e,t){const r=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return n(e,t,{safe:!0})}catch(e){return null}finally{Error.stackTraceLimit=r}},pS.exports.scan=i,pS.exports}(),t=QE(),r=iS(),n=oS(),i=aS(),o=sS(),a=nS(),s=cS(),c=fE(),{LEVELS:u,LEVEL_KEY:l,LEVEL_NAMES:d}=kg(),f=t=>{try{return{value:e.parse(t,{protoAction:"remove"})}}catch(e){return{err:e}}};return lS}var mS=function(){if(fS)return bm.exports;fS=1;const{isColorSupported:e}=wm(),t=Nm(),{Transform:r}=(ng||(ng=1,function(e){const t=xg(),r=Tg(),n=t.Readable.destroy;e.exports=t.Readable,e.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,e.exports._isUint8Array=t._isUint8Array,e.exports.isDisturbed=t.isDisturbed,e.exports.isErrored=t.isErrored,e.exports.isReadable=t.isReadable,e.exports.Readable=t.Readable,e.exports.Writable=t.Writable,e.exports.Duplex=t.Duplex,e.exports.Transform=t.Transform,e.exports.PassThrough=t.PassThrough,e.exports.addAbortSignal=t.addAbortSignal,e.exports.finished=t.finished,e.exports.destroy=t.destroy,e.exports.destroy=n,e.exports.pipeline=t.pipeline,e.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get:()=>r}),e.exports.Stream=t.Stream,e.exports.default=e.exports}($m)),$m.exports),n=Ig(),i=Rg(),{ERROR_LIKE_KEYS:o,LEVEL_KEY:a,LEVEL_LABEL:s,MESSAGE_KEY:c,TIMESTAMP_KEY:u}=kg(),{buildSafeSonicBoom:l,parseFactoryOptions:d}=VE?qE:(VE=1,qE={buildSafeSonicBoom:tE(),createDate:nE(),deleteLogProperty:aE(),filterLog:fE(),formatTime:KE(),getPropertyValue:oE(),handleCustomLevelsNamesOpts:ZE(),handleCustomLevelsOpts:JE(),interpretConditionals:YE(),isObject:QE(),isValidDate:rE(),joinLinesWithIndentation:XE(),noop:X_(),parseFactoryOptions:eS(),prettifyErrorLog:iS(),prettifyError:rS(),prettifyLevel:oS(),prettifyMessage:aS(),prettifyMetadata:sS(),prettifyObject:nS(),prettifyTime:cS(),splitPropertyKey:iE(),getLevelLabelData:jg()}),f=hS(),p={colorize:e,colorizeObjects:!0,crlf:!1,customColors:null,customLevels:null,customPrettifiers:{},errorLikeObjectKeys:o,errorProps:"",hideObject:!1,ignore:"hostname",include:void 0,levelFirst:!1,levelKey:a,levelLabel:s,messageFormat:null,messageKey:c,minimumLevel:void 0,outputStream:process.stdout,singleLine:!1,timestampKey:u,translateTime:!0,useOnlyCustomProps:!0};function h(e){const t=d(Object.assign({},p,e));return f.bind({...t,context:t})}function m(e={}){let i,a=h(e);return n(function(n){n.on("message",function t(r){r&&"PINO_CONFIG"===r.code&&(Object.assign(e,{messageKey:r.config.messageKey,errorLikeObjectKeys:Array.from(new Set([...e.errorLikeObjectKeys||o,r.config.errorKey])),customLevels:r.config.levels.values}),a=h(e),n.off("message",t))});const s=new r({objectMode:!0,autoDestroy:!0,transform(e,t,r){r(null,a(e))}});return i="object"==typeof e.destination&&"function"==typeof e.destination.write?e.destination:l({dest:e.destination||1,append:e.append,mkdir:e.mkdir,sync:e.sync}),n.on("unknown",function(e){i.write(e+"\n")}),t(n,s,i),s},{parse:"lines",close(e,t){i.on("close",()=>{t(e)})}})}return bm.exports=m,bm.exports.build=m,bm.exports.PinoPretty=m,bm.exports.prettyFactory=h,bm.exports.colorizerFactory=i,bm.exports.isColorSupported=e,bm.exports.default=m,bm.exports}(),yS=w(mS);function gS(e){var t=e||{},r=t.level,n=t.component,i=yS({colorize:!0}),o=gm({level:process.env.LOG_LEVEL||r||"error",redact:{paths:["pid","hostname"],remove:!0}},i);return n?o.child({component:n}):o}var bS=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return Boolean}),k("design:type",Boolean)],e.prototype,"threadExists",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"state",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"messages",void 0),e=x([Ed()],e)}(),vS=function(){function e(){}return x([gd(function(){return String}),k("design:type",String)],e.prototype,"threadId",void 0),x([gd(function(){return String}),k("design:type",String)],e.prototype,"agentName",void 0),e=x([bd()],e)}(),wS=function(){function e(){}return e.prototype.loadAgentState=function(e,t){return j(this,void 0,void 0,function(){var e,n;return R(this,function(i){if(n=(e=[]).some(function(e){return e.name===t.agentName}),!n)throw new r.CopilotKitAgentDiscoveryError({agentName:t.agentName,availableAgents:e.map(function(e){return{name:e.name,id:e.name}})});return[2,{}]})})},x([Sd(function(){return bS}),I(0,md()),I(1,hd("data")),k("design:type",Function),k("design:paramtypes",[Object,vS]),k("design:returntype",Promise)],e.prototype,"loadAgentState",null),e=x([Od(function(){return bS})],e)}(),_S=gS(),ES={onResponse:function(e){e.response.headers.set("X-CopilotKit-Runtime-Version","1.51.3-next.2")}};function SS(e,t,r){return j(this,arguments,void 0,function(e,t,r,n){return void 0===n&&(n={}),R(this,function(i){return _S.debug({copilotKitContext:t},"Creating GraphQL context"),[2,T(T({},e),{_copilotkit:T({},t),properties:T({},n),logger:r})]})})}function OS(e){void 0===e&&(e={}),_S.debug("Building GraphQL schema...");var t=Xf({resolvers:[Dh,wS],emitSchemaFile:e.emitSchemaFile});return _S.debug("GraphQL schema built successfully"),t}function AS(e){var n,i=process.env.LOG_LEVEL||e.logLevel||"error";gS({level:i,component:"getCommonConfig"});var o=gS({level:i});e.cloud&&Rh.setCloudConfiguration({publicApiKey:e.cloud.publicApiKey,baseUrl:e.cloud.baseUrl}),(null===(n=e.properties)||void 0===n?void 0:n._copilotkit)&&Rh.setGlobalProperties({_copilotkit:T({},e.properties._copilotkit)}),Rh.setGlobalProperties({runtime:{serviceAdapter:e.serviceAdapter.constructor.name}});var a=[r.CopilotKitErrorCode.AGENT_NOT_FOUND,r.CopilotKitErrorCode.API_NOT_FOUND,r.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,r.CopilotKitErrorCode.CONFIGURATION_ERROR,r.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR];return{logging:gS({component:"Yoga GraphQL",level:i}),schema:OS(),plugins:[{onSchemaChange:({schema:e,replaceSchema:r})=>{const n=[];null==e.getDirective("defer")&&n.push(Gh),null==e.getDirective("stream")&&n.push(qh),n.length&&r(new t.GraphQLSchema({...e.toConfig(),directives:[...e.getDirectives(),...n]}))},onValidate:({params:e,addValidationRule:t})=>{e.rules||=[],e.rules=e.rules.filter(e=>"OverlappingFieldsCanBeMergedRule"!==e.name),t(Qh),t(Vh),t(Wh),t(lm)}},ES],context:function(t){return SS(t,e,o,e.properties)},maskedErrors:{maskError:function(e,t,n){var i=e.originalError||e,o=e.extensions,s=null==o?void 0:o.code;return s&&a.includes(s)||i instanceof r.CopilotKitError&&a.includes(i.code)?(console.debug("User configuration error:",e.message),e):(console.error("Application error:",e),e)}}}}function TS(e,t){var r;return null==e?{body:null}:e instanceof Buffer||e instanceof Uint8Array?{body:e}:"string"==typeof e?{body:e,contentType:null!==(r=t.get("content-type"))&&void 0!==r?r:"text/plain"}:{body:JSON.stringify(e),contentType:"application/json"}}function xS(e){var t,r,n=AS(e);Rh.setGlobalProperties({runtime:{framework:"node-http"}}),(null===(t=e.properties)||void 0===t?void 0:t._copilotkit)&&Rh.setGlobalProperties({_copilotkit:e.properties._copilotkit}),Rh.capture("oss.runtime.instance_created",Nh(e));var i=n.logging;i.debug("Creating Node HTTP endpoint");var o=e.serviceAdapter;o&&e.runtime.handleServiceAdapter(o);var a=u.createCopilotEndpointSingleRoute(T({runtime:e.runtime.instance,basePath:null!==(r=e.baseUrl)&&void 0!==r?r:e.endpoint},e.cors&&{cors:e.cors})),s=function(e,t){return j(this,void 0,void 0,function(){var r,n,o,s,c,u,l,d,f,p,h,m,g,b,v,w;return R(this,function(_){switch(_.label){case 0:r=function(e){var t=e.url||"/",r=e.headers["x-forwarded-host"]||e.headers.host||"localhost",n=e.headers["x-forwarded-proto"]||(e.socket.encrypted?"https":"http");return"".concat(n,"://").concat(r).concat(t)}(e),n="GET"!==e.method&&"HEAD"!==e.method,o=function(e){for(var t=new Headers,r=function(e,r){return void 0===r?"continue":Array.isArray(r)?(r.forEach(function(r){return t.append(e,r)}),"continue"):void t.append(e,r)},n=0,i=Object.entries(e);n<i.length;n++){var o=i[n];r(o[0],o[1])}return t}(e.headers),s=e.body,c=function(e){var t=e._readableState;return Boolean(e.readableEnded||e.complete||(null==t?void 0:t.ended)||(null==t?void 0:t.endEmitted))}(e)||void 0!==s,u=n&&!c,l=void 0,d=!1,n&&u&&(A=e,l=new ReadableStream({start:function(e){A.on("data",function(t){e.enqueue(t instanceof Buffer?new Uint8Array(t):t)}),A.on("end",function(){e.close()}),A.on("error",function(t){e.error(t)})},cancel:function(){A.destroy()}}),d=!0),n&&c&&(void 0!==s?(b=TS(s,o),l=null!==(v=b.body)&&void 0!==v?v:void 0,o.delete("content-length"),b.contentType&&o.set("content-type",b.contentType),i.debug("Request stream already consumed; using parsed req.body to rebuild request.")):(i.warn("Request stream consumed with no available body; sending empty payload."),l=void 0)),f=function(t,n,i){return new Request(r,{method:e.method,headers:n,body:t,duplex:i?"half":void 0})},_.label=1;case 1:return _.trys.push([1,3,,7]),[4,a.fetch(f(l,o,d))];case 2:return p=_.sent(),[3,7];case 3:return h=_.sent(),(O=h)instanceof TypeError&&"string"==typeof O.message&&(O.message.includes("disturbed")||O.message.includes("locked"))&&n?(i.warn("Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload."),m=new Headers(o),g=void 0,void 0!==s?(b=TS(s,m),g=null!==(w=b.body)&&void 0!==w?w:void 0,m.delete("content-length"),b.contentType&&m.set("content-type",b.contentType)):g=void 0,[4,a.fetch(f(g,m,!1))]):[3,5];case 4:return p=_.sent(),[3,6];case 5:throw h;case 6:return[3,7];case 7:return t.statusCode=p.status,p.headers.forEach(function(e,r){t.setHeader(r,e)}),p.body?(E=p.body,S=E.getReader(),new y.Readable({read:function(){return j(this,void 0,void 0,function(){var e,t,r,n;return R(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,S.read()];case 1:return e=i.sent(),t=e.done,r=e.value,t?this.push(null):this.push(Buffer.from(r)),[3,3];case 2:return n=i.sent(),this.destroy(n),[3,3];case 3:return[2]}})})}})).pipe(t):t.end(),[2]}var E,S,O,A})})};return function(e,t){if(e instanceof Request)return a.fetch(e);if(!t)throw new TypeError("ServerResponse is required for Node HTTP requests");return s(e,t)}}var IS=function(){throw new Error("LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead")},kS=function(){throw new Error("LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead")},jS=function(){function e(e){this.name=e.name,this.description=e.description,this.chainUrl=e.chainUrl,this.parameters=e.parameters,this.parameterType=e.parameterType||"multi"}return e.prototype.toAction=function(){return j(this,void 0,void 0,function(){var e=this;return R(this,function(t){switch(t.label){case 0:return this.parameters?[3,2]:[4,this.inferLangServeParameters()];case 1:t.sent(),t.label=2;case 2:return[2,{name:this.name,description:this.description,parameters:this.parameters,handler:function(t){return j(e,void 0,void 0,function(){var e,r,n;return R(this,function(i){switch(i.label){case 0:return e=require("langchain/runnables/remote").RemoteRunnable,r=new e({url:this.chainUrl}),n="single"===this.parameterType?t[Object.keys(t)[0]]:t,[4,r.invoke(n)];case 1:return[2,i.sent()]}})})}}]}})})},e.prototype.inferLangServeParameters=function(){return j(this,void 0,void 0,function(){var e,t,r;return R(this,function(n){switch(n.label){case 0:return e=["string","number","boolean"],t=this.chainUrl.replace(/\/+$/,"")+"/input_schema",[4,fetch(t).then(function(e){return e.json()}).catch(function(){throw new Error("Failed to fetch langserve schema at "+t)})];case 1:if(r=n.sent(),e.includes(r.type))this.parameterType="single",this.parameters=[{name:"input",type:r.type,description:"The input to the chain"}];else{if("object"!==r.type)throw new Error("Unsupported schema type");this.parameterType="multi",this.parameters=Object.keys(r.properties).map(function(t){var n,i=r.properties[t];if(!e.includes(i.type))throw new Error("Unsupported schema type");return{name:t,type:i.type,description:i.description||"",required:(null===(n=r.required)||void 0===n?void 0:n.includes(t))||!1}})}return[2]}})})},e}();function RS(e,t,r,n){n||(n=NS);var i=[],o=function(e,t){if(0===t.length)return 0;var r=JSON.stringify(t);return CS(e,r)}(r,t);if(o>n)throw new Error("Too many tokens in function definitions: ".concat(o," > ").concat(n));n-=o;for(var a=0,s=e;a<s.length;a++){if("system"===(d=s[a]).role)if((n-=f=PS(r,d))<0)throw new Error("Not enough tokens for system message.")}for(var c=!1,u=0,l=P([],e,!0).reverse();u<l.length;u++){var d,f;if("system"!==(d=l[u]).role){if(!c)n<(f=PS(r,d))?c=!0:(i.unshift(d),n-=f)}else i.unshift(d)}return i}var NS=128e3;function PS(e,t){return CS(e,JSON.stringify(t.content)||"")}function CS(e,t){return t.length/3}function LS(e){return{name:e.name,description:e.description,input_schema:JSON.parse(e.jsonSchema)}}var MS=function(){function e(e){this.model="claude-3-5-sonnet-latest",this.provider="anthropic",(null==e?void 0:e.anthropic)&&(this._anthropic=e.anthropic),(null==e?void 0:e.model)&&(this.model=e.model),this.promptCaching=(null==e?void 0:e.promptCaching)||{enabled:!1}}return Object.defineProperty(e.prototype,"anthropic",{get:function(){return this._anthropic},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"AnthropicAdapter"},enumerable:!1,configurable:!0}),e.prototype.ensureAnthropic=function(){if(!this._anthropic){var e=require("@anthropic-ai/sdk").default;this._anthropic=new e({})}return this._anthropic},e.prototype.addSystemPromptCaching=function(e,t){if(void 0===t&&(t=!1),!this.promptCaching.enabled||!e)return e;var r=e.length;return t&&console.log("[ANTHROPIC CACHE DEBUG] Added cache control to system prompt (".concat(r," chars).")),[{type:"text",text:e,cache_control:{type:"ephemeral"}}]},e.prototype.addIncrementalMessageCaching=function(e,t){if(void 0===t&&(t=!1),!this.promptCaching.enabled||0===e.length)return e;var r=e[e.length-1],n=e.length;if(Array.isArray(r.content)&&r.content.length>0){var i=r.content[r.content.length-1],o=P(P([],e.slice(0,-1),!0),[T(T({},r),{content:P(P([],r.content.slice(0,-1),!0),[T(T({},i),{cache_control:{type:"ephemeral"}})],!1)})],!1);return t&&console.log("[ANTHROPIC CACHE DEBUG] Added cache control to final message (message ".concat(n,").")),o}return e},e.prototype.shouldGenerateFallbackResponse=function(e){var t,r,n;if(0===e.length)return!1;var i=e[e.length-1],o="user"===i.role&&Array.isArray(i.content)&&i.content.some(function(e){return"tool_result"===e.type});if(e.length>=3&&o){var a=e.slice(-3);return"user"===(null===(t=a[0])||void 0===t?void 0:t.role)&&"assistant"===(null===(r=a[1])||void 0===r?void 0:r.role)&&Array.isArray(a[1].content)&&a[1].content.some(function(e){return"tool_use"===e.type})&&"user"===(null===(n=a[2])||void 0===n?void 0:n.role)&&Array.isArray(a[2].content)&&a[2].content.some(function(e){return"tool_result"===e.type})}return o},e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w,_,E,S,O,A=this;return R(this,function(x){switch(x.label){case 0:for(t=e.threadId,n=e.model,i=void 0===n?this.model:n,o=e.messages,a=e.actions,s=e.eventSource,c=e.forwardedParameters,u=a.map(LS),l=P([],o,!0),d=l.shift(),f=d.isTextMessage()?d.content:"",p=new Set,h=0,m=l;h<m.length;h++)(y=m[h]).isActionExecutionMessage()&&p.add(y.id);g=new Set,b=l.map(function(e){return e.isResultMessage()?p.has(e.actionExecutionId)?g.has(e.actionExecutionId)?null:(g.add(e.actionExecutionId),{role:"user",content:[{type:"tool_result",content:e.result||"Action completed successfully",tool_use_id:e.actionExecutionId}]}):null:function(e){if(e.isTextMessage())return"system"===e.role?{role:"assistant",content:[{type:"text",text:"THE FOLLOWING MESSAGE IS A SYSTEM MESSAGE: "+e.content}]}:{role:"user"===e.role?"user":"assistant",content:[{type:"text",text:e.content}]};if(e.isImageMessage()){var t=void 0;switch(e.format){case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"webp":t="image/webp";break;case"gif":t="image/gif";break;default:throw new Error("Unsupported image format: ".concat(e.format))}return{role:"user",content:[{type:"image",source:{type:"base64",media_type:t,data:e.bytes}}]}}return e.isActionExecutionMessage()?{role:"assistant",content:[{id:e.id,type:"tool_use",input:e.arguments,name:e.name}]}:e.isResultMessage()?{role:"user",content:[{type:"tool_result",content:e.result||"Action completed successfully",tool_use_id:e.actionExecutionId}]}:void 0}(e)}).filter(Boolean).filter(function(e){return"assistant"!==e.role||!Array.isArray(e.content)||!(1===e.content.length&&"text"===e.content[0].type&&(!e.content[0].text||""===e.content[0].text.trim()))}),v=RS(b,u,i),w=this.addSystemPromptCaching(f,this.promptCaching.debug),_=this.addIncrementalMessageCaching(v,this.promptCaching.debug),E=null==c?void 0:c.toolChoice,"function"===(null==c?void 0:c.toolChoice)&&(E={type:"tool",name:c.toolChoiceFunctionName}),x.label=1;case 1:return x.trys.push([1,3,,4]),S=T(T(T(T({system:w,model:this.model,messages:_,max_tokens:(null==c?void 0:c.maxTokens)||1024},(null==c?void 0:c.temperature)?{temperature:c.temperature}:{}),u.length>0&&{tools:u}),E&&{tool_choice:E}),{stream:!0}),[4,this.ensureAnthropic().messages.create(S)];case 2:return O=x.sent(),s.stream(function(e){return j(A,void 0,void 0,function(){var t,n,i,o,a,s,c,u,l,d,f,p,h,m,y,g,b,v,w;return R(this,function(E){switch(E.label){case 0:t=null,n=!1,i=r.randomId(),o=r.randomId(),a=new BS,s=!1,E.label=1;case 1:E.trys.push([1,14,,15]),E.label=2;case 2:E.trys.push([2,7,8,13]),c=!0,u=C(O),E.label=3;case 3:return[4,u.next()];case 4:if(l=E.sent(),g=l.done)return[3,6];w=l.value,c=!1,"message_start"===(d=w).type?i=d.message.id:"content_block_start"===d.type?(s=!0,"text"===d.content_block.type?(n=!1,a.reset(),t="message"):"tool_use"===d.content_block.type&&(o=d.content_block.id,e.sendActionExecutionStart({actionExecutionId:o,actionName:d.content_block.name,parentMessageId:i}),t="function")):"content_block_delta"===d.type?"text_delta"===d.delta.type?(f=a.onTextChunk(d.delta.text)).length>0&&(n||(e.sendTextMessageStart({messageId:i}),n=!0),e.sendTextMessageContent({messageId:i,content:f})):"input_json_delta"===d.delta.type&&e.sendActionExecutionArgs({actionExecutionId:o,args:d.delta.partial_json}):"content_block_stop"===d.type&&("message"===t?n&&e.sendTextMessageEnd({messageId:i}):"function"===t&&e.sendActionExecutionEnd({actionExecutionId:o})),E.label=5;case 5:return c=!0,[3,3];case 6:return[3,13];case 7:return p=E.sent(),b={error:p},[3,13];case 8:return E.trys.push([8,,11,12]),c||g||!(v=u.return)?[3,10]:[4,v.call(u)];case 9:E.sent(),E.label=10;case 10:return[3,12];case 11:if(b)throw b.error;return[7];case 12:return[7];case 13:return[3,15];case 14:throw G(E.sent(),"Anthropic");case 15:return!s&&this.shouldGenerateFallbackResponse(_)&&(h="Task completed successfully.","user"===(null==(m=_[_.length-1])?void 0:m.role)&&Array.isArray(m.content)&&(null==(y=m.content.find(function(e){return"tool_result"===e.type}))?void 0:y.content)&&"Action completed successfully"!==y.content&&(h=y.content),i=r.randomId(),e.sendTextMessageStart({messageId:i}),e.sendTextMessageContent({messageId:i,content:h}),e.sendTextMessageEnd({messageId:i})),e.complete(),[2]}})})}),[3,4];case 3:throw G(x.sent(),"Anthropic");case 4:return[2,{threadId:t||r.randomUUID()}]}})})},e}(),$S="<thinking>",DS="</thinking>",BS=function(){function e(){this.didFilterThinkingTag=!1,this.buffer=""}return e.prototype.onTextChunk=function(e){if(this.buffer+=e,this.didFilterThinkingTag)return e;var t=this.buffer.slice(0,10);if($S.startsWith(t)){if(this.buffer.includes(DS)){var r=this.buffer.indexOf(DS),n=this.buffer.slice(r+11);return this.buffer=n,this.didFilterThinkingTag=!0,n}return""}return e},e.prototype.reset=function(){this.buffer="",this.didFilterThinkingTag=!1},e}(),FS=function(){function e(e){this.provider="ollama",(null==e?void 0:e.model)?this.model=e.model:this.model="llama3:latest"}return Object.defineProperty(e.prototype,"name",{get:function(){return"OllamaAdapter"},enumerable:!1,configurable:!0}),e.prototype.process=function(e){return j(this,void 0,void 0,function(){var t,n,i,o,a,s,c=this;return R(this,function(u){switch(u.label){case 0:return t=e.messages,e.actions,n=e.eventSource,i=require("@langchain/community/llms/ollama").Ollama,o=new i({model:this.model}),a=t.filter(function(e){return e.isTextMessage()}).map(function(e){return e.content}),[4,o.stream(a)];case 1:return s=u.sent(),n.stream(function(e){return j(c,void 0,void 0,function(){var t,n,i,o,a,c,u,l,d,f;return R(this,function(p){switch(p.label){case 0:t=r.randomId(),e.sendTextMessageStart({messageId:t}),p.label=1;case 1:p.trys.push([1,6,7,12]),n=!0,i=C(s),p.label=2;case 2:return[4,i.next()];case 3:if(o=p.sent(),u=o.done)return[3,5];f=o.value,n=!1,a=f,e.sendTextMessageContent({messageId:t,content:a}),p.label=4;case 4:return n=!0,[3,2];case 5:return[3,12];case 6:return c=p.sent(),l={error:c},[3,12];case 7:return p.trys.push([7,,10,11]),n||u||!(d=i.return)?[3,9]:[4,d.call(i)];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(l)throw l.error;return[7];case 11:return[7];case 12:return e.sendTextMessageEnd({messageId:t}),e.complete(),[2]}})})}),[2,{threadId:e.threadId||r.randomUUID()}]}})})},e}(),US=function(e){function t(t){var r=e.call(this,{chainFn:function(e){return j(r,[e],void 0,function(e){var r,n,i,o=e.messages,a=e.tools;return e.threadId,R(this,function(e){return r=require("@langchain/aws").ChatBedrockConverse,this.model=null!==(n=null==t?void 0:t.model)&&void 0!==n?n:"amazon.nova-lite-v1:0",[2,new r({model:this.model,region:null!==(i=null==t?void 0:t.region)&&void 0!==i?i:"us-east-1",credentials:(null==t?void 0:t.credentials)?{accessKeyId:t.credentials.accessKeyId,secretAccessKey:t.credentials.secretAccessKey}:void 0}).bindTools(a).stream(o)]})})}})||this;return r.provider="bedrock",r.model="amazon.nova-lite-v1:0",r}return A(t,e),t}(Nl),zS=function(){function e(){}return e.prototype.process=function(e){return j(this,void 0,void 0,function(){return R(this,function(t){return[2,{threadId:e.threadId||r.randomUUID()}]})})},Object.defineProperty(e.prototype,"name",{get:function(){return"EmptyAdapter"},enumerable:!1,configurable:!0}),e}(),GS=zS,qS=function(e){this.groups=[],this.each=!1,this.context=void 0,this.type=e.type,this.name=e.name,this.target=e.target,this.propertyName=e.propertyName,this.constraints=null==e?void 0:e.constraints,this.constraintCls=e.constraintCls,this.validationTypeOptions=e.validationTypeOptions,e.validationOptions&&(this.message=e.validationOptions.message,this.groups=e.validationOptions.groups,this.always=e.validationOptions.always,this.each=e.validationOptions.each,this.context=e.validationOptions.context)},VS=function(){function e(){}return e.prototype.transform=function(e){var t=[];return Object.keys(e.properties).forEach(function(r){e.properties[r].forEach(function(n){var i={message:n.message,groups:n.groups,always:n.always,each:n.each},o={type:n.type,name:n.name,target:e.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:i};t.push(new qS(o))})}),t},e}();function WS(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function HS(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}var KS=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ZS=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},JS=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},YS=function(){function e(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(e.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),e.prototype.addValidationSchema=function(e){var t=this;(new VS).transform(e).forEach(function(e){return t.addValidationMetadata(e)})},e.prototype.addValidationMetadata=function(e){var t=this.validationMetadatas.get(e.target);t?t.push(e):this.validationMetadatas.set(e.target,[e])},e.prototype.addConstraintMetadata=function(e){var t=this.constraintMetadatas.get(e.target);t?t.push(e):this.constraintMetadatas.set(e.target,[e])},e.prototype.groupByPropertyName=function(e){var t={};return e.forEach(function(e){t[e.propertyName]||(t[e.propertyName]=[]),t[e.propertyName].push(e)}),t},e.prototype.getTargetValidationMetadatas=function(e,t,r,n,i){var o,a,s=function(e){return void 0!==e.always?e.always:(!e.groups||!e.groups.length)&&r},c=function(e){return!(!n||i&&i.length||!e.groups||!e.groups.length)},u=(this.validationMetadatas.get(e)||[]).filter(function(r){return(r.target===e||r.target===t)&&(!!s(r)||!c(r)&&(!(i&&i.length>0)||r.groups&&!!r.groups.find(function(e){return-1!==i.indexOf(e)})))}),l=[];try{for(var d=KS(this.validationMetadatas.entries()),f=d.next();!f.done;f=d.next()){var p=ZS(f.value,2),h=p[0],m=p[1];e.prototype instanceof h&&l.push.apply(l,JS([],ZS(m),!1))}}catch(e){o={error:e}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}var y=l.filter(function(t){return"string"!=typeof t.target&&(t.target!==e&&((!(t.target instanceof Function)||e.prototype instanceof t.target)&&(!!s(t)||!c(t)&&(!(i&&i.length>0)||t.groups&&!!t.groups.find(function(e){return-1!==i.indexOf(e)})))))}).filter(function(e){return!u.find(function(t){return t.propertyName===e.propertyName&&t.type===e.type})});return u.concat(y)},e.prototype.getTargetValidatorConstraints=function(e){return this.constraintMetadatas.get(e)||[]},e}();function QS(){var e=WS();return e.classValidatorMetadataStorage||(e.classValidatorMetadataStorage=new YS),e.classValidatorMetadataStorage}var XS=function(){function e(){}return e.prototype.toString=function(e,t,r,n){var i=this;void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var o=e?"":"",a=e?"":"",s=function(e){return" - property ".concat(o).concat(r).concat(e).concat(a," has failed the following constraints: ").concat(o).concat((n?Object.values:Object.keys)(null!==(t=i.constraints)&&void 0!==t?t:{}).join(", ")).concat(a," \n");var t};if(t){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map(function(t){return t.toString(e,!0,"".concat(r).concat(c),n)}).join(""):""}return"An instance of ".concat(o).concat(this.target?this.target.constructor.name:"an object").concat(a," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map(function(t){return t.toString(e,!0,i.property,n)}).join(""):"")},e}(),eO=function(){function e(){}return e.isValid=function(e){var t=this;return"isValid"!==e&&"getMessage"!==e&&-1!==Object.keys(this).map(function(e){return t[e]}).indexOf(e)},e.CUSTOM_VALIDATION="customValidation",e.NESTED_VALIDATION="nestedValidation",e.PROMISE_VALIDATION="promiseValidation",e.CONDITIONAL_VALIDATION="conditionalValidation",e.WHITELIST="whitelistValidation",e.IS_DEFINED="isDefined",e}();var tO=function(){function e(){}return e.replaceMessageSpecialTokens=function(e,t){var r;return e instanceof Function?r=e(t):"string"==typeof e&&(r=e),r&&Array.isArray(t.constraints)&&t.constraints.forEach(function(e,t){r=r.replace(new RegExp("\\$constraint".concat(t+1),"g"),function(e){return Array.isArray(e)?e.join(", "):("symbol"==typeof e&&(e=e.description),"".concat(e))}(e))}),r&&void 0!==t.value&&null!==t.value&&["string","boolean","number"].includes(typeof t.value)&&(r=r.replace(/\$value/g,t.value)),r&&(r=r.replace(/\$property/g,t.property)),r&&(r=r.replace(/\$target/g,t.targetName)),r},e}(),rO=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},nO=function(){function e(e,t){this.validator=e,this.validatorOptions=t,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=QS()}return e.prototype.execute=function(e,t,r){var n,i,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var a=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(i=this.validatorOptions)||void 0===i?void 0:i.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(e.constructor,t,c,s,a),d=this.metadataStorage.groupByPropertyName(l);if(u&&!l.length){var f=new XS;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=e),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(e,d,r),Object.keys(d).forEach(function(t){var n=e[t],i=d[t].filter(function(e){return e.type===eO.IS_DEFINED}),a=d[t].filter(function(e){return e.type!==eO.IS_DEFINED&&e.type!==eO.WHITELIST});n instanceof Promise&&a.find(function(e){return e.type===eO.PROMISE_VALIDATION})?o.awaitingPromises.push(n.then(function(n){o.performValidations(e,n,t,i,a,r)})):o.performValidations(e,n,t,i,a,r)})},e.prototype.whitelist=function(e,t,r){var n=this,i=[];Object.keys(e).forEach(function(e){t[e]&&0!==t[e].length||i.push(e)}),i.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?i.forEach(function(t){var i,o=n.generateValidationError(e,e[t],t);o.constraints=((i={})[eO.WHITELIST]="property ".concat(t," should not exist"),i),o.children=void 0,r.push(o)}):i.forEach(function(t){return delete e[t]}))},e.prototype.stripEmptyErrors=function(e){var t=this;return e.filter(function(e){if(e.children&&(e.children=t.stripEmptyErrors(e.children)),0===Object.keys(e.constraints).length){if(0===e.children.length)return!1;delete e.constraints}return!0})},e.prototype.performValidations=function(e,t,r,n,i,o){var a=i.filter(function(e){return e.type===eO.CUSTOM_VALIDATION}),s=i.filter(function(e){return e.type===eO.NESTED_VALIDATION}),c=i.filter(function(e){return e.type===eO.CONDITIONAL_VALIDATION}),u=this.generateValidationError(e,t,r);o.push(u),this.conditionalValidations(e,t,c)&&(this.customValidations(e,t,n,u),this.mapContexts(e,t,n,u),void 0===t&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===t&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==t&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(e,t,a,u),this.nestedValidations(t,s,u),this.mapContexts(e,t,i,u),this.mapContexts(e,t,a,u)))},e.prototype.generateValidationError=function(e,t,r){var n=new XS;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=e),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=t),n.property=r,n.children=[],n.constraints={},n},e.prototype.conditionalValidations=function(e,t,r){return r.map(function(r){return r.constraints[0](e,t)}).reduce(function(e,t){return e&&t},!0)},e.prototype.customValidations=function(e,t,r,n){var i=this;r.forEach(function(r){i.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach(function(o){if(!(o.async&&i.ignoreAsyncValidations||i.validatorOptions&&i.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var a={targetName:e.constructor?e.constructor.name:void 0,property:r.propertyName,object:e,value:t,constraints:r.constraints};if(r.each&&(Array.isArray(t)||t instanceof Set||t instanceof Map)){var s,c=((s=t)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map(function(e){return o.instance.validate(e,a)});if(c.some(function(e){return HS(e)})){var u=c.map(function(e){return HS(e)?e:Promise.resolve(e)}),l=Promise.all(u).then(function(a){var s=a.every(function(e){return e});if(!s){var c=rO(i.createValidationError(e,t,r,o),2),u=c[0],l=c[1];n.constraints[u]=l,r.context&&(n.contexts||(n.contexts={}),n.contexts[u]=Object.assign(n.contexts[u]||{},r.context))}});i.awaitingPromises.push(l)}else{var d=c.every(function(e){return e});if(!d){var f=rO(i.createValidationError(e,t,r,o),2);y=f[0],g=f[1];n.constraints[y]=g}}}else{var p=o.instance.validate(t,a);if(HS(p)){var h=p.then(function(a){if(!a){var s=rO(i.createValidationError(e,t,r,o),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}});i.awaitingPromises.push(h)}else if(!p){var m=rO(i.createValidationError(e,t,r,o),2),y=m[0],g=m[1];n.constraints[y]=g}}}})})},e.prototype.nestedValidations=function(e,t,r){var n=this;void 0!==e&&t.forEach(function(i){if((i.type===eO.NESTED_VALIDATION||i.type===eO.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(e)||e instanceof Set||e instanceof Map)(e instanceof Set?Array.from(e):e).forEach(function(i,o){n.performValidations(e,i,o.toString(),[],t,r.children)});else if(e instanceof Object){var o="string"==typeof i.target?i.target:i.target.name;n.execute(e,o,r.children)}else{var a=rO(n.createValidationError(i.target,e,i),2),s=a[0],c=a[1];r.constraints[s]=c}})},e.prototype.mapContexts=function(e,t,r,n){var i=this;return r.forEach(function(e){if(e.context){var t=void 0;if(e.type===eO.CUSTOM_VALIDATION)t=i.metadataStorage.getTargetValidatorConstraints(e.constraintCls)[0];var r=i.getConstraintType(e,t);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},e.context))}})},e.prototype.createValidationError=function(e,t,r,n){var i=e.constructor?e.constructor.name:void 0,o=this.getConstraintType(r,n),a={targetName:i,property:r.propertyName,object:e,value:t,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(a)),[o,tO.replaceMessageSpecialTokens(s,a)]},e.prototype.getConstraintType=function(e,t){return t&&t.name?t.name:e.type},e}(),iO=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(a,s)}c((n=n.apply(e,t||[])).next())})},oO=function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},aO=function(){function e(){}return e.prototype.validate=function(e,t,r){return this.coreValidate(e,t,r)},e.prototype.validateOrReject=function(e,t,r){return iO(this,void 0,void 0,function(){var n;return oO(this,function(i){switch(i.label){case 0:return[4,this.coreValidate(e,t,r)];case 1:return(n=i.sent()).length?[2,Promise.reject(n)]:[2]}})})},e.prototype.validateSync=function(e,t,r){var n="string"==typeof e?t:e,i="string"==typeof e?e:void 0,o=new nO(this,"string"==typeof e?r:t);o.ignoreAsyncValidations=!0;var a=[];return o.execute(n,i,a),o.stripEmptyErrors(a)},e.prototype.coreValidate=function(e,t,r){var n="string"==typeof e?t:e,i="string"==typeof e?e:void 0,o=new nO(this,"string"==typeof e?r:t),a=[];return o.execute(n,i,a),Promise.all(o.awaitingPromises).then(function(){return o.stripEmptyErrors(a)})},e}(),sO=new(function(){function e(){this.instances=[]}return e.prototype.get=function(e){var t=this.instances.find(function(t){return t.type===e});return t||(t={type:e,object:new e},this.instances.push(t)),t.object},e}());function cO(e){return sO.get(e)}var uO=Object.freeze({__proto__:null,MetadataStorage:YS,ValidationError:XS,ValidationTypes:eO,Validator:aO,getFromContainer:cO,getMetadataStorage:QS,validateOrReject:function(e,t,r){return"string"==typeof e?cO(aO).validateOrReject(e,t,r):cO(aO).validateOrReject(e,t)}});e.AnthropicAdapter=MS,e.BedrockAdapter=US,e.CopilotRuntime=Ih,e.EmptyAdapter=zS,e.ExperimentalEmptyAdapter=GS,e.ExperimentalOllamaAdapter=FS,e.GoogleGenerativeAIAdapter=Ll,e.GroqAdapter=Bl,e.GuardrailsValidationFailureResponse=hh,e.LangChainAdapter=Nl,e.LangGraphAgent=IS,e.LangGraphHttpAgent=kS,e.MessageStreamInterruptedResponse=mh,e.OpenAIAdapter=W,e.OpenAIAssistantAdapter=Ml,e.RemoteChain=jS,e.TelemetryAgentRunner=Th,e.UnifyAdapter=Dl,e.UnknownErrorResponse=yh,e.addCustomHeaderPlugin=ES,e.buildSchema=OS,e.config={api:{bodyParser:!1}},e.convertMCPToolsToActions=function(e,t){for(var r=this,n=[],i=function(e,i){var o=xh(i);n.push({name:e,description:i.description||"MCP tool: ".concat(e," (from ").concat(t,")"),parameters:o,handler:function(n){return j(r,void 0,void 0,function(){var r,o;return R(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,i.execute(n)];case 1:return[2,"string"==typeof(r=a.sent())?r:JSON.stringify(r)];case 2:throw o=a.sent(),console.error("Error executing MCP tool '".concat(e,"' from endpoint ").concat(t,":"),o),new Error("Execution failed for MCP tool '".concat(e,"': ").concat(o instanceof Error?o.message:String(o)));case 3:return[2]}})})},_isMCPTool:!0,_mcpEndpoint:t})},o=0,a=Object.entries(e);o<a.length;o++){var s=a[o];i(s[0],s[1])}return n},e.convertServiceAdapterError=G,e.copilotKitEndpoint=function(e){return T(T({},e),{type:Ah.CopilotKit})},e.copilotRuntimeNestEndpoint=function(e){return Rh.setGlobalProperties({runtime:{framework:"nest"}}),Rh.capture("oss.runtime.instance_created",Nh(e)),xS(e)},e.copilotRuntimeNextJSAppRouterEndpoint=function(e){var t,r,n=AS(e);Rh.setGlobalProperties({runtime:{framework:"nextjs-app-router"}}),(null===(t=e.properties)||void 0===t?void 0:t._copilotkit)&&Rh.setGlobalProperties({_copilotkit:e.properties._copilotkit}),Rh.capture("oss.runtime.instance_created",Nh(e)),n.logging.debug("Creating NextJS App Router endpoint");var i=e.serviceAdapter;i&&e.runtime.handleServiceAdapter(i);var o,a=u.createCopilotEndpointSingleRoute(T({runtime:e.runtime.instance,basePath:null!==(r=e.baseUrl)&&void 0!==r?r:e.endpoint},e.cors&&{cors:e.cors}));return{handleRequest:(o=a,e=>o.fetch(e))}},e.copilotRuntimeNextJSPagesRouterEndpoint=function(e){var t,r=AS(e);return Rh.setGlobalProperties({runtime:{framework:"nextjs-pages-router"}}),(null===(t=e.properties)||void 0===t?void 0:t._copilotkit)&&Rh.setGlobalProperties({_copilotkit:e.properties._copilotkit}),Rh.capture("oss.runtime.instance_created",Nh(e)),r.logging.debug("Creating NextJS Pages Router endpoint"),xS(e)},e.copilotRuntimeNodeExpressEndpoint=function(e){return Rh.setGlobalProperties({runtime:{framework:"node-express"}}),Rh.capture("oss.runtime.instance_created",Nh(e)),xS(e)},e.copilotRuntimeNodeHttpEndpoint=xS,e.createContext=SS,e.createLogger=gS,e.extractParametersFromSchema=xh,e.generateMcpToolInstructions=function(e){if(!e||0===Object.keys(e).length)return"";var t=Object.entries(e).map(function(e){var t,r=e[0],n=e[1],i=" No parameters required";try{if(n.schema&&"object"==typeof n.schema){var o=n.schema,a=(null===(t=o.parameters)||void 0===t?void 0:t.jsonSchema)||o.parameters,s=(null==a?void 0:a.properties)||o.properties,c=(null==a?void 0:a.required)||o.required||[];if(s){var u=Object.entries(s).map(function(e){var t=e[0],r=e[1],n=c.includes(t)?"*":"",i=r.type||"any",o=r.description?" - ".concat(r.description):"";if("array"===i&&r.items){var a=r.items.type||"object";if("object"===a&&r.items.properties){var s=Object.keys(r.items.properties).join(", ");i="array<object>",o=o+(o?" ":" - ")+"Array of objects with properties: ".concat(s)}else i="array<".concat(a,">")}if(r.enum&&Array.isArray(r.enum)){var u=r.enum.join(" | ");o=o+(o?" ":" - ")+"Allowed values: ".concat(u)}if("object"===i&&r.properties){var l=Object.keys(r.properties).join(", ");o=o+(o?" ":" - ")+"Object with properties: ".concat(l)}return" - ".concat(t).concat(n," (").concat(i,")").concat(o)});u.length>0&&(i=u.join("\n"))}}}catch(e){console.error("Error parsing schema for tool ".concat(r,":"),e)}return"- ".concat(r,": ").concat(n.description||"","\n").concat(i)}).join("\n\n");return"You have access to the following external tools provided by Model Context Protocol (MCP) servers:\n\n".concat(t,"\n\nWhen using these tools:\n1. Only provide valid parameters according to their type requirements\n2. Required parameters are marked with *\n3. For array parameters, provide data in the correct array format\n4. For object parameters, include all required nested properties\n5. For enum parameters, use only the allowed values listed\n6. Format API calls correctly with the expected parameter structure\n7. Always check tool responses to determine your next action")},e.getCommonConfig=AS,e.langGraphPlatformEndpoint=function(e){return T(T({},e),{type:Ah.LangGraphPlatform})},e.resolveEndpointType=kh});
48
+ //# sourceMappingURL=index.umd.js.map