@mcp-use/inspector 0.4.10 → 0.4.11-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -3
- package/dist/client/assets/chunk-VL2OQCWN-BE4txAap.js +8 -0
- package/dist/client/assets/{embeddings-BvWgxmh-.js → embeddings-D0mnwVrX.js} +1 -1
- package/dist/client/assets/{index-F8MAAt6D.js → index-B0MYHYe6.js} +1 -1
- package/dist/client/assets/{index-CWYxvW-c.js → index-BEMSyME5.js} +2 -2
- package/dist/client/assets/{index-DHsHh1_g.js → index-BgupETL3.js} +1 -1
- package/dist/client/assets/{index-Dnm19mgK.js → index-CQ9XIRcv.js} +2 -2
- package/dist/client/assets/index-DrYUC3_O.js +1775 -0
- package/dist/client/assets/index-mBO7pd_t.js +1 -0
- package/dist/client/assets/index-wkxN17B9.js +4 -0
- package/dist/client/assets/langfuse-MO3AMDBE-DYoZ4Kwk.js +570 -0
- package/dist/client/index.html +2 -2
- package/dist/server/{chunk-UAGOQUEV.js → chunk-5JZ2RXUR.js} +3 -3
- package/dist/server/{chunk-GZSRGACL.js → chunk-AFTM3F6I.js} +1 -1
- package/dist/server/{chunk-G2KU64MV.js → chunk-JTBAUVJ3.js} +1 -1
- package/dist/server/{chunk-HPZTE753.js → chunk-RK4WSNY7.js} +3 -3
- package/dist/server/{chunk-BE2QCYB4.js → chunk-VMVT3HVZ.js} +3 -3
- package/dist/server/cli.js +4 -4
- package/dist/server/index.js +5 -5
- package/dist/server/middleware.js +5 -5
- package/dist/server/server.js +5 -5
- package/dist/server/shared-routes.js +2 -2
- package/dist/server/shared-static.js +2 -2
- package/dist/server/shared-utils-browser.js +1 -1
- package/dist/server/shared-utils.js +1 -1
- package/package.json +2 -2
- package/dist/client/assets/browser-BkJdGGVq.js +0 -611
- package/dist/client/assets/chunk-VL2OQCWN-Dm4XquLI.js +0 -8
- package/dist/client/assets/index-BxUJEXs5.js +0 -1734
- package/dist/client/assets/index-CEkgKN2t.js +0 -1
- package/dist/client/assets/index-WLUXcbDv.js +0 -4
- package/dist/client/assets/langfuse-6AJGHMAV-QljN0jPu.js +0 -1
- package/dist/client/assets/v4-BKrj-4V8.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -321,15 +321,15 @@ function generateWidgetContentHtml(widgetData) {
|
|
|
321
321
|
return { html: "", error: "No HTML content found" };
|
|
322
322
|
}
|
|
323
323
|
const widgetStateKey = `openai-widget-state:${toolId}`;
|
|
324
|
-
const safeToolInput = JSON.stringify(toolInput).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
325
|
-
const safeToolOutput = JSON.stringify(toolOutput).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
324
|
+
const safeToolInput = JSON.stringify(toolInput ?? null).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
325
|
+
const safeToolOutput = JSON.stringify(toolOutput ?? null).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
326
326
|
const safeToolId = JSON.stringify(toolId);
|
|
327
327
|
const safeWidgetStateKey = JSON.stringify(widgetStateKey);
|
|
328
328
|
const apiScript = `
|
|
329
329
|
<script>
|
|
330
330
|
(function() {
|
|
331
331
|
'use strict';
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
// Change URL to "/" for React Router compatibility
|
|
334
334
|
if (window.location.pathname !== '/') {
|
|
335
335
|
history.replaceState(null, '', '/');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{g as pe,r as Ln}from"./index-DrYUC3_O.js";var Xe,ot;function qn(){return ot||(ot=1,Xe=function(e,t){if(typeof e!="string")throw new TypeError("Expected a string");return t=typeof t>"u"?"_":t,e.replace(/([a-z\d])([A-Z])/g,"$1"+t+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+t+"$2").toLowerCase()}),Xe}var jn=qn();const Vi=pe(jn);var Ne={exports:{}},at;function Dn(){if(at)return Ne.exports;at=1;const e=/[\p{Lu}]/u,t=/[\p{Ll}]/u,r=/^[\p{Lu}](?![\p{Lu}])/gu,n=/([\p{Alpha}\p{N}_]|$)/u,s=/[_.\- ]+/,u=new RegExp("^"+s.source),i=new RegExp(s.source+n.source,"gu"),o=new RegExp("\\d+"+n.source,"gu"),c=(d,m,h)=>{let p=!1,g=!1,v=!1;for(let E=0;E<d.length;E++){const y=d[E];p&&e.test(y)?(d=d.slice(0,E)+"-"+d.slice(E),p=!1,v=g,g=!0,E++):g&&v&&t.test(y)?(d=d.slice(0,E-1)+"-"+d.slice(E-1),v=g,g=!1,p=!0):(p=m(y)===y&&h(y)!==y,v=g,g=h(y)===y&&m(y)!==y)}return d},l=(d,m)=>(r.lastIndex=0,d.replace(r,h=>m(h))),a=(d,m)=>(i.lastIndex=0,o.lastIndex=0,d.replace(i,(h,p)=>m(p)).replace(o,h=>m(h))),f=(d,m)=>{if(!(typeof d=="string"||Array.isArray(d)))throw new TypeError("Expected the input to be `string | string[]`");if(m={pascalCase:!1,preserveConsecutiveUppercase:!1,...m},Array.isArray(d)?d=d.map(v=>v.trim()).filter(v=>v.length).join("-"):d=d.trim(),d.length===0)return"";const h=m.locale===!1?v=>v.toLowerCase():v=>v.toLocaleLowerCase(m.locale),p=m.locale===!1?v=>v.toUpperCase():v=>v.toLocaleUpperCase(m.locale);return d.length===1?m.pascalCase?p(d):h(d):(d!==h(d)&&(d=c(d,h,p)),d=d.replace(u,""),m.preserveConsecutiveUppercase?d=l(d,h):d=h(d),m.pascalCase&&(d=p(d.charAt(0))+d.slice(1)),a(d,p))};return Ne.exports=f,Ne.exports.default=f,Ne.exports}var Un=Dn();const Bi=pe(Un),Mn=/^(?:[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 Fn(e){return typeof e=="string"&&Mn.test(e)}function Gn(e){if(!Fn(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var H=[];for(var Je=0;Je<256;++Je)H.push((Je+256).toString(16).slice(1));function Rn(e,t=0){return(H[e[t+0]]+H[e[t+1]]+H[e[t+2]]+H[e[t+3]]+"-"+H[e[t+4]]+H[e[t+5]]+"-"+H[e[t+6]]+H[e[t+7]]+"-"+H[e[t+8]]+H[e[t+9]]+"-"+H[e[t+10]]+H[e[t+11]]+H[e[t+12]]+H[e[t+13]]+H[e[t+14]]+H[e[t+15]]).toLowerCase()}var Ae,Vn=new Uint8Array(16);function Bn(){if(!Ae&&(Ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ae))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ae(Vn)}function Zn(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var Xn="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Jn="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Hn(e,t,r){function n(s,u,i,o){var c;if(typeof s=="string"&&(s=Zn(s)),typeof u=="string"&&(u=Gn(u)),((c=u)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+s.length);if(l.set(u),l.set(s,u.length),l=r(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=l[a];return i}return Rn(l)}try{n.name=e}catch{}return n.DNS=Xn,n.URL=Jn,n}var Yn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const ut={randomUUID:Yn};function Zi(e,t,r){if(ut.randomUUID&&!e)return ut.randomUUID();e=e||{};var n=e.random||(e.rng||Bn)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Rn(n)}function Kn(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function He(e,t){return e<<t|e>>>32-t}function Wn(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=[];for(var s=0;s<n.length;++s)e.push(n.charCodeAt(s))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var u=e.length/4+2,i=Math.ceil(u/16),o=new Array(i),c=0;c<i;++c){for(var l=new Uint32Array(16),a=0;a<16;++a)l[a]=e[c*64+a*4]<<24|e[c*64+a*4+1]<<16|e[c*64+a*4+2]<<8|e[c*64+a*4+3];o[c]=l}o[i-1][14]=(e.length-1)*8/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=(e.length-1)*8&4294967295;for(var f=0;f<i;++f){for(var d=new Uint32Array(80),m=0;m<16;++m)d[m]=o[f][m];for(var h=16;h<80;++h)d[h]=He(d[h-3]^d[h-8]^d[h-14]^d[h-16],1);for(var p=r[0],g=r[1],v=r[2],E=r[3],y=r[4],q=0;q<80;++q){var M=Math.floor(q/20),U=He(p,5)+Kn(M,g,v,E)+y+t[M]+d[q]>>>0;y=E,E=v,v=He(g,30)>>>0,g=p,p=U}r[0]=r[0]+p>>>0,r[1]=r[1]+g>>>0,r[2]=r[2]+v>>>0,r[3]=r[3]+E>>>0,r[4]=r[4]+y>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var Xi=Hn("v5",80,Wn),_e={exports:{}},Ye={},Ke,ct;function Qn(){if(ct)return Ke;ct=1;function e(t,r){typeof r=="boolean"&&(r={forever:r}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=r||{},this._maxRetryTime=r&&r.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 Ke=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(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var r=new Date().getTime();if(t&&r-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var s=this;return this._timer=setTimeout(function(){s._attempts++,s._operationTimeoutCb&&(s._timeout=setTimeout(function(){s._operationTimeoutCb(s._attempts)},s._operationTimeout),s._options.unref&&s._timeout.unref()),s._fn(s._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(t,r){this._fn=t,r&&(r.timeout&&(this._operationTimeout=r.timeout),r.cb&&(this._operationTimeoutCb=r.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},e.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},e.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},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(this._errors.length===0)return null;for(var t={},r=null,n=0,s=0;s<this._errors.length;s++){var u=this._errors[s],i=u.message,o=(t[i]||0)+1;t[i]=o,o>=n&&(r=u,n=o)}return r},Ke}var lt;function es(){return lt||(lt=1,(function(e){var t=Qn();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(r){if(r instanceof Array)return[].concat(r);var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in r)n[s]=r[s];if(n.minTimeout>n.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var u=[],i=0;i<n.retries;i++)u.push(this.createTimeout(i,n));return r&&r.forever&&!u.length&&u.push(this.createTimeout(i,n)),u.sort(function(o,c){return o-c}),u},e.createTimeout=function(r,n){var s=n.randomize?Math.random()+1:1,u=Math.round(s*Math.max(n.minTimeout,1)*Math.pow(n.factor,r));return u=Math.min(u,n.maxTimeout),u},e.wrap=function(r,n,s){if(n instanceof Array&&(s=n,n=null),!s){s=[];for(var u in r)typeof r[u]=="function"&&s.push(u)}for(var i=0;i<s.length;i++){var o=s[i],c=r[o];r[o]=(function(a){var f=e.operation(n),d=Array.prototype.slice.call(arguments,1),m=d.pop();d.push(function(h){f.retry(h)||(h&&(arguments[0]=f.mainError()),m.apply(this,arguments))}),f.attempt(function(){a.apply(r,d)})}).bind(r,c),r[o].options=n}}})(Ye)),Ye}var We,ft;function rs(){return ft||(ft=1,We=es()),We}var dt;function ts(){if(dt)return _e.exports;dt=1;const e=rs(),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(o){super(),o instanceof Error?(this.originalError=o,{message:o}=o):(this.originalError=new Error(o),this.originalError.stack=this.stack),this.name="AbortError",this.message=o}}const n=(i,o,c)=>{const l=c.retries-(o-1);return i.attemptNumber=o,i.retriesLeft=l,i},s=i=>t.includes(i),u=(i,o)=>new Promise((c,l)=>{o={onFailedAttempt:()=>{},retries:10,...o};const a=e.operation(o);a.attempt(async f=>{try{c(await i(f))}catch(d){if(!(d instanceof Error)){l(new TypeError(`Non-error was thrown: "${d}". You should only throw errors.`));return}if(d instanceof r)a.stop(),l(d.originalError);else if(d instanceof TypeError&&!s(d.message))a.stop(),l(d);else{n(d,f,o);try{await o.onFailedAttempt(d)}catch(m){l(m);return}a.retry(d)||l(a.mainError())}}})});return _e.exports=u,_e.exports.default=u,_e.exports.AbortError=r,_e.exports}var ns=ts();const Ji=pe(ns);var ke={},Qe={exports:{}},ht;function ss(){return ht||(ht=1,(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function s(c,l,a){this.fn=c,this.context=l,this.once=a||!1}function u(c,l,a,f,d){if(typeof a!="function")throw new TypeError("The listener must be a function");var m=new s(a,f||c,d),h=r?r+l:l;return c._events[h]?c._events[h].fn?c._events[h]=[c._events[h],m]:c._events[h].push(m):(c._events[h]=m,c._eventsCount++),c}function i(c,l){--c._eventsCount===0?c._events=new n:delete c._events[l]}function o(){this._events=new n,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],a,f;if(this._eventsCount===0)return l;for(f in a=this._events)t.call(a,f)&&l.push(r?f.slice(1):f);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(a)):l},o.prototype.listeners=function(l){var a=r?r+l:l,f=this._events[a];if(!f)return[];if(f.fn)return[f.fn];for(var d=0,m=f.length,h=new Array(m);d<m;d++)h[d]=f[d].fn;return h},o.prototype.listenerCount=function(l){var a=r?r+l:l,f=this._events[a];return f?f.fn?1:f.length:0},o.prototype.emit=function(l,a,f,d,m,h){var p=r?r+l:l;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,E,y;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,a),!0;case 3:return g.fn.call(g.context,a,f),!0;case 4:return g.fn.call(g.context,a,f,d),!0;case 5:return g.fn.call(g.context,a,f,d,m),!0;case 6:return g.fn.call(g.context,a,f,d,m,h),!0}for(y=1,E=new Array(v-1);y<v;y++)E[y-1]=arguments[y];g.fn.apply(g.context,E)}else{var q=g.length,M;for(y=0;y<q;y++)switch(g[y].once&&this.removeListener(l,g[y].fn,void 0,!0),v){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,a);break;case 3:g[y].fn.call(g[y].context,a,f);break;case 4:g[y].fn.call(g[y].context,a,f,d);break;default:if(!E)for(M=1,E=new Array(v-1);M<v;M++)E[M-1]=arguments[M];g[y].fn.apply(g[y].context,E)}}return!0},o.prototype.on=function(l,a,f){return u(this,l,a,f,!1)},o.prototype.once=function(l,a,f){return u(this,l,a,f,!0)},o.prototype.removeListener=function(l,a,f,d){var m=r?r+l:l;if(!this._events[m])return this;if(!a)return i(this,m),this;var h=this._events[m];if(h.fn)h.fn===a&&(!d||h.once)&&(!f||h.context===f)&&i(this,m);else{for(var p=0,g=[],v=h.length;p<v;p++)(h[p].fn!==a||d&&!h[p].once||f&&h[p].context!==f)&&g.push(h[p]);g.length?this._events[m]=g.length===1?g[0]:g:i(this,m)}return this},o.prototype.removeAllListeners=function(l){var a;return l?(a=r?r+l:l,this._events[a]&&i(this,a)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o})(Qe)),Qe.exports}var $e={exports:{}},er,pt;function is(){return pt||(pt=1,er=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))),er}var mt;function os(){if(mt)return $e.exports;mt=1;const e=is();class t extends Error{constructor(s){super(s),this.name="TimeoutError"}}const r=(n,s,u)=>new Promise((i,o)=>{if(typeof s!="number"||s<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(s===1/0){i(n);return}const c=setTimeout(()=>{if(typeof u=="function"){try{i(u())}catch(f){o(f)}return}const l=typeof u=="string"?u:`Promise timed out after ${s} milliseconds`,a=u instanceof Error?u:new t(l);typeof n.cancel=="function"&&n.cancel(),o(a)},s);e(n.then(i,o),()=>{clearTimeout(c)})});return $e.exports=r,$e.exports.default=r,$e.exports.TimeoutError=t,$e.exports}var ze={},Ce={},gt;function as(){if(gt)return Ce;gt=1,Object.defineProperty(Ce,"__esModule",{value:!0});function e(t,r,n){let s=0,u=t.length;for(;u>0;){const i=u/2|0;let o=s+i;n(t[o],r)<=0?(s=++o,u-=i+1):u=i}return s}return Ce.default=e,Ce}var vt;function us(){if(vt)return ze;vt=1,Object.defineProperty(ze,"__esModule",{value:!0});const e=as();class t{constructor(){this._queue=[]}enqueue(n,s){s=Object.assign({priority:0},s);const u={priority:s.priority,run:n};if(this.size&&this._queue[this.size-1].priority>=s.priority){this._queue.push(u);return}const i=e.default(this._queue,u,(o,c)=>c.priority-o.priority);this._queue.splice(i,0,u)}dequeue(){const n=this._queue.shift();return n?.run}filter(n){return this._queue.filter(s=>s.priority===n.priority).map(s=>s.run)}get size(){return this._queue.length}}return ze.default=t,ze}var yt;function cs(){if(yt)return ke;yt=1,Object.defineProperty(ke,"__esModule",{value:!0});const e=ss(),t=os(),r=us(),n=()=>{},s=new t.TimeoutError;class u extends e{constructor(o){var c,l,a,f;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=n,this._resolveIdle=n,o=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:r.default},o),!(typeof o.intervalCap=="number"&&o.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(l=(c=o.intervalCap)===null||c===void 0?void 0:c.toString())!==null&&l!==void 0?l:""}\` (${typeof o.intervalCap})`);if(o.interval===void 0||!(Number.isFinite(o.interval)&&o.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(f=(a=o.interval)===null||a===void 0?void 0:a.toString())!==null&&f!==void 0?f:""}\` (${typeof o.interval})`);this._carryoverConcurrencyCount=o.carryoverConcurrencyCount,this._isIntervalIgnored=o.intervalCap===1/0||o.interval===0,this._intervalCap=o.intervalCap,this._interval=o.interval,this._queue=new o.queueClass,this._queueClass=o.queueClass,this.concurrency=o.concurrency,this._timeout=o.timeout,this._throwOnTimeout=o.throwOnTimeout===!0,this._isPaused=o.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=n,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=n,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){const o=Date.now();if(this._intervalId===void 0){const c=this._intervalEnd-o;if(c<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},c)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const o=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const c=this._queue.dequeue();return c?(this.emit("active"),c(),o&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(o){if(!(typeof o=="number"&&o>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${o}\` (${typeof o})`);this._concurrency=o,this._processQueue()}async add(o,c={}){return new Promise((l,a)=>{const f=async()=>{this._pendingCount++,this._intervalCount++;try{const d=this._timeout===void 0&&c.timeout===void 0?o():t.default(Promise.resolve(o()),c.timeout===void 0?this._timeout:c.timeout,()=>{(c.throwOnTimeout===void 0?this._throwOnTimeout:c.throwOnTimeout)&&a(s)});l(await d)}catch(d){a(d)}this._next()};this._queue.enqueue(f,c),this._tryToStartAnother(),this.emit("add")})}async addAll(o,c){return Promise.all(o.map(async l=>this.add(l,c)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(o=>{const c=this._resolveEmpty;this._resolveEmpty=()=>{c(),o()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(o=>{const c=this._resolveIdle;this._resolveIdle=()=>{c(),o()}})}get size(){return this._queue.size}sizeBy(o){return this._queue.filter(o).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(o){this._timeout=o}}return ke.default=u,ke}var ls=cs();const Hi=pe(ls);var Le={exports:{}},rr,_t;function De(){if(_t)return rr;_t=1;const e="2.0.0",t=256,r=Number.MAX_SAFE_INTEGER||9007199254740991,n=16,s=t-6;return rr={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:s,MAX_SAFE_INTEGER:r,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},rr}var tr,$t;function Ue(){if($t)return tr;$t=1;var e={};return tr=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{},tr}var Et;function be(){return Et||(Et=1,(function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:s}=De(),u=Ue();t=e.exports={};const i=t.re=[],o=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],a=t.t={};let f=0;const d="[a-zA-Z0-9-]",m=[["\\s",1],["\\d",s],[d,n]],h=g=>{for(const[v,E]of m)g=g.split(`${v}*`).join(`${v}{0,${E}}`).split(`${v}+`).join(`${v}{1,${E}}`);return g},p=(g,v,E)=>{const y=h(v),q=f++;u(g,q,v),a[g]=q,c[q]=v,l[q]=y,i[q]=new RegExp(v,E?"g":void 0),o[q]=new RegExp(y,E?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),p("MAINVERSION",`(${c[a.NUMERICIDENTIFIER]})\\.(${c[a.NUMERICIDENTIFIER]})\\.(${c[a.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${c[a.NUMERICIDENTIFIERLOOSE]})\\.(${c[a.NUMERICIDENTIFIERLOOSE]})\\.(${c[a.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${c[a.NONNUMERICIDENTIFIER]}|${c[a.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${c[a.NONNUMERICIDENTIFIER]}|${c[a.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${c[a.PRERELEASEIDENTIFIER]}(?:\\.${c[a.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${c[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[a.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${d}+`),p("BUILD",`(?:\\+(${c[a.BUILDIDENTIFIER]}(?:\\.${c[a.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${c[a.MAINVERSION]}${c[a.PRERELEASE]}?${c[a.BUILD]}?`),p("FULL",`^${c[a.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${c[a.MAINVERSIONLOOSE]}${c[a.PRERELEASELOOSE]}?${c[a.BUILD]}?`),p("LOOSE",`^${c[a.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${c[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${c[a.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${c[a.XRANGEIDENTIFIER]})(?:\\.(${c[a.XRANGEIDENTIFIER]})(?:\\.(${c[a.XRANGEIDENTIFIER]})(?:${c[a.PRERELEASE]})?${c[a.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${c[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[a.XRANGEIDENTIFIERLOOSE]})(?:${c[a.PRERELEASELOOSE]})?${c[a.BUILD]}?)?)?`),p("XRANGE",`^${c[a.GTLT]}\\s*${c[a.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${c[a.GTLT]}\\s*${c[a.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),p("COERCE",`${c[a.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",c[a.COERCEPLAIN]+`(?:${c[a.PRERELEASE]})?(?:${c[a.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",c[a.COERCE],!0),p("COERCERTLFULL",c[a.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${c[a.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${c[a.LONETILDE]}${c[a.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${c[a.LONETILDE]}${c[a.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${c[a.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${c[a.LONECARET]}${c[a.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${c[a.LONECARET]}${c[a.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${c[a.GTLT]}\\s*(${c[a.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${c[a.GTLT]}\\s*(${c[a.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${c[a.GTLT]}\\s*(${c[a.LOOSEPLAIN]}|${c[a.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${c[a.XRANGEPLAIN]})\\s+-\\s+(${c[a.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${c[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[a.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Le,Le.exports)),Le.exports}var nr,wt;function Jr(){if(wt)return nr;wt=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return nr=n=>n?typeof n!="object"?e:n:t,nr}var sr,Rt;function bn(){if(Rt)return sr;Rt=1;const e=/^[0-9]+$/,t=(n,s)=>{if(typeof n=="number"&&typeof s=="number")return n===s?0:n<s?-1:1;const u=e.test(n),i=e.test(s);return u&&i&&(n=+n,s=+s),n===s?0:u&&!i?-1:i&&!u?1:n<s?-1:1};return sr={compareIdentifiers:t,rcompareIdentifiers:(n,s)=>t(s,n)},sr}var ir,bt;function K(){if(bt)return ir;bt=1;const e=Ue(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=De(),{safeRe:n,t:s}=be(),u=Jr(),{compareIdentifiers:i}=bn();class o{constructor(l,a){if(a=u(a),l instanceof o){if(l.loose===!!a.loose&&l.includePrerelease===!!a.includePrerelease)return l;l=l.version}else if(typeof l!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof l}".`);if(l.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",l,a),this.options=a,this.loose=!!a.loose,this.includePrerelease=!!a.includePrerelease;const f=l.trim().match(a.loose?n[s.LOOSE]:n[s.FULL]);if(!f)throw new TypeError(`Invalid Version: ${l}`);if(this.raw=l,this.major=+f[1],this.minor=+f[2],this.patch=+f[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");f[4]?this.prerelease=f[4].split(".").map(d=>{if(/^[0-9]+$/.test(d)){const m=+d;if(m>=0&&m<r)return m}return d}):this.prerelease=[],this.build=f[5]?f[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(l){if(e("SemVer.compare",this.version,this.options,l),!(l instanceof o)){if(typeof l=="string"&&l===this.version)return 0;l=new o(l,this.options)}return l.version===this.version?0:this.compareMain(l)||this.comparePre(l)}compareMain(l){return l instanceof o||(l=new o(l,this.options)),this.major<l.major?-1:this.major>l.major?1:this.minor<l.minor?-1:this.minor>l.minor?1:this.patch<l.patch?-1:this.patch>l.patch?1:0}comparePre(l){if(l instanceof o||(l=new o(l,this.options)),this.prerelease.length&&!l.prerelease.length)return-1;if(!this.prerelease.length&&l.prerelease.length)return 1;if(!this.prerelease.length&&!l.prerelease.length)return 0;let a=0;do{const f=this.prerelease[a],d=l.prerelease[a];if(e("prerelease compare",a,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return i(f,d)}while(++a)}compareBuild(l){l instanceof o||(l=new o(l,this.options));let a=0;do{const f=this.build[a],d=l.build[a];if(e("build compare",a,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return i(f,d)}while(++a)}inc(l,a,f){if(l.startsWith("pre")){if(!a&&f===!1)throw new Error("invalid increment argument: identifier is empty");if(a){const d=`-${a}`.match(this.options.loose?n[s.PRERELEASELOOSE]:n[s.PRERELEASE]);if(!d||d[1]!==a)throw new Error(`invalid identifier: ${a}`)}}switch(l){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",a,f);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",a,f);break;case"prepatch":this.prerelease.length=0,this.inc("patch",a,f),this.inc("pre",a,f);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",a,f),this.inc("pre",a,f);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const d=Number(f)?1:0;if(this.prerelease.length===0)this.prerelease=[d];else{let m=this.prerelease.length;for(;--m>=0;)typeof this.prerelease[m]=="number"&&(this.prerelease[m]++,m=-2);if(m===-1){if(a===this.prerelease.join(".")&&f===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(d)}}if(a){let m=[a,d];f===!1&&(m=[a]),i(this.prerelease[0],a)===0?isNaN(this.prerelease[1])&&(this.prerelease=m):this.prerelease=m}break}default:throw new Error(`invalid increment argument: ${l}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return ir=o,ir}var or,It;function me(){if(It)return or;It=1;const e=K();return or=(r,n,s=!1)=>{if(r instanceof e)return r;try{return new e(r,n)}catch(u){if(!s)return null;throw u}},or}var ar,Ot;function fs(){if(Ot)return ar;Ot=1;const e=me();return ar=(r,n)=>{const s=e(r,n);return s?s.version:null},ar}var ur,Tt;function ds(){if(Tt)return ur;Tt=1;const e=me();return ur=(r,n)=>{const s=e(r.trim().replace(/^[=v]+/,""),n);return s?s.version:null},ur}var cr,xt;function hs(){if(xt)return cr;xt=1;const e=K();return cr=(r,n,s,u,i)=>{typeof s=="string"&&(i=u,u=s,s=void 0);try{return new e(r instanceof e?r.version:r,s).inc(n,u,i).version}catch{return null}},cr}var lr,St;function ps(){if(St)return lr;St=1;const e=me();return lr=(r,n)=>{const s=e(r,null,!0),u=e(n,null,!0),i=s.compare(u);if(i===0)return null;const o=i>0,c=o?s:u,l=o?u:s,a=!!c.prerelease.length;if(!!l.prerelease.length&&!a){if(!l.patch&&!l.minor)return"major";if(l.compareMain(c)===0)return l.minor&&!l.patch?"minor":"patch"}const d=a?"pre":"";return s.major!==u.major?d+"major":s.minor!==u.minor?d+"minor":s.patch!==u.patch?d+"patch":"prerelease"},lr}var fr,Pt;function ms(){if(Pt)return fr;Pt=1;const e=K();return fr=(r,n)=>new e(r,n).major,fr}var dr,Nt;function gs(){if(Nt)return dr;Nt=1;const e=K();return dr=(r,n)=>new e(r,n).minor,dr}var hr,At;function vs(){if(At)return hr;At=1;const e=K();return hr=(r,n)=>new e(r,n).patch,hr}var pr,kt;function ys(){if(kt)return pr;kt=1;const e=me();return pr=(r,n)=>{const s=e(r,n);return s&&s.prerelease.length?s.prerelease:null},pr}var mr,zt;function ee(){if(zt)return mr;zt=1;const e=K();return mr=(r,n,s)=>new e(r,s).compare(new e(n,s)),mr}var gr,Ct;function _s(){if(Ct)return gr;Ct=1;const e=ee();return gr=(r,n,s)=>e(n,r,s),gr}var vr,Lt;function $s(){if(Lt)return vr;Lt=1;const e=ee();return vr=(r,n)=>e(r,n,!0),vr}var yr,qt;function Hr(){if(qt)return yr;qt=1;const e=K();return yr=(r,n,s)=>{const u=new e(r,s),i=new e(n,s);return u.compare(i)||u.compareBuild(i)},yr}var _r,jt;function Es(){if(jt)return _r;jt=1;const e=Hr();return _r=(r,n)=>r.sort((s,u)=>e(s,u,n)),_r}var $r,Dt;function ws(){if(Dt)return $r;Dt=1;const e=Hr();return $r=(r,n)=>r.sort((s,u)=>e(u,s,n)),$r}var Er,Ut;function Me(){if(Ut)return Er;Ut=1;const e=ee();return Er=(r,n,s)=>e(r,n,s)>0,Er}var wr,Mt;function Yr(){if(Mt)return wr;Mt=1;const e=ee();return wr=(r,n,s)=>e(r,n,s)<0,wr}var Rr,Ft;function In(){if(Ft)return Rr;Ft=1;const e=ee();return Rr=(r,n,s)=>e(r,n,s)===0,Rr}var br,Gt;function On(){if(Gt)return br;Gt=1;const e=ee();return br=(r,n,s)=>e(r,n,s)!==0,br}var Ir,Vt;function Kr(){if(Vt)return Ir;Vt=1;const e=ee();return Ir=(r,n,s)=>e(r,n,s)>=0,Ir}var Or,Bt;function Wr(){if(Bt)return Or;Bt=1;const e=ee();return Or=(r,n,s)=>e(r,n,s)<=0,Or}var Tr,Zt;function Tn(){if(Zt)return Tr;Zt=1;const e=In(),t=On(),r=Me(),n=Kr(),s=Yr(),u=Wr();return Tr=(o,c,l,a)=>{switch(c){case"===":return typeof o=="object"&&(o=o.version),typeof l=="object"&&(l=l.version),o===l;case"!==":return typeof o=="object"&&(o=o.version),typeof l=="object"&&(l=l.version),o!==l;case"":case"=":case"==":return e(o,l,a);case"!=":return t(o,l,a);case">":return r(o,l,a);case">=":return n(o,l,a);case"<":return s(o,l,a);case"<=":return u(o,l,a);default:throw new TypeError(`Invalid operator: ${c}`)}},Tr}var xr,Xt;function Rs(){if(Xt)return xr;Xt=1;const e=K(),t=me(),{safeRe:r,t:n}=be();return xr=(u,i)=>{if(u instanceof e)return u;if(typeof u=="number"&&(u=String(u)),typeof u!="string")return null;i=i||{};let o=null;if(!i.rtl)o=u.match(i.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);else{const m=i.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let h;for(;(h=m.exec(u))&&(!o||o.index+o[0].length!==u.length);)(!o||h.index+h[0].length!==o.index+o[0].length)&&(o=h),m.lastIndex=h.index+h[1].length+h[2].length;m.lastIndex=-1}if(o===null)return null;const c=o[2],l=o[3]||"0",a=o[4]||"0",f=i.includePrerelease&&o[5]?`-${o[5]}`:"",d=i.includePrerelease&&o[6]?`+${o[6]}`:"";return t(`${c}.${l}.${a}${f}${d}`,i)},xr}var Sr,Jt;function bs(){if(Jt)return Sr;Jt=1;class e{constructor(){this.max=1e3,this.map=new Map}get(r){const n=this.map.get(r);if(n!==void 0)return this.map.delete(r),this.map.set(r,n),n}delete(r){return this.map.delete(r)}set(r,n){if(!this.delete(r)&&n!==void 0){if(this.map.size>=this.max){const u=this.map.keys().next().value;this.delete(u)}this.map.set(r,n)}return this}}return Sr=e,Sr}var Pr,Ht;function re(){if(Ht)return Pr;Ht=1;const e=/\s+/g;class t{constructor(_,x){if(x=s(x),_ instanceof t)return _.loose===!!x.loose&&_.includePrerelease===!!x.includePrerelease?_:new t(_.raw,x);if(_ instanceof u)return this.raw=_.value,this.set=[[_]],this.formatted=void 0,this;if(this.options=x,this.loose=!!x.loose,this.includePrerelease=!!x.includePrerelease,this.raw=_.trim().replace(e," "),this.set=this.raw.split("||").map(I=>this.parseRange(I.trim())).filter(I=>I.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const I=this.set[0];if(this.set=this.set.filter(S=>!p(S[0])),this.set.length===0)this.set=[I];else if(this.set.length>1){for(const S of this.set)if(S.length===1&&g(S[0])){this.set=[S];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let _=0;_<this.set.length;_++){_>0&&(this.formatted+="||");const x=this.set[_];for(let I=0;I<x.length;I++)I>0&&(this.formatted+=" "),this.formatted+=x[I].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(_){const I=((this.options.includePrerelease&&m)|(this.options.loose&&h))+":"+_,S=n.get(I);if(S)return S;const O=this.options.loose,A=O?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];_=_.replace(A,de(this.options.includePrerelease)),i("hyphen replace",_),_=_.replace(c[l.COMPARATORTRIM],a),i("comparator trim",_),_=_.replace(c[l.TILDETRIM],f),i("tilde trim",_),_=_.replace(c[l.CARETTRIM],d),i("caret trim",_);let j=_.split(" ").map(D=>E(D,this.options)).join(" ").split(/\s+/).map(D=>oe(D,this.options));O&&(j=j.filter(D=>(i("loose invalid filter",D,this.options),!!D.match(c[l.COMPARATORLOOSE])))),i("range list",j);const L=new Map,F=j.map(D=>new u(D,this.options));for(const D of F){if(p(D))return[D];L.set(D.value,D)}L.size>1&&L.has("")&&L.delete("");const J=[...L.values()];return n.set(I,J),J}intersects(_,x){if(!(_ instanceof t))throw new TypeError("a Range is required");return this.set.some(I=>v(I,x)&&_.set.some(S=>v(S,x)&&I.every(O=>S.every(A=>O.intersects(A,x)))))}test(_){if(!_)return!1;if(typeof _=="string")try{_=new o(_,this.options)}catch{return!1}for(let x=0;x<this.set.length;x++)if(he(this.set[x],_,this.options))return!0;return!1}}Pr=t;const r=bs(),n=new r,s=Jr(),u=Fe(),i=Ue(),o=K(),{safeRe:c,t:l,comparatorTrimReplace:a,tildeTrimReplace:f,caretTrimReplace:d}=be(),{FLAG_INCLUDE_PRERELEASE:m,FLAG_LOOSE:h}=De(),p=w=>w.value==="<0.0.0-0",g=w=>w.value==="",v=(w,_)=>{let x=!0;const I=w.slice();let S=I.pop();for(;x&&I.length;)x=I.every(O=>S.intersects(O,_)),S=I.pop();return x},E=(w,_)=>(w=w.replace(c[l.BUILD],""),i("comp",w,_),w=U(w,_),i("caret",w),w=q(w,_),i("tildes",w),w=C(w,_),i("xrange",w),w=ie(w,_),i("stars",w),w),y=w=>!w||w.toLowerCase()==="x"||w==="*",q=(w,_)=>w.trim().split(/\s+/).map(x=>M(x,_)).join(" "),M=(w,_)=>{const x=_.loose?c[l.TILDELOOSE]:c[l.TILDE];return w.replace(x,(I,S,O,A,j)=>{i("tilde",w,I,S,O,A,j);let L;return y(S)?L="":y(O)?L=`>=${S}.0.0 <${+S+1}.0.0-0`:y(A)?L=`>=${S}.${O}.0 <${S}.${+O+1}.0-0`:j?(i("replaceTilde pr",j),L=`>=${S}.${O}.${A}-${j} <${S}.${+O+1}.0-0`):L=`>=${S}.${O}.${A} <${S}.${+O+1}.0-0`,i("tilde return",L),L})},U=(w,_)=>w.trim().split(/\s+/).map(x=>B(x,_)).join(" "),B=(w,_)=>{i("caret",w,_);const x=_.loose?c[l.CARETLOOSE]:c[l.CARET],I=_.includePrerelease?"-0":"";return w.replace(x,(S,O,A,j,L)=>{i("caret",w,S,O,A,j,L);let F;return y(O)?F="":y(A)?F=`>=${O}.0.0${I} <${+O+1}.0.0-0`:y(j)?O==="0"?F=`>=${O}.${A}.0${I} <${O}.${+A+1}.0-0`:F=`>=${O}.${A}.0${I} <${+O+1}.0.0-0`:L?(i("replaceCaret pr",L),O==="0"?A==="0"?F=`>=${O}.${A}.${j}-${L} <${O}.${A}.${+j+1}-0`:F=`>=${O}.${A}.${j}-${L} <${O}.${+A+1}.0-0`:F=`>=${O}.${A}.${j}-${L} <${+O+1}.0.0-0`):(i("no pr"),O==="0"?A==="0"?F=`>=${O}.${A}.${j}${I} <${O}.${A}.${+j+1}-0`:F=`>=${O}.${A}.${j}${I} <${O}.${+A+1}.0-0`:F=`>=${O}.${A}.${j} <${+O+1}.0.0-0`),i("caret return",F),F})},C=(w,_)=>(i("replaceXRanges",w,_),w.split(/\s+/).map(x=>te(x,_)).join(" ")),te=(w,_)=>{w=w.trim();const x=_.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return w.replace(x,(I,S,O,A,j,L)=>{i("xRange",w,I,S,O,A,j,L);const F=y(O),J=F||y(A),D=J||y(j),ne=D;return S==="="&&ne&&(S=""),L=_.includePrerelease?"-0":"",F?S===">"||S==="<"?I="<0.0.0-0":I="*":S&&ne?(J&&(A=0),j=0,S===">"?(S=">=",J?(O=+O+1,A=0,j=0):(A=+A+1,j=0)):S==="<="&&(S="<",J?O=+O+1:A=+A+1),S==="<"&&(L="-0"),I=`${S+O}.${A}.${j}${L}`):J?I=`>=${O}.0.0${L} <${+O+1}.0.0-0`:D&&(I=`>=${O}.${A}.0${L} <${O}.${+A+1}.0-0`),i("xRange return",I),I})},ie=(w,_)=>(i("replaceStars",w,_),w.trim().replace(c[l.STAR],"")),oe=(w,_)=>(i("replaceGTE0",w,_),w.trim().replace(c[_.includePrerelease?l.GTE0PRE:l.GTE0],"")),de=w=>(_,x,I,S,O,A,j,L,F,J,D,ne)=>(y(I)?x="":y(S)?x=`>=${I}.0.0${w?"-0":""}`:y(O)?x=`>=${I}.${S}.0${w?"-0":""}`:A?x=`>=${x}`:x=`>=${x}${w?"-0":""}`,y(F)?L="":y(J)?L=`<${+F+1}.0.0-0`:y(D)?L=`<${F}.${+J+1}.0-0`:ne?L=`<=${F}.${J}.${D}-${ne}`:w?L=`<${F}.${J}.${+D+1}-0`:L=`<=${L}`,`${x} ${L}`.trim()),he=(w,_,x)=>{for(let I=0;I<w.length;I++)if(!w[I].test(_))return!1;if(_.prerelease.length&&!x.includePrerelease){for(let I=0;I<w.length;I++)if(i(w[I].semver),w[I].semver!==u.ANY&&w[I].semver.prerelease.length>0){const S=w[I].semver;if(S.major===_.major&&S.minor===_.minor&&S.patch===_.patch)return!0}return!1}return!0};return Pr}var Nr,Yt;function Fe(){if(Yt)return Nr;Yt=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(a,f){if(f=r(f),a instanceof t){if(a.loose===!!f.loose)return a;a=a.value}a=a.trim().split(/\s+/).join(" "),i("comparator",a,f),this.options=f,this.loose=!!f.loose,this.parse(a),this.semver===e?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(a){const f=this.options.loose?n[s.COMPARATORLOOSE]:n[s.COMPARATOR],d=a.match(f);if(!d)throw new TypeError(`Invalid comparator: ${a}`);this.operator=d[1]!==void 0?d[1]:"",this.operator==="="&&(this.operator=""),d[2]?this.semver=new o(d[2],this.options.loose):this.semver=e}toString(){return this.value}test(a){if(i("Comparator.test",a,this.options.loose),this.semver===e||a===e)return!0;if(typeof a=="string")try{a=new o(a,this.options)}catch{return!1}return u(a,this.operator,this.semver,this.options)}intersects(a,f){if(!(a instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(a.value,f).test(this.value):a.operator===""?a.value===""?!0:new c(this.value,f).test(a.semver):(f=r(f),f.includePrerelease&&(this.value==="<0.0.0-0"||a.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||a.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&a.operator.startsWith(">")||this.operator.startsWith("<")&&a.operator.startsWith("<")||this.semver.version===a.semver.version&&this.operator.includes("=")&&a.operator.includes("=")||u(this.semver,"<",a.semver,f)&&this.operator.startsWith(">")&&a.operator.startsWith("<")||u(this.semver,">",a.semver,f)&&this.operator.startsWith("<")&&a.operator.startsWith(">")))}}Nr=t;const r=Jr(),{safeRe:n,t:s}=be(),u=Tn(),i=Ue(),o=K(),c=re();return Nr}var Ar,Kt;function Ge(){if(Kt)return Ar;Kt=1;const e=re();return Ar=(r,n,s)=>{try{n=new e(n,s)}catch{return!1}return n.test(r)},Ar}var kr,Wt;function Is(){if(Wt)return kr;Wt=1;const e=re();return kr=(r,n)=>new e(r,n).set.map(s=>s.map(u=>u.value).join(" ").trim().split(" ")),kr}var zr,Qt;function Os(){if(Qt)return zr;Qt=1;const e=K(),t=re();return zr=(n,s,u)=>{let i=null,o=null,c=null;try{c=new t(s,u)}catch{return null}return n.forEach(l=>{c.test(l)&&(!i||o.compare(l)===-1)&&(i=l,o=new e(i,u))}),i},zr}var Cr,en;function Ts(){if(en)return Cr;en=1;const e=K(),t=re();return Cr=(n,s,u)=>{let i=null,o=null,c=null;try{c=new t(s,u)}catch{return null}return n.forEach(l=>{c.test(l)&&(!i||o.compare(l)===1)&&(i=l,o=new e(i,u))}),i},Cr}var Lr,rn;function xs(){if(rn)return Lr;rn=1;const e=K(),t=re(),r=Me();return Lr=(s,u)=>{s=new t(s,u);let i=new e("0.0.0");if(s.test(i)||(i=new e("0.0.0-0"),s.test(i)))return i;i=null;for(let o=0;o<s.set.length;++o){const c=s.set[o];let l=null;c.forEach(a=>{const f=new e(a.semver.version);switch(a.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!l||r(f,l))&&(l=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${a.operator}`)}}),l&&(!i||r(i,l))&&(i=l)}return i&&s.test(i)?i:null},Lr}var qr,tn;function Ss(){if(tn)return qr;tn=1;const e=re();return qr=(r,n)=>{try{return new e(r,n).range||"*"}catch{return null}},qr}var jr,nn;function Qr(){if(nn)return jr;nn=1;const e=K(),t=Fe(),{ANY:r}=t,n=re(),s=Ge(),u=Me(),i=Yr(),o=Wr(),c=Kr();return jr=(a,f,d,m)=>{a=new e(a,m),f=new n(f,m);let h,p,g,v,E;switch(d){case">":h=u,p=o,g=i,v=">",E=">=";break;case"<":h=i,p=c,g=u,v="<",E="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(a,f,m))return!1;for(let y=0;y<f.set.length;++y){const q=f.set[y];let M=null,U=null;if(q.forEach(B=>{B.semver===r&&(B=new t(">=0.0.0")),M=M||B,U=U||B,h(B.semver,M.semver,m)?M=B:g(B.semver,U.semver,m)&&(U=B)}),M.operator===v||M.operator===E||(!U.operator||U.operator===v)&&p(a,U.semver))return!1;if(U.operator===E&&g(a,U.semver))return!1}return!0},jr}var Dr,sn;function Ps(){if(sn)return Dr;sn=1;const e=Qr();return Dr=(r,n,s)=>e(r,n,">",s),Dr}var Ur,on;function Ns(){if(on)return Ur;on=1;const e=Qr();return Ur=(r,n,s)=>e(r,n,"<",s),Ur}var Mr,an;function As(){if(an)return Mr;an=1;const e=re();return Mr=(r,n,s)=>(r=new e(r,s),n=new e(n,s),r.intersects(n,s)),Mr}var Fr,un;function ks(){if(un)return Fr;un=1;const e=Ge(),t=ee();return Fr=(r,n,s)=>{const u=[];let i=null,o=null;const c=r.sort((d,m)=>t(d,m,s));for(const d of c)e(d,n,s)?(o=d,i||(i=d)):(o&&u.push([i,o]),o=null,i=null);i&&u.push([i,null]);const l=[];for(const[d,m]of u)d===m?l.push(d):!m&&d===c[0]?l.push("*"):m?d===c[0]?l.push(`<=${m}`):l.push(`${d} - ${m}`):l.push(`>=${d}`);const a=l.join(" || "),f=typeof n.raw=="string"?n.raw:String(n);return a.length<f.length?a:n},Fr}var Gr,cn;function zs(){if(cn)return Gr;cn=1;const e=re(),t=Fe(),{ANY:r}=t,n=Ge(),s=ee(),u=(f,d,m={})=>{if(f===d)return!0;f=new e(f,m),d=new e(d,m);let h=!1;e:for(const p of f.set){for(const g of d.set){const v=c(p,g,m);if(h=h||v!==null,v)continue e}if(h)return!1}return!0},i=[new t(">=0.0.0-0")],o=[new t(">=0.0.0")],c=(f,d,m)=>{if(f===d)return!0;if(f.length===1&&f[0].semver===r){if(d.length===1&&d[0].semver===r)return!0;m.includePrerelease?f=i:f=o}if(d.length===1&&d[0].semver===r){if(m.includePrerelease)return!0;d=o}const h=new Set;let p,g;for(const C of f)C.operator===">"||C.operator===">="?p=l(p,C,m):C.operator==="<"||C.operator==="<="?g=a(g,C,m):h.add(C.semver);if(h.size>1)return null;let v;if(p&&g){if(v=s(p.semver,g.semver,m),v>0)return null;if(v===0&&(p.operator!==">="||g.operator!=="<="))return null}for(const C of h){if(p&&!n(C,String(p),m)||g&&!n(C,String(g),m))return null;for(const te of d)if(!n(C,String(te),m))return!1;return!0}let E,y,q,M,U=g&&!m.includePrerelease&&g.semver.prerelease.length?g.semver:!1,B=p&&!m.includePrerelease&&p.semver.prerelease.length?p.semver:!1;U&&U.prerelease.length===1&&g.operator==="<"&&U.prerelease[0]===0&&(U=!1);for(const C of d){if(M=M||C.operator===">"||C.operator===">=",q=q||C.operator==="<"||C.operator==="<=",p){if(B&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===B.major&&C.semver.minor===B.minor&&C.semver.patch===B.patch&&(B=!1),C.operator===">"||C.operator===">="){if(E=l(p,C,m),E===C&&E!==p)return!1}else if(p.operator===">="&&!n(p.semver,String(C),m))return!1}if(g){if(U&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===U.major&&C.semver.minor===U.minor&&C.semver.patch===U.patch&&(U=!1),C.operator==="<"||C.operator==="<="){if(y=a(g,C,m),y===C&&y!==g)return!1}else if(g.operator==="<="&&!n(g.semver,String(C),m))return!1}if(!C.operator&&(g||p)&&v!==0)return!1}return!(p&&q&&!g&&v!==0||g&&M&&!p&&v!==0||B||U)},l=(f,d,m)=>{if(!f)return d;const h=s(f.semver,d.semver,m);return h>0?f:h<0||d.operator===">"&&f.operator===">="?d:f},a=(f,d,m)=>{if(!f)return d;const h=s(f.semver,d.semver,m);return h<0?f:h>0||d.operator==="<"&&f.operator==="<="?d:f};return Gr=u,Gr}var Vr,ln;function Cs(){if(ln)return Vr;ln=1;const e=be(),t=De(),r=K(),n=bn(),s=me(),u=fs(),i=ds(),o=hs(),c=ps(),l=ms(),a=gs(),f=vs(),d=ys(),m=ee(),h=_s(),p=$s(),g=Hr(),v=Es(),E=ws(),y=Me(),q=Yr(),M=In(),U=On(),B=Kr(),C=Wr(),te=Tn(),ie=Rs(),oe=Fe(),de=re(),he=Ge(),w=Is(),_=Os(),x=Ts(),I=xs(),S=Ss(),O=Qr(),A=Ps(),j=Ns(),L=As(),F=ks(),J=zs();return Vr={parse:s,valid:u,clean:i,inc:o,diff:c,major:l,minor:a,patch:f,prerelease:d,compare:m,rcompare:h,compareLoose:p,compareBuild:g,sort:v,rsort:E,gt:y,lt:q,eq:M,neq:U,gte:B,lte:C,cmp:te,coerce:ie,Comparator:oe,Range:de,satisfies:he,toComparators:w,maxSatisfying:_,minSatisfying:x,minVersion:I,validRange:S,outside:O,gtr:A,ltr:j,intersects:L,simplifyRange:F,subset:J,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},Vr}Cs();var je={exports:{}};je.exports;var fn;function Ls(){return fn||(fn=1,(function(e){const r=(u=0)=>i=>`\x1B[${38+u};5;${i}m`,n=(u=0)=>(i,o,c)=>`\x1B[${38+u};2;${i};${o};${c}m`;function s(){const u=new Map,i={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]}};i.color.gray=i.color.blackBright,i.bgColor.bgGray=i.bgColor.bgBlackBright,i.color.grey=i.color.blackBright,i.bgColor.bgGrey=i.bgColor.bgBlackBright;for(const[o,c]of Object.entries(i)){for(const[l,a]of Object.entries(c))i[l]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},c[l]=i[l],u.set(a[0],a[1]);Object.defineProperty(i,o,{value:c,enumerable:!1})}return Object.defineProperty(i,"codes",{value:u,enumerable:!1}),i.color.close="\x1B[39m",i.bgColor.close="\x1B[49m",i.color.ansi256=r(),i.color.ansi16m=n(),i.bgColor.ansi256=r(10),i.bgColor.ansi16m=n(10),Object.defineProperties(i,{rgbToAnsi256:{value:(o,c,l)=>o===c&&c===l?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(c/255*5)+Math.round(l/255*5),enumerable:!1},hexToRgb:{value:o=>{const c=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(o.toString(16));if(!c)return[0,0,0];let{colorString:l}=c.groups;l.length===3&&(l=l.split("").map(f=>f+f).join(""));const a=Number.parseInt(l,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:o=>i.rgbToAnsi256(...i.hexToRgb(o)),enumerable:!1}}),i}Object.defineProperty(e,"exports",{enumerable:!0,get:s})})(je)),je.exports}var qs=Ls();const Yi=pe(qs);function G(e,t,r){function n(o,c){var l;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(l=o._zod).traits??(l.traits=new Set),o._zod.traits.add(e),t(o,c);for(const a in i.prototype)a in o||Object.defineProperty(o,a,{value:i.prototype[a].bind(o)});o._zod.constr=i,o._zod.def=c}const s=r?.Parent??Object;class u extends s{}Object.defineProperty(u,"name",{value:e});function i(o){var c;const l=r?.Parent?new u:this;n(l,o),(c=l._zod).deferred??(c.deferred=[]);for(const a of l._zod.deferred)a();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Re extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const js={};function le(e){return js}function Ds(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function Us(e,t){return typeof t=="bigint"?t.toString():t}function et(e){return e==null}function rt(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Z(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ms(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}const xn=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Br(e){if(dn(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(dn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Sn(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function ge(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ki(e,t){if(!Br(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return Ms(this,"shape",n),n},checks:[]};return Sn(e,r)}function Wi(e,t,r){const n=t._zod.def.shape,s={...n};for(const u in n)s[u]=e?new e({type:"optional",innerType:n[u]}):n[u];return Sn(t,{...t._zod.def,shape:s,checks:[]})}function Ee(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Fs(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function qe(e){return typeof e=="string"?e:e?.message}function fe(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const s=qe(e.inst?._zod.def?.error?.(e))??qe(t?.error?.(e))??qe(r.customError?.(e))??qe(r.localeError?.(e))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function tt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gs(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Pn=(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(){return JSON.stringify(t,Us,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vs=G("$ZodError",Pn),Ve=G("$ZodError",Pn,{Parent:Error});function Qi(e,t=r=>r.message){const r={},n=[];for(const s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}}function eo(e,t){const r=t||function(u){return u.message},n={_errors:[]},s=u=>{for(const i of u.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>s({issues:o}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(e),n}function Bs(e){const t=[];for(const r of e)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function ro(e){const t=[],r=[...e.issues].sort((n,s)=>n.path.length-s.path.length);for(const n of r)t.push(`✖ ${n.message}`),n.path?.length&&t.push(` → at ${Bs(n.path)}`);return t.join(`
|
|
2
|
+
`)}const Zs=e=>(t,r,n,s)=>{const u=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},u);if(i instanceof Promise)throw new Re;if(i.issues.length){const o=new(s?.Err??e)(i.issues.map(c=>fe(c,u,le())));throw xn(o,s?.callee),o}return i.value},to=Zs(Ve),Xs=e=>async(t,r,n,s)=>{const u=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},u);if(i instanceof Promise&&(i=await i),i.issues.length){const o=new(s?.Err??e)(i.issues.map(c=>fe(c,u,le())));throw xn(o,s?.callee),o}return i.value},no=Xs(Ve),Js=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},u=t._zod.run({value:r,issues:[]},s);if(u instanceof Promise)throw new Re;return u.issues.length?{success:!1,error:new(e??Vs)(u.issues.map(i=>fe(i,s,le())))}:{success:!0,data:u.value}},Hs=Js(Ve),Ys=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let u=t._zod.run({value:r,issues:[]},s);return u instanceof Promise&&(u=await u),u.issues.length?{success:!1,error:new e(u.issues.map(i=>fe(i,s,le())))}:{success:!0,data:u.value}},Ks=Ys(Ve),Ie=G("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ws=G("$ZodCheckMaxLength",(e,t)=>{var r;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!et(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const s=n.value;if(s.length<=t.maximum)return;const i=tt(s);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Qs=G("$ZodCheckMinLength",(e,t)=>{var r;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!et(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const s=n.value;if(s.length>=t.minimum)return;const i=tt(s);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),ei=G("$ZodCheckLengthEquals",(e,t)=>{var r;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!et(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=n=>{const s=n.value,u=s.length;if(u===t.length)return;const i=tt(s),o=u>t.length;n.issues.push({origin:i,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ri=G("$ZodCheckOverwrite",(e,t)=>{Ie.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),ti={major:4,minor:0,patch:0},Y=G("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ti;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const s of n)for(const u of s._zod.onattach)u(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(u,i,o)=>{let c=Ee(u),l;for(const a of i){if(a._zod.def.when){if(!a._zod.def.when(u))continue}else if(c)continue;const f=u.issues.length,d=a._zod.check(u);if(d instanceof Promise&&o?.async===!1)throw new Re;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await d,u.issues.length!==f&&(c||(c=Ee(u,f)))});else{if(u.issues.length===f)continue;c||(c=Ee(u,f))}}return l?l.then(()=>u):u};e._zod.run=(u,i)=>{const o=e._zod.parse(u,i);if(o instanceof Promise){if(i.async===!1)throw new Re;return o.then(c=>s(c,n,i))}return s(o,n,i)}}e["~standard"]={validate:s=>{try{const u=Hs(e,s);return u.success?{value:u.data}:{issues:u.error?.issues}}catch{return Ks(e,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),so=G("$ZodAny",(e,t)=>{Y.init(e,t),e._zod.parse=r=>r}),io=G("$ZodUnknown",(e,t)=>{Y.init(e,t),e._zod.parse=r=>r}),oo=G("$ZodNever",(e,t)=>{Y.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function hn(e,t,r){e.issues.length&&t.issues.push(...Fs(r,e.issues)),t.value[r]=e.value}const ao=G("$ZodArray",(e,t)=>{Y.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const u=[];for(let i=0;i<s.length;i++){const o=s[i],c=t.element._zod.run({value:o,issues:[]},n);c instanceof Promise?u.push(c.then(l=>hn(l,r,i))):hn(c,r,i)}return u.length?Promise.all(u).then(()=>r):r}});function pn(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(u=>fe(u,n,le())))}),t}const uo=G("$ZodUnion",(e,t)=>{Y.init(e,t),Z(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Z(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Z(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Z(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>rt(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let s=!1;const u=[];for(const i of t.options){const o=i._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)u.push(o),s=!0;else{if(o.issues.length===0)return o;u.push(o)}}return s?Promise.all(u).then(i=>pn(i,r,e,n)):pn(u,r,e,n)}}),co=G("$ZodIntersection",(e,t)=>{Y.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,u=t.left._zod.run({value:s,issues:[]},n),i=t.right._zod.run({value:s,issues:[]},n);return u instanceof Promise||i instanceof Promise?Promise.all([u,i]).then(([c,l])=>mn(r,c,l)):mn(r,u,i)}});function Zr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Br(e)&&Br(t)){const r=Object.keys(t),n=Object.keys(e).filter(u=>r.indexOf(u)!==-1),s={...e,...t};for(const u of n){const i=Zr(e[u],t[u]);if(!i.valid)return{valid:!1,mergeErrorPath:[u,...i.mergeErrorPath]};s[u]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const s=e[n],u=t[n],i=Zr(s,u);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function mn(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ee(e))return e;const n=Zr(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const lo=G("$ZodTransform",(e,t)=>{Y.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Re;return r.value=s,r}}),fo=G("$ZodOptional",(e,t)=>{Y.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Z(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${rt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),ho=G("$ZodNullable",(e,t)=>{Y.init(e,t),Z(e._zod,"optin",()=>t.innerType._zod.optin),Z(e._zod,"optout",()=>t.innerType._zod.optout),Z(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${rt(r.source)}|null)$`):void 0}),Z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),po=G("$ZodDefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(u=>gn(u,t)):gn(s,t)}});function gn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const mo=G("$ZodPrefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),go=G("$ZodNonOptional",(e,t)=>{Y.init(e,t),Z(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(u=>vn(u,e)):vn(s,e)}});function vn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const vo=G("$ZodCatch",(e,t)=>{Y.init(e,t),e._zod.optin="optional",Z(e._zod,"optout",()=>t.innerType._zod.optout),Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(u=>(r.value=u.value,u.issues.length&&(r.value=t.catchValue({...r,error:{issues:u.issues.map(i=>fe(i,n,le()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(u=>fe(u,n,le()))},input:r.value}),r.issues=[]),r)}}),yo=G("$ZodPipe",(e,t)=>{Y.init(e,t),Z(e._zod,"values",()=>t.in._zod.values),Z(e._zod,"optin",()=>t.in._zod.optin),Z(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{const s=t.in._zod.run(r,n);return s instanceof Promise?s.then(u=>yn(u,t,n)):yn(s,t,n)}});function yn(e,t,r){return Ee(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const _o=G("$ZodReadonly",(e,t)=>{Y.init(e,t),Z(e._zod,"propValues",()=>t.innerType._zod.propValues),Z(e._zod,"values",()=>t.innerType._zod.values),Z(e._zod,"optin",()=>t.innerType._zod.optin),Z(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(_n):_n(s)}});function _n(e){return e.value=Object.freeze(e.value),e}const $o=G("$ZodCustom",(e,t)=>{Ie.init(e,t),Y.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(u=>$n(u,r,n,e));$n(s,r,n,e)}});function $n(e,t,r,n){if(!e){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),t.issues.push(Gs(s))}}class Nn{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function ni(){return new Nn}const si=ni();function Eo(e){return new e({type:"any"})}function wo(e){return new e({type:"unknown"})}function Ro(e,t){return new e({type:"never",...ge(t)})}function bo(e,t){return new Ws({check:"max_length",...ge(t),maximum:e})}function Io(e,t){return new Qs({check:"min_length",...ge(t),minimum:e})}function Oo(e,t){return new ei({check:"length_equals",...ge(t),length:e})}function To(e){return new ri({check:"overwrite",tx:e})}function xo(e,t,r){return new e({type:"array",element:t,...ge(r)})}function So(e,t,r){return new e({type:"custom",check:"custom",fn:t,...ge(r)})}class En{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??si,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;const s=t._zod.def,u={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(t);if(i)return i.count++,r.schemaPath.includes(t)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,o);const c=t._zod.toJSONSchema?.();if(c)o.schema=c;else{const f={...r,schemaPath:[...r.schemaPath,t],path:r.path},d=t._zod.parent;if(d)o.ref=d,this.process(d,f),this.seen.get(d).isParent=!0;else{const m=o.schema;switch(s.type){case"string":{const h=m;h.type="string";const{minimum:p,maximum:g,format:v,patterns:E,contentEncoding:y}=t._zod.bag;if(typeof p=="number"&&(h.minLength=p),typeof g=="number"&&(h.maxLength=g),v&&(h.format=u[v]??v,h.format===""&&delete h.format),y&&(h.contentEncoding=y),E&&E.size>0){const q=[...E];q.length===1?h.pattern=q[0].source:q.length>1&&(o.schema.allOf=[...q.map(M=>({...this.target==="draft-7"?{type:"string"}:{},pattern:M.source}))])}break}case"number":{const h=m,{minimum:p,maximum:g,format:v,multipleOf:E,exclusiveMaximum:y,exclusiveMinimum:q}=t._zod.bag;typeof v=="string"&&v.includes("int")?h.type="integer":h.type="number",typeof q=="number"&&(h.exclusiveMinimum=q),typeof p=="number"&&(h.minimum=p,typeof q=="number"&&(q>=p?delete h.minimum:delete h.exclusiveMinimum)),typeof y=="number"&&(h.exclusiveMaximum=y),typeof g=="number"&&(h.maximum=g,typeof y=="number"&&(y<=g?delete h.maximum:delete h.exclusiveMaximum)),typeof E=="number"&&(h.multipleOf=E);break}case"boolean":{const h=m;h.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const h=m,{minimum:p,maximum:g}=t._zod.bag;typeof p=="number"&&(h.minItems=p),typeof g=="number"&&(h.maxItems=g),h.type="array",h.items=this.process(s.element,{...f,path:[...f.path,"items"]});break}case"object":{const h=m;h.type="object",h.properties={};const p=s.shape;for(const E in p)h.properties[E]=this.process(p[E],{...f,path:[...f.path,"properties",E]});const g=new Set(Object.keys(p)),v=new Set([...g].filter(E=>{const y=s.shape[E]._zod;return this.io==="input"?y.optin===void 0:y.optout===void 0}));v.size>0&&(h.required=Array.from(v)),s.catchall?._zod.def.type==="never"?h.additionalProperties=!1:s.catchall?s.catchall&&(h.additionalProperties=this.process(s.catchall,{...f,path:[...f.path,"additionalProperties"]})):this.io==="output"&&(h.additionalProperties=!1);break}case"union":{const h=m;h.anyOf=s.options.map((p,g)=>this.process(p,{...f,path:[...f.path,"anyOf",g]}));break}case"intersection":{const h=m,p=this.process(s.left,{...f,path:[...f.path,"allOf",0]}),g=this.process(s.right,{...f,path:[...f.path,"allOf",1]}),v=y=>"allOf"in y&&Object.keys(y).length===1,E=[...v(p)?p.allOf:[p],...v(g)?g.allOf:[g]];h.allOf=E;break}case"tuple":{const h=m;h.type="array";const p=s.items.map((E,y)=>this.process(E,{...f,path:[...f.path,"prefixItems",y]}));if(this.target==="draft-2020-12"?h.prefixItems=p:h.items=p,s.rest){const E=this.process(s.rest,{...f,path:[...f.path,"items"]});this.target==="draft-2020-12"?h.items=E:h.additionalItems=E}s.rest&&(h.items=this.process(s.rest,{...f,path:[...f.path,"items"]}));const{minimum:g,maximum:v}=t._zod.bag;typeof g=="number"&&(h.minItems=g),typeof v=="number"&&(h.maxItems=v);break}case"record":{const h=m;h.type="object",h.propertyNames=this.process(s.keyType,{...f,path:[...f.path,"propertyNames"]}),h.additionalProperties=this.process(s.valueType,{...f,path:[...f.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const h=m,p=Ds(s.entries);p.every(g=>typeof g=="number")&&(h.type="number"),p.every(g=>typeof g=="string")&&(h.type="string"),h.enum=p;break}case"literal":{const h=m,p=[];for(const g of s.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");p.push(Number(g))}else p.push(g);if(p.length!==0)if(p.length===1){const g=p[0];h.type=g===null?"null":typeof g,h.const=g}else p.every(g=>typeof g=="number")&&(h.type="number"),p.every(g=>typeof g=="string")&&(h.type="string"),p.every(g=>typeof g=="boolean")&&(h.type="string"),p.every(g=>g===null)&&(h.type="null"),h.enum=p;break}case"file":{const h=m,p={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:v,mime:E}=t._zod.bag;g!==void 0&&(p.minLength=g),v!==void 0&&(p.maxLength=v),E?E.length===1?(p.contentMediaType=E[0],Object.assign(h,p)):h.anyOf=E.map(y=>({...p,contentMediaType:y})):Object.assign(h,p);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const h=this.process(s.innerType,f);m.anyOf=[h,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"success":{const h=m;h.type="boolean";break}case"default":{this.process(s.innerType,f),o.ref=s.innerType,m.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,f),o.ref=s.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,f),o.ref=s.innerType;let h;try{h=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=h;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const h=m,p=t._zod.pattern;if(!p)throw new Error("Pattern not found in template literal");h.type="string",h.pattern=p.source;break}case"pipe":{const h=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(h,f),o.ref=h;break}case"readonly":{this.process(s.innerType,f),o.ref=s.innerType,m.readOnly=!0;break}case"promise":{this.process(s.innerType,f),o.ref=s.innerType;break}case"optional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"lazy":{const h=t._zod.innerType;this.process(h,f),o.ref=h;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const l=this.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),this.io==="input"&&X(t)&&(delete o.schema.examples,delete o.schema.default),this.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(t).schema}emit(t,r){const n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const u=a=>{const f=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const p=n.external.registry.get(a[0])?.id,g=n.external.uri??(E=>E);if(p)return{ref:g(p)};const v=a[1].defId??a[1].schema.id??`schema${this.counter++}`;return a[1].defId=v,{defId:v,ref:`${g("__shared")}#/${f}/${v}`}}if(a[1]===s)return{ref:"#"};const m=`#/${f}/`,h=a[1].schema.id??`__schema${this.counter++}`;return{defId:h,ref:m+h}},i=a=>{if(a[1].schema.$ref)return;const f=a[1],{ref:d,defId:m}=u(a);f.def={...f.schema},m&&(f.defId=m);const h=f.schema;for(const p in h)delete h[p];h.$ref=d};if(n.cycles==="throw")for(const a of this.seen.entries()){const f=a[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
|
|
3
|
+
|
|
4
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of this.seen.entries()){const f=a[1];if(t===a[0]){i(a);continue}if(n.external){const m=n.external.registry.get(a[0])?.id;if(t!==a[0]&&m){i(a);continue}}if(this.metadataRegistry.get(a[0])?.id){i(a);continue}if(f.cycle){i(a);continue}if(f.count>1&&n.reused==="ref"){i(a);continue}}const o=(a,f)=>{const d=this.seen.get(a),m=d.def??d.schema,h={...m};if(d.ref===null)return;const p=d.ref;if(d.ref=null,p){o(p,f);const g=this.seen.get(p).schema;g.$ref&&f.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,h))}d.isParent||this.override({zodSchema:a,jsonSchema:m,path:d.path??[]})};for(const a of[...this.seen.entries()].reverse())o(a[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){const a=n.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(a)}Object.assign(c,s.def);const l=n.external?.defs??{};for(const a of this.seen.entries()){const f=a[1];f.def&&f.defId&&(l[f.defId]=f.def)}n.external||Object.keys(l).length>0&&(this.target==="draft-2020-12"?c.$defs=l:c.definitions=l);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function Po(e,t){if(e instanceof Nn){const n=new En(t),s={};for(const o of e._idmap.entries()){const[c,l]=o;n.process(l)}const u={},i={registry:e,uri:t?.uri,defs:s};for(const o of e._idmap.entries()){const[c,l]=o;u[c]=n.emit(l,{...t,external:i})}if(Object.keys(s).length>0){const o=n.target==="draft-2020-12"?"$defs":"definitions";u.__shared={[o]:s}}return{schemas:u}}const r=new En(t);return r.process(e),r.emit(e,t)}function X(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const s=e._zod.def;switch(s.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":return!1;case"array":return X(s.element,r);case"object":{for(const u in s.shape)if(X(s.shape[u],r))return!0;return!1}case"union":{for(const u of s.options)if(X(u,r))return!0;return!1}case"intersection":return X(s.left,r)||X(s.right,r);case"tuple":{for(const u of s.items)if(X(u,r))return!0;return!!(s.rest&&X(s.rest,r))}case"record":return X(s.keyType,r)||X(s.valueType,r);case"map":return X(s.keyType,r)||X(s.valueType,r);case"set":return X(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return X(s.innerType,r);case"lazy":return X(s.getter(),r);case"default":return X(s.innerType,r);case"prefault":return X(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return X(s.in,r)||X(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}function we(e,t){const r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(!we(e[s],t[s]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const i of n)if(!we(e[i],t[i]))return!1;return!0}return e===t}function Q(e){return encodeURI(ii(e))}function ii(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}const oi={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},ai={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},ui={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 ci=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function ce(e,t=Object.create(null),r=ci,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){const u=e.$id||e.id;if(u){const i=new URL(u,r.href);i.hash.length>1?t[i.href]=e:(i.hash="",n===""?r=i:ce(e,t,r))}}else if(e!==!0&&e!==!1)return t;const s=r.href+(n?"#"+n:"");if(t[s]!==void 0)throw new Error(`Duplicate schema URI "${s}".`);if(t[s]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:s}),e.$ref&&e.__absolute_ref__===void 0){const u=new URL(e.$ref,r.href);u.hash=u.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:u.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){const u=new URL(e.$recursiveRef,r.href);u.hash=u.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:u.href})}if(e.$anchor){const u=new URL("#"+e.$anchor,r.href);t[u.href]=e}for(let u in e){if(ui[u])continue;const i=`${n}/${Q(u)}`,o=e[u];if(Array.isArray(o)){if(oi[u]){const c=o.length;for(let l=0;l<c;l++)ce(o[l],t,r,`${i}/${l}`)}}else if(ai[u])for(let c in o)ce(o[c],t,r,`${i}/${Q(c)}`);else ce(o,t,r,i)}return t}const li=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,fi=[0,31,28,31,30,31,30,31,31,30,31,30,31],di=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,hi=/^(?=.{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,pi=/^(?:[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,mi=/^(?:(?:[^\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,gi=/^(?:(?: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,vi=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,yi=/^(?:\/(?:[^~/]|~0|~1)*)*$/,_i=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,$i=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ei=e=>{if(e[0]==='"')return!1;const[t,r,...n]=e.split("@");return!t||!r||n.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(s=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(s))},wi=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Ri=/^((([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,bi=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function se(e){return e.test.bind(e)}const wn={date:An,time:kn.bind(void 0,!1),"date-time":Ti,duration:bi,uri:Pi,"uri-reference":se(pi),"uri-template":se(mi),url:se(gi),email:Ei,hostname:se(hi),ipv4:se(wi),ipv6:se(Ri),regex:Ai,uuid:se(vi),"json-pointer":se(yi),"json-pointer-uri-fragment":se(_i),"relative-json-pointer":se($i)};function Ii(e){return e%4===0&&(e%100!==0||e%400===0)}function An(e){const t=e.match(li);if(!t)return!1;const r=+t[1],n=+t[2],s=+t[3];return n>=1&&n<=12&&s>=1&&s<=(n==2&&Ii(r)?29:fi[n])}function kn(e,t){const r=t.match(di);if(!r)return!1;const n=+r[1],s=+r[2],u=+r[3],i=!!r[5];return(n<=23&&s<=59&&u<=59||n==23&&s==59&&u==60)&&(!e||i)}const Oi=/t|\s/i;function Ti(e){const t=e.split(Oi);return t.length==2&&An(t[0])&&kn(!0,t[1])}const xi=/\/|:/,Si=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Pi(e){return xi.test(e)&&Si.test(e)}const Ni=/[^\\]\\Z/;function Ai(e){if(Ni.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function ki(e){let t=0,r=e.length,n=0,s;for(;n<r;)t++,s=e.charCodeAt(n++),s>=55296&&s<=56319&&n<r&&(s=e.charCodeAt(n),(s&64512)==56320&&n++);return t}function V(e,t,r="2019-09",n=ce(t),s=!0,u=null,i="#",o="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:i,keyword:"false",keywordLocation:i,error:"False boolean schema."}]};const l=typeof e;let a;switch(l){case"boolean":case"number":case"string":a=l;break;case"object":e===null?a="null":Array.isArray(e)?a="array":a="object";break;default:throw new Error(`Instances of "${l}" type are not supported.`)}const{$ref:f,$recursiveRef:d,$recursiveAnchor:m,type:h,const:p,enum:g,required:v,not:E,anyOf:y,allOf:q,oneOf:M,if:U,then:B,else:C,format:te,properties:ie,patternProperties:oe,additionalProperties:de,unevaluatedProperties:he,minProperties:w,maxProperties:_,propertyNames:x,dependentRequired:I,dependentSchemas:S,dependencies:O,prefixItems:A,items:j,additionalItems:L,unevaluatedItems:F,contains:J,minContains:D,maxContains:ne,minItems:Be,maxItems:Ze,uniqueItems:zn,minimum:ae,maximum:ue,exclusiveMinimum:ve,exclusiveMaximum:ye,multipleOf:Oe,minLength:Te,maxLength:xe,pattern:nt,__absolute_ref__:Se,__absolute_recursive_ref__:Cn}=t,R=[];if(m===!0&&u===null&&(u=t),d==="#"){const P=u===null?n[Cn]:u,T=`${o}/$recursiveRef`,z=V(e,u===null?t:u,r,n,s,P,i,T,c);z.valid||R.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:T,error:"A subschema had errors."},...z.errors)}if(f!==void 0){const T=n[Se||f];if(T===void 0){let $=`Unresolved $ref "${f}".`;throw Se&&Se!==f&&($+=` Absolute URI "${Se}".`),$+=`
|
|
5
|
+
Known schemas:
|
|
6
|
+
- ${Object.keys(n).join(`
|
|
7
|
+
- `)}`,new Error($)}const z=`${o}/$ref`,b=V(e,T,r,n,s,u,i,z,c);if(b.valid||R.push({instanceLocation:i,keyword:"$ref",keywordLocation:z,error:"A subschema had errors."},...b.errors),r==="4"||r==="7")return{valid:R.length===0,errors:R}}if(Array.isArray(h)){let P=h.length,T=!1;for(let z=0;z<P;z++)if(a===h[z]||h[z]==="integer"&&a==="number"&&e%1===0&&e===e){T=!0;break}T||R.push({instanceLocation:i,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${a}" is invalid. Expected "${h.join('", "')}".`})}else h==="integer"?(a!=="number"||e%1||e!==e)&&R.push({instanceLocation:i,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${a}" is invalid. Expected "${h}".`}):h!==void 0&&a!==h&&R.push({instanceLocation:i,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${a}" is invalid. Expected "${h}".`});if(p!==void 0&&(a==="object"||a==="array"?we(e,p)||R.push({instanceLocation:i,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(p)}.`}):e!==p&&R.push({instanceLocation:i,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(p)}.`})),g!==void 0&&(a==="object"||a==="array"?g.some(P=>we(e,P))||R.push({instanceLocation:i,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(P=>e===P)||R.push({instanceLocation:i,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),E!==void 0){const P=`${o}/not`;V(e,E,r,n,s,u,i,P).valid&&R.push({instanceLocation:i,keyword:"not",keywordLocation:P,error:'Instance matched "not" schema.'})}let Pe=[];if(y!==void 0){const P=`${o}/anyOf`,T=R.length;let z=!1;for(let b=0;b<y.length;b++){const $=y[b],k=Object.create(c),N=V(e,$,r,n,s,m===!0?u:null,i,`${P}/${b}`,k);R.push(...N.errors),z=z||N.valid,N.valid&&Pe.push(k)}z?R.length=T:R.splice(T,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:P,error:"Instance does not match any subschemas."})}if(q!==void 0){const P=`${o}/allOf`,T=R.length;let z=!0;for(let b=0;b<q.length;b++){const $=q[b],k=Object.create(c),N=V(e,$,r,n,s,m===!0?u:null,i,`${P}/${b}`,k);R.push(...N.errors),z=z&&N.valid,N.valid&&Pe.push(k)}z?R.length=T:R.splice(T,0,{instanceLocation:i,keyword:"allOf",keywordLocation:P,error:"Instance does not match every subschema."})}if(M!==void 0){const P=`${o}/oneOf`,T=R.length,z=M.filter((b,$)=>{const k=Object.create(c),N=V(e,b,r,n,s,m===!0?u:null,i,`${P}/${$}`,k);return R.push(...N.errors),N.valid&&Pe.push(k),N.valid}).length;z===1?R.length=T:R.splice(T,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:P,error:`Instance does not match exactly one subschema (${z} matches).`})}if((a==="object"||a==="array")&&Object.assign(c,...Pe),U!==void 0){const P=`${o}/if`;if(V(e,U,r,n,s,u,i,P,c).valid){if(B!==void 0){const z=V(e,B,r,n,s,u,i,`${o}/then`,c);z.valid||R.push({instanceLocation:i,keyword:"if",keywordLocation:P,error:'Instance does not match "then" schema.'},...z.errors)}}else if(C!==void 0){const z=V(e,C,r,n,s,u,i,`${o}/else`,c);z.valid||R.push({instanceLocation:i,keyword:"if",keywordLocation:P,error:'Instance does not match "else" schema.'},...z.errors)}}if(a==="object"){if(v!==void 0)for(const b of v)b in e||R.push({instanceLocation:i,keyword:"required",keywordLocation:`${o}/required`,error:`Instance does not have required property "${b}".`});const P=Object.keys(e);if(w!==void 0&&P.length<w&&R.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${o}/minProperties`,error:`Instance does not have at least ${w} properties.`}),_!==void 0&&P.length>_&&R.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${o}/maxProperties`,error:`Instance does not have at least ${_} properties.`}),x!==void 0){const b=`${o}/propertyNames`;for(const $ in e){const k=`${i}/${Q($)}`,N=V($,x,r,n,s,u,k,b);N.valid||R.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:b,error:`Property name "${$}" does not match schema.`},...N.errors)}}if(I!==void 0){const b=`${o}/dependantRequired`;for(const $ in I)if($ in e){const k=I[$];for(const N of k)N in e||R.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:b,error:`Instance has "${$}" but does not have "${N}".`})}}if(S!==void 0)for(const b in S){const $=`${o}/dependentSchemas`;if(b in e){const k=V(e,S[b],r,n,s,u,i,`${$}/${Q(b)}`,c);k.valid||R.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:$,error:`Instance has "${b}" but does not match dependant schema.`},...k.errors)}}if(O!==void 0){const b=`${o}/dependencies`;for(const $ in O)if($ in e){const k=O[$];if(Array.isArray(k))for(const N of k)N in e||R.push({instanceLocation:i,keyword:"dependencies",keywordLocation:b,error:`Instance has "${$}" but does not have "${N}".`});else{const N=V(e,k,r,n,s,u,i,`${b}/${Q($)}`);N.valid||R.push({instanceLocation:i,keyword:"dependencies",keywordLocation:b,error:`Instance has "${$}" but does not match dependant schema.`},...N.errors)}}}const T=Object.create(null);let z=!1;if(ie!==void 0){const b=`${o}/properties`;for(const $ in ie){if(!($ in e))continue;const k=`${i}/${Q($)}`,N=V(e[$],ie[$],r,n,s,u,k,`${b}/${Q($)}`);if(N.valid)c[$]=T[$]=!0;else if(z=s,R.push({instanceLocation:i,keyword:"properties",keywordLocation:b,error:`Property "${$}" does not match schema.`},...N.errors),z)break}}if(!z&&oe!==void 0){const b=`${o}/patternProperties`;for(const $ in oe){const k=new RegExp($,"u"),N=oe[$];for(const W in e){if(!k.test(W))continue;const st=`${i}/${Q(W)}`,it=V(e[W],N,r,n,s,u,st,`${b}/${Q($)}`);it.valid?c[W]=T[W]=!0:(z=s,R.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:b,error:`Property "${W}" matches pattern "${$}" but does not match associated schema.`},...it.errors))}}}if(!z&&de!==void 0){const b=`${o}/additionalProperties`;for(const $ in e){if(T[$])continue;const k=`${i}/${Q($)}`,N=V(e[$],de,r,n,s,u,k,b);N.valid?c[$]=!0:(z=s,R.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:b,error:`Property "${$}" does not match additional properties schema.`},...N.errors))}}else if(!z&&he!==void 0){const b=`${o}/unevaluatedProperties`;for(const $ in e)if(!c[$]){const k=`${i}/${Q($)}`,N=V(e[$],he,r,n,s,u,k,b);N.valid?c[$]=!0:R.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:b,error:`Property "${$}" does not match unevaluated properties schema.`},...N.errors)}}}else if(a==="array"){Ze!==void 0&&e.length>Ze&&R.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${o}/maxItems`,error:`Array has too many items (${e.length} > ${Ze}).`}),Be!==void 0&&e.length<Be&&R.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${o}/minItems`,error:`Array has too few items (${e.length} < ${Be}).`});const P=e.length;let T=0,z=!1;if(A!==void 0){const b=`${o}/prefixItems`,$=Math.min(A.length,P);for(;T<$;T++){const k=V(e[T],A[T],r,n,s,u,`${i}/${T}`,`${b}/${T}`);if(c[T]=!0,!k.valid&&(z=s,R.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:b,error:"Items did not match schema."},...k.errors),z))break}}if(j!==void 0){const b=`${o}/items`;if(Array.isArray(j)){const $=Math.min(j.length,P);for(;T<$;T++){const k=V(e[T],j[T],r,n,s,u,`${i}/${T}`,`${b}/${T}`);if(c[T]=!0,!k.valid&&(z=s,R.push({instanceLocation:i,keyword:"items",keywordLocation:b,error:"Items did not match schema."},...k.errors),z))break}}else for(;T<P;T++){const $=V(e[T],j,r,n,s,u,`${i}/${T}`,b);if(c[T]=!0,!$.valid&&(z=s,R.push({instanceLocation:i,keyword:"items",keywordLocation:b,error:"Items did not match schema."},...$.errors),z))break}if(!z&&L!==void 0){const $=`${o}/additionalItems`;for(;T<P;T++){const k=V(e[T],L,r,n,s,u,`${i}/${T}`,$);c[T]=!0,k.valid||(z=s,R.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:$,error:"Items did not match additional items schema."},...k.errors))}}}if(J!==void 0)if(P===0&&D===void 0)R.push({instanceLocation:i,keyword:"contains",keywordLocation:`${o}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(D!==void 0&&P<D)R.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array has less items (${P}) than minContains (${D}).`});else{const b=`${o}/contains`,$=R.length;let k=0;for(let N=0;N<P;N++){const W=V(e[N],J,r,n,s,u,`${i}/${N}`,b);W.valid?(c[N]=!0,k++):R.push(...W.errors)}k>=(D||0)&&(R.length=$),D===void 0&&ne===void 0&&k===0?R.splice($,0,{instanceLocation:i,keyword:"contains",keywordLocation:b,error:"Array does not contain item matching schema."}):D!==void 0&&k<D?R.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array must contain at least ${D} items matching schema. Only ${k} items were found.`}):ne!==void 0&&k>ne&&R.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${o}/maxContains`,error:`Array may contain at most ${ne} items matching schema. ${k} items were found.`})}if(!z&&F!==void 0){const b=`${o}/unevaluatedItems`;for(T;T<P;T++){if(c[T])continue;const $=V(e[T],F,r,n,s,u,`${i}/${T}`,b);c[T]=!0,$.valid||R.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:b,error:"Items did not match unevaluated items schema."},...$.errors)}}if(zn)for(let b=0;b<P;b++){const $=e[b],k=typeof $=="object"&&$!==null;for(let N=0;N<P;N++){if(b===N)continue;const W=e[N];($===W||k&&(typeof W=="object"&&W!==null)&&we($,W))&&(R.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${o}/uniqueItems`,error:`Duplicate items at indexes ${b} and ${N}.`}),b=Number.MAX_SAFE_INTEGER,N=Number.MAX_SAFE_INTEGER)}}}else if(a==="number"){if(r==="4"?(ae!==void 0&&(ve===!0&&e<=ae||e<ae)&&R.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${e} is less than ${ve?"or equal to ":""} ${ae}.`}),ue!==void 0&&(ye===!0&&e>=ue||e>ue)&&R.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${e} is greater than ${ye?"or equal to ":""} ${ue}.`})):(ae!==void 0&&e<ae&&R.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${e} is less than ${ae}.`}),ue!==void 0&&e>ue&&R.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${e} is greater than ${ue}.`}),ve!==void 0&&e<=ve&&R.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${o}/exclusiveMinimum`,error:`${e} is less than ${ve}.`}),ye!==void 0&&e>=ye&&R.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${o}/exclusiveMaximum`,error:`${e} is greater than or equal to ${ye}.`})),Oe!==void 0){const P=e%Oe;Math.abs(0-P)>=11920929e-14&&Math.abs(Oe-P)>=11920929e-14&&R.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${o}/multipleOf`,error:`${e} is not a multiple of ${Oe}.`})}}else if(a==="string"){const P=Te===void 0&&xe===void 0?0:ki(e);Te!==void 0&&P<Te&&R.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${o}/minLength`,error:`String is too short (${P} < ${Te}).`}),xe!==void 0&&P>xe&&R.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${o}/maxLength`,error:`String is too long (${P} > ${xe}).`}),nt!==void 0&&!new RegExp(nt,"u").test(e)&&R.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${o}/pattern`,error:"String does not match pattern."}),te!==void 0&&wn[te]&&!wn[te](e)&&R.push({instanceLocation:i,keyword:"format",keywordLocation:`${o}/format`,error:`String does not match format "${te}".`})}return{valid:R.length===0,errors:R}}class No{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",n=!0){this.schema=t,this.draft=r,this.shortCircuit=n,this.lookup=ce(t)}validate(t){return V(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),ce(t,this.lookup)}}var zi=Ln();const Ci=pe(zi);var Li=Object.defineProperty,qi=(e,t,r)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ji=(e,t,r)=>(qi(e,t+"",r),r);function Di(e,t){let r=Array.from({length:e.length},(n,s)=>({start:s,end:s+1}));for(;r.length>1;){let n=null;for(let s=0;s<r.length-1;s++){const u=e.slice(r[s].start,r[s+1].end),i=t.get(u.join(","));i!=null&&(n==null||i<n[0])&&(n=[i,s])}if(n!=null){const s=n[1];r[s]={start:r[s].start,end:r[s+1].end},r.splice(s+1,1)}else break}return r}function Ui(e,t){return e.length===1?[t.get(e.join(","))]:Di(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function Mi(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Xr=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(`
|
|
8
|
+
`).filter(Boolean).reduce((n,s)=>{const[u,i,...o]=s.split(" "),c=Number.parseInt(i,10);return o.forEach((l,a)=>n[l]=c+a),n},{});for(const[n,s]of Object.entries(r)){const u=Ci.toByteArray(n);this.rankMap.set(u.join(","),s),this.textMap.set(s,u)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((n,[s,u])=>(n[u]=this.textEncoder.encode(s),n),{})}encode(e,t=[],r="all"){const n=new RegExp(this.patStr,"ug"),s=Xr.specialTokenRegex(Object.keys(this.specialTokens)),u=[],i=new Set(t==="all"?Object.keys(this.specialTokens):t),o=new Set(r==="all"?Object.keys(this.specialTokens).filter(l=>!i.has(l)):r);if(o.size>0){const l=Xr.specialTokenRegex([...o]),a=e.match(l);if(a!=null)throw new Error(`The text contains a special token that is not allowed: ${a[0]}`)}let c=0;for(;;){let l=null,a=c;for(;s.lastIndex=a,l=s.exec(e),!(l==null||i.has(l[0]));)a=l.index+1;const f=l?.index??e.length;for(const m of e.substring(c,f).matchAll(n)){const h=this.textEncoder.encode(m[0]),p=this.rankMap.get(h.join(","));if(p!=null){u.push(p);continue}u.push(...Ui(h,this.rankMap))}if(l==null)break;let d=this.specialTokens[l[0]];u.push(d),c=l.index+l[0].length}return u}decode(e){const t=[];let r=0;for(let u=0;u<e.length;++u){const i=e[u],o=this.textMap.get(i)??this.inverseSpecialTokens[i];o!=null&&(t.push(o),r+=o.length)}const n=new Uint8Array(r);let s=0;for(const u of t)n.set(u,s),s+=u.length;return this.textDecoder.decode(n)}},Fi=Xr;ji(Fi,"specialTokenRegex",e=>new RegExp(e.map(t=>Mi(t)).join("|"),"g"));function Ao(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}export{oo as $,Qi as A,eo as B,Zs as C,Js as D,Xs as E,Ys as F,Eo as G,so as H,Y as I,To as J,So as K,ge as L,xo as M,Ie as N,Gs as O,Hi as P,ho as Q,go as R,uo as S,Fi as T,co as U,No as V,yo as W,lo as X,po as Y,mo as Z,Ro as _,Xi as a,vo as a0,_o as a1,ao as a2,Io as a3,bo as a4,Oo as a5,$o as a6,Bi as a7,Nn as a8,Yi as b,no as c,Sn as d,wo as e,Wi as f,si as g,fo as h,to as i,Ki as j,io as k,we as l,ce as m,Fn as n,Ao as o,Ji as p,ro as q,V as r,Vi as s,Po as t,Bn as u,Zi as v,Rn as w,Gn as x,G as y,Vs as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,A as d}from"./index-
|
|
1
|
+
import{_ as e,A as d}from"./index-CQ9XIRcv.js";var l={};e(l,{chunkArray:()=>u});const u=(r,n)=>r.reduce((a,o,s)=>{const c=Math.floor(s/n),t=a[c]||[];return a[c]=t.concat([o]),a},[]);var _={};e(_,{Embeddings:()=>h});var h=class{caller;constructor(r){this.caller=new d(r??{})}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as Ds,g as Fs,q as Ba,r as Ua,s as Wa,l as qa,O as Bs,u as Ja,v as za,f as Ue,_ as yn,m as Ka,n as Zn,i as Ce,h as Us,S as Hn,J as Vn,t as Ze,w as Za,x as Ha,R as Xn,o as Va,T as Vt,j as Ws,k as qs,p as Gn,y as Qn,b as Xt,C as Gt,c as Qt,z as Xa,D as Yn,F as Ga,E as Qa,G as Ya,I as ei,K as st,L as ti,M as ni,N as si,P as es,Q as ri,U as ai,V as ii,W as Yt,X as oi,Y as li,Z as ci,$ as Ft,a0 as ui,a1 as wn,a2 as di,a3 as hi,a4 as fi,a5 as ts,a6 as ns,a7 as ss,a8 as pi,a9 as mi}from"./index-
|
|
1
|
+
import{d as Ds,g as Fs,q as Ba,r as Ua,s as Wa,l as qa,O as Bs,u as Ja,v as za,f as Ue,_ as yn,m as Ka,n as Zn,i as Ce,h as Us,S as Hn,J as Vn,t as Ze,w as Za,x as Ha,R as Xn,o as Va,T as Vt,j as Ws,k as qs,p as Gn,y as Qn,b as Xt,C as Gt,c as Qt,z as Xa,D as Yn,F as Ga,E as Qa,G as Ya,I as ei,K as st,L as ti,M as ni,N as si,P as es,Q as ri,U as ai,V as ii,W as Yt,X as oi,Y as li,Z as ci,$ as Ft,a0 as ui,a1 as wn,a2 as di,a3 as hi,a4 as fi,a5 as ts,a6 as ns,a7 as ss,a8 as pi,a9 as mi}from"./index-CQ9XIRcv.js";import{Z as A,o as gi,s as _i}from"./index-DrYUC3_O.js";import{t as Js,i as yi,q as wi,r as bi}from"./chunk-VL2OQCWN-BE4txAap.js";import"./embeddings-D0mnwVrX.js";const pe=t=>t();function We(t){return t?!!(/^o\d/.test(t??"")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-chat")):!1}function vi(t){return t.role!=="system"&&t.role!=="developer"&&t.role!=="assistant"&&t.role!=="user"&&t.role!=="function"&&t.role!=="tool"&&console.warn(`Unknown message role: ${t.role}`),t.role}function qe(t){const e=t._getType();switch(e){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!Ds.isInstance(t))throw new Error("Invalid generic chat message");return vi(t);default:throw new Error(`Unknown message type: ${e}`)}}function xi(t){const{azureOpenAIApiDeploymentName:e,azureOpenAIApiInstanceName:n,azureOpenAIApiKey:s,azureOpenAIBasePath:r,baseURL:a,azureADTokenProvider:i,azureOpenAIEndpoint:o}=t;if((s||i)&&r&&e)return`${r}/${e}`;if((s||i)&&o&&e)return`${o}/openai/deployments/${e}`;if(s||i){if(!n)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!e)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${n}.openai.azure.com/openai/deployments/${e}`}return a}function Si(t,e){let n;return Fs(t)?n=Ba(t):n=t,e?.strict!==void 0&&(n.function.strict=e.strict),n}function ki(t){return t.anyOf!==void 0&&Array.isArray(t.anyOf)}function Ai(t){const e=["namespace functions {",""];for(const n of t)n.description&&e.push(`// ${n.description}`),Object.keys(n.parameters.properties??{}).length>0?(e.push(`type ${n.name} = (_: {`),e.push(zs(n.parameters,0)),e.push("}) => any;")):e.push(`type ${n.name} = () => any;`),e.push("");return e.push("} // namespace functions"),e.join(`
|
|
2
2
|
`)}function zs(t,e){const n=[];for(const[s,r]of Object.entries(t.properties??{}))r.description&&e<2&&n.push(`// ${r.description}`),t.required?.includes(s)?n.push(`${s}: ${ft(r,e)},`):n.push(`${s}?: ${ft(r,e)},`);return n.map(s=>" ".repeat(e)+s).join(`
|
|
3
3
|
`)}function ft(t,e){if(ki(t))return t.anyOf.map(n=>ft(n,e)).join(" | ");switch(t.type){case"string":return t.enum?t.enum.map(n=>`"${n}"`).join(" | "):"string";case"number":return t.enum?t.enum.map(n=>`${n}`).join(" | "):"number";case"integer":return t.enum?t.enum.map(n=>`${n}`).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",zs(t,e+2),"}"].join(`
|
|
4
4
|
`);case"array":return t.items?`${ft(t.items,e)}[]`:"any[]";default:return""}}function Ks(t){if(t)return t==="any"||t==="required"?"required":t==="auto"?"auto":t==="none"?"none":typeof t=="string"?{type:"function",function:{name:t}}:t}function bn(t){return"type"in t&&t.type!=="function"}function Ci(t){return t!=null&&typeof t=="object"&&"type"in t&&t.type!=="function"}function pt(t){return typeof t=="object"&&t!==null&&"metadata"in t&&typeof t.metadata=="object"&&t.metadata!==null&&"customTool"in t.metadata&&typeof t.metadata.customTool=="object"&&t.metadata.customTool!==null}function Zs(t){return"type"in t&&t.type==="custom"&&"custom"in t&&typeof t.custom=="object"&&t.custom!==null}function Oi(t){if(t.type==="custom_tool_call")return{...t,type:"tool_call",call_id:t.id,id:t.call_id,name:t.name,isCustomTool:!0,args:{input:t.input}}}function Ti(t){return t.type==="tool_call"&&"isCustomTool"in t&&t.isCustomTool===!0}function Pi(t){const e=()=>{if(t.custom.format){if(t.custom.format.type==="grammar")return{type:"grammar",definition:t.custom.format.grammar.definition,syntax:t.custom.format.grammar.syntax};if(t.custom.format.type==="text")return{type:"text"}}};return{type:"custom",name:t.custom.name,description:t.custom.description,format:e()}}function Ii(t){const e=()=>{if(t.format){if(t.format.type==="grammar")return{type:"grammar",grammar:{definition:t.format.definition,syntax:t.format.syntax}};if(t.format.type==="text")return{type:"text"}}};return{type:"custom",custom:{name:t.name,description:t.description,format:e()}}}function en(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const tn=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class x extends Error{}class q extends x{constructor(e,n,s,r){super(`${q.makeMessage(e,n,s)}`),this.status=e,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,n,s,r){if(!e||!r)return new Ct({message:s,cause:tn(n)});const a=n?.error;return e===400?new Hs(e,a,s,r):e===401?new Vs(e,a,s,r):e===403?new Xs(e,a,s,r):e===404?new Gs(e,a,s,r):e===409?new Qs(e,a,s,r):e===422?new Ys(e,a,s,r):e===429?new er(e,a,s,r):e>=500?new tr(e,a,s,r):new q(e,a,s,r)}}class X extends q{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Ct extends q{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class Ot extends Ct{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Hs extends q{}class Vs extends q{}class Xs extends q{}class Gs extends q{}class Qs extends q{}class Ys extends q{}class er extends q{}class tr extends q{}class nr extends x{constructor(){super("Could not parse response content as the length limit was reached")}}class sr extends x{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Oe extends Error{constructor(e){super(e)}}function mt(t){return t!==void 0&&"function"in t&&t.function!==void 0}function Ri(t,e){const n={...t};return Object.defineProperties(n,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:e,enumerable:!1}}),n}function vn(t){return t?.$brand==="auto-parseable-response-format"}function Je(t){return t?.$brand==="auto-parseable-tool"}function $i(t,e){return!e||!rr(e)?{...t,choices:t.choices.map(n=>(ar(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:xn(t,e)}function xn(t,e){const n=t.choices.map(s=>{if(s.finish_reason==="length")throw new nr;if(s.finish_reason==="content_filter")throw new sr;return ar(s.message.tool_calls),{...s,message:{...s.message,...s.message.tool_calls?{tool_calls:s.message.tool_calls?.map(r=>Mi(e,r))??void 0}:void 0,parsed:s.message.content&&!s.message.refusal?Ei(e,s.message.content):null}}});return{...t,choices:n}}function Ei(t,e){return t.response_format?.type!=="json_schema"?null:t.response_format?.type==="json_schema"?"$parseRaw"in t.response_format?t.response_format.$parseRaw(e):JSON.parse(e):null}function Mi(t,e){const n=t.tools?.find(s=>mt(s)&&s.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:Je(n)?n.$parseRaw(e.function.arguments):n?.function.strict?JSON.parse(e.function.arguments):null}}}function Ni(t,e){if(!t||!("tools"in t)||!t.tools)return!1;const n=t.tools?.find(s=>mt(s)&&s.function?.name===e.function.name);return mt(n)&&(Je(n)||n?.function.strict||!1)}function rr(t){return vn(t.response_format)?!0:t.tools?.some(e=>Je(e)||e.type==="function"&&e.function.strict===!0)??!1}function ar(t){for(const e of t||[])if(e.type!=="function")throw new x(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function Li(t){for(const e of t??[]){if(e.type!=="function")throw new x(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new x(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}const ji=Symbol("Let zodToJsonSchema decide on which parser to use"),rs={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Di=t=>typeof t=="string"?{...rs,basePath:["#"],definitions:{},name:t}:{...rs,basePath:["#"],definitions:{},...t},nn=t=>"_def"in t?t._def:t;function Fi(t){if(!t)return!0;for(const e in t)return!1;return!0}const Bi=t=>{const e=Di(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[nn(r),{def:nn(r),path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};function ir(t,e,n,s){s?.errorMessages&&n&&(t.errorMessage={...t.errorMessage,[e]:n})}function I(t,e,n,s,r){t[e]=n,ir(t,e,s,r)}function Ui(){return{}}function Wi(t,e){const n={type:"array"};return t.type?._def?.typeName!==A.ZodAny&&(n.items=T(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&I(n,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&I(n,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(I(n,"minItems",t.exactLength.value,t.exactLength.message,e),I(n,"maxItems",t.exactLength.value,t.exactLength.message,e)),n}function qi(t,e){const n={type:"integer",format:"int64"};if(!t.checks)return n;for(const s of t.checks)switch(s.kind){case"min":e.target==="jsonSchema7"?s.inclusive?I(n,"minimum",s.value,s.message,e):I(n,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?I(n,"maximum",s.value,s.message,e):I(n,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",s.value,s.message,e));break;case"multipleOf":I(n,"multipleOf",s.value,s.message,e);break}return n}function Ji(){return{type:"boolean"}}function zi(t,e){return T(t.type._def,e)}const Ki=(t,e)=>T(t.innerType._def,e);function or(t,e,n){const s=n??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,a)=>or(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Zi(t,e)}}const Zi=(t,e)=>{const n={type:"integer",format:"unix-time"};if(e.target==="openApi3")return n;for(const s of t.checks)switch(s.kind){case"min":I(n,"minimum",s.value,s.message,e);break;case"max":I(n,"maximum",s.value,s.message,e);break}return n};function Hi(t,e){return{...T(t.innerType._def,e),default:t.defaultValue()}}function Vi(t,e,n){return e.effectStrategy==="input"?T(t.schema._def,e,n):{}}function Xi(t){return{type:"string",enum:[...t.values]}}const Gi=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Qi(t,e){const n=[T(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),T(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const r=[];return n.forEach(a=>{if(Gi(a))r.push(...a.allOf),a.unevaluatedProperties===void 0&&(s=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...l}=a;i=l}else s=void 0;r.push(i)}}),r.length?{allOf:r,...s}:void 0}function Yi(t,e){const n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}let Bt;const le={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Bt===void 0&&(Bt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Bt),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function lr(t,e){const n={type:"string"};function s(r){return e.patternStrategy==="escape"?eo(r):r}if(t.checks)for(const r of t.checks)switch(r.kind){case"min":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e);break;case"max":I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"email":switch(e.emailStrategy){case"format:email":G(n,"email",r.message,e);break;case"format:idn-email":G(n,"idn-email",r.message,e);break;case"pattern:zod":Q(n,le.email,r.message,e);break}break;case"url":G(n,"uri",r.message,e);break;case"uuid":G(n,"uuid",r.message,e);break;case"regex":Q(n,r.regex,r.message,e);break;case"cuid":Q(n,le.cuid,r.message,e);break;case"cuid2":Q(n,le.cuid2,r.message,e);break;case"startsWith":Q(n,RegExp(`^${s(r.value)}`),r.message,e);break;case"endsWith":Q(n,RegExp(`${s(r.value)}$`),r.message,e);break;case"datetime":G(n,"date-time",r.message,e);break;case"date":G(n,"date",r.message,e);break;case"time":G(n,"time",r.message,e);break;case"duration":G(n,"duration",r.message,e);break;case"length":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e),I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"includes":{Q(n,RegExp(s(r.value)),r.message,e);break}case"ip":{r.version!=="v6"&&G(n,"ipv4",r.message,e),r.version!=="v4"&&G(n,"ipv6",r.message,e);break}case"emoji":Q(n,le.emoji,r.message,e);break;case"ulid":{Q(n,le.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{G(n,"binary",r.message,e);break}case"contentEncoding:base64":{I(n,"contentEncoding","base64",r.message,e);break}case"pattern:zod":{Q(n,le.base64,r.message,e);break}}break}case"nanoid":Q(n,le.nanoid,r.message,e)}return n}const eo=t=>Array.from(t).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),G=(t,e,n,s)=>{t.format||t.anyOf?.some(r=>r.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&s.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...n&&s.errorMessages&&{errorMessage:{format:n}}})):I(t,"format",e,n,s)},Q=(t,e,n,s)=>{t.pattern||t.allOf?.some(r=>r.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&s.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:as(e,s),...n&&s.errorMessages&&{errorMessage:{pattern:n}}})):I(t,"pattern",as(e,s),n,s)},as=(t,e)=>{const n=typeof t=="function"?t():t;if(!e.applyRegexFlags||!n.flags)return n.source;const s={i:n.flags.includes("i"),m:n.flags.includes("m"),s:n.flags.includes("s")},r=s.i?n.source.toLowerCase():n.source;let a="",i=!1,o=!1,l=!1;for(let c=0;c<r.length;c++){if(i){a+=r[c],i=!1;continue}if(s.i){if(o){if(r[c].match(/[a-z]/)){l?(a+=r[c],a+=`${r[c-2]}-${r[c]}`.toUpperCase(),l=!1):r[c+1]==="-"&&r[c+2]?.match(/[a-z]/)?(a+=r[c],l=!0):a+=`${r[c]}${r[c].toUpperCase()}`;continue}}else if(r[c].match(/[a-z]/)){a+=`[${r[c]}${r[c].toUpperCase()}]`;continue}}if(s.m){if(r[c]==="^"){a+=`(^|(?<=[\r
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as ne,t as fe,a as he,b as pe,C as ge,c as me,d as Ce,e as ye,f as oe,g as se,h as ie,j as _e,k as Ee,p as A,B as ve,l as we,O as Te,m as Ie,n as Oe,J as Re,R as D,o as Se}from"./index-
|
|
1
|
+
import{i as ne,t as fe,a as he,b as pe,C as ge,c as me,d as Ce,e as ye,f as oe,g as se,h as ie,j as _e,k as Ee,p as A,B as ve,l as we,O as Te,m as Ie,n as Oe,J as Re,R as D,o as Se}from"./index-CQ9XIRcv.js";import{v as ae}from"./index-DrYUC3_O.js";import"./embeddings-D0mnwVrX.js";import"./chunk-VL2OQCWN-BE4txAap.js";function _(e){if(typeof e=="object"&&e!==null){const n={...e};"additionalProperties"in n&&delete n.additionalProperties,"$schema"in n&&delete n.$schema,"strict"in n&&delete n.strict;for(const t in n)t in n&&(Array.isArray(n[t])?n[t]=n[t].map(_):typeof n[t]=="object"&&n[t]!==null&&(n[t]=_(n[t])));return n}return e}function N(e){const n=_(ne(e)?fe(e):e),{$schema:t,...o}=n;return o}function Ae(e){const n=_(e),{$schema:t,...o}=n;return o}function Ne(e){const n=e._getType();return Ce.isInstance(e)?e.role:n==="tool"?n:e.name??n}function be(e){switch(e){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${e}`)}}function Me(e){if("mimeType"in e&&"data"in e)return{inlineData:{mimeType:e.mimeType,data:e.data}};if("mimeType"in e&&"fileUri"in e)return{fileData:{mimeType:e.mimeType,fileUri:e.fileUri}};throw new Error("Invalid media content")}function xe(e,n){return n.map(t=>oe(t)?t.tool_calls??[]:[]).flat().find(t=>t.id===e.tool_call_id)?.name}function De(e){return{providerName:"Google Gemini",fromStandardTextBlock(t){return{text:t.text}},fromStandardImageBlock(t){if(!e)throw new Error("This model does not support images");if(t.source_type==="url"){const o=A({dataUrl:t.url});return o?{inlineData:{mimeType:o.mime_type,data:o.data}}:{fileData:{mimeType:t.mime_type??"",fileUri:t.url}}}if(t.source_type==="base64")return{inlineData:{mimeType:t.mime_type??"",data:t.data}};throw new Error(`Unsupported source type: ${t.source_type}`)},fromStandardAudioBlock(t){if(!e)throw new Error("This model does not support audio");if(t.source_type==="url"){const o=A({dataUrl:t.url});return o?{inlineData:{mimeType:o.mime_type,data:o.data}}:{fileData:{mimeType:t.mime_type??"",fileUri:t.url}}}if(t.source_type==="base64")return{inlineData:{mimeType:t.mime_type??"",data:t.data}};throw new Error(`Unsupported source type: ${t.source_type}`)},fromStandardFileBlock(t){if(!e)throw new Error("This model does not support files");if(t.source_type==="text")return{text:t.text};if(t.source_type==="url"){const o=A({dataUrl:t.url});return o?{inlineData:{mimeType:o.mime_type,data:o.data}}:{fileData:{mimeType:t.mime_type??"",fileUri:t.url}}}if(t.source_type==="base64")return{inlineData:{mimeType:t.mime_type??"",data:t.data}};throw new Error(`Unsupported source type: ${t.source_type}`)}}}function G(e,n){if(_e(e))return Ee(e,De(n));if(e.type==="text")return{text:e.text};if(e.type==="executableCode")return{executableCode:e.executableCode};if(e.type==="codeExecutionResult")return{codeExecutionResult:e.codeExecutionResult};if(e.type==="image_url"){if(!n)throw new Error("This model does not support images");let t;if(typeof e.image_url=="string")t=e.image_url;else if(typeof e.image_url=="object"&&"url"in e.image_url)t=e.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[o,s]=t.split(",");if(!o.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[i,a]=o.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:s,mimeType:i}}}else{if(e.type==="media")return Me(e);if(e.type==="tool_use")return{functionCall:{name:e.name,args:e.input}};if(e.type?.includes("/")&&e.type.split("/").length===2&&"data"in e&&typeof e.data=="string")return{inlineData:{mimeType:e.type,data:e.data}};if("functionCall"in e)return;throw"type"in e?new Error(`Unknown content type ${e.type}`):new Error(`Unknown content ${JSON.stringify(e)}`)}}function Ge(e,n,t){if(ye(e)){const i=e.name??xe(e,t);if(i===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${e.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const a=Array.isArray(e.content)?e.content.map(c=>G(c,n)).filter(c=>c!==void 0):e.content;return e.status==="error"?[{functionResponse:{name:i,response:{error:{details:a}}}}]:[{functionResponse:{name:i,response:{result:a}}}]}let o=[];const s=[];return typeof e.content=="string"&&e.content&&s.push({text:e.content}),Array.isArray(e.content)&&s.push(...e.content.map(i=>G(i,n)).filter(i=>i!==void 0)),oe(e)&&e.tool_calls?.length&&(o=e.tool_calls.map(i=>({functionCall:{name:i.name,args:i.args}}))),[...s,...o]}function k(e,n,t=!1){return e.reduce((o,s,i)=>{if(!he(s))throw new Error("Unsupported message input");const a=Ne(s);if(a==="system"&&i!==0)throw new Error("System message should be the first one");const c=be(a),u=o.content[o.content.length];if(!o.mergeWithPreviousContent&&u&&u.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const r=Ge(s,n,e.slice(0,i));if(o.mergeWithPreviousContent){const d=o.content[o.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...r),{mergeWithPreviousContent:!1,content:o.content}}let p=c;(p==="function"||p==="system"&&!t)&&(p="user");const f={role:p,parts:r};return{mergeWithPreviousContent:a==="system"&&!t,content:[...o.content,f]}},{content:[],mergeWithPreviousContent:!1}).content}function ke(e,n){if(!e.candidates||e.candidates.length===0||!e.candidates[0])return{generations:[],llmOutput:{filters:e.promptFeedback}};const t=e.functionCalls(),[o]=e.candidates,{content:s,...i}=o;let a;Array.isArray(s?.parts)&&s.parts.length===1&&s.parts[0].text?a=s.parts[0].text:Array.isArray(s?.parts)&&s.parts.length>0?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let c="";return typeof a=="string"?c=a:Array.isArray(a)&&a.length>0&&(c=a.find(p=>"text"in p)?.text??c),{generations:[{text:c,message:new pe({content:a??"",tool_calls:t?.map(r=>({...r,type:"tool_call",id:"id"in r&&typeof r.id=="string"?r.id:ae()})),additional_kwargs:{...i},usage_metadata:n?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:n?.usageMetadata?.input_tokens,completionTokens:n?.usageMetadata?.output_tokens,totalTokens:n?.usageMetadata?.total_tokens}}}}function Ue(e,n){if(!e.candidates||e.candidates.length===0)return null;const t=e.functionCalls(),[o]=e.candidates,{content:s,...i}=o;let a;Array.isArray(s?.parts)&&s.parts.every(r=>"text"in r)?a=s.parts.map(r=>r.text).join(""):Array.isArray(s?.parts)?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let c="";a&&typeof a=="string"?c=a:Array.isArray(a)&&(c=a.find(p=>"text"in p)?.text??"");const u=[];return t&&u.push(...t.map(r=>({...r,args:JSON.stringify(r.args),index:n.index,type:"tool_call_chunk",id:"id"in r&&typeof r.id=="string"?r.id:ae()}))),new ge({text:c,message:new me({content:a||"",name:s?s.role:void 0,tool_call_chunks:u,additional_kwargs:{},response_metadata:{model_provider:"google-genai"},usage_metadata:n.usageMetadata}),generationInfo:i})}function Le(e){return e.every(n=>"functionDeclarations"in n&&Array.isArray(n.functionDeclarations))?e:[{functionDeclarations:e.map(n=>{if(se(n)){const t=N(n.schema);return t.type==="object"&&"properties"in t&&Object.keys(t.properties).length===0?{name:n.name,description:n.description}:{name:n.name,description:n.description,parameters:t}}return ie(n)?{name:n.function.name,description:n.function.description??"A function available to call.",parameters:Ae(n.function.parameters)}:n})}]}var U=class extends ve{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,this.zodSchema=e.zodSchema}async _validateResult(e){if(this.zodSchema===void 0)return e;const n=await we(this.zodSchema,e);if(n.success)return n.data;throw new Te(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(n.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(e){const n=e.flatMap(s=>{const{message:i}=s;return!("tool_calls"in i)||!Array.isArray(i.tool_calls)?[]:i.tool_calls});if(n[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[t]=n;return await this._validateResult(t.args)}},L;(function(e){e.STRING="string",e.NUMBER="number",e.INTEGER="integer",e.BOOLEAN="boolean",e.ARRAY="array",e.OBJECT="object"})(L||(L={}));/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2024 Google LLC
|
|
4
4
|
*
|
|
@@ -209,4 +209,4 @@ import{i as ne,t as fe,a as he,b as pe,C as ge,c as me,d as Ce,e as ye,f as oe,g
|
|
|
209
209
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
210
210
|
* See the License for the specific language governing permissions and
|
|
211
211
|
* limitations under the License.
|
|
212
|
-
*/class ee{constructor(n){this.apiKey=n}getGenerativeModel(n,t){if(!n.model)throw new g("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new Z(this.apiKey,n,t)}getGenerativeModelFromCachedContent(n,t,o){if(!n.name)throw new y("Cached content must contain a `name` field.");if(!n.model)throw new y("Cached content must contain a `model` field.");const s=["model","systemInstruction"];for(const a of s)if(t?.[a]&&n[a]&&t?.[a]!==n[a]){if(a==="model"){const c=t.model.startsWith("models/")?t.model.replace("models/",""):t.model,u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model;if(c===u)continue}throw new y(`Different value for "${a}" specified in modelParams (${t[a]}) and cachedContent (${n[a]})`)}const i=Object.assign(Object.assign({},t),{model:n.model,tools:n.tools,toolConfig:n.toolConfig,systemInstruction:n.systemInstruction,cachedContent:n});return new Z(this.apiKey,i,o)}}function te(e,n){const t=ht(e),o=gt(t,n);return{tools:t,toolConfig:o}}function ht(e){let n=[];const t=[];return e.forEach(s=>{if(se(s)){const[i]=Le([s]);i.functionDeclarations&&n.push(...i.functionDeclarations)}else if(ie(s)){const{functionDeclarations:i}=pt(s);if(i)n.push(...i);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else t.push(s)}),t.find(s=>"functionDeclarations"in s)?t.map(s=>{if(n?.length>0&&"functionDeclarations"in s){const i={functionDeclarations:[...s.functionDeclarations||[],...n]};return n=[],i}return s}):[...t,...n.length>0?[{functionDeclarations:n}]:[]]}function pt(e){return{functionDeclarations:[{name:e.function.name,description:e.function.description,parameters:_(e.function.parameters)}]}}function gt(e,n){if(!e.length||!n)return;const{toolChoice:t,allowedFunctionNames:o}=n,s={any:w.ANY,auto:w.AUTO,none:w.NONE};if(t&&["any","auto","none"].includes(t))return{functionCallingConfig:{mode:s[t]??"MODE_UNSPECIFIED",allowedFunctionNames:o}};if(typeof t=="string"||o)return{functionCallingConfig:{mode:w.ANY,allowedFunctionNames:[...o??[],...t&&typeof t=="string"?[t]:[]]}}}var
|
|
212
|
+
*/class ee{constructor(n){this.apiKey=n}getGenerativeModel(n,t){if(!n.model)throw new g("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new Z(this.apiKey,n,t)}getGenerativeModelFromCachedContent(n,t,o){if(!n.name)throw new y("Cached content must contain a `name` field.");if(!n.model)throw new y("Cached content must contain a `model` field.");const s=["model","systemInstruction"];for(const a of s)if(t?.[a]&&n[a]&&t?.[a]!==n[a]){if(a==="model"){const c=t.model.startsWith("models/")?t.model.replace("models/",""):t.model,u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model;if(c===u)continue}throw new y(`Different value for "${a}" specified in modelParams (${t[a]}) and cachedContent (${n[a]})`)}const i=Object.assign(Object.assign({},t),{model:n.model,tools:n.tools,toolConfig:n.toolConfig,systemInstruction:n.systemInstruction,cachedContent:n});return new Z(this.apiKey,i,o)}}function te(e,n){const t=ht(e),o=gt(t,n);return{tools:t,toolConfig:o}}function ht(e){let n=[];const t=[];return e.forEach(s=>{if(se(s)){const[i]=Le([s]);i.functionDeclarations&&n.push(...i.functionDeclarations)}else if(ie(s)){const{functionDeclarations:i}=pt(s);if(i)n.push(...i);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else t.push(s)}),t.find(s=>"functionDeclarations"in s)?t.map(s=>{if(n?.length>0&&"functionDeclarations"in s){const i={functionDeclarations:[...s.functionDeclarations||[],...n]};return n=[],i}return s}):[...t,...n.length>0?[{functionDeclarations:n}]:[]]}function pt(e){return{functionDeclarations:[{name:e.function.name,description:e.function.description,parameters:_(e.function.parameters)}]}}function gt(e,n){if(!e.length||!n)return;const{toolChoice:t,allowedFunctionNames:o}=n,s={any:w.ANY,auto:w.AUTO,none:w.NONE};if(t&&["any","auto","none"].includes(t))return{functionCallingConfig:{mode:s[t]??"MODE_UNSPECIFIED",allowedFunctionNames:o}};if(typeof t=="string"||o)return{functionCallingConfig:{mode:w.ANY,allowedFunctionNames:[...o??[],...t&&typeof t=="string"?[t]:[]]}}}var Et=class extends Ie{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")}constructor(e){if(super(e),this.model=e.model.replace(/^models\//,""),this.maxOutputTokens=e.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=e.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=e.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=e.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=e.stopSequences??this.stopSequences,this.apiKey=e.apiKey??Oe("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=e.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(t=>t.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=e.streaming??this.streaming,this.json=e.json,this.client=new ee(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{}}},{apiVersion:e.apiVersion,baseUrl:e.baseUrl}),this.streamUsage=e.streamUsage??this.streamUsage}useCachedContent(e,n,t){this.apiKey&&(this.client=new ee(this.apiKey).getGenerativeModelFromCachedContent(e,n,t))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(e){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:e.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(e,n){return this.withConfig({tools:te(e)?.tools,...n})}invocationParams(e){const n=e?.tools?.length?te(e.tools,{toolChoice:e.tool_choice,allowedFunctionNames:e.allowedFunctionNames}):void 0;return e?.responseSchema?(this.client.generationConfig.responseSchema=e.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...n?.tools?{tools:n.tools}:{},...n?.toolConfig?{toolConfig:n.toolConfig}:{}}}async _generate(e,n,t){const o=k(e,this._isMultimodalModel,this.useSystemInstruction);let s=o;if(o[0].role==="system"){const[r]=o;this.client.systemInstruction=r,s=o.slice(1)}const i=this.invocationParams(n);if(this.streaming){const r={},p=this._streamResponseChunks(e,n,t),f={};for await(const l of p){const h=l.generationInfo?.completion??0;f[h]===void 0?f[h]=l:f[h]=f[h].concat(l)}return{generations:Object.entries(f).sort(([l],[h])=>parseInt(l,10)-parseInt(h,10)).map(([l,h])=>h),llmOutput:{estimatedTokenUsage:r}}}const a=await this.completionWithRetry({...i,contents:s});let c;if("usageMetadata"in a.response){const r=a.response.usageMetadata;c={input_tokens:r.promptTokenCount??0,output_tokens:r.candidatesTokenCount??0,total_tokens:r.totalTokenCount??0}}const u=ke(a.response,{usageMetadata:c});return u.generations?.length>0&&await t?.handleLLMNewToken(u.generations[0]?.text??""),u}async*_streamResponseChunks(e,n,t){const o=k(e,this._isMultimodalModel,this.useSystemInstruction);let s=o;if(o[0].role==="system"){const[l]=o;this.client.systemInstruction=l,s=o.slice(1)}const a={...this.invocationParams(n),contents:s},c=await this.caller.callWithOptions({signal:n?.signal},async()=>{const{stream:l}=await this.client.generateContentStream(a);return l});let u,r=0,p=0,f=0,d=0;for await(const l of c){if("usageMetadata"in l&&l.usageMetadata!==void 0&&this.streamUsage!==!1&&n.streamUsage!==!1){u={input_tokens:l.usageMetadata.promptTokenCount??0,output_tokens:l.usageMetadata.candidatesTokenCount??0,total_tokens:l.usageMetadata.totalTokenCount??0};const m=l.usageMetadata.promptTokenCount??0;u.input_tokens=Math.max(0,m-r),r=m;const M=l.usageMetadata.candidatesTokenCount??0;u.output_tokens=Math.max(0,M-p),p=M;const x=l.usageMetadata.totalTokenCount??0;u.total_tokens=Math.max(0,x-f),f=x}const h=Ue(l,{usageMetadata:u,index:d});d+=1,h&&(yield h,await t?.handleLLMNewToken(h.text??""))}}async completionWithRetry(e,n){return this.caller.callWithOptions({signal:n?.signal},async()=>{try{return await this.client.generateContent(e)}catch(t){throw t.message?.includes("400 Bad Request")&&(t.status=400),t}})}withStructuredOutput(e,n){const t=e,o=n?.name,s=n?.method,i=n?.includeRaw;if(s==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let a,c;if(s==="functionCalling"){let f=o??"extract",d;if(ne(t)){const l=N(t);d=[{functionDeclarations:[{name:f,description:l.description??"A function available to call.",parameters:l}]}],c=new U({returnSingle:!0,keyName:f,zodSchema:t})}else{let l;typeof t.name=="string"&&typeof t.parameters=="object"&&t.parameters!=null?(l=t,l.parameters=_(t.parameters),f=t.name):l={name:f,description:t.description??"",parameters:_(t)},d=[{functionDeclarations:[l]}],c=new U({returnSingle:!0,keyName:f})}a=this.bindTools(d).withConfig({allowedFunctionNames:[f]})}else{const f=N(t);a=this.withConfig({responseSchema:f}),c=new Re}if(!i)return a.pipe(c).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const u=D.assign({parsed:(f,d)=>c.invoke(f.raw,d)}),r=D.assign({parsed:()=>null}),p=u.withFallbacks({fallbacks:[r]});return Se.from([{raw:a},p]).withConfig({runName:"StructuredOutputRunnable"})}};export{Et as ChatGoogleGenerativeAI};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as $n,O as bt,l as jn,p as nn,f as xt,H as St,j as Bn,k as Ln,c as A,b as kt,m as Un,n as qn,h as Wn,g as Fn,t as be,i as Mt,C as Dn,R as Tt,o as Hn}from"./index-Dnm19mgK.js";import"./chunk-VL2OQCWN-Dm4XquLI.js";import"./index-BxUJEXs5.js";var Rt=class extends $n{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new bt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(s.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const n=await jn(this.zodSchema,e);if(n.success)return n.data;throw new bt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(r=>{const{message:i}=r;return Array.isArray(i.content)?sn(i.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}};function sn(t){const e=[];for(const n of t)n.type==="tool_use"&&e.push({name:n.name,args:n.input,id:n.id,type:"tool_call"});return e}function Kn(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}function Jn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function Xn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function zn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function Vn(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const Qn={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=nn({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Gn=t=>t();function Yn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Zn(t){function*e(){for(const n of t)Yn(n)&&(n.source==="char"?yield{type:"char_location",file_id:n.url??"",start_char_index:n.startIndex??0,end_char_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="page"?yield{type:"page_location",file_id:n.url??"",start_page_number:n.startIndex??0,end_page_number:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="block"?yield{type:"content_block_location",file_id:n.url??"",start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="url"?yield{type:"web_search_result_location",url:n.url??"",title:n.title??null,encrypted_index:String(n.startIndex??0),cited_text:n.citedText??""}:n.source==="search"&&(yield{type:"search_result_location",title:n.title??null,start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,search_result_index:0,source:n.source??"",cited_text:n.citedText??""}))}return Array.from(e())}function G(t){return typeof t=="string"?t:es(t)}function es(t){const e=[];for(let n=0,{length:s}=t;n<s;n++)e.push(String.fromCharCode(t[n]));return btoa(e.join(""))}function Ve(t){return(t??"").split(";")[0].toLowerCase()}function he(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function H(t,e){const n=he(e,"cache_control");n!==void 0&&(t.cache_control=n);const s=he(e,"citations");s!==void 0&&(t.citations=s);const r=he(e,"context");r!==void 0&&(t.context=r);const i=he(e,"title");return i!==void 0&&(t.title=i),t}function Qe(t,e){const n=he(e,"cache_control");return n!==void 0&&(t.cache_control=n),t}function At(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function ts(t){const e=[],n=t.response_metadata,s="model_provider"in n&&n?.model_provider==="anthropic";for(const r of t.contentBlocks)if(r.type==="text")r.annotations?e.push({type:"text",text:r.text,citations:Zn(r.annotations)}):e.push({type:"text",text:r.text});else if(r.type==="tool_call")e.push({type:"tool_use",id:r.id??"",name:r.name,input:r.args});else if(r.type==="tool_call_chunk"){const i=Gn(()=>{if(typeof r.args!="string")return r.args;try{return JSON.parse(r.args)}catch{return{}}});e.push({type:"tool_use",id:r.id??"",name:r.name??"",input:i})}else if(r.type==="reasoning"&&s)e.push({type:"thinking",thinking:r.reasoning,signature:String(r.signature)});else if(r.type==="server_tool_call"&&s)r.name==="web_search"?e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args}):r.name==="code_execution"&&e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args});else if(r.type==="server_tool_call_result"&&s)if(r.name==="web_search"&&Array.isArray(r.output.urls)){const i=r.output.urls.map(a=>({type:"web_search_result",title:"",encrypted_content:"",url:a}));e.push({type:"web_search_tool_result",tool_use_id:r.toolCallId??"",content:i})}else r.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:r.toolCallId??"",content:r.output}):r.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:r.toolCallId??"",content:r.output});else{if(r.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(r.type==="file"){const i=r.metadata;if(r.fileId){e.push(H({type:"document",source:{type:"file",file_id:r.fileId}},i));continue}if(r.url){const a=Ve(r.mimeType);if(a==="application/pdf"||a===""){e.push(H({type:"document",source:{type:"url",url:r.url}},i));continue}}if(r.data){const a=Ve(r.mimeType);if(a===""||a==="application/pdf")e.push(H({type:"document",source:{type:"base64",data:G(r.data),media_type:"application/pdf"}},i));else if(a==="text/plain")e.push(H({type:"document",source:{type:"text",data:G(r.data),media_type:"text/plain"}},i));else if(At(a))e.push(H({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:G(r.data),media_type:a}}]}},i));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${a}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(r.type==="image"){const i=r.metadata;if(r.fileId){e.push(Qe({type:"image",source:{type:"file",file_id:r.fileId}},i));continue}if(r.url){e.push(Qe({type:"image",source:{type:"url",url:r.url}},i));continue}if(r.data){const a=Ve(r.mimeType)||"image/png";At(a)&&e.push(Qe({type:"image",source:{type:"base64",data:G(r.data),media_type:a}},i));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else r.type==="video"||(r.type==="text-plain"?r.data&&e.push(H({type:"document",source:{type:"text",data:G(r.data),media_type:"text/plain"}},r.metadata)):r.type==="non_standard"&&s&&e.push(r.value))}return e}function vt(t){const e=nn({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let n;try{n=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
1
|
+
import{B as $n,O as bt,l as jn,p as nn,f as xt,H as St,j as Bn,k as Ln,c as A,b as kt,m as Un,n as qn,h as Wn,g as Fn,t as be,i as Mt,C as Dn,R as Tt,o as Hn}from"./index-CQ9XIRcv.js";import"./chunk-VL2OQCWN-BE4txAap.js";import"./index-DrYUC3_O.js";var Rt=class extends $n{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new bt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(s.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const n=await jn(this.zodSchema,e);if(n.success)return n.data;throw new bt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(r=>{const{message:i}=r;return Array.isArray(i.content)?sn(i.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}};function sn(t){const e=[];for(const n of t)n.type==="tool_use"&&e.push({name:n.name,args:n.input,id:n.id,type:"tool_call"});return e}function Kn(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}function Jn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function Xn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function zn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function Vn(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const Qn={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=nn({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Gn=t=>t();function Yn(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Zn(t){function*e(){for(const n of t)Yn(n)&&(n.source==="char"?yield{type:"char_location",file_id:n.url??"",start_char_index:n.startIndex??0,end_char_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="page"?yield{type:"page_location",file_id:n.url??"",start_page_number:n.startIndex??0,end_page_number:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="block"?yield{type:"content_block_location",file_id:n.url??"",start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="url"?yield{type:"web_search_result_location",url:n.url??"",title:n.title??null,encrypted_index:String(n.startIndex??0),cited_text:n.citedText??""}:n.source==="search"&&(yield{type:"search_result_location",title:n.title??null,start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,search_result_index:0,source:n.source??"",cited_text:n.citedText??""}))}return Array.from(e())}function G(t){return typeof t=="string"?t:es(t)}function es(t){const e=[];for(let n=0,{length:s}=t;n<s;n++)e.push(String.fromCharCode(t[n]));return btoa(e.join(""))}function Ve(t){return(t??"").split(";")[0].toLowerCase()}function he(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function H(t,e){const n=he(e,"cache_control");n!==void 0&&(t.cache_control=n);const s=he(e,"citations");s!==void 0&&(t.citations=s);const r=he(e,"context");r!==void 0&&(t.context=r);const i=he(e,"title");return i!==void 0&&(t.title=i),t}function Qe(t,e){const n=he(e,"cache_control");return n!==void 0&&(t.cache_control=n),t}function At(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function ts(t){const e=[],n=t.response_metadata,s="model_provider"in n&&n?.model_provider==="anthropic";for(const r of t.contentBlocks)if(r.type==="text")r.annotations?e.push({type:"text",text:r.text,citations:Zn(r.annotations)}):e.push({type:"text",text:r.text});else if(r.type==="tool_call")e.push({type:"tool_use",id:r.id??"",name:r.name,input:r.args});else if(r.type==="tool_call_chunk"){const i=Gn(()=>{if(typeof r.args!="string")return r.args;try{return JSON.parse(r.args)}catch{return{}}});e.push({type:"tool_use",id:r.id??"",name:r.name??"",input:i})}else if(r.type==="reasoning"&&s)e.push({type:"thinking",thinking:r.reasoning,signature:String(r.signature)});else if(r.type==="server_tool_call"&&s)r.name==="web_search"?e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args}):r.name==="code_execution"&&e.push({type:"server_tool_use",name:r.name,id:r.id??"",input:r.args});else if(r.type==="server_tool_call_result"&&s)if(r.name==="web_search"&&Array.isArray(r.output.urls)){const i=r.output.urls.map(a=>({type:"web_search_result",title:"",encrypted_content:"",url:a}));e.push({type:"web_search_tool_result",tool_use_id:r.toolCallId??"",content:i})}else r.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:r.toolCallId??"",content:r.output}):r.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:r.toolCallId??"",content:r.output});else{if(r.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(r.type==="file"){const i=r.metadata;if(r.fileId){e.push(H({type:"document",source:{type:"file",file_id:r.fileId}},i));continue}if(r.url){const a=Ve(r.mimeType);if(a==="application/pdf"||a===""){e.push(H({type:"document",source:{type:"url",url:r.url}},i));continue}}if(r.data){const a=Ve(r.mimeType);if(a===""||a==="application/pdf")e.push(H({type:"document",source:{type:"base64",data:G(r.data),media_type:"application/pdf"}},i));else if(a==="text/plain")e.push(H({type:"document",source:{type:"text",data:G(r.data),media_type:"text/plain"}},i));else if(At(a))e.push(H({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:G(r.data),media_type:a}}]}},i));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${a}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(r.type==="image"){const i=r.metadata;if(r.fileId){e.push(Qe({type:"image",source:{type:"file",file_id:r.fileId}},i));continue}if(r.url){e.push(Qe({type:"image",source:{type:"url",url:r.url}},i));continue}if(r.data){const a=Ve(r.mimeType)||"image/png";At(a)&&e.push(Qe({type:"image",source:{type:"base64",data:G(r.data),media_type:a}},i));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else r.type==="video"||(r.type==="text-plain"?r.data&&e.push(H({type:"document",source:{type:"text",data:G(r.data),media_type:"text/plain"}},r.metadata)):r.type==="non_standard"&&s&&e.push(r.value))}return e}function vt(t){const e=nn({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let n;try{n=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
2
2
|
|
|
3
3
|
`))}if(n.protocol==="http:"||n.protocol==="https:")return{type:"url",url:t};throw new Error([`Invalid image URL protocol: ${JSON.stringify(n.protocol)}. Anthropic only supports images as http, https, or base64-encoded data URLs on 'image_url' content blocks.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
|
|
4
4
|
|