@szdziedzic/sim-on 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/simon.mjs +139 -137
- package/package.json +2 -2
package/dist/simon.mjs
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
1
|
import { createRequire as __cr } from "node:module"; const require = __cr(import.meta.url);
|
|
2
|
-
var iN=Object.create;var rp=Object.defineProperty;var oN=Object.getOwnPropertyDescriptor;var aN=Object.getOwnPropertyNames;var cN=Object.getPrototypeOf,uN=Object.prototype.hasOwnProperty;var ke=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(t&&(e=t(t=0)),e);var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Bn=(t,e)=>{for(var r in e)rp(t,r,{get:e[r],enumerable:!0})},lN=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of aN(e))!uN.call(t,s)&&s!==r&&rp(t,s,{get:()=>e[s],enumerable:!(n=oN(e,s))||n.enumerable});return t};var Mt=(t,e,r)=>(r=t!=null?iN(cN(t)):{},lN(e||!t||!t.__esModule?rp(r,"default",{value:t,enumerable:!0}):r,t));var Ar=w((tK,zv)=>{"use strict";var Nv=["nodebuffer","arraybuffer","fragments"],Rv=typeof Blob<"u";Rv&&Nv.push("blob");zv.exports={BINARY_TYPES:Nv,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Rv,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ao=w((rK,Qc)=>{"use strict";var{EMPTY_BUFFER:dN}=Ar(),np=Buffer[Symbol.species];function fN(t,e){if(t.length===0)return dN;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,n),n+=i.length}return n<e?new np(r.buffer,r.byteOffset,n):r}function Mv(t,e,r,n,s){for(let i=0;i<s;i++)r[n+i]=t[i]^e[i&3]}function Cv(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function pN(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function sp(t){if(sp.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new np(t):ArrayBuffer.isView(t)?e=new np(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),sp.readOnly=!1),e}Qc.exports={concat:fN,mask:Mv,toArrayBuffer:pN,toBuffer:sp,unmask:Cv};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ke("bufferutil");Qc.exports.mask=function(e,r,n,s,i){i<48?Mv(e,r,n,s,i):t.mask(e,r,n,s,i)},Qc.exports.unmask=function(e,r){e.length<32?Cv(e,r):t.unmask(e,r)}}catch{}});var qv=w((nK,Lv)=>{"use strict";var jv=Symbol("kDone"),ip=Symbol("kRun"),op=class{constructor(e){this[jv]=()=>{this.pending--,this[ip]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ip]()}[ip](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[jv])}}};Lv.exports=op});var ei=w((sK,Fv)=>{"use strict";var No=ke("zlib"),Dv=Ao(),hN=qv(),{kStatusCode:Zv}=Ar(),mN=Buffer[Symbol.species],gN=Buffer.from([0,0,255,255]),tu=Symbol("permessage-deflate"),Nr=Symbol("total-length"),Xs=Symbol("callback"),en=Symbol("buffers"),Qs=Symbol("error"),eu,ap=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!eu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;eu=new hN(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Xs];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,n=e.find(s=>!(r.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>s.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(n=>{let s=r[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=s})}),e}decompress(e,r,n){eu.add(s=>{this._decompress(e,r,(i,o)=>{s(),n(i,o)})})}compress(e,r,n){eu.add(s=>{this._compress(e,r,(i,o)=>{s(),n(i,o)})})}_decompress(e,r,n){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?No.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=No.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[tu]=this,this._inflate[Nr]=0,this._inflate[en]=[],this._inflate.on("error",_N),this._inflate.on("data",Uv)}this._inflate[Xs]=n,this._inflate.write(e),r&&this._inflate.write(gN),this._inflate.flush(()=>{let i=this._inflate[Qs];if(i){this._inflate.close(),this._inflate=null,n(i);return}let o=Dv.concat(this._inflate[en],this._inflate[Nr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Nr]=0,this._inflate[en]=[],r&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,r,n){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?No.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=No.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Nr]=0,this._deflate[en]=[],this._deflate.on("data",yN)}this._deflate[Xs]=n,this._deflate.write(e),this._deflate.flush(No.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Dv.concat(this._deflate[en],this._deflate[Nr]);r&&(i=new mN(i.buffer,i.byteOffset,i.length-4)),this._deflate[Xs]=null,this._deflate[Nr]=0,this._deflate[en]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,i)})}};Fv.exports=ap;function yN(t){this[en].push(t),this[Nr]+=t.length}function Uv(t){if(this[Nr]+=t.length,this[tu]._maxPayload<1||this[Nr]<=this[tu]._maxPayload){this[en].push(t);return}this[Qs]=new RangeError("Max payload size exceeded"),this[Qs].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qs][Zv]=1009,this.removeListener("data",Uv),this.reset()}function _N(t){if(this[tu]._inflate=null,this[Qs]){this[Xs](this[Qs]);return}t[Zv]=1007,this[Xs](t)}});var ti=w((iK,ru)=>{"use strict";var{isUtf8:Bv}=ke("buffer"),{hasBlob:bN}=Ar(),wN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function vN(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function cp(t){let e=t.length,r=0;for(;r<e;)if(!(t[r]&128))r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function xN(t){return bN&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ru.exports={isBlob:xN,isValidStatusCode:vN,isValidUTF8:cp,tokenChars:wN};if(Bv)ru.exports.isValidUTF8=function(t){return t.length<24?cp(t):Bv(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ke("utf-8-validate");ru.exports.isValidUTF8=function(e){return e.length<32?cp(e):t(e)}}catch{}});var pp=w((oK,Yv)=>{"use strict";var{Writable:SN}=ke("stream"),Vv=ei(),{BINARY_TYPES:kN,EMPTY_BUFFER:Hv,kStatusCode:$N,kWebSocket:EN}=Ar(),{concat:up,toArrayBuffer:TN,unmask:PN}=Ao(),{isValidStatusCode:ON,isValidUTF8:Wv}=ti(),nu=Buffer[Symbol.species],Ct=0,Kv=1,Jv=2,Gv=3,lp=4,dp=5,su=6,fp=class extends SN{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||kN[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[EN]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Ct}_write(e,r,n){if(this._opcode===8&&this._state==Ct)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new nu(n.buffer,n.byteOffset+e,n.length-e),new nu(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=r.length-e;e>=n.length?r.set(this._buffers.shift(),s):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new nu(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case Ct:this.getInfo(e);break;case Kv:this.getPayloadLength16(e);break;case Jv:this.getPayloadLength64(e);break;case Gv:this.getMask();break;case lp:this.getData(e);break;case dp:case su:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if(r[0]&48){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Vv.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=Kv:this._payloadLength===127?this._state=Jv:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Gv:this._state=lp}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=lp}getData(e){let r=Hv;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&PN(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=dp,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[Vv.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return r(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let o=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(o);return}this._fragments.push(i)}this.dataMessage(r),this._state===Ct&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=Ct;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=up(n,r):this._binaryType==="arraybuffer"?s=TN(up(n,r)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=Ct):(this._state=su,setImmediate(()=>{this.emit("message",s,!0),this._state=Ct,this.startLoop(e)}))}else{let s=up(n,r);if(!this._skipUTF8Validation&&!Wv(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===dp||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=Ct):(this._state=su,setImmediate(()=>{this.emit("message",s,!1),this._state=Ct,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Hv),this.end();else{let n=e.readUInt16BE(0);if(!ON(n)){let i=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(i);return}let s=new nu(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Wv(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(i);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=Ct;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Ct):(this._state=su,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Ct,this.startLoop(r)}))}createError(e,r,n,s,i){this._loop=!1,this._errored=!0;let o=new e(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=i,o[$N]=s,o}};Yv.exports=fp});var gp=w((cK,e0)=>{"use strict";var{Duplex:aK}=ke("stream"),{randomFillSync:IN}=ke("crypto"),{types:{isUint8Array:AN}}=ke("util"),Xv=ei(),{EMPTY_BUFFER:NN,kWebSocket:RN,NOOP:zN}=Ar(),{isBlob:ri,isValidStatusCode:MN}=ti(),{mask:Qv,toBuffer:Vn}=Ao(),jt=Symbol("kByteLength"),CN=Buffer.alloc(4),iu=8*1024,Hn,ni=iu,tr=0,jN=1,LN=2,hp=class t{constructor(e,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=tr,this.onerror=zN,this[RN]=void 0}static frame(e,r){let n,s=!1,i=2,o=!1;r.mask&&(n=r.maskBuffer||CN,r.generateMask?r.generateMask(n):(ni===iu&&(Hn===void 0&&(Hn=Buffer.alloc(iu)),IN(Hn,0,iu),ni=0),n[0]=Hn[ni++],n[1]=Hn[ni++],n[2]=Hn[ni++],n[3]=Hn[ni++]),o=(n[0]|n[1]|n[2]|n[3])===0,i=6);let a;typeof e=="string"?(!r.mask||o)&&r[jt]!==void 0?a=r[jt]:(e=Buffer.from(e),a=e.length):(a=e.length,s=r.mask&&r.readOnly&&!o);let c=a;a>=65536?(i+=8,c=127):a>125&&(i+=2,c=126);let u=Buffer.allocUnsafe(s?a+i:i);return u[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),r.mask?(u[1]|=128,u[i-4]=n[0],u[i-3]=n[1],u[i-2]=n[2],u[i-1]=n[3],o?[u,e]:s?(Qv(e,n,u,i,a),[u]):(Qv(e,n,e,0,a),[u,e])):[u,e]}close(e,r,n,s){let i;if(e===void 0)i=NN;else{if(typeof e!="number"||!MN(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(i=Buffer.allocUnsafe(2+a),i.writeUInt16BE(e,0),typeof r=="string")i.write(r,2);else if(AN(r))i.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[jt]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==tr?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(t.frame(i,o),s)}ping(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ri(e)?(s=e.size,i=!1):(e=Vn(e),s=e.length,i=Vn.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[jt]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};ri(e)?this._state!==tr?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==tr?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}pong(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ri(e)?(s=e.size,i=!1):(e=Vn(e),s=e.length,i=Vn.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[jt]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};ri(e)?this._state!==tr?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==tr?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}send(e,r,n){let s=this._extensions[Xv.extensionName],i=r.binary?2:1,o=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):ri(e)?(a=e.size,c=!1):(e=Vn(e),a=e.length,c=Vn.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,i=0),r.fin&&(this._firstFragment=!0);let u={[jt]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};ri(e)?this._state!==tr?this.enqueue([this.getBlobData,e,this._compress,u,n]):this.getBlobData(e,this._compress,u,n):this._state!==tr?this.enqueue([this.dispatch,e,this._compress,u,n]):this.dispatch(e,this._compress,u,n)}getBlobData(e,r,n,s){this._bufferedBytes+=n[jt],this._state=LN,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(mp,this,a,s);return}this._bufferedBytes-=n[jt];let o=Vn(i);r?this.dispatch(o,r,n,s):(this._state=tr,this.sendFrame(t.frame(o,n),s),this.dequeue())}).catch(i=>{process.nextTick(qN,this,i,s)})}dispatch(e,r,n,s){if(!r){this.sendFrame(t.frame(e,n),s);return}let i=this._extensions[Xv.extensionName];this._bufferedBytes+=n[jt],this._state=jN,i.compress(e,n.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");mp(this,c,s);return}this._bufferedBytes-=n[jt],this._state=tr,n.readOnly=!1,this.sendFrame(t.frame(a,n),s),this.dequeue()})}dequeue(){for(;this._state===tr&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][jt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][jt],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};e0.exports=hp;function mp(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let s=t._queue[n],i=s[s.length-1];typeof i=="function"&&i(e)}}function qN(t,e,r){mp(t,e,r),t.onerror(e)}});var u0=w((uK,c0)=>{"use strict";var{kForOnEventAttribute:Ro,kListener:yp}=Ar(),t0=Symbol("kCode"),r0=Symbol("kData"),n0=Symbol("kError"),s0=Symbol("kMessage"),i0=Symbol("kReason"),si=Symbol("kTarget"),o0=Symbol("kType"),a0=Symbol("kWasClean"),Rr=class{constructor(e){this[si]=null,this[o0]=e}get target(){return this[si]}get type(){return this[o0]}};Object.defineProperty(Rr.prototype,"target",{enumerable:!0});Object.defineProperty(Rr.prototype,"type",{enumerable:!0});var Wn=class extends Rr{constructor(e,r={}){super(e),this[t0]=r.code===void 0?0:r.code,this[i0]=r.reason===void 0?"":r.reason,this[a0]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[t0]}get reason(){return this[i0]}get wasClean(){return this[a0]}};Object.defineProperty(Wn.prototype,"code",{enumerable:!0});Object.defineProperty(Wn.prototype,"reason",{enumerable:!0});Object.defineProperty(Wn.prototype,"wasClean",{enumerable:!0});var ii=class extends Rr{constructor(e,r={}){super(e),this[n0]=r.error===void 0?null:r.error,this[s0]=r.message===void 0?"":r.message}get error(){return this[n0]}get message(){return this[s0]}};Object.defineProperty(ii.prototype,"error",{enumerable:!0});Object.defineProperty(ii.prototype,"message",{enumerable:!0});var zo=class extends Rr{constructor(e,r={}){super(e),this[r0]=r.data===void 0?null:r.data}get data(){return this[r0]}};Object.defineProperty(zo.prototype,"data",{enumerable:!0});var DN={addEventListener(t,e,r={}){for(let s of this.listeners(t))if(!r[Ro]&&s[yp]===e&&!s[Ro])return;let n;if(t==="message")n=function(i,o){let a=new zo("message",{data:o?i:i.toString()});a[si]=this,ou(e,this,a)};else if(t==="close")n=function(i,o){let a=new Wn("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[si]=this,ou(e,this,a)};else if(t==="error")n=function(i){let o=new ii("error",{error:i,message:i.message});o[si]=this,ou(e,this,o)};else if(t==="open")n=function(){let i=new Rr("open");i[si]=this,ou(e,this,i)};else return;n[Ro]=!!r[Ro],n[yp]=e,r.once?this.once(t,n):this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[yp]===e&&!r[Ro]){this.removeListener(t,r);break}}};c0.exports={CloseEvent:Wn,ErrorEvent:ii,Event:Rr,EventTarget:DN,MessageEvent:zo};function ou(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var au=w((lK,l0)=>{"use strict";var{tokenChars:Mo}=ti();function hr(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ZN(t){let e=Object.create(null),r=Object.create(null),n=!1,s=!1,i=!1,o,a,c=-1,u=-1,l=-1,d=0;for(;d<t.length;d++)if(u=t.charCodeAt(d),o===void 0)if(l===-1&&Mo[u]===1)c===-1&&(c=d);else if(d!==0&&(u===32||u===9))l===-1&&c!==-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d);let p=t.slice(c,l);u===44?(hr(e,p,r),r=Object.create(null)):o=p,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);else if(a===void 0)if(l===-1&&Mo[u]===1)c===-1&&(c=d);else if(u===32||u===9)l===-1&&c!==-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d),hr(r,t.slice(c,l),!0),u===44&&(hr(e,o,r),r=Object.create(null),o=void 0),c=l=-1}else if(u===61&&c!==-1&&l===-1)a=t.slice(c,d),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(s){if(Mo[u]!==1)throw new SyntaxError(`Unexpected character at index ${d}`);c===-1?c=d:n||(n=!0),s=!1}else if(i)if(Mo[u]===1)c===-1&&(c=d);else if(u===34&&c!==-1)i=!1,l=d;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(u===34&&t.charCodeAt(d-1)===61)i=!0;else if(l===-1&&Mo[u]===1)c===-1&&(c=d);else if(c!==-1&&(u===32||u===9))l===-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d);let p=t.slice(c,l);n&&(p=p.replace(/\\/g,""),n=!1),hr(r,a,p),u===44&&(hr(e,o,r),r=Object.create(null),o=void 0),a=void 0,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);if(c===-1||i||u===32||u===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=d);let f=t.slice(c,l);return o===void 0?hr(e,f,r):(a===void 0?hr(r,f,!0):n?hr(r,a,f.replace(/\\/g,"")):hr(r,a,f),hr(e,o,r)),e}function UN(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(s=>{let i=n[s];return Array.isArray(i)||(i=[i]),i.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}l0.exports={format:UN,parse:ZN}});var du=w((pK,x0)=>{"use strict";var FN=ke("events"),BN=ke("https"),VN=ke("http"),p0=ke("net"),HN=ke("tls"),{randomBytes:WN,createHash:KN}=ke("crypto"),{Duplex:dK,Readable:fK}=ke("stream"),{URL:_p}=ke("url"),tn=ei(),JN=pp(),GN=gp(),{isBlob:YN}=ti(),{BINARY_TYPES:d0,CLOSE_TIMEOUT:XN,EMPTY_BUFFER:cu,GUID:QN,kForOnEventAttribute:bp,kListener:eR,kStatusCode:tR,kWebSocket:He,NOOP:h0}=Ar(),{EventTarget:{addEventListener:rR,removeEventListener:nR}}=u0(),{format:sR,parse:iR}=au(),{toBuffer:oR}=Ao(),m0=Symbol("kAborted"),wp=[8,13],zr=["CONNECTING","OPEN","CLOSING","CLOSED"],aR=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Pe=class t extends FN{constructor(e,r,n){super(),this._binaryType=d0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=cu,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),g0(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){d0.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let s=new JN({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),i=new GN(e,this._extensions,n.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[He]=this,i[He]=this,e[He]=this,s.on("conclude",lR),s.on("drain",dR),s.on("error",fR),s.on("message",pR),s.on("ping",hR),s.on("pong",mR),i.onerror=gR,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",b0),e.on("data",lu),e.on("end",w0),e.on("error",v0),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[tn.extensionName]&&this._extensions[tn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Tt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),_0(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){vp(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||cu,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){vp(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||cu,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){vp(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[tn.extensionName]||(s.compress=!1),this._sender.send(e||cu,s,n)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Tt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(Pe,"CONNECTING",{enumerable:!0,value:zr.indexOf("CONNECTING")});Object.defineProperty(Pe.prototype,"CONNECTING",{enumerable:!0,value:zr.indexOf("CONNECTING")});Object.defineProperty(Pe,"OPEN",{enumerable:!0,value:zr.indexOf("OPEN")});Object.defineProperty(Pe.prototype,"OPEN",{enumerable:!0,value:zr.indexOf("OPEN")});Object.defineProperty(Pe,"CLOSING",{enumerable:!0,value:zr.indexOf("CLOSING")});Object.defineProperty(Pe.prototype,"CLOSING",{enumerable:!0,value:zr.indexOf("CLOSING")});Object.defineProperty(Pe,"CLOSED",{enumerable:!0,value:zr.indexOf("CLOSED")});Object.defineProperty(Pe.prototype,"CLOSED",{enumerable:!0,value:zr.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(Pe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(Pe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[bp])return e[eR];return null},set(e){for(let r of this.listeners(t))if(r[bp]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[bp]:!0})}})});Pe.prototype.addEventListener=rR;Pe.prototype.removeEventListener=nR;x0.exports=Pe;function g0(t,e,r,n){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:XN,protocolVersion:wp[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=s.autoPong,t._closeTimeout=s.closeTimeout,!wp.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${wp.join(", ")})`);let i;if(e instanceof _p)i=e;else try{i=new _p(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),t._url=i.href;let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",c;if(i.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!i.pathname?c="The URL's pathname is empty":i.hash&&(c="The URL contains a fragment identifier"),c){let h=new SyntaxError(c);if(t._redirects===0)throw h;uu(t,h);return}let u=o?443:80,l=WN(16).toString("base64"),d=o?BN.request:VN.request,f=new Set,p;if(s.createConnection=s.createConnection||(o?uR:cR),s.defaultPort=s.defaultPort||u,s.port=i.port||u,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(p=new tn({...s.perMessageDeflate,isServer:!1,maxPayload:s.maxPayload}),s.headers["Sec-WebSocket-Extensions"]=sR({[tn.extensionName]:p.offer()})),r.length){for(let h of r){if(typeof h!="string"||!aR.test(h)||f.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(h)}s.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),a){let h=s.path.split(":");s.socketPath=h[0],s.path=h[1]}let m;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?s.socketPath:i.host;let h=n&&n.headers;if(n={...n,headers:{}},h)for(let[g,y]of Object.entries(h))n.headers[g.toLowerCase()]=y}else if(t.listenerCount("redirect")===0){let h=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:i.host===t._originalHostOrSocketPath;(!h||t._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,h||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),m=t._req=d(s),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=d(s);s.timeout&&m.on("timeout",()=>{Tt(t,m,"Opening handshake has timed out")}),m.on("error",h=>{m===null||m[m0]||(m=t._req=null,uu(t,h))}),m.on("response",h=>{let g=h.headers.location,y=h.statusCode;if(g&&s.followRedirects&&y>=300&&y<400){if(++t._redirects>s.maxRedirects){Tt(t,m,"Maximum redirects exceeded");return}m.abort();let _;try{_=new _p(g,e)}catch{let k=new SyntaxError(`Invalid URL: ${g}`);uu(t,k);return}g0(t,_,r,n)}else t.emit("unexpected-response",m,h)||Tt(t,m,`Unexpected server response: ${h.statusCode}`)}),m.on("upgrade",(h,g,y)=>{if(t.emit("upgrade",h),t.readyState!==Pe.CONNECTING)return;m=t._req=null;let _=h.headers.upgrade;if(_===void 0||_.toLowerCase()!=="websocket"){Tt(t,g,"Invalid Upgrade header");return}let v=KN("sha1").update(l+QN).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Tt(t,g,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],E;if(k!==void 0?f.size?f.has(k)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":f.size&&(E="Server sent no subprotocol"),E){Tt(t,g,E);return}k&&(t._protocol=k);let C=h.headers["sec-websocket-extensions"];if(C!==void 0){if(!p){Tt(t,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=iR(C)}catch{Tt(t,g,"Invalid Sec-WebSocket-Extensions header");return}let R=Object.keys(B);if(R.length!==1||R[0]!==tn.extensionName){Tt(t,g,"Server indicated an extension that was not requested");return}try{p.accept(B[tn.extensionName])}catch{Tt(t,g,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[tn.extensionName]=p}t.setSocket(g,y,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(m,t):m.end()}function uu(t,e){t._readyState=Pe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function cR(t){return t.path=t.socketPath,p0.connect(t)}function uR(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=p0.isIP(t.host)?"":t.host),HN.connect(t)}function Tt(t,e,r){t._readyState=Pe.CLOSING;let n=new Error(r);Error.captureStackTrace(n,Tt),e.setHeader?(e[m0]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(uu,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function vp(t,e,r){if(e){let n=YN(e)?e.size:oR(e).length;t._socket?t._sender._bufferedBytes+=n:t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${zr[t.readyState]})`);process.nextTick(r,n)}}function lR(t,e){let r=this[He];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[He]!==void 0&&(r._socket.removeListener("data",lu),process.nextTick(y0,r._socket),t===1005?r.close():r.close(t,e))}function dR(){let t=this[He];t.isPaused||t._socket.resume()}function fR(t){let e=this[He];e._socket[He]!==void 0&&(e._socket.removeListener("data",lu),process.nextTick(y0,e._socket),e.close(t[tR])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function f0(){this[He].emitClose()}function pR(t,e){this[He].emit("message",t,e)}function hR(t){let e=this[He];e._autoPong&&e.pong(t,!this._isServer,h0),e.emit("ping",t)}function mR(t){this[He].emit("pong",t)}function y0(t){t.resume()}function gR(t){let e=this[He];e.readyState!==Pe.CLOSED&&(e.readyState===Pe.OPEN&&(e._readyState=Pe.CLOSING,_0(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function _0(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function b0(){let t=this[He];if(this.removeListener("close",b0),this.removeListener("data",lu),this.removeListener("end",w0),t._readyState=Pe.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[He]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",f0),t._receiver.on("finish",f0))}function lu(t){this[He]._receiver.write(t)||this.pause()}function w0(){let t=this[He];t._readyState=Pe.CLOSING,t._receiver.end(),this.end()}function v0(){let t=this[He];this.removeListener("error",v0),this.on("error",h0),t&&(t._readyState=Pe.CLOSING,this.destroy())}});var E0=w((mK,$0)=>{"use strict";var hK=du(),{Duplex:yR}=ke("stream");function S0(t){t.emit("close")}function _R(){!this.destroyed&&this._writableState.finished&&this.destroy()}function k0(t){this.removeListener("error",k0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function bR(t,e){let r=!0,n=new yR({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(i,o){let a=!o&&n._readableState.objectMode?i.toString():i;n.push(a)||t.pause()}),t.once("error",function(i){n.destroyed||(r=!1,n.destroy(i))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,i){if(t.readyState===t.CLOSED){i(s),process.nextTick(S0,n);return}let o=!1;t.once("error",function(c){o=!0,i(c)}),t.once("close",function(){o||i(s),process.nextTick(S0,n)}),r&&t.terminate()},n._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){n._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},n._write=function(s,i,o){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(s,i,o)});return}t.send(s,o)},n.on("end",_R),n.on("error",k0),n}$0.exports=bR});var xp=w((gK,T0)=>{"use strict";var{tokenChars:wR}=ti();function vR(t){let e=new Set,r=-1,n=-1,s=0;for(s;s<t.length;s++){let o=t.charCodeAt(s);if(n===-1&&wR[o]===1)r===-1&&(r=s);else if(s!==0&&(o===32||o===9))n===-1&&r!==-1&&(n=s);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=t.slice(r,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}T0.exports={parse:vR}});var z0=w((_K,R0)=>{"use strict";var xR=ke("events"),fu=ke("http"),{Duplex:yK}=ke("stream"),{createHash:SR}=ke("crypto"),P0=au(),Kn=ei(),kR=xp(),$R=du(),{CLOSE_TIMEOUT:ER,GUID:TR,kWebSocket:PR}=Ar(),OR=/^[+/0-9A-Za-z]{22}==$/,O0=0,I0=1,N0=2,Sp=class extends xR{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:ER,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:$R,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=fu.createServer((n,s)=>{let i=fu.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=IR(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,o)=>{this.handleUpgrade(s,i,o,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=O0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===N0){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Co,this);return}if(e&&this.once("close",e),this._state!==I0)if(this._state=I0,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Co,this):process.nextTick(Co,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Co(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,s){r.on("error",A0);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Jn(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Jn(this,e,r,400,"Invalid Upgrade header");return}if(i===void 0||!OR.test(i)){Jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){jo(r,400);return}let c=e.headers["sec-websocket-protocol"],u=new Set;if(c!==void 0)try{u=kR.parse(c)}catch{Jn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&l!==void 0){let f=new Kn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let p=P0.parse(l);p[Kn.extensionName]&&(f.accept(p[Kn.extensionName]),d[Kn.extensionName]=f)}catch{Jn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(p,m,h,g)=>{if(!p)return jo(r,m||401,h,g);this.completeUpgrade(d,i,u,e,r,n,s)});return}if(!this.options.verifyClient(f))return jo(r,401)}this.completeUpgrade(d,i,u,e,r,n,s)}completeUpgrade(e,r,n,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[PR])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>O0)return jo(i,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${SR("sha1").update(r+TR).digest("base64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(n.size){let d=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;d&&(u.push(`Sec-WebSocket-Protocol: ${d}`),l._protocol=d)}if(e[Kn.extensionName]){let d=e[Kn.extensionName].params,f=P0.format({[Kn.extensionName]:[d]});u.push(`Sec-WebSocket-Extensions: ${f}`),l._extensions=e}this.emit("headers",u,s),i.write(u.concat(`\r
|
|
2
|
+
var oN=Object.create;var np=Object.defineProperty;var aN=Object.getOwnPropertyDescriptor;var cN=Object.getOwnPropertyNames;var uN=Object.getPrototypeOf,lN=Object.prototype.hasOwnProperty;var ke=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(t&&(e=t(t=0)),e);var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Vn=(t,e)=>{for(var r in e)np(t,r,{get:e[r],enumerable:!0})},dN=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of cN(e))!lN.call(t,s)&&s!==r&&np(t,s,{get:()=>e[s],enumerable:!(n=aN(e,s))||n.enumerable});return t};var Ct=(t,e,r)=>(r=t!=null?oN(uN(t)):{},dN(e||!t||!t.__esModule?np(r,"default",{value:t,enumerable:!0}):r,t));var Nr=w((nK,Mv)=>{"use strict";var Rv=["nodebuffer","arraybuffer","fragments"],zv=typeof Blob<"u";zv&&Rv.push("blob");Mv.exports={BINARY_TYPES:Rv,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:zv,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var No=w((sK,eu)=>{"use strict";var{EMPTY_BUFFER:fN}=Nr(),sp=Buffer[Symbol.species];function pN(t,e){if(t.length===0)return fN;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,n),n+=i.length}return n<e?new sp(r.buffer,r.byteOffset,n):r}function Cv(t,e,r,n,s){for(let i=0;i<s;i++)r[n+i]=t[i]^e[i&3]}function jv(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function hN(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ip(t){if(ip.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new sp(t):ArrayBuffer.isView(t)?e=new sp(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ip.readOnly=!1),e}eu.exports={concat:pN,mask:Cv,toArrayBuffer:hN,toBuffer:ip,unmask:jv};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ke("bufferutil");eu.exports.mask=function(e,r,n,s,i){i<48?Cv(e,r,n,s,i):t.mask(e,r,n,s,i)},eu.exports.unmask=function(e,r){e.length<32?jv(e,r):t.unmask(e,r)}}catch{}});var Dv=w((iK,qv)=>{"use strict";var Lv=Symbol("kDone"),op=Symbol("kRun"),ap=class{constructor(e){this[Lv]=()=>{this.pending--,this[op]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[op]()}[op](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Lv])}}};qv.exports=ap});var ti=w((oK,Bv)=>{"use strict";var Ro=ke("zlib"),Zv=No(),mN=Dv(),{kStatusCode:Uv}=Nr(),gN=Buffer[Symbol.species],yN=Buffer.from([0,0,255,255]),ru=Symbol("permessage-deflate"),Rr=Symbol("total-length"),Qs=Symbol("callback"),tn=Symbol("buffers"),ei=Symbol("error"),tu,cp=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!tu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;tu=new mN(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Qs];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,n=e.find(s=>!(r.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>s.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(n=>{let s=r[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=s})}),e}decompress(e,r,n){tu.add(s=>{this._decompress(e,r,(i,o)=>{s(),n(i,o)})})}compress(e,r,n){tu.add(s=>{this._compress(e,r,(i,o)=>{s(),n(i,o)})})}_decompress(e,r,n){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?Ro.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=Ro.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ru]=this,this._inflate[Rr]=0,this._inflate[tn]=[],this._inflate.on("error",bN),this._inflate.on("data",Fv)}this._inflate[Qs]=n,this._inflate.write(e),r&&this._inflate.write(yN),this._inflate.flush(()=>{let i=this._inflate[ei];if(i){this._inflate.close(),this._inflate=null,n(i);return}let o=Zv.concat(this._inflate[tn],this._inflate[Rr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Rr]=0,this._inflate[tn]=[],r&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,r,n){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?Ro.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=Ro.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Rr]=0,this._deflate[tn]=[],this._deflate.on("data",_N)}this._deflate[Qs]=n,this._deflate.write(e),this._deflate.flush(Ro.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Zv.concat(this._deflate[tn],this._deflate[Rr]);r&&(i=new gN(i.buffer,i.byteOffset,i.length-4)),this._deflate[Qs]=null,this._deflate[Rr]=0,this._deflate[tn]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,i)})}};Bv.exports=cp;function _N(t){this[tn].push(t),this[Rr]+=t.length}function Fv(t){if(this[Rr]+=t.length,this[ru]._maxPayload<1||this[Rr]<=this[ru]._maxPayload){this[tn].push(t);return}this[ei]=new RangeError("Max payload size exceeded"),this[ei].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ei][Uv]=1009,this.removeListener("data",Fv),this.reset()}function bN(t){if(this[ru]._inflate=null,this[ei]){this[Qs](this[ei]);return}t[Uv]=1007,this[Qs](t)}});var ri=w((aK,nu)=>{"use strict";var{isUtf8:Vv}=ke("buffer"),{hasBlob:wN}=Nr(),vN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function xN(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function up(t){let e=t.length,r=0;for(;r<e;)if(!(t[r]&128))r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function SN(t){return wN&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}nu.exports={isBlob:SN,isValidStatusCode:xN,isValidUTF8:up,tokenChars:vN};if(Vv)nu.exports.isValidUTF8=function(t){return t.length<24?up(t):Vv(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ke("utf-8-validate");nu.exports.isValidUTF8=function(e){return e.length<32?up(e):t(e)}}catch{}});var hp=w((cK,Xv)=>{"use strict";var{Writable:kN}=ke("stream"),Hv=ti(),{BINARY_TYPES:$N,EMPTY_BUFFER:Wv,kStatusCode:EN,kWebSocket:TN}=Nr(),{concat:lp,toArrayBuffer:PN,unmask:ON}=No(),{isValidStatusCode:IN,isValidUTF8:Kv}=ri(),su=Buffer[Symbol.species],jt=0,Jv=1,Gv=2,Yv=3,dp=4,fp=5,iu=6,pp=class extends kN{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||$N[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[TN]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=jt}_write(e,r,n){if(this._opcode===8&&this._state==jt)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new su(n.buffer,n.byteOffset+e,n.length-e),new su(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=r.length-e;e>=n.length?r.set(this._buffers.shift(),s):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new su(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case jt:this.getInfo(e);break;case Jv:this.getPayloadLength16(e);break;case Gv:this.getPayloadLength64(e);break;case Yv:this.getMask();break;case dp:this.getData(e);break;case fp:case iu:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if(r[0]&48){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Hv.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=Jv:this._payloadLength===127?this._state=Gv:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Yv:this._state=dp}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=dp}getData(e){let r=Wv;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&ON(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=fp,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[Hv.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return r(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let o=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(o);return}this._fragments.push(i)}this.dataMessage(r),this._state===jt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=jt;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=lp(n,r):this._binaryType==="arraybuffer"?s=PN(lp(n,r)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=jt):(this._state=iu,setImmediate(()=>{this.emit("message",s,!0),this._state=jt,this.startLoop(e)}))}else{let s=lp(n,r);if(!this._skipUTF8Validation&&!Kv(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===fp||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=jt):(this._state=iu,setImmediate(()=>{this.emit("message",s,!1),this._state=jt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Wv),this.end();else{let n=e.readUInt16BE(0);if(!IN(n)){let i=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(i);return}let s=new su(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Kv(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(i);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=jt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=jt):(this._state=iu,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=jt,this.startLoop(r)}))}createError(e,r,n,s,i){this._loop=!1,this._errored=!0;let o=new e(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=i,o[EN]=s,o}};Xv.exports=pp});var yp=w((lK,t0)=>{"use strict";var{Duplex:uK}=ke("stream"),{randomFillSync:AN}=ke("crypto"),{types:{isUint8Array:NN}}=ke("util"),Qv=ti(),{EMPTY_BUFFER:RN,kWebSocket:zN,NOOP:MN}=Nr(),{isBlob:ni,isValidStatusCode:CN}=ri(),{mask:e0,toBuffer:Hn}=No(),Lt=Symbol("kByteLength"),jN=Buffer.alloc(4),ou=8*1024,Wn,si=ou,rr=0,LN=1,qN=2,mp=class t{constructor(e,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=rr,this.onerror=MN,this[zN]=void 0}static frame(e,r){let n,s=!1,i=2,o=!1;r.mask&&(n=r.maskBuffer||jN,r.generateMask?r.generateMask(n):(si===ou&&(Wn===void 0&&(Wn=Buffer.alloc(ou)),AN(Wn,0,ou),si=0),n[0]=Wn[si++],n[1]=Wn[si++],n[2]=Wn[si++],n[3]=Wn[si++]),o=(n[0]|n[1]|n[2]|n[3])===0,i=6);let a;typeof e=="string"?(!r.mask||o)&&r[Lt]!==void 0?a=r[Lt]:(e=Buffer.from(e),a=e.length):(a=e.length,s=r.mask&&r.readOnly&&!o);let c=a;a>=65536?(i+=8,c=127):a>125&&(i+=2,c=126);let u=Buffer.allocUnsafe(s?a+i:i);return u[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),r.mask?(u[1]|=128,u[i-4]=n[0],u[i-3]=n[1],u[i-2]=n[2],u[i-1]=n[3],o?[u,e]:s?(e0(e,n,u,i,a),[u]):(e0(e,n,e,0,a),[u,e])):[u,e]}close(e,r,n,s){let i;if(e===void 0)i=RN;else{if(typeof e!="number"||!CN(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(i=Buffer.allocUnsafe(2+a),i.writeUInt16BE(e,0),typeof r=="string")i.write(r,2);else if(NN(r))i.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[Lt]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==rr?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(t.frame(i,o),s)}ping(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ni(e)?(s=e.size,i=!1):(e=Hn(e),s=e.length,i=Hn.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Lt]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};ni(e)?this._state!==rr?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==rr?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}pong(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ni(e)?(s=e.size,i=!1):(e=Hn(e),s=e.length,i=Hn.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[Lt]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};ni(e)?this._state!==rr?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==rr?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}send(e,r,n){let s=this._extensions[Qv.extensionName],i=r.binary?2:1,o=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):ni(e)?(a=e.size,c=!1):(e=Hn(e),a=e.length,c=Hn.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,i=0),r.fin&&(this._firstFragment=!0);let u={[Lt]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};ni(e)?this._state!==rr?this.enqueue([this.getBlobData,e,this._compress,u,n]):this.getBlobData(e,this._compress,u,n):this._state!==rr?this.enqueue([this.dispatch,e,this._compress,u,n]):this.dispatch(e,this._compress,u,n)}getBlobData(e,r,n,s){this._bufferedBytes+=n[Lt],this._state=qN,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(gp,this,a,s);return}this._bufferedBytes-=n[Lt];let o=Hn(i);r?this.dispatch(o,r,n,s):(this._state=rr,this.sendFrame(t.frame(o,n),s),this.dequeue())}).catch(i=>{process.nextTick(DN,this,i,s)})}dispatch(e,r,n,s){if(!r){this.sendFrame(t.frame(e,n),s);return}let i=this._extensions[Qv.extensionName];this._bufferedBytes+=n[Lt],this._state=LN,i.compress(e,n.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");gp(this,c,s);return}this._bufferedBytes-=n[Lt],this._state=rr,n.readOnly=!1,this.sendFrame(t.frame(a,n),s),this.dequeue()})}dequeue(){for(;this._state===rr&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Lt],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};t0.exports=mp;function gp(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let s=t._queue[n],i=s[s.length-1];typeof i=="function"&&i(e)}}function DN(t,e,r){gp(t,e,r),t.onerror(e)}});var l0=w((dK,u0)=>{"use strict";var{kForOnEventAttribute:zo,kListener:_p}=Nr(),r0=Symbol("kCode"),n0=Symbol("kData"),s0=Symbol("kError"),i0=Symbol("kMessage"),o0=Symbol("kReason"),ii=Symbol("kTarget"),a0=Symbol("kType"),c0=Symbol("kWasClean"),zr=class{constructor(e){this[ii]=null,this[a0]=e}get target(){return this[ii]}get type(){return this[a0]}};Object.defineProperty(zr.prototype,"target",{enumerable:!0});Object.defineProperty(zr.prototype,"type",{enumerable:!0});var Kn=class extends zr{constructor(e,r={}){super(e),this[r0]=r.code===void 0?0:r.code,this[o0]=r.reason===void 0?"":r.reason,this[c0]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[r0]}get reason(){return this[o0]}get wasClean(){return this[c0]}};Object.defineProperty(Kn.prototype,"code",{enumerable:!0});Object.defineProperty(Kn.prototype,"reason",{enumerable:!0});Object.defineProperty(Kn.prototype,"wasClean",{enumerable:!0});var oi=class extends zr{constructor(e,r={}){super(e),this[s0]=r.error===void 0?null:r.error,this[i0]=r.message===void 0?"":r.message}get error(){return this[s0]}get message(){return this[i0]}};Object.defineProperty(oi.prototype,"error",{enumerable:!0});Object.defineProperty(oi.prototype,"message",{enumerable:!0});var Mo=class extends zr{constructor(e,r={}){super(e),this[n0]=r.data===void 0?null:r.data}get data(){return this[n0]}};Object.defineProperty(Mo.prototype,"data",{enumerable:!0});var ZN={addEventListener(t,e,r={}){for(let s of this.listeners(t))if(!r[zo]&&s[_p]===e&&!s[zo])return;let n;if(t==="message")n=function(i,o){let a=new Mo("message",{data:o?i:i.toString()});a[ii]=this,au(e,this,a)};else if(t==="close")n=function(i,o){let a=new Kn("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ii]=this,au(e,this,a)};else if(t==="error")n=function(i){let o=new oi("error",{error:i,message:i.message});o[ii]=this,au(e,this,o)};else if(t==="open")n=function(){let i=new zr("open");i[ii]=this,au(e,this,i)};else return;n[zo]=!!r[zo],n[_p]=e,r.once?this.once(t,n):this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[_p]===e&&!r[zo]){this.removeListener(t,r);break}}};u0.exports={CloseEvent:Kn,ErrorEvent:oi,Event:zr,EventTarget:ZN,MessageEvent:Mo};function au(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var cu=w((fK,d0)=>{"use strict";var{tokenChars:Co}=ri();function mr(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function UN(t){let e=Object.create(null),r=Object.create(null),n=!1,s=!1,i=!1,o,a,c=-1,u=-1,l=-1,d=0;for(;d<t.length;d++)if(u=t.charCodeAt(d),o===void 0)if(l===-1&&Co[u]===1)c===-1&&(c=d);else if(d!==0&&(u===32||u===9))l===-1&&c!==-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d);let p=t.slice(c,l);u===44?(mr(e,p,r),r=Object.create(null)):o=p,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);else if(a===void 0)if(l===-1&&Co[u]===1)c===-1&&(c=d);else if(u===32||u===9)l===-1&&c!==-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d),mr(r,t.slice(c,l),!0),u===44&&(mr(e,o,r),r=Object.create(null),o=void 0),c=l=-1}else if(u===61&&c!==-1&&l===-1)a=t.slice(c,d),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(s){if(Co[u]!==1)throw new SyntaxError(`Unexpected character at index ${d}`);c===-1?c=d:n||(n=!0),s=!1}else if(i)if(Co[u]===1)c===-1&&(c=d);else if(u===34&&c!==-1)i=!1,l=d;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(u===34&&t.charCodeAt(d-1)===61)i=!0;else if(l===-1&&Co[u]===1)c===-1&&(c=d);else if(c!==-1&&(u===32||u===9))l===-1&&(l=d);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);l===-1&&(l=d);let p=t.slice(c,l);n&&(p=p.replace(/\\/g,""),n=!1),mr(r,a,p),u===44&&(mr(e,o,r),r=Object.create(null),o=void 0),a=void 0,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);if(c===-1||i||u===32||u===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=d);let f=t.slice(c,l);return o===void 0?mr(e,f,r):(a===void 0?mr(r,f,!0):n?mr(r,a,f.replace(/\\/g,"")):mr(r,a,f),mr(e,o,r)),e}function FN(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(s=>{let i=n[s];return Array.isArray(i)||(i=[i]),i.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}d0.exports={format:FN,parse:UN}});var fu=w((mK,S0)=>{"use strict";var BN=ke("events"),VN=ke("https"),HN=ke("http"),h0=ke("net"),WN=ke("tls"),{randomBytes:KN,createHash:JN}=ke("crypto"),{Duplex:pK,Readable:hK}=ke("stream"),{URL:bp}=ke("url"),rn=ti(),GN=hp(),YN=yp(),{isBlob:XN}=ri(),{BINARY_TYPES:f0,CLOSE_TIMEOUT:QN,EMPTY_BUFFER:uu,GUID:eR,kForOnEventAttribute:wp,kListener:tR,kStatusCode:rR,kWebSocket:We,NOOP:m0}=Nr(),{EventTarget:{addEventListener:nR,removeEventListener:sR}}=l0(),{format:iR,parse:oR}=cu(),{toBuffer:aR}=No(),g0=Symbol("kAborted"),vp=[8,13],Mr=["CONNECTING","OPEN","CLOSING","CLOSED"],cR=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Oe=class t extends BN{constructor(e,r,n){super(),this._binaryType=f0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=uu,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),y0(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){f0.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let s=new GN({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),i=new YN(e,this._extensions,n.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[We]=this,i[We]=this,e[We]=this,s.on("conclude",dR),s.on("drain",fR),s.on("error",pR),s.on("message",hR),s.on("ping",mR),s.on("pong",gR),i.onerror=yR,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",w0),e.on("data",du),e.on("end",v0),e.on("error",x0),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[rn.extensionName]&&this._extensions[rn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Pt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),b0(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){xp(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||uu,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){xp(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||uu,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){xp(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[rn.extensionName]||(s.compress=!1),this._sender.send(e||uu,s,n)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Pt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(Oe,"CONNECTING",{enumerable:!0,value:Mr.indexOf("CONNECTING")});Object.defineProperty(Oe.prototype,"CONNECTING",{enumerable:!0,value:Mr.indexOf("CONNECTING")});Object.defineProperty(Oe,"OPEN",{enumerable:!0,value:Mr.indexOf("OPEN")});Object.defineProperty(Oe.prototype,"OPEN",{enumerable:!0,value:Mr.indexOf("OPEN")});Object.defineProperty(Oe,"CLOSING",{enumerable:!0,value:Mr.indexOf("CLOSING")});Object.defineProperty(Oe.prototype,"CLOSING",{enumerable:!0,value:Mr.indexOf("CLOSING")});Object.defineProperty(Oe,"CLOSED",{enumerable:!0,value:Mr.indexOf("CLOSED")});Object.defineProperty(Oe.prototype,"CLOSED",{enumerable:!0,value:Mr.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(Oe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(Oe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[wp])return e[tR];return null},set(e){for(let r of this.listeners(t))if(r[wp]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[wp]:!0})}})});Oe.prototype.addEventListener=nR;Oe.prototype.removeEventListener=sR;S0.exports=Oe;function y0(t,e,r,n){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:QN,protocolVersion:vp[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=s.autoPong,t._closeTimeout=s.closeTimeout,!vp.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${vp.join(", ")})`);let i;if(e instanceof bp)i=e;else try{i=new bp(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),t._url=i.href;let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",c;if(i.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!i.pathname?c="The URL's pathname is empty":i.hash&&(c="The URL contains a fragment identifier"),c){let h=new SyntaxError(c);if(t._redirects===0)throw h;lu(t,h);return}let u=o?443:80,l=KN(16).toString("base64"),d=o?VN.request:HN.request,f=new Set,p;if(s.createConnection=s.createConnection||(o?lR:uR),s.defaultPort=s.defaultPort||u,s.port=i.port||u,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(p=new rn({...s.perMessageDeflate,isServer:!1,maxPayload:s.maxPayload}),s.headers["Sec-WebSocket-Extensions"]=iR({[rn.extensionName]:p.offer()})),r.length){for(let h of r){if(typeof h!="string"||!cR.test(h)||f.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(h)}s.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),a){let h=s.path.split(":");s.socketPath=h[0],s.path=h[1]}let m;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?s.socketPath:i.host;let h=n&&n.headers;if(n={...n,headers:{}},h)for(let[g,y]of Object.entries(h))n.headers[g.toLowerCase()]=y}else if(t.listenerCount("redirect")===0){let h=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:i.host===t._originalHostOrSocketPath;(!h||t._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,h||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),m=t._req=d(s),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=d(s);s.timeout&&m.on("timeout",()=>{Pt(t,m,"Opening handshake has timed out")}),m.on("error",h=>{m===null||m[g0]||(m=t._req=null,lu(t,h))}),m.on("response",h=>{let g=h.headers.location,y=h.statusCode;if(g&&s.followRedirects&&y>=300&&y<400){if(++t._redirects>s.maxRedirects){Pt(t,m,"Maximum redirects exceeded");return}m.abort();let _;try{_=new bp(g,e)}catch{let k=new SyntaxError(`Invalid URL: ${g}`);lu(t,k);return}y0(t,_,r,n)}else t.emit("unexpected-response",m,h)||Pt(t,m,`Unexpected server response: ${h.statusCode}`)}),m.on("upgrade",(h,g,y)=>{if(t.emit("upgrade",h),t.readyState!==Oe.CONNECTING)return;m=t._req=null;let _=h.headers.upgrade;if(_===void 0||_.toLowerCase()!=="websocket"){Pt(t,g,"Invalid Upgrade header");return}let v=JN("sha1").update(l+eR).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Pt(t,g,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],E;if(k!==void 0?f.size?f.has(k)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":f.size&&(E="Server sent no subprotocol"),E){Pt(t,g,E);return}k&&(t._protocol=k);let C=h.headers["sec-websocket-extensions"];if(C!==void 0){if(!p){Pt(t,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=oR(C)}catch{Pt(t,g,"Invalid Sec-WebSocket-Extensions header");return}let R=Object.keys(B);if(R.length!==1||R[0]!==rn.extensionName){Pt(t,g,"Server indicated an extension that was not requested");return}try{p.accept(B[rn.extensionName])}catch{Pt(t,g,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[rn.extensionName]=p}t.setSocket(g,y,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(m,t):m.end()}function lu(t,e){t._readyState=Oe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function uR(t){return t.path=t.socketPath,h0.connect(t)}function lR(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=h0.isIP(t.host)?"":t.host),WN.connect(t)}function Pt(t,e,r){t._readyState=Oe.CLOSING;let n=new Error(r);Error.captureStackTrace(n,Pt),e.setHeader?(e[g0]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lu,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function xp(t,e,r){if(e){let n=XN(e)?e.size:aR(e).length;t._socket?t._sender._bufferedBytes+=n:t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${Mr[t.readyState]})`);process.nextTick(r,n)}}function dR(t,e){let r=this[We];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[We]!==void 0&&(r._socket.removeListener("data",du),process.nextTick(_0,r._socket),t===1005?r.close():r.close(t,e))}function fR(){let t=this[We];t.isPaused||t._socket.resume()}function pR(t){let e=this[We];e._socket[We]!==void 0&&(e._socket.removeListener("data",du),process.nextTick(_0,e._socket),e.close(t[rR])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function p0(){this[We].emitClose()}function hR(t,e){this[We].emit("message",t,e)}function mR(t){let e=this[We];e._autoPong&&e.pong(t,!this._isServer,m0),e.emit("ping",t)}function gR(t){this[We].emit("pong",t)}function _0(t){t.resume()}function yR(t){let e=this[We];e.readyState!==Oe.CLOSED&&(e.readyState===Oe.OPEN&&(e._readyState=Oe.CLOSING,b0(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function b0(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function w0(){let t=this[We];if(this.removeListener("close",w0),this.removeListener("data",du),this.removeListener("end",v0),t._readyState=Oe.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[We]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",p0),t._receiver.on("finish",p0))}function du(t){this[We]._receiver.write(t)||this.pause()}function v0(){let t=this[We];t._readyState=Oe.CLOSING,t._receiver.end(),this.end()}function x0(){let t=this[We];this.removeListener("error",x0),this.on("error",m0),t&&(t._readyState=Oe.CLOSING,this.destroy())}});var T0=w((yK,E0)=>{"use strict";var gK=fu(),{Duplex:_R}=ke("stream");function k0(t){t.emit("close")}function bR(){!this.destroyed&&this._writableState.finished&&this.destroy()}function $0(t){this.removeListener("error",$0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function wR(t,e){let r=!0,n=new _R({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(i,o){let a=!o&&n._readableState.objectMode?i.toString():i;n.push(a)||t.pause()}),t.once("error",function(i){n.destroyed||(r=!1,n.destroy(i))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,i){if(t.readyState===t.CLOSED){i(s),process.nextTick(k0,n);return}let o=!1;t.once("error",function(c){o=!0,i(c)}),t.once("close",function(){o||i(s),process.nextTick(k0,n)}),r&&t.terminate()},n._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){n._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},n._write=function(s,i,o){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(s,i,o)});return}t.send(s,o)},n.on("end",bR),n.on("error",$0),n}E0.exports=wR});var Sp=w((_K,P0)=>{"use strict";var{tokenChars:vR}=ri();function xR(t){let e=new Set,r=-1,n=-1,s=0;for(s;s<t.length;s++){let o=t.charCodeAt(s);if(n===-1&&vR[o]===1)r===-1&&(r=s);else if(s!==0&&(o===32||o===9))n===-1&&r!==-1&&(n=s);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=t.slice(r,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}P0.exports={parse:xR}});var M0=w((wK,z0)=>{"use strict";var SR=ke("events"),pu=ke("http"),{Duplex:bK}=ke("stream"),{createHash:kR}=ke("crypto"),O0=cu(),Jn=ti(),$R=Sp(),ER=fu(),{CLOSE_TIMEOUT:TR,GUID:PR,kWebSocket:OR}=Nr(),IR=/^[+/0-9A-Za-z]{22}==$/,I0=0,A0=1,R0=2,kp=class extends SR{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:TR,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ER,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pu.createServer((n,s)=>{let i=pu.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=AR(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,o)=>{this.handleUpgrade(s,i,o,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=I0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===R0){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(jo,this);return}if(e&&this.once("close",e),this._state!==A0)if(this._state=A0,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(jo,this):process.nextTick(jo,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{jo(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,s){r.on("error",N0);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Gn(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Gn(this,e,r,400,"Invalid Upgrade header");return}if(i===void 0||!IR.test(i)){Gn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Gn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Lo(r,400);return}let c=e.headers["sec-websocket-protocol"],u=new Set;if(c!==void 0)try{u=$R.parse(c)}catch{Gn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&l!==void 0){let f=new Jn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let p=O0.parse(l);p[Jn.extensionName]&&(f.accept(p[Jn.extensionName]),d[Jn.extensionName]=f)}catch{Gn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(p,m,h,g)=>{if(!p)return Lo(r,m||401,h,g);this.completeUpgrade(d,i,u,e,r,n,s)});return}if(!this.options.verifyClient(f))return Lo(r,401)}this.completeUpgrade(d,i,u,e,r,n,s)}completeUpgrade(e,r,n,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[OR])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>I0)return Lo(i,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${kR("sha1").update(r+PR).digest("base64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(n.size){let d=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;d&&(u.push(`Sec-WebSocket-Protocol: ${d}`),l._protocol=d)}if(e[Jn.extensionName]){let d=e[Jn.extensionName].params,f=O0.format({[Jn.extensionName]:[d]});u.push(`Sec-WebSocket-Extensions: ${f}`),l._extensions=e}this.emit("headers",u,s),i.write(u.concat(`\r
|
|
3
3
|
`).join(`\r
|
|
4
|
-
`)),i.removeListener("error",
|
|
4
|
+
`)),i.removeListener("error",N0),l.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(jo,this)})),a(l,s)}};z0.exports=kp;function AR(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function jo(t){t._state=R0,t.emit("close")}function N0(){this.destroy()}function Lo(t,e,r,n){r=r||pu.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pu.STATUS_CODES[e]}\r
|
|
5
5
|
`+Object.keys(n).map(s=>`${s}: ${n[s]}`).join(`\r
|
|
6
6
|
`)+`\r
|
|
7
7
|
\r
|
|
8
|
-
`+r)}function
|
|
9
|
-
`),byRef:c,elementCount:o.length,sparse:o.length<3}}function
|
|
10
|
-
`)}};
|
|
11
|
-
`)?
|
|
8
|
+
`+r)}function Gn(t,e,r,n,s,i){if(t.listenerCount("wsClientError")){let o=new Error(s);Error.captureStackTrace(o,Gn),t.emit("wsClientError",o,r,e)}else Lo(r,n,s,i)}});var Y0=$(()=>{"use strict"});function Qn(t){let e=[],r=n=>{e.push(n),n.children?.forEach(r)};return r(t),e}function Zo(t){return{x:t.frame.x+t.frame.width/2,y:t.frame.y+t.frame.height/2}}var Op=$(()=>{"use strict"});var X0=$(()=>{"use strict"});var yu,Ip,Q0=$(()=>{"use strict";yu=17e3,Ip=7e3});function es(t,e){let{width:r,height:n}=t.screen,s=e?.maxElements??120,o=Qn(t.root).filter(l=>{if(l.frame.width<=0||l.frame.height<=0)return!1;let d=!!(l.id||l.label||l.value),f=l.role?QR.has(l.role):!1;return e?.interactiveOnly?f||d&&l.role==="StaticText":f||d}),a=[],c=new Map,u=!1;for(let l of o){if(a.length>=s){u=!0;break}let d=`@e${l.i}`;c.set(d,l);let f=((l.frame.x+l.frame.width/2)/r).toFixed(2),p=((l.frame.y+l.frame.height/2)/n).toFixed(2),m=(l.frame.width/r).toFixed(2),h=(l.frame.height/n).toFixed(2),g=[d,l.role??"View"];l.label&&g.push(JSON.stringify(l.label)),l.id&&g.push(`id=${JSON.stringify(l.id)}`),l.value&&l.value!==l.label&&g.push(`value=${JSON.stringify(ez(l.value,60))}`),l.enabled||g.push("disabled"),g.push(`(${f},${p} ${m}\xD7${h})`),a.push(g.join(" "))}return u&&a.push(`\u2026 ${o.length-s} more elements truncated`),{text:a.join(`
|
|
9
|
+
`),byRef:c,elementCount:o.length,sparse:o.length<3}}function ez(t,e){return t.length>e?t.slice(0,e-1)+"\u2026":t}var QR,ex=$(()=>{"use strict";Op();QR=new Set(["Button","TextField","SecureTextField","TextArea","SearchField","Switch","Slider","Link","Cell","MenuItem","CheckBox","RadioButton","PopUpButton","Incrementor","TabGroup","Image"])});var tx={};Vn(tx,{OPTIONAL_LOOKUP_TIMEOUT_MS:()=>Ip,REQUIRED_LOOKUP_TIMEOUT_MS:()=>yu,centerOf:()=>Zo,flattenUiTree:()=>Qn,renderUiTree:()=>es});var sn=$(()=>{"use strict";Y0();Op();X0();Q0();ex()});var le=w(Qe=>{"use strict";var Rp=Symbol.for("yaml.alias"),fx=Symbol.for("yaml.document"),xu=Symbol.for("yaml.map"),px=Symbol.for("yaml.pair"),zp=Symbol.for("yaml.scalar"),Su=Symbol.for("yaml.seq"),Cr=Symbol.for("yaml.node.type"),yz=t=>!!t&&typeof t=="object"&&t[Cr]===Rp,_z=t=>!!t&&typeof t=="object"&&t[Cr]===fx,bz=t=>!!t&&typeof t=="object"&&t[Cr]===xu,wz=t=>!!t&&typeof t=="object"&&t[Cr]===px,hx=t=>!!t&&typeof t=="object"&&t[Cr]===zp,vz=t=>!!t&&typeof t=="object"&&t[Cr]===Su;function mx(t){if(t&&typeof t=="object")switch(t[Cr]){case xu:case Su:return!0}return!1}function xz(t){if(t&&typeof t=="object")switch(t[Cr]){case Rp:case xu:case zp:case Su:return!0}return!1}var Sz=t=>(hx(t)||mx(t))&&!!t.anchor;Qe.ALIAS=Rp;Qe.DOC=fx;Qe.MAP=xu;Qe.NODE_TYPE=Cr;Qe.PAIR=px;Qe.SCALAR=zp;Qe.SEQ=Su;Qe.hasAnchor=Sz;Qe.isAlias=yz;Qe.isCollection=mx;Qe.isDocument=_z;Qe.isMap=bz;Qe.isNode=xz;Qe.isPair=wz;Qe.isScalar=hx;Qe.isSeq=vz});var Bo=w(Mp=>{"use strict";var Fe=le(),yt=Symbol("break visit"),gx=Symbol("skip children"),yr=Symbol("remove node");function ku(t,e){let r=yx(e);Fe.isDocument(t)?ci(null,t.contents,r,Object.freeze([t]))===yr&&(t.contents=null):ci(null,t,r,Object.freeze([]))}ku.BREAK=yt;ku.SKIP=gx;ku.REMOVE=yr;function ci(t,e,r,n){let s=_x(t,e,r,n);if(Fe.isNode(s)||Fe.isPair(s))return bx(t,n,s),ci(t,s,r,n);if(typeof s!="symbol"){if(Fe.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=ci(i,e.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===yt)return yt;o===yr&&(e.items.splice(i,1),i-=1)}}}else if(Fe.isPair(e)){n=Object.freeze(n.concat(e));let i=ci("key",e.key,r,n);if(i===yt)return yt;i===yr&&(e.key=null);let o=ci("value",e.value,r,n);if(o===yt)return yt;o===yr&&(e.value=null)}}return s}async function $u(t,e){let r=yx(e);Fe.isDocument(t)?await ui(null,t.contents,r,Object.freeze([t]))===yr&&(t.contents=null):await ui(null,t,r,Object.freeze([]))}$u.BREAK=yt;$u.SKIP=gx;$u.REMOVE=yr;async function ui(t,e,r,n){let s=await _x(t,e,r,n);if(Fe.isNode(s)||Fe.isPair(s))return bx(t,n,s),ui(t,s,r,n);if(typeof s!="symbol"){if(Fe.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=await ui(i,e.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===yt)return yt;o===yr&&(e.items.splice(i,1),i-=1)}}}else if(Fe.isPair(e)){n=Object.freeze(n.concat(e));let i=await ui("key",e.key,r,n);if(i===yt)return yt;i===yr&&(e.key=null);let o=await ui("value",e.value,r,n);if(o===yt)return yt;o===yr&&(e.value=null)}}return s}function yx(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function _x(t,e,r,n){if(typeof r=="function")return r(t,e,n);if(Fe.isMap(e))return r.Map?.(t,e,n);if(Fe.isSeq(e))return r.Seq?.(t,e,n);if(Fe.isPair(e))return r.Pair?.(t,e,n);if(Fe.isScalar(e))return r.Scalar?.(t,e,n);if(Fe.isAlias(e))return r.Alias?.(t,e,n)}function bx(t,e,r){let n=e[e.length-1];if(Fe.isCollection(n))n.items[t]=r;else if(Fe.isPair(n))t==="key"?n.key=r:n.value=r;else if(Fe.isDocument(n))n.contents=r;else{let s=Fe.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}Mp.visit=ku;Mp.visitAsync=$u});var Cp=w(vx=>{"use strict";var wx=le(),kz=Bo(),$z={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ez=t=>t.replace(/[!,[\]{}]/g,e=>$z[e]),Vo=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,o),!1}}default:return r(0,`Unknown directive ${s}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,n,s]=e.match(/^(.*!)([^!]*)$/s);s||r(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(o){return r(String(o)),null}return n==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,n]of Object.entries(this.tags))if(e.startsWith(n))return r+Ez(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(e&&n.length>0&&wx.isNode(e.contents)){let i={};kz.visit(e.contents,(o,a)=>{wx.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of n)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&r.push(`%TAG ${i} ${o}`);return r.join(`
|
|
10
|
+
`)}};Vo.defaultYaml={explicit:!1,version:"1.2"};Vo.defaultTags={"!!":"tag:yaml.org,2002:"};vx.Directives=Vo});var Eu=w(Ho=>{"use strict";var xx=le(),Tz=Bo();function Pz(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Sx(t){let e=new Set;return Tz.visit(t,{Value(r,n){n.anchor&&e.add(n.anchor)}}),e}function kx(t,e){for(let r=1;;++r){let n=`${t}${r}`;if(!e.has(n))return n}}function Oz(t,e){let r=[],n=new Map,s=null;return{onAnchor:i=>{r.push(i),s??(s=Sx(t));let o=kx(e,s);return s.add(o),o},setAnchors:()=>{for(let i of r){let o=n.get(i);if(typeof o=="object"&&o.anchor&&(xx.isScalar(o.node)||xx.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}Ho.anchorIsValid=Pz;Ho.anchorNames=Sx;Ho.createNodeAnchors=Oz;Ho.findNewAnchor=kx});var jp=w($x=>{"use strict";function Wo(t,e,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,i=n.length;s<i;++s){let o=n[s],a=Wo(t,n,String(s),o);a===void 0?delete n[s]:a!==o&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let i=n.get(s),o=Wo(t,n,s,i);o===void 0?n.delete(s):o!==i&&n.set(s,o)}else if(n instanceof Set)for(let s of Array.from(n)){let i=Wo(t,n,s,s);i===void 0?n.delete(s):i!==s&&(n.delete(s),n.add(i))}else for(let[s,i]of Object.entries(n)){let o=Wo(t,n,s,i);o===void 0?delete n[s]:o!==i&&(n[s]=o)}return t.call(e,r,n)}$x.applyReviver=Wo});var on=w(Tx=>{"use strict";var Iz=le();function Ex(t,e,r){if(Array.isArray(t))return t.map((n,s)=>Ex(n,String(s),r));if(t&&typeof t.toJSON=="function"){if(!r||!Iz.hasAnchor(t))return t.toJSON(e,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(t,n),r.onCreate=i=>{n.res=i,delete r.onCreate};let s=t.toJSON(e,r);return r.onCreate&&r.onCreate(s),s}return typeof t=="bigint"&&!r?.keep?Number(t):t}Tx.toJS=Ex});var Tu=w(Ox=>{"use strict";var Az=jp(),Px=le(),Nz=on(),Lp=class{constructor(e){Object.defineProperty(this,Px.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:i}={}){if(!Px.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=Nz.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:u}of o.anchors.values())s(u,c);return typeof i=="function"?Az.applyReviver(i,{"":a},"",a):a}};Ox.NodeBase=Lp});var Ko=w(Ix=>{"use strict";var Rz=Eu(),zz=Bo(),li=le(),Mz=Tu(),Cz=on(),qp=class extends Mz.NodeBase{constructor(e){super(li.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],zz.visit(e,{Node:(i,o)=>{(li.isAlias(o)||li.hasAnchor(o))&&n.push(o)}}),r&&(r.aliasResolveCache=n));let s;for(let i of n){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,r){if(!r)return{source:this.source};let{anchors:n,doc:s,maxAliasCount:i}=r,o=this.resolve(s,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=n.get(o);if(a||(Cz.toJS(o,null,r),a=n.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Pu(s,o,n)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,r,n){let s=`*${this.source}`;if(e){if(Rz.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function Pu(t,e,r){if(li.isAlias(e)){let n=e.resolve(t),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(li.isCollection(e)){let n=0;for(let s of e.items){let i=Pu(t,s,r);i>n&&(n=i)}return n}else if(li.isPair(e)){let n=Pu(t,e.key,r),s=Pu(t,e.value,r);return Math.max(n,s)}return 1}Ix.Alias=qp});var Ze=w(Dp=>{"use strict";var jz=le(),Lz=Tu(),qz=on(),Dz=t=>!t||typeof t!="function"&&typeof t!="object",an=class extends Lz.NodeBase{constructor(e){super(jz.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:qz.toJS(this.value,e,r)}toString(){return String(this.value)}};an.BLOCK_FOLDED="BLOCK_FOLDED";an.BLOCK_LITERAL="BLOCK_LITERAL";an.PLAIN="PLAIN";an.QUOTE_DOUBLE="QUOTE_DOUBLE";an.QUOTE_SINGLE="QUOTE_SINGLE";Dp.Scalar=an;Dp.isScalarValue=Dz});var Jo=w(Nx=>{"use strict";var Zz=Ko(),ts=le(),Ax=Ze(),Uz="tag:yaml.org,2002:";function Fz(t,e,r){if(e){let n=r.filter(i=>i.tag===e),s=n.find(i=>!i.format)??n[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return r.find(n=>n.identify?.(t)&&!n.format)}function Bz(t,e,r){if(ts.isDocument(t)&&(t=t.contents),ts.isNode(t))return t;if(ts.isPair(t)){let d=r.schema[ts.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=r,c;if(n&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=s(t)),new Zz.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Uz+e.slice(2));let u=Fz(t,e,o.tags);if(!u){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Ax.Scalar(t);return c&&(c.node=d),d}u=t instanceof Map?o[ts.MAP]:Symbol.iterator in Object(t)?o[ts.SEQ]:o[ts.MAP]}i&&(i(u),delete r.onTagObj);let l=u?.createNode?u.createNode(r.schema,t,r):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(r.schema,t,r):new Ax.Scalar(t);return e?l.tag=e:u.default||(l.tag=u.tag),c&&(c.node=l),l}Nx.createNode=Bz});var Iu=w(Ou=>{"use strict";var Vz=Jo(),_r=le(),Hz=Tu();function Zp(t,e,r){let n=r;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return Vz.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Rx=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Up=class extends Hz.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(n=>_r.isNode(n)||_r.isPair(n)?n.clone(e):n),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Rx(e))this.add(r);else{let[n,...s]=e,i=this.get(n,!0);if(_r.isCollection(i))i.addIn(s,r);else if(i===void 0&&this.schema)this.set(n,Zp(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(e){let[r,...n]=e;if(n.length===0)return this.delete(r);let s=this.get(r,!0);if(_r.isCollection(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(e,r){let[n,...s]=e,i=this.get(n,!0);return s.length===0?!r&&_r.isScalar(i)?i.value:i:_r.isCollection(i)?i.getIn(s,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!_r.isPair(r))return!1;let n=r.value;return n==null||e&&_r.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[r,...n]=e;if(n.length===0)return this.has(r);let s=this.get(r,!0);return _r.isCollection(s)?s.hasIn(n):!1}setIn(e,r){let[n,...s]=e;if(s.length===0)this.set(n,r);else{let i=this.get(n,!0);if(_r.isCollection(i))i.setIn(s,r);else if(i===void 0&&this.schema)this.set(n,Zp(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}};Ou.Collection=Up;Ou.collectionFromPath=Zp;Ou.isEmptyPath=Rx});var Go=w(Au=>{"use strict";var Wz=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Fp(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Kz=(t,e,r)=>t.endsWith(`
|
|
11
|
+
`)?Fp(r,e):r.includes(`
|
|
12
12
|
`)?`
|
|
13
|
-
`+
|
|
14
|
-
`)r===
|
|
13
|
+
`+Fp(r,e):(t.endsWith(" ")?"":" ")+r;Au.indentComment=Fp;Au.lineComment=Kz;Au.stringifyComment=Wz});var Mx=w(Yo=>{"use strict";var Jz="flow",Bp="block",Nu="quoted";function Gz(t,e,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let c=Math.max(1+i,1+s-e.length);if(t.length<=c)return t;let u=[],l={},d=s-e.length;typeof n=="number"&&(n>s-Math.max(2,i)?u.push(0):d=s-n);let f,p,m=!1,h=-1,g=-1,y=-1;r===Bp&&(h=zx(t,h,e.length),h!==-1&&(d=h+c));for(let v;v=t[h+=1];){if(r===Nu&&v==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(v===`
|
|
14
|
+
`)r===Bp&&(h=zx(t,h,e.length)),d=h+e.length+c,f=void 0;else{if(v===" "&&p&&p!==" "&&p!==`
|
|
15
15
|
`&&p!==" "){let k=t[h+1];k&&k!==" "&&k!==`
|
|
16
|
-
`&&k!==" "&&(f=h)}if(h>=d)if(f)u.push(f),d=f+c,f=void 0;else if(r===
|
|
17
|
-
${e}${t.slice(0,E)}`:(r===
|
|
18
|
-
${e}${t.slice(k+1,E)}`)}return _}function
|
|
19
|
-
`);n=e,s=e+1,i=t[s]}return n}
|
|
20
|
-
`){if(i-o>n)return!0;if(o=i+1,s-o<=n)return!1}return!0}function
|
|
16
|
+
`&&k!==" "&&(f=h)}if(h>=d)if(f)u.push(f),d=f+c,f=void 0;else if(r===Nu){for(;p===" "||p===" ";)p=v,v=t[h+=1],m=!0;let k=h>y+1?h-2:g-1;if(l[k])return t;u.push(k),l[k]=!0,d=k+c,f=void 0}else m=!0}p=v}if(m&&a&&a(),u.length===0)return t;o&&o();let _=t.slice(0,u[0]);for(let v=0;v<u.length;++v){let k=u[v],E=u[v+1]||t.length;k===0?_=`
|
|
17
|
+
${e}${t.slice(0,E)}`:(r===Nu&&l[k]&&(_+=`${t[k]}\\`),_+=`
|
|
18
|
+
${e}${t.slice(k+1,E)}`)}return _}function zx(t,e,r){let n=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+r)i=t[++e];else{do i=t[++e];while(i&&i!==`
|
|
19
|
+
`);n=e,s=e+1,i=t[s]}return n}Yo.FOLD_BLOCK=Bp;Yo.FOLD_FLOW=Jz;Yo.FOLD_QUOTED=Nu;Yo.foldFlowLines=Gz});var Qo=w(Cx=>{"use strict";var nr=Ze(),cn=Mx(),zu=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Mu=t=>/^(%|---|\.\.\.)/m.test(t);function Yz(t,e,r){if(!e||e<0)return!1;let n=e-r,s=t.length;if(s<=n)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
|
|
20
|
+
`){if(i-o>n)return!0;if(o=i+1,s-o<=n)return!1}return!0}function Xo(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Mu(t)?" ":""),o="",a=0;for(let c=0,u=r[c];u;u=r[++c])if(u===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(a,c)+"\\ ",c+=1,a=c,u="\\"),u==="\\")switch(r[c+1]){case"u":{o+=r.slice(a,c);let l=r.substr(c+2,4);switch(l){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:l.substr(0,2)==="00"?o+="\\x"+l.substr(2):o+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(n||r[c+2]==='"'||r.length<s)c+=1;else{for(o+=r.slice(a,c)+`
|
|
21
21
|
|
|
22
22
|
`;r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"';)o+=`
|
|
23
|
-
`,c+=2;o+=i,r[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+r.slice(a):r,n?o:
|
|
24
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
25
|
-
${r}`)+"'";return e.implicitKey?n:
|
|
23
|
+
`,c+=2;o+=i,r[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+r.slice(a):r,n?o:cn.foldFlowLines(o,i,cn.FOLD_QUOTED,zu(e,!1))}function Vp(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
24
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return Xo(t,e);let r=e.indent||(Mu(t)?" ":""),n="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
25
|
+
${r}`)+"'";return e.implicitKey?n:cn.foldFlowLines(n,r,cn.FOLD_FLOW,zu(e,!1))}function di(t,e){let{singleQuote:r}=e.options,n;if(r===!1)n=Xo;else{let s=t.includes('"'),i=t.includes("'");s&&!i?n=Vp:i&&!s?n=Xo:n=r?Vp:Xo}return n(t,e)}var Hp;try{Hp=new RegExp(`(^|(?<!
|
|
26
26
|
))
|
|
27
27
|
+(?!
|
|
28
|
-
|$)`,"g")}catch{
|
|
28
|
+
|$)`,"g")}catch{Hp=/\n+(?!\n|$)/g}function Ru({comment:t,type:e,value:r},n,s,i){let{blockQuote:o,commentString:a,lineWidth:c}=n.options;if(!o||/\n[\t ]+$/.test(r))return di(r,n);let u=n.indent||(n.forceBlockIndent||Mu(r)?" ":""),l=o==="literal"?!0:o==="folded"||e===nr.Scalar.BLOCK_FOLDED?!1:e===nr.Scalar.BLOCK_LITERAL?!0:!Yz(r,c,u.length);if(!r)return l?`|
|
|
29
29
|
`:`>
|
|
30
30
|
`;let d,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
|
|
31
31
|
`&&E!==" "&&E!==" ")break}let p=r.substring(f),m=p.indexOf(`
|
|
32
32
|
`);m===-1?d="-":r===p||m!==p.length-1?(d="+",i&&i()):d="",p&&(r=r.slice(0,-p.length),p[p.length-1]===`
|
|
33
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
33
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Hp,`$&${u}`));let h=!1,g,y=-1;for(g=0;g<r.length;++g){let E=r[g];if(E===" ")h=!0;else if(E===`
|
|
34
34
|
`)y=g;else break}let _=r.substring(0,y<g?y+1:g);_&&(r=r.substring(_.length),_=_.replace(/\n+/g,`$&${u}`));let k=(h?u?"2":"1":"")+d;if(t&&(k+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!l){let E=r.replace(/\n+/g,`
|
|
35
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),C=!1,B=
|
|
35
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),C=!1,B=zu(n,!0);o!=="folded"&&e!==nr.Scalar.BLOCK_FOLDED&&(B.onOverflow=()=>{C=!0});let R=cn.foldFlowLines(`${_}${E}${p}`,u,cn.FOLD_BLOCK,B);if(!C)return`>${k}
|
|
36
36
|
${u}${R}`}return r=r.replace(/\n+/g,`$&${u}`),`|${k}
|
|
37
|
-
${u}${_}${r}${p}`}function
|
|
38
|
-
`)||l&&/[[\]{},]/.test(i))return
|
|
39
|
-
`)?
|
|
40
|
-
`))return
|
|
41
|
-
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(f)||p?.some(f))return
|
|
42
|
-
${e.indent}${a}`:a}
|
|
43
|
-
${a}:`):(g=`${g}:`,f&&(g+=
|
|
37
|
+
${u}${_}${r}${p}`}function Xz(t,e,r,n){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:c,indentStep:u,inFlow:l}=e;if(a&&i.includes(`
|
|
38
|
+
`)||l&&/[[\]{},]/.test(i))return di(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||l||!i.includes(`
|
|
39
|
+
`)?di(i,e):Ru(t,e,r,n);if(!a&&!l&&s!==nr.Scalar.PLAIN&&i.includes(`
|
|
40
|
+
`))return Ru(t,e,r,n);if(Mu(i)){if(c==="")return e.forceBlockIndent=!0,Ru(t,e,r,n);if(a&&c===u)return di(i,e)}let d=i.replace(/\n+/g,`$&
|
|
41
|
+
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(f)||p?.some(f))return di(i,e)}return a?d:cn.foldFlowLines(d,c,cn.FOLD_FLOW,zu(e,!1))}function Qz(t,e,r,n){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==nr.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=nr.Scalar.QUOTE_DOUBLE);let c=l=>{switch(l){case nr.Scalar.BLOCK_FOLDED:case nr.Scalar.BLOCK_LITERAL:return s||i?di(o.value,e):Ru(o,e,r,n);case nr.Scalar.QUOTE_DOUBLE:return Xo(o.value,e);case nr.Scalar.QUOTE_SINGLE:return Vp(o.value,e);case nr.Scalar.PLAIN:return Xz(o,e,r,n);default:return null}},u=c(a);if(u===null){let{defaultKeyType:l,defaultStringType:d}=e.options,f=s&&l||d;if(u=c(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}Cx.stringifyString=Qz});var ea=w(Wp=>{"use strict";var eM=Eu(),un=le(),tM=Go(),rM=Qo();function nM(t,e){let r=Object.assign({blockQuote:!0,commentString:tM.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function sM(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let r,n;if(un.isScalar(e)){n=e.value;let s=t.filter(i=>i.identify?.(n));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}r=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else n=e,r=t.find(s=>s.nodeClass&&n instanceof s.nodeClass);if(!r){let s=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${s} value`)}return r}function iM(t,e,{anchors:r,doc:n}){if(!n.directives)return"";let s=[],i=(un.isScalar(t)||un.isCollection(t))&&t.anchor;i&&eM.anchorIsValid(i)&&(r.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(n.directives.tagString(o)),s.join(" ")}function oM(t,e,r,n){if(un.isPair(t))return t.toString(e,r,n);if(un.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=un.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>s=c});s??(s=sM(e.doc.schema.tags,i));let o=iM(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,r,n):un.isScalar(i)?rM.stringifyString(i,e,r,n):i.toString(e,r,n);return o?un.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
42
|
+
${e.indent}${a}`:a}Wp.createStringifyContext=nM;Wp.stringify=oM});var Dx=w(qx=>{"use strict";var jr=le(),jx=Ze(),Lx=ea(),ta=Go();function aM({key:t,value:e},r,n,s){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:u,indentSeq:l,simpleKeys:d}}=r,f=jr.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(jr.isCollection(t)||!jr.isNode(t)&&typeof t=="object"){let B="With simple keys, collection cannot be used as a key value";throw new Error(B)}}let p=!d&&(!t||f&&e==null&&!r.inFlow||jr.isCollection(t)||(jr.isScalar(t)?t.type===jx.Scalar.BLOCK_FOLDED||t.type===jx.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+c});let m=!1,h=!1,g=Lx.stringify(t,r,()=>m=!0,()=>h=!0);if(!p&&!r.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(i||e==null)return m&&n&&n(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,f&&!m?g+=ta.lineComment(g,r.indent,u(f)):h&&s&&s(),g;m&&(f=null),p?(f&&(g+=ta.lineComment(g,r.indent,u(f))),g=`? ${g}
|
|
43
|
+
${a}:`):(g=`${g}:`,f&&(g+=ta.lineComment(g,r.indent,u(f))));let y,_,v;jr.isNode(e)?(y=!!e.spaceBefore,_=e.commentBefore,v=e.comment):(y=!1,_=null,v=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!p&&!f&&jr.isScalar(e)&&(r.indentAtStart=g.length+1),h=!1,!l&&c.length>=2&&!r.inFlow&&!p&&jr.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let k=!1,E=Lx.stringify(e,r,()=>k=!0,()=>h=!0),C=" ";if(f||y||_){if(C=y?`
|
|
44
44
|
`:"",_){let B=u(_);C+=`
|
|
45
|
-
${
|
|
45
|
+
${ta.indentComment(B,r.indent)}`}E===""&&!r.inFlow?C===`
|
|
46
46
|
`&&v&&(C=`
|
|
47
47
|
|
|
48
48
|
`):C+=`
|
|
49
|
-
${r.indent}`}else if(!p&&
|
|
49
|
+
${r.indent}`}else if(!p&&jr.isCollection(e)){let B=E[0],R=E.indexOf(`
|
|
50
50
|
`),ue=R!==-1,I=r.inFlow??e.flow??e.items.length===0;if(ue||!I){let K=!1;if(ue&&(B==="&"||B==="!")){let J=E.indexOf(" ");B==="&"&&J!==-1&&J<R&&E[J+1]==="!"&&(J=E.indexOf(" ",J+1)),(J===-1||R<J)&&(K=!0)}K||(C=`
|
|
51
51
|
${r.indent}`)}}else(E===""||E[0]===`
|
|
52
|
-
`)&&(C="");return g+=C+E,r.inFlow?k&&n&&n():v&&!k?g+=
|
|
52
|
+
`)&&(C="");return g+=C+E,r.inFlow?k&&n&&n():v&&!k?g+=ta.lineComment(g,r.indent,u(v)):h&&s&&s(),g}qx.stringifyPair=aM});var Jp=w(Kp=>{"use strict";var Zx=ke("process");function cM(t,...e){t==="debug"&&console.log(...e)}function uM(t,e){(t==="debug"||t==="warn")&&(typeof Zx.emitWarning=="function"?Zx.emitWarning(e):console.warn(e))}Kp.debug=cM;Kp.warn=uM});var Du=w(qu=>{"use strict";var Lu=le(),Ux=Ze(),Cu="<<",ju={identify:t=>t===Cu||typeof t=="symbol"&&t.description===Cu,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ux.Scalar(Symbol(Cu)),{addToJSMap:Fx}),stringify:()=>Cu},lM=(t,e)=>(ju.identify(e)||Lu.isScalar(e)&&(!e.type||e.type===Ux.Scalar.PLAIN)&&ju.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===ju.tag&&r.default);function Fx(t,e,r){let n=Bx(t,r);if(Lu.isSeq(n))for(let s of n.items)Gp(t,e,s);else if(Array.isArray(n))for(let s of n)Gp(t,e,s);else Gp(t,e,n)}function Gp(t,e,r){let n=Bx(t,r);if(!Lu.isMap(n))throw new Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function Bx(t,e){return t&&Lu.isAlias(e)?e.resolve(t.doc,t):e}qu.addMergeToJSMap=Fx;qu.isMergeKey=lM;qu.merge=ju});var Xp=w(Wx=>{"use strict";var dM=Jp(),Vx=Du(),fM=ea(),Hx=le(),Yp=on();function pM(t,e,{key:r,value:n}){if(Hx.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,n);else if(Vx.isMergeKey(t,r))Vx.addMergeToJSMap(t,e,n);else{let s=Yp.toJS(r,"",t);if(e instanceof Map)e.set(s,Yp.toJS(n,s,t));else if(e instanceof Set)e.add(s);else{let i=hM(r,s,t),o=Yp.toJS(n,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function hM(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(Hx.isNode(t)&&r?.doc){let n=fM.createStringifyContext(r.doc,{});n.anchors=new Set;for(let i of r.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=t.toString(n);if(!r.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),dM.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return s}return JSON.stringify(e)}Wx.addPairToJSMap=pM});var ln=w(Qp=>{"use strict";var Kx=Jo(),mM=Dx(),gM=Xp(),Zu=le();function yM(t,e,r){let n=Kx.createNode(t,void 0,r),s=Kx.createNode(e,void 0,r);return new Uu(n,s)}var Uu=class t{constructor(e,r=null){Object.defineProperty(this,Zu.NODE_TYPE,{value:Zu.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:n}=this;return Zu.isNode(r)&&(r=r.clone(e)),Zu.isNode(n)&&(n=n.clone(e)),new t(r,n)}toJSON(e,r){let n=r?.mapAsMap?new Map:{};return gM.addPairToJSMap(r,n,this)}toString(e,r,n){return e?.doc?mM.stringifyPair(this,e,r,n):JSON.stringify(this)}};Qp.Pair=Uu;Qp.createPair=yM});var eh=w(Gx=>{"use strict";var rs=le(),Jx=ea(),Fu=Go();function _M(t,e,r){return(e.inFlow??t.flow?wM:bM)(t,e,r)}function bM({comment:t,items:e},r,{blockItemPrefix:n,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:u}}=r,l=Object.assign({},r,{indent:i,type:null}),d=!1,f=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(rs.isNode(h))!d&&h.spaceBefore&&f.push(""),Bu(r,f,h.commentBefore,d),h.comment&&(g=h.comment);else if(rs.isPair(h)){let _=rs.isNode(h.key)?h.key:null;_&&(!d&&_.spaceBefore&&f.push(""),Bu(r,f,_.commentBefore,d))}d=!1;let y=Jx.stringify(h,l,()=>g=null,()=>d=!0);g&&(y+=Fu.lineComment(y,i,u(g))),d&&g&&(d=!1),f.push(n+y)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let m=1;m<f.length;++m){let h=f[m];p+=h?`
|
|
53
53
|
${c}${h}`:`
|
|
54
54
|
`}}return t?(p+=`
|
|
55
|
-
`+
|
|
56
|
-
`)),m<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(u||(u=d.reduce((_,v)=>_+v.length+2,2)+(y.length+2)>e.options.lineWidth)),u&&(y+=",")),g&&(y+=
|
|
55
|
+
`+Fu.indentComment(u(t),c),a&&a()):d&&o&&o(),p}function wM({items:t},e,{flowChars:r,itemIndent:n}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;n+=i;let c=Object.assign({},e,{indent:n,inFlow:!0,type:null}),u=!1,l=0,d=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(rs.isNode(h))h.spaceBefore&&d.push(""),Bu(e,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(rs.isPair(h)){let _=rs.isNode(h.key)?h.key:null;_&&(_.spaceBefore&&d.push(""),Bu(e,d,_.commentBefore,!1),_.comment&&(u=!0));let v=rs.isNode(h.value)?h.value:null;v?(v.comment&&(g=v.comment),v.commentBefore&&(u=!0)):h.value==null&&_?.comment&&(g=_.comment)}g&&(u=!0);let y=Jx.stringify(h,c,()=>g=null);u||(u=d.length>l||y.includes(`
|
|
56
|
+
`)),m<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(u||(u=d.reduce((_,v)=>_+v.length+2,2)+(y.length+2)>e.options.lineWidth)),u&&(y+=",")),g&&(y+=Fu.lineComment(y,n,a(g))),d.push(y),l=d.length}let{start:f,end:p}=r;if(d.length===0)return f+p;if(!u){let m=d.reduce((h,g)=>h+g.length+2,2);u=e.options.lineWidth>0&&m>e.options.lineWidth}if(u){let m=f;for(let h of d)m+=h?`
|
|
57
57
|
${i}${s}${h}`:`
|
|
58
58
|
`;return`${m}
|
|
59
|
-
${s}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function
|
|
60
|
-
`:" ")}return
|
|
59
|
+
${s}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function Bu({indent:t,options:{commentString:e}},r,n,s){if(n&&s&&(n=n.replace(/^\n+/,"")),n){let i=Fu.indentComment(e(n),t);r.push(i.trimStart())}}Gx.stringifyCollection=_M});var fn=w(rh=>{"use strict";var vM=eh(),xM=Xp(),SM=Iu(),dn=le(),Vu=ln(),kM=Ze();function ra(t,e){let r=dn.isScalar(e)?e.value:e;for(let n of t)if(dn.isPair(n)&&(n.key===e||n.key===r||dn.isScalar(n.key)&&n.key.value===r))return n}var th=class extends SM.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(dn.MAP,e),this.items=[]}static from(e,r,n){let{keepUndefined:s,replacer:i}=n,o=new this(e),a=(c,u)=>{if(typeof i=="function")u=i.call(r,c,u);else if(Array.isArray(i)&&!i.includes(c))return;(u!==void 0||s)&&o.items.push(Vu.createPair(c,u,n))};if(r instanceof Map)for(let[c,u]of r)a(c,u);else if(r&&typeof r=="object")for(let c of Object.keys(r))a(c,r[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let n;dn.isPair(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new Vu.Pair(e,e?.value):n=new Vu.Pair(e.key,e.value);let s=ra(this.items,n.key),i=this.schema?.sortMapEntries;if(s){if(!r)throw new Error(`Key ${n.key} already set`);dn.isScalar(s.value)&&kM.isScalarValue(n.value)?s.value.value=n.value:s.value=n.value}else if(i){let o=this.items.findIndex(a=>i(n,a)<0);o===-1?this.items.push(n):this.items.splice(o,0,n)}else this.items.push(n)}delete(e){let r=ra(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let s=ra(this.items,e)?.value;return(!r&&dn.isScalar(s)?s.value:s)??void 0}has(e){return!!ra(this.items,e)}set(e,r){this.add(new Vu.Pair(e,r),!0)}toJSON(e,r,n){let s=n?new n:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(s);for(let i of this.items)xM.addPairToJSMap(r,s,i);return s}toString(e,r,n){if(!e)return JSON.stringify(this);for(let s of this.items)if(!dn.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),vM.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:r})}};rh.YAMLMap=th;rh.findPair=ra});var fi=w(Xx=>{"use strict";var $M=le(),Yx=fn(),EM={collection:"map",default:!0,nodeClass:Yx.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return $M.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>Yx.YAMLMap.from(t,e,r)};Xx.map=EM});var pn=w(Qx=>{"use strict";var TM=Jo(),PM=eh(),OM=Iu(),Wu=le(),IM=Ze(),AM=on(),nh=class extends OM.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Wu.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=Hu(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let n=Hu(e);if(typeof n!="number")return;let s=this.items[n];return!r&&Wu.isScalar(s)?s.value:s}has(e){let r=Hu(e);return typeof r=="number"&&r<this.items.length}set(e,r){let n=Hu(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[n];Wu.isScalar(s)&&IM.isScalarValue(r)?s.value=r:this.items[n]=r}toJSON(e,r){let n=[];r?.onCreate&&r.onCreate(n);let s=0;for(let i of this.items)n.push(AM.toJS(i,String(s++),r));return n}toString(e,r,n){return e?PM.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:r}):JSON.stringify(this)}static from(e,r,n){let{replacer:s}=n,i=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let a of r){if(typeof s=="function"){let c=r instanceof Set?a:String(o++);a=s.call(r,c,a)}i.items.push(TM.createNode(a,void 0,n))}}return i}};function Hu(t){let e=Wu.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Qx.YAMLSeq=nh});var pi=w(tS=>{"use strict";var NM=le(),eS=pn(),RM={collection:"seq",default:!0,nodeClass:eS.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return NM.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>eS.YAMLSeq.from(t,e,r)};tS.seq=RM});var na=w(rS=>{"use strict";var zM=Qo(),MM={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,n){return e=Object.assign({actualString:!0},e),zM.stringifyString(t,e,r,n)}};rS.string=MM});var Ku=w(iS=>{"use strict";var nS=Ze(),sS={identify:t=>t==null,createNode:()=>new nS.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new nS.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&sS.test.test(t)?t:e.options.nullStr};iS.nullTag=sS});var sh=w(aS=>{"use strict";var CM=Ze(),oS={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new CM.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&oS.test.test(t)){let n=t[0]==="t"||t[0]==="T";if(e===n)return t}return e?r.options.trueStr:r.options.falseStr}};aS.boolTag=oS});var hi=w(cS=>{"use strict";function jM({format:t,minFractionDigits:e,tag:r,value:n}){if(typeof n=="bigint")return String(n);let s=typeof n=="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}cS.stringifyNumber=jM});var oh=w(Ju=>{"use strict";var LM=Ze(),ih=hi(),qM={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ih.stringifyNumber},DM={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():ih.stringifyNumber(t)}},ZM={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new LM.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:ih.stringifyNumber};Ju.float=ZM;Ju.floatExp=DM;Ju.floatNaN=qM});var ch=w(Yu=>{"use strict";var uS=hi(),Gu=t=>typeof t=="bigint"||Number.isInteger(t),ah=(t,e,r,{intAsBigInt:n})=>n?BigInt(t):parseInt(t.substring(e),r);function lS(t,e,r){let{value:n}=t;return Gu(n)&&n>=0?r+n.toString(e):uS.stringifyNumber(t)}var UM={identify:t=>Gu(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>ah(t,2,8,r),stringify:t=>lS(t,8,"0o")},FM={identify:Gu,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>ah(t,0,10,r),stringify:uS.stringifyNumber},BM={identify:t=>Gu(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>ah(t,2,16,r),stringify:t=>lS(t,16,"0x")};Yu.int=FM;Yu.intHex=BM;Yu.intOct=UM});var fS=w(dS=>{"use strict";var VM=fi(),HM=Ku(),WM=pi(),KM=na(),JM=sh(),uh=oh(),lh=ch(),GM=[VM.map,WM.seq,KM.string,HM.nullTag,JM.boolTag,lh.intOct,lh.int,lh.intHex,uh.floatNaN,uh.floatExp,uh.float];dS.schema=GM});var mS=w(hS=>{"use strict";var YM=Ze(),XM=fi(),QM=pi();function pS(t){return typeof t=="bigint"||Number.isInteger(t)}var Xu=({value:t})=>JSON.stringify(t),eC=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Xu},{identify:t=>t==null,createNode:()=>new YM.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Xu},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Xu},{identify:pS,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>pS(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Xu}],tC={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},rC=[XM.map,QM.seq].concat(eC,tC);hS.schema=rC});var fh=w(gS=>{"use strict";var sa=ke("buffer"),dh=Ze(),nC=Qo(),sC={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof sa.Buffer=="function")return sa.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let s=0;s<r.length;++s)n[s]=r.charCodeAt(s);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},n,s,i){if(!r)return"";let o=r,a;if(typeof sa.Buffer=="function")a=o instanceof sa.Buffer?o.toString("base64"):sa.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let u=0;u<o.length;++u)c+=String.fromCharCode(o[u]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=dh.Scalar.BLOCK_LITERAL),e!==dh.Scalar.QUOTE_DOUBLE){let c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),u=Math.ceil(a.length/c),l=new Array(u);for(let d=0,f=0;d<u;++d,f+=c)l[d]=a.substr(f,c);a=l.join(e===dh.Scalar.BLOCK_LITERAL?`
|
|
60
|
+
`:" ")}return nC.stringifyString({comment:t,type:e,value:a},n,s,i)}};gS.binary=sC});var tl=w(el=>{"use strict";var Qu=le(),ph=ln(),iC=Ze(),oC=pn();function yS(t,e){if(Qu.isSeq(t))for(let r=0;r<t.items.length;++r){let n=t.items[r];if(!Qu.isPair(n)){if(Qu.isMap(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");let s=n.items[0]||new ph.Pair(new iC.Scalar(null));if(n.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
|
|
61
61
|
${s.key.commentBefore}`:n.commentBefore),n.comment){let i=s.value??s.key;i.comment=i.comment?`${n.comment}
|
|
62
|
-
${i.comment}`:n.comment}n=s}t.items[r]=Xu.isPair(n)?n:new fh.Pair(n)}}else e("Expected a sequence for this tag");return t}function yS(t,e,r){let{replacer:n}=r,s=new iC.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let u=Object.keys(o);if(u.length===1)a=u[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=o;s.items.push(fh.createPair(a,c,r))}return s}var oC={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:gS,createNode:yS};Qu.createPairs=yS;Qu.pairs=oC;Qu.resolvePairs=gS});var mh=w(hh=>{"use strict";var _S=le(),ph=sn(),sa=dn(),aC=fn(),bS=el(),rs=class t extends aC.YAMLSeq{constructor(){super(),this.add=sa.YAMLMap.prototype.add.bind(this),this.delete=sa.YAMLMap.prototype.delete.bind(this),this.get=sa.YAMLMap.prototype.get.bind(this),this.has=sa.YAMLMap.prototype.has.bind(this),this.set=sa.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let n=new Map;r?.onCreate&&r.onCreate(n);for(let s of this.items){let i,o;if(_S.isPair(s)?(i=ph.toJS(s.key,"",r),o=ph.toJS(s.value,i,r)):i=ph.toJS(s,"",r),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,r,n){let s=bS.createPairs(e,r,n),i=new this;return i.items=s.items,i}};rs.tag="tag:yaml.org,2002:omap";var cC={collection:"seq",identify:t=>t instanceof Map,nodeClass:rs,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=bS.resolvePairs(t,e),n=[];for(let{key:s}of r.items)_S.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new rs,r)},createNode:(t,e,r)=>rs.from(t,e,r)};hh.YAMLOMap=rs;hh.omap=cC});var kS=w(gh=>{"use strict";var wS=De();function vS({value:t,source:e},r){return e&&(t?xS:SS).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var xS={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new wS.Scalar(!0),stringify:vS},SS={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new wS.Scalar(!1),stringify:vS};gh.falseTag=SS;gh.trueTag=xS});var $S=w(tl=>{"use strict";var uC=De(),yh=pi(),lC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:yh.stringifyNumber},dC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():yh.stringifyNumber(t)}},fC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new uC.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let n=t.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:yh.stringifyNumber};tl.float=fC;tl.floatExp=dC;tl.floatNaN=lC});var TS=w(oa=>{"use strict";var ES=pi(),ia=t=>typeof t=="bigint"||Number.isInteger(t);function rl(t,e,r,{intAsBigInt:n}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,r);return s==="-"?-1*i:i}function _h(t,e,r){let{value:n}=t;if(ia(n)){let s=n.toString(e);return n<0?"-"+r+s.substr(1):r+s}return ES.stringifyNumber(t)}var pC={identify:ia,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>rl(t,2,2,r),stringify:t=>_h(t,2,"0b")},hC={identify:ia,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>rl(t,1,8,r),stringify:t=>_h(t,8,"0")},mC={identify:ia,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>rl(t,0,10,r),stringify:ES.stringifyNumber},gC={identify:ia,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>rl(t,2,16,r),stringify:t=>_h(t,16,"0x")};oa.int=mC;oa.intBin=pC;oa.intHex=gC;oa.intOct=hC});var wh=w(bh=>{"use strict";var il=le(),nl=un(),sl=dn(),ns=class t extends sl.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;il.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new nl.Pair(e.key,null):r=new nl.Pair(e,null),sl.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let n=sl.findPair(this.items,e);return!r&&il.isPair(n)?il.isScalar(n.key)?n.key.value:n.key:n}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=sl.findPair(this.items,e);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new nl.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(e,r,n){let{replacer:s}=n,i=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof s=="function"&&(o=s.call(r,o,o)),i.items.push(nl.createPair(o,null,n));return i}};ns.tag="tag:yaml.org,2002:set";var yC={collection:"map",identify:t=>t instanceof Set,nodeClass:ns,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>ns.from(t,e,r),resolve(t,e){if(il.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ns,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};bh.YAMLSet=ns;bh.set=yC});var xh=w(ol=>{"use strict";var _C=pi();function vh(t,e){let r=t[0],n=r==="-"||r==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return r==="-"?s(-1)*i:i}function PS(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return _C.stringifyNumber(t);let n="";e<0&&(n="-",e*=r(-1));let s=r(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),n+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var bC={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>vh(t,r),stringify:PS},wC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>vh(t,!1),stringify:PS},OS={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(OS.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,u=Date.UTC(r,n-1,s,i||0,o||0,a||0,c),l=e[8];if(l&&l!=="Z"){let d=vh(l,!1);Math.abs(d)<30&&(d*=60),u-=6e4*d}return new Date(u)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ol.floatTime=wC;ol.intTime=bC;ol.timestamp=OS});var NS=w(AS=>{"use strict";var vC=di(),xC=Wu(),SC=fi(),kC=ra(),$C=dh(),IS=kS(),Sh=$S(),al=TS(),EC=qu(),TC=mh(),PC=el(),OC=wh(),kh=xh(),IC=[vC.map,SC.seq,kC.string,xC.nullTag,IS.trueTag,IS.falseTag,al.intBin,al.intOct,al.int,al.intHex,Sh.floatNaN,Sh.floatExp,Sh.float,$C.binary,EC.merge,TC.omap,PC.pairs,OC.set,kh.intTime,kh.floatTime,kh.timestamp];AS.schema=IC});var US=w(Th=>{"use strict";var CS=di(),AC=Wu(),jS=fi(),NC=ra(),RC=nh(),$h=ih(),Eh=ah(),zC=dS(),MC=hS(),LS=dh(),aa=qu(),qS=mh(),DS=el(),RS=NS(),ZS=wh(),cl=xh(),zS=new Map([["core",zC.schema],["failsafe",[CS.map,jS.seq,NC.string]],["json",MC.schema],["yaml11",RS.schema],["yaml-1.1",RS.schema]]),MS={binary:LS.binary,bool:RC.boolTag,float:$h.float,floatExp:$h.floatExp,floatNaN:$h.floatNaN,floatTime:cl.floatTime,int:Eh.int,intHex:Eh.intHex,intOct:Eh.intOct,intTime:cl.intTime,map:CS.map,merge:aa.merge,null:AC.nullTag,omap:qS.omap,pairs:DS.pairs,seq:jS.seq,set:ZS.set,timestamp:cl.timestamp},CC={"tag:yaml.org,2002:binary":LS.binary,"tag:yaml.org,2002:merge":aa.merge,"tag:yaml.org,2002:omap":qS.omap,"tag:yaml.org,2002:pairs":DS.pairs,"tag:yaml.org,2002:set":ZS.set,"tag:yaml.org,2002:timestamp":cl.timestamp};function jC(t,e,r){let n=zS.get(e);if(n&&!t)return r&&!n.includes(aa.merge)?n.concat(aa.merge):n.slice();let s=n;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(zS.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return r&&(s=s.concat(aa.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?MS[o]:o;if(!a){let c=JSON.stringify(o),u=Object.keys(MS).map(l=>JSON.stringify(l)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return i.includes(a)||i.push(a),i},[])}Th.coreKnownTags=CC;Th.getTags=jC});var Ih=w(FS=>{"use strict";var Ph=le(),LC=di(),qC=fi(),DC=ra(),ul=US(),ZC=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Oh=class t{constructor({compat:e,customTags:r,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ul.getTags(e,"compat"):e?ul.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?ul.coreKnownTags:{},this.tags=ul.getTags(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,Ph.MAP,{value:LC.map}),Object.defineProperty(this,Ph.SCALAR,{value:DC.string}),Object.defineProperty(this,Ph.SEQ,{value:qC.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ZC:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};FS.Schema=Oh});var VS=w(BS=>{"use strict";var UC=le(),Ah=Qo(),ca=Jo();function FC(t,e){let r=[],n=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),n=!0):t.directives.docStart&&(n=!0)}n&&r.push("---");let s=Ah.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=i(t.commentBefore);r.unshift(ca.indentComment(c,""))}let o=!1,a=null;if(t.contents){if(UC.isNode(t.contents)){if(t.contents.spaceBefore&&n&&r.push(""),t.contents.commentBefore){let l=i(t.contents.commentBefore);r.push(ca.indentComment(l,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,u=Ah.stringify(t.contents,s,()=>a=null,c);a&&(u+=ca.lineComment(u,"",i(a))),(u[0]==="|"||u[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${u}`:r.push(u)}else r.push(Ah.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let c=i(t.comment);c.includes(`
|
|
63
|
-
`)?(r.push("..."),r.push(
|
|
62
|
+
${i.comment}`:n.comment}n=s}t.items[r]=Qu.isPair(n)?n:new ph.Pair(n)}}else e("Expected a sequence for this tag");return t}function _S(t,e,r){let{replacer:n}=r,s=new oC.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let u=Object.keys(o);if(u.length===1)a=u[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=o;s.items.push(ph.createPair(a,c,r))}return s}var aC={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:yS,createNode:_S};el.createPairs=_S;el.pairs=aC;el.resolvePairs=yS});var gh=w(mh=>{"use strict";var bS=le(),hh=on(),ia=fn(),cC=pn(),wS=tl(),ns=class t extends cC.YAMLSeq{constructor(){super(),this.add=ia.YAMLMap.prototype.add.bind(this),this.delete=ia.YAMLMap.prototype.delete.bind(this),this.get=ia.YAMLMap.prototype.get.bind(this),this.has=ia.YAMLMap.prototype.has.bind(this),this.set=ia.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let n=new Map;r?.onCreate&&r.onCreate(n);for(let s of this.items){let i,o;if(bS.isPair(s)?(i=hh.toJS(s.key,"",r),o=hh.toJS(s.value,i,r)):i=hh.toJS(s,"",r),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,r,n){let s=wS.createPairs(e,r,n),i=new this;return i.items=s.items,i}};ns.tag="tag:yaml.org,2002:omap";var uC={collection:"seq",identify:t=>t instanceof Map,nodeClass:ns,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=wS.resolvePairs(t,e),n=[];for(let{key:s}of r.items)bS.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new ns,r)},createNode:(t,e,r)=>ns.from(t,e,r)};mh.YAMLOMap=ns;mh.omap=uC});var $S=w(yh=>{"use strict";var vS=Ze();function xS({value:t,source:e},r){return e&&(t?SS:kS).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var SS={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new vS.Scalar(!0),stringify:xS},kS={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new vS.Scalar(!1),stringify:xS};yh.falseTag=kS;yh.trueTag=SS});var ES=w(rl=>{"use strict";var lC=Ze(),_h=hi(),dC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:_h.stringifyNumber},fC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():_h.stringifyNumber(t)}},pC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new lC.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let n=t.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:_h.stringifyNumber};rl.float=pC;rl.floatExp=fC;rl.floatNaN=dC});var PS=w(aa=>{"use strict";var TS=hi(),oa=t=>typeof t=="bigint"||Number.isInteger(t);function nl(t,e,r,{intAsBigInt:n}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,r);return s==="-"?-1*i:i}function bh(t,e,r){let{value:n}=t;if(oa(n)){let s=n.toString(e);return n<0?"-"+r+s.substr(1):r+s}return TS.stringifyNumber(t)}var hC={identify:oa,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>nl(t,2,2,r),stringify:t=>bh(t,2,"0b")},mC={identify:oa,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>nl(t,1,8,r),stringify:t=>bh(t,8,"0")},gC={identify:oa,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>nl(t,0,10,r),stringify:TS.stringifyNumber},yC={identify:oa,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>nl(t,2,16,r),stringify:t=>bh(t,16,"0x")};aa.int=gC;aa.intBin=hC;aa.intHex=yC;aa.intOct=mC});var vh=w(wh=>{"use strict";var ol=le(),sl=ln(),il=fn(),ss=class t extends il.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ol.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new sl.Pair(e.key,null):r=new sl.Pair(e,null),il.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let n=il.findPair(this.items,e);return!r&&ol.isPair(n)?ol.isScalar(n.key)?n.key.value:n.key:n}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=il.findPair(this.items,e);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new sl.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(e,r,n){let{replacer:s}=n,i=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof s=="function"&&(o=s.call(r,o,o)),i.items.push(sl.createPair(o,null,n));return i}};ss.tag="tag:yaml.org,2002:set";var _C={collection:"map",identify:t=>t instanceof Set,nodeClass:ss,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>ss.from(t,e,r),resolve(t,e){if(ol.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ss,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};wh.YAMLSet=ss;wh.set=_C});var Sh=w(al=>{"use strict";var bC=hi();function xh(t,e){let r=t[0],n=r==="-"||r==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return r==="-"?s(-1)*i:i}function OS(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return bC.stringifyNumber(t);let n="";e<0&&(n="-",e*=r(-1));let s=r(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),n+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var wC={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>xh(t,r),stringify:OS},vC={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>xh(t,!1),stringify:OS},IS={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(IS.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,u=Date.UTC(r,n-1,s,i||0,o||0,a||0,c),l=e[8];if(l&&l!=="Z"){let d=xh(l,!1);Math.abs(d)<30&&(d*=60),u-=6e4*d}return new Date(u)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};al.floatTime=vC;al.intTime=wC;al.timestamp=IS});var RS=w(NS=>{"use strict";var xC=fi(),SC=Ku(),kC=pi(),$C=na(),EC=fh(),AS=$S(),kh=ES(),cl=PS(),TC=Du(),PC=gh(),OC=tl(),IC=vh(),$h=Sh(),AC=[xC.map,kC.seq,$C.string,SC.nullTag,AS.trueTag,AS.falseTag,cl.intBin,cl.intOct,cl.int,cl.intHex,kh.floatNaN,kh.floatExp,kh.float,EC.binary,TC.merge,PC.omap,OC.pairs,IC.set,$h.intTime,$h.floatTime,$h.timestamp];NS.schema=AC});var FS=w(Ph=>{"use strict";var jS=fi(),NC=Ku(),LS=pi(),RC=na(),zC=sh(),Eh=oh(),Th=ch(),MC=fS(),CC=mS(),qS=fh(),ca=Du(),DS=gh(),ZS=tl(),zS=RS(),US=vh(),ul=Sh(),MS=new Map([["core",MC.schema],["failsafe",[jS.map,LS.seq,RC.string]],["json",CC.schema],["yaml11",zS.schema],["yaml-1.1",zS.schema]]),CS={binary:qS.binary,bool:zC.boolTag,float:Eh.float,floatExp:Eh.floatExp,floatNaN:Eh.floatNaN,floatTime:ul.floatTime,int:Th.int,intHex:Th.intHex,intOct:Th.intOct,intTime:ul.intTime,map:jS.map,merge:ca.merge,null:NC.nullTag,omap:DS.omap,pairs:ZS.pairs,seq:LS.seq,set:US.set,timestamp:ul.timestamp},jC={"tag:yaml.org,2002:binary":qS.binary,"tag:yaml.org,2002:merge":ca.merge,"tag:yaml.org,2002:omap":DS.omap,"tag:yaml.org,2002:pairs":ZS.pairs,"tag:yaml.org,2002:set":US.set,"tag:yaml.org,2002:timestamp":ul.timestamp};function LC(t,e,r){let n=MS.get(e);if(n&&!t)return r&&!n.includes(ca.merge)?n.concat(ca.merge):n.slice();let s=n;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(MS.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return r&&(s=s.concat(ca.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?CS[o]:o;if(!a){let c=JSON.stringify(o),u=Object.keys(CS).map(l=>JSON.stringify(l)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return i.includes(a)||i.push(a),i},[])}Ph.coreKnownTags=jC;Ph.getTags=LC});var Ah=w(BS=>{"use strict";var Oh=le(),qC=fi(),DC=pi(),ZC=na(),ll=FS(),UC=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Ih=class t{constructor({compat:e,customTags:r,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ll.getTags(e,"compat"):e?ll.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?ll.coreKnownTags:{},this.tags=ll.getTags(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,Oh.MAP,{value:qC.map}),Object.defineProperty(this,Oh.SCALAR,{value:ZC.string}),Object.defineProperty(this,Oh.SEQ,{value:DC.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?UC:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};BS.Schema=Ih});var HS=w(VS=>{"use strict";var FC=le(),Nh=ea(),ua=Go();function BC(t,e){let r=[],n=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),n=!0):t.directives.docStart&&(n=!0)}n&&r.push("---");let s=Nh.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=i(t.commentBefore);r.unshift(ua.indentComment(c,""))}let o=!1,a=null;if(t.contents){if(FC.isNode(t.contents)){if(t.contents.spaceBefore&&n&&r.push(""),t.contents.commentBefore){let l=i(t.contents.commentBefore);r.push(ua.indentComment(l,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,u=Nh.stringify(t.contents,s,()=>a=null,c);a&&(u+=ua.lineComment(u,"",i(a))),(u[0]==="|"||u[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${u}`:r.push(u)}else r.push(Nh.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let c=i(t.comment);c.includes(`
|
|
63
|
+
`)?(r.push("..."),r.push(ua.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&r[r.length-1]!==""&&r.push(""),r.push(ua.indentComment(i(c),"")))}return r.join(`
|
|
64
64
|
`)+`
|
|
65
|
-
`}
|
|
65
|
+
`}VS.stringifyDocument=BC});var la=w(WS=>{"use strict";var VC=Ko(),mi=Iu(),qt=le(),HC=ln(),WC=on(),KC=Ah(),JC=HS(),Rh=Eu(),GC=jp(),YC=Jo(),zh=Cp(),Mh=class t{constructor(e,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,qt.NODE_TYPE,{value:qt.DOC});let s=null;typeof r=="function"||Array.isArray(r)?s=r:n===void 0&&r&&(n=r,r=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=i;let{version:o}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new zh.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,s,n)}clone(){let e=Object.create(t.prototype,{[qt.NODE_TYPE]:{value:qt.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=qt.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){gi(this.contents)&&this.contents.add(e)}addIn(e,r){gi(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let n=Rh.anchorNames(this);e.anchor=!r||n.has(r)?Rh.findNewAnchor(r||"a",n):r}return new VC.Alias(e.anchor)}createNode(e,r,n){let s;if(typeof r=="function")e=r.call({"":e},"",e),s=r;else if(Array.isArray(r)){let g=_=>typeof _=="number"||_ instanceof String||_ instanceof Number,y=r.filter(g).map(String);y.length>0&&(r=r.concat(y)),s=r}else n===void 0&&r&&(n=r,r=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:u,tag:l}=n??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Rh.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:u,replacer:s,schema:this.schema,sourceObjects:p},h=YC.createNode(e,l,m);return a&&qt.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,r,n={}){let s=this.createNode(e,null,n),i=this.createNode(r,null,n);return new HC.Pair(s,i)}delete(e){return gi(this.contents)?this.contents.delete(e):!1}deleteIn(e){return mi.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):gi(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return qt.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return mi.isEmptyPath(e)?!r&&qt.isScalar(this.contents)?this.contents.value:this.contents:qt.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return qt.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return mi.isEmptyPath(e)?this.contents!==void 0:qt.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=mi.collectionFromPath(this.schema,[e],r):gi(this.contents)&&this.contents.set(e,r)}setIn(e,r){mi.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=mi.collectionFromPath(this.schema,Array.from(e),r):gi(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new zh.Directives({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new zh.Directives({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(n)this.schema=new KC.Schema(Object.assign(n,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:n,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},c=WC.toJS(this.contents,r??"",a);if(typeof i=="function")for(let{count:u,res:l}of a.anchors.values())i(l,u);return typeof o=="function"?GC.applyReviver(o,{"":c},"",c):c}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return JC.stringifyDocument(this,e)}};function gi(t){if(qt.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}WS.Document=Mh});var pa=w(fa=>{"use strict";var da=class extends Error{constructor(e,r,n,s){super(),this.name=e,this.code=n,this.message=s,this.pos=r}},Ch=class extends da{constructor(e,r,n){super("YAMLParseError",e,r,n)}},jh=class extends da{constructor(e,r,n){super("YAMLWarning",e,r,n)}},XC=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>e.linePos(a));let{line:n,col:s}=r.linePos[0];r.message+=` at line ${n}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),n>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[n-2],e.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
66
66
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=r.linePos[1];c?.line===n&&c.col>s&&(a=Math.max(1,Math.min(c.col-s,80-i)));let u=" ".repeat(i)+"^".repeat(a);r.message+=`:
|
|
67
67
|
|
|
68
68
|
${o}
|
|
69
69
|
${u}
|
|
70
|
-
`}};
|
|
71
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(
|
|
72
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
73
|
-
`+v.comment:_.comment=v.comment);let k=new
|
|
74
|
-
`+C.comment:u.comment=C.comment),d=C.end;continue}!o&&r.options.strict&&
|
|
75
|
-
`+B:R.comment=B,C.comment=C.comment.substring(B.length+1)}}if(!o&&!k&&!C.found){let B=E?t(r,E,C,s):e(r,C.end,k,null,C,s);u.items.push(B),d=B.range[2],
|
|
76
|
-
`+ue.comment:R.comment=ue.comment);let K=new
|
|
77
|
-
`+g.comment:u.comment=g.comment),u.range=[n.offset,h,g.offset]}else u.range=[n.offset,h,h];return u}
|
|
70
|
+
`}};fa.YAMLError=da;fa.YAMLParseError=Ch;fa.YAMLWarning=jh;fa.prettifyError=XC});var ha=w(KS=>{"use strict";function QC(t,{flow:e,indicator:r,next:n,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,u=a,l=a,d="",f="",p=!1,m=!1,h=null,g=null,y=null,_=null,v=null,k=null,E=null;for(let R of t)switch(m&&(R.type!=="space"&&R.type!=="newline"&&R.type!=="comma"&&i(R.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(u&&R.type!=="comment"&&R.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),R.type){case"space":!e&&(r!=="doc-start"||n?.type!=="flow-collection")&&R.source.includes(" ")&&(h=R),l=!0;break;case"comment":{l||i(R,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let ue=R.source.substring(1)||" ";d?d+=f+ue:d=ue,f="",u=!1;break}case"newline":u?d?d+=R.source:(!k||r!=="seq-item-ind")&&(c=!0):f+=R.source,u=!0,p=!0,(g||y)&&(_=R),l=!0;break;case"anchor":g&&i(R,"MULTIPLE_ANCHORS","A node can have at most one anchor"),R.source.endsWith(":")&&i(R.offset+R.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=R,E??(E=R.offset),u=!1,l=!1,m=!0;break;case"tag":{y&&i(R,"MULTIPLE_TAGS","A node can have at most one tag"),y=R,E??(E=R.offset),u=!1,l=!1,m=!0;break}case r:(g||y)&&i(R,"BAD_PROP_ORDER",`Anchors and tags must be after the ${R.source} indicator`),k&&i(R,"UNEXPECTED_TOKEN",`Unexpected ${R.source} in ${e??"collection"}`),k=R,u=r==="seq-item-ind"||r==="explicit-key-ind",l=!1;break;case"comma":if(e){v&&i(R,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),v=R,u=!1,l=!1;break}default:i(R,"UNEXPECTED_TOKEN",`Unexpected ${R.type} token`),u=!1,l=!1}let C=t[t.length-1],B=C?C.offset+C.source.length:s;return m&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(u&&h.indent<=o||n?.type==="block-map"||n?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:k,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:y,newlineAfterProp:_,end:B,start:E??B}}KS.resolveProps=QC});var dl=w(JS=>{"use strict";function Lh(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
71
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(Lh(e.key)||Lh(e.value))return!0}return!1;default:return!0}}JS.containsNewline=Lh});var qh=w(GS=>{"use strict";var ej=dl();function tj(t,e,r){if(e?.type==="flow-collection"){let n=e.end[0];n.indent===t&&(n.source==="]"||n.source==="}")&&ej.containsNewline(e)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}GS.flowIndentCheck=tj});var Dh=w(XS=>{"use strict";var YS=le();function rj(t,e,r){let{uniqueKeys:n}=t.options;if(n===!1)return!1;let s=typeof n=="function"?n:(i,o)=>i===o||YS.isScalar(i)&&YS.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,r))}XS.mapIncludes=rj});var sk=w(nk=>{"use strict";var QS=ln(),nj=fn(),ek=ha(),sj=dl(),tk=qh(),ij=Dh(),rk="All mapping items must start at the same column";function oj({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=i?.nodeClass??nj.YAMLMap,a=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=n.offset,u=null;for(let l of n.items){let{start:d,key:f,sep:p,value:m}=l,h=ek.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0}),g=!h.found;if(g){if(f&&(f.type==="block-seq"?s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==n.indent&&s(c,"BAD_INDENT",rk)),!h.anchor&&!h.tag&&!p){u=h.end,h.comment&&(a.comment?a.comment+=`
|
|
72
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||sj.containsNewline(f))&&s(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==n.indent&&s(c,"BAD_INDENT",rk);r.atKey=!0;let y=h.end,_=f?t(r,f,h,s):e(r,y,d,null,h,s);r.schema.compat&&tk.flowIndentCheck(n.indent,f,s),r.atKey=!1,ij.mapIncludes(r,a.items,_)&&s(y,"DUPLICATE_KEY","Map keys must be unique");let v=ek.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:_.range[2],onError:s,parentIndent:n.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=v.end,v.found){g&&(m?.type==="block-map"&&!v.hasNewline&&s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<v.found.offset-1024&&s(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=m?t(r,m,v,s):e(r,c,p,null,v,s);r.schema.compat&&tk.flowIndentCheck(n.indent,m,s),c=k.range[2];let E=new QS.Pair(_,k);r.options.keepSourceTokens&&(E.srcToken=l),a.items.push(E)}else{g&&s(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),v.comment&&(_.comment?_.comment+=`
|
|
73
|
+
`+v.comment:_.comment=v.comment);let k=new QS.Pair(_);r.options.keepSourceTokens&&(k.srcToken=l),a.items.push(k)}}return u&&u<c&&s(u,"IMPOSSIBLE","Map comment with trailing content"),a.range=[n.offset,c,u??c],a}nk.resolveBlockMap=oj});var ok=w(ik=>{"use strict";var aj=pn(),cj=ha(),uj=qh();function lj({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=i?.nodeClass??aj.YAMLSeq,a=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=n.offset,u=null;for(let{start:l,value:d}of n.items){let f=cj.resolveProps(l,{indicator:"seq-item-ind",next:d,offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(c,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(a.comment=f.comment);continue}let p=d?t(r,d,f,s):e(r,f.end,l,null,f,s);r.schema.compat&&uj.flowIndentCheck(n.indent,d,s),c=p.range[2],a.items.push(p)}return a.range=[n.offset,c,u??c],a}ik.resolveBlockSeq=lj});var yi=w(ak=>{"use strict";function dj(t,e,r,n){let s="";if(t){let i=!1,o="";for(let a of t){let{source:c,type:u}=a;switch(u){case"space":i=!0;break;case"comment":{r&&!i&&n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let l=c.substring(1)||" ";s?s+=o+l:s=l,o="";break}case"newline":s&&(o+=c),i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=c.length}}return{comment:s,offset:e}}ak.resolveEnd=dj});var dk=w(lk=>{"use strict";var fj=le(),pj=ln(),ck=fn(),hj=pn(),mj=yi(),uk=ha(),gj=dl(),yj=Dh(),Zh="Block collections are not allowed within flow collections",Uh=t=>t&&(t.type==="block-map"||t.type==="block-seq");function _j({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?ck.YAMLMap:hj.YAMLSeq),u=new c(r.schema);u.flow=!0;let l=r.atRoot;l&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=n.offset+n.start.source.length;for(let g=0;g<n.items.length;++g){let y=n.items[g],{start:_,key:v,sep:k,value:E}=y,C=uk.resolveProps(_,{flow:a,indicator:"explicit-key-ind",next:v??k?.[0],offset:d,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!k&&!E){g===0&&C.comma?s(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<n.items.length-1&&s(C.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),C.comment&&(u.comment?u.comment+=`
|
|
74
|
+
`+C.comment:u.comment=C.comment),d=C.end;continue}!o&&r.options.strict&&gj.containsNewline(v)&&s(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)C.comma&&s(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(C.comma||s(C.start,"MISSING_CHAR",`Missing , between ${a} items`),C.comment){let B="";e:for(let R of _)switch(R.type){case"comma":case"space":break;case"comment":B=R.source.substring(1);break e;default:break e}if(B){let R=u.items[u.items.length-1];fj.isPair(R)&&(R=R.value??R.key),R.comment?R.comment+=`
|
|
75
|
+
`+B:R.comment=B,C.comment=C.comment.substring(B.length+1)}}if(!o&&!k&&!C.found){let B=E?t(r,E,C,s):e(r,C.end,k,null,C,s);u.items.push(B),d=B.range[2],Uh(E)&&s(B.range,"BLOCK_IN_FLOW",Zh)}else{r.atKey=!0;let B=C.end,R=v?t(r,v,C,s):e(r,B,_,null,C,s);Uh(v)&&s(R.range,"BLOCK_IN_FLOW",Zh),r.atKey=!1;let ue=uk.resolveProps(k??[],{flow:a,indicator:"map-value-ind",next:E,offset:R.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(ue.found){if(!o&&!C.found&&r.options.strict){if(k)for(let J of k){if(J===ue.found)break;if(J.type==="newline"){s(J,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}C.start<ue.found.offset-1024&&s(ue.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?s(E,"MISSING_CHAR",`Missing space after : in ${a}`):s(ue.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let I=E?t(r,E,ue,s):ue.found?e(r,ue.end,k,null,ue,s):null;I?Uh(E)&&s(I.range,"BLOCK_IN_FLOW",Zh):ue.comment&&(R.comment?R.comment+=`
|
|
76
|
+
`+ue.comment:R.comment=ue.comment);let K=new pj.Pair(R,I);if(r.options.keepSourceTokens&&(K.srcToken=y),o){let J=u;yj.mapIncludes(r,J.items,R)&&s(B,"DUPLICATE_KEY","Map keys must be unique"),J.items.push(K)}else{let J=new ck.YAMLMap(r.schema);J.flow=!0,J.items.push(K);let ze=(I??R).range;J.range=[R.range[0],ze[1],ze[2]],u.items.push(J)}d=I?I.range[2]:ue.end}}let f=o?"}":"]",[p,...m]=n.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),y=l?`${g} must end with a ${f}`:`${g} in block collection must be sufficiently indented and end with a ${f}`;s(d,l?"MISSING_CHAR":"BAD_INDENT",y),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let g=mj.resolveEnd(m,h,r.options.strict,s);g.comment&&(u.comment?u.comment+=`
|
|
77
|
+
`+g.comment:u.comment=g.comment),u.range=[n.offset,h,g.offset]}else u.range=[n.offset,h,h];return u}lk.resolveFlowCollection=_j});var pk=w(fk=>{"use strict";var bj=le(),wj=Ze(),vj=fn(),xj=pn(),Sj=sk(),kj=ok(),$j=dk();function Fh(t,e,r,n,s,i){let o=r.type==="block-map"?Sj.resolveBlockMap(t,e,r,n,i):r.type==="block-seq"?kj.resolveBlockSeq(t,e,r,n,i):$j.resolveFlowCollection(t,e,r,n,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function Ej(t,e,r,n,s){let i=n.tag,o=i?e.directives.tagName(i.source,f=>s(i,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=n,m=f&&i?f.offset>i.offset?f:i:f??i;m&&(!p||p.offset<m.offset)&&s(m,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===vj.YAMLMap.tagName&&a==="map"||o===xj.YAMLSeq.tagName&&a==="seq")return Fh(t,e,r,s,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!c){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?s(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Fh(t,e,r,s,o)}let u=Fh(t,e,r,s,o,c),l=c.resolve?.(u,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??u,d=bj.isNode(l)?l:new wj.Scalar(l);return d.range=u.range,d.tag=o,c?.format&&(d.format=c.format),d}fk.composeCollection=Ej});var Vh=w(hk=>{"use strict";var Bh=Ze();function Tj(t,e,r){let n=e.offset,s=Pj(e,t.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let i=s.mode===">"?Bh.Scalar.BLOCK_FOLDED:Bh.Scalar.BLOCK_LITERAL,o=e.source?Oj(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
|
|
78
78
|
`.repeat(Math.max(1,o.length-1)):"",g=n+s.length;return e.source&&(g+=e.source.length),{value:h,type:i,comment:s.comment,range:[n,g,g]}}let c=e.indent+s.indent,u=e.offset+s.length,l=0;for(let h=0;h<a;++h){let[g,y]=o[h];if(y===""||y==="\r")s.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&r(u+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(c=g.length),l=h,c===0&&!t.atRoot&&r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=g.length+y.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>c&&(a=h+1);let d="",f="",p=!1;for(let h=0;h<l;++h)d+=o[h][0].slice(c)+`
|
|
79
|
-
`;for(let h=l;h<a;++h){let[g,y]=o[h];u+=g.length+y.length+1;let _=y[y.length-1]==="\r";if(_&&(y=y.slice(0,-1)),y&&g.length<c){let k=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(u-y.length-(_?2:1),"BAD_INDENT",k),g=""}i===
|
|
79
|
+
`;for(let h=l;h<a;++h){let[g,y]=o[h];u+=g.length+y.length+1;let _=y[y.length-1]==="\r";if(_&&(y=y.slice(0,-1)),y&&g.length<c){let k=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(u-y.length-(_?2:1),"BAD_INDENT",k),g=""}i===Bh.Scalar.BLOCK_LITERAL?(d+=f+g.slice(c)+y,f=`
|
|
80
80
|
`):g.length>c||y[0]===" "?(f===" "?f=`
|
|
81
81
|
`:!p&&f===`
|
|
82
82
|
`&&(f=`
|
|
@@ -89,69 +89,69 @@ ${u}
|
|
|
89
89
|
`+o[h][0].slice(c);d[d.length-1]!==`
|
|
90
90
|
`&&(d+=`
|
|
91
91
|
`);break;default:d+=`
|
|
92
|
-
`}let m=n+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[n,m,m]}}function
|
|
92
|
+
`}let m=n+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[n,m,m]}}function Pj({offset:t,props:e},r,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",c=-1;for(let f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:c===-1&&(c=t+f)}}c!==-1&&n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let u=!1,l="",d=s.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":u=!0;case"newline":d+=p.source.length;break;case"comment":r&&!u&&n(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,l=p.source.substring(1);break;case"error":n(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;n(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:l,length:d}}function Oj(t){let e=t.split(/\n( *)/),r=e[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}hk.resolveBlockScalar=Tj});var Wh=w(gk=>{"use strict";var Hh=Ze(),Ij=yi();function Aj(t,e,r){let{offset:n,type:s,source:i,end:o}=t,a,c,u=(f,p,m)=>r(n+f,p,m);switch(s){case"scalar":a=Hh.Scalar.PLAIN,c=Nj(i,u);break;case"single-quoted-scalar":a=Hh.Scalar.QUOTE_SINGLE,c=Rj(i,u);break;case"double-quoted-scalar":a=Hh.Scalar.QUOTE_DOUBLE,c=zj(i,u);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let l=n+i.length,d=Ij.resolveEnd(o,l,e,r);return{value:c,type:a,comment:d.comment,range:[n,l,d.offset]}}function Nj(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),mk(t)}function Rj(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),mk(t.slice(1,-1)).replace(/''/g,"'")}function mk(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
93
93
|
`,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
94
94
|
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(t);if(!n)return t;let s=n[1],i=" ",o=e.lastIndex;for(r.lastIndex=o;n=r.exec(t);)n[1]===""?i===`
|
|
95
95
|
`?s+=i:i=`
|
|
96
|
-
`:(s+=i+n[1],i=" "),o=r.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(t),s+i+(n?.[1]??"")}function
|
|
96
|
+
`:(s+=i+n[1],i=" "),o=r.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(t),s+i+(n?.[1]??"")}function zj(t,e){let r="";for(let n=1;n<t.length-1;++n){let s=t[n];if(!(s==="\r"&&t[n+1]===`
|
|
97
97
|
`))if(s===`
|
|
98
|
-
`){let{fold:i,offset:o}=
|
|
98
|
+
`){let{fold:i,offset:o}=Mj(t,n);r+=i,n=o}else if(s==="\\"){let i=t[++n],o=Cj[i];if(o)r+=o;else if(i===`
|
|
99
99
|
`)for(i=t[n+1];i===" "||i===" ";)i=t[++n+1];else if(i==="\r"&&t[n+1]===`
|
|
100
|
-
`)for(i=t[++n+1];i===" "||i===" ";)i=t[++n+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=
|
|
100
|
+
`)for(i=t[++n+1];i===" "||i===" ";)i=t[++n+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=jj(t,n+1,a,e),n+=a}else{let a=t.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(s===" "||s===" "){let i=n,o=t[n+1];for(;o===" "||o===" ";)o=t[++n+1];o!==`
|
|
101
101
|
`&&!(o==="\r"&&t[n+2]===`
|
|
102
|
-
`)&&(r+=n>i?t.slice(i,n+1):s)}else r+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function
|
|
102
|
+
`)&&(r+=n>i?t.slice(i,n+1):s)}else r+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function Mj(t,e){let r="",n=t[e+1];for(;(n===" "||n===" "||n===`
|
|
103
103
|
`||n==="\r")&&!(n==="\r"&&t[e+2]!==`
|
|
104
104
|
`);)n===`
|
|
105
105
|
`&&(r+=`
|
|
106
|
-
`),e+=1,n=t[e+1];return r||(r=" "),{fold:r,offset:e}}var
|
|
107
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
106
|
+
`),e+=1,n=t[e+1];return r||(r=" "),{fold:r,offset:e}}var Cj={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
107
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function jj(t,e,r,n){let s=t.substr(e,r),o=s.length===r&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(o)}catch{let a=t.substr(e-2,r+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}gk.resolveFlowScalar=Aj});var bk=w(_k=>{"use strict";var is=le(),yk=Ze(),Lj=Vh(),qj=Wh();function Dj(t,e,r,n){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?Lj.resolveBlockScalar(t,e,n):qj.resolveFlowScalar(e,t.options.strict,n),c=r?t.directives.tagName(r.source,d=>n(r,"TAG_RESOLVE_FAILED",d)):null,u;t.options.stringKeys&&t.atKey?u=t.schema[is.SCALAR]:c?u=Zj(t.schema,s,c,r,n):e.type==="scalar"?u=Uj(t,s,e,n):u=t.schema[is.SCALAR];let l;try{let d=u.resolve(s,f=>n(r??e,"TAG_RESOLVE_FAILED",f),t.options);l=is.isScalar(d)?d:new yk.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);n(r??e,"TAG_RESOLVE_FAILED",f),l=new yk.Scalar(s)}return l.range=a,l.source=s,i&&(l.type=i),c&&(l.tag=c),u.format&&(l.format=u.format),o&&(l.comment=o),l}function Zj(t,e,r,n,s){if(r==="!")return t[is.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[is.SCALAR])}function Uj({atKey:t,directives:e,schema:r},n,s,i){let o=r.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(n))||r[is.SCALAR];if(r.compat){let a=r.compat.find(c=>c.default&&c.test?.test(n))??r[is.SCALAR];if(o.tag!==a.tag){let c=e.tagString(o.tag),u=e.tagString(a.tag),l=`Value may be parsed as either ${c} or ${u}`;i(s,"TAG_RESOLVE_FAILED",l,!0)}}return o}_k.composeScalar=Dj});var vk=w(wk=>{"use strict";function Fj(t,e,r){if(e){r??(r=e.length);for(let n=r-1;n>=0;--n){let s=e[n];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++n];s?.type==="space";)t+=s.source.length,s=e[++n];break}}return t}wk.emptyScalarPosition=Fj});var kk=w(Jh=>{"use strict";var Bj=Ko(),Vj=le(),Hj=pk(),xk=bk(),Wj=yi(),Kj=vk(),Jj={composeNode:Sk,composeEmptyNode:Kh};function Sk(t,e,r,n){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=r,u,l=!0;switch(e.type){case"alias":u=Gj(t,e,n),(a||c)&&n(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=xk.composeScalar(t,e,c,n),a&&(u.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=Hj.composeCollection(Jj,t,e,r,n),a&&(u.anchor=a.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);n(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",d),l=!1}}return u??(u=Kh(t,e.offset,void 0,null,r,n)),a&&u.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!Vj.isScalar(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&n(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(u.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?u.comment=o:u.commentBefore=o),t.options.keepSourceTokens&&l&&(u.srcToken=e),u}function Kh(t,e,r,n,{spaceBefore:s,comment:i,anchor:o,tag:a,end:c},u){let l={type:"scalar",offset:Kj.emptyScalarPosition(e,r,n),indent:-1,source:""},d=xk.composeScalar(t,l,a,u);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&u(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=c),d}function Gj({options:t},{offset:e,source:r,end:n},s){let i=new Bj.Alias(r.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,a=Wj.resolveEnd(n,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Jh.composeEmptyNode=Kh;Jh.composeNode=Sk});var Tk=w(Ek=>{"use strict";var Yj=la(),$k=kk(),Xj=yi(),Qj=ha();function e2(t,e,{offset:r,start:n,value:s,end:i},o){let a=Object.assign({_directives:e},t),c=new Yj.Document(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},l=Qj.resolveProps(n,{indicator:"doc-start",next:s??i?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!l.hasNewline&&o(l.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=s?$k.composeNode(u,s,l,o):$k.composeEmptyNode(u,l.end,n,null,l,o);let d=c.contents.range[2],f=Xj.resolveEnd(i,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}Ek.composeDoc=e2});var Yh=w(Ik=>{"use strict";var t2=ke("process"),r2=Cp(),n2=la(),ma=pa(),Pk=le(),s2=Tk(),i2=yi();function ga(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function Ok(t){let e="",r=!1,n=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":n?`
|
|
108
108
|
|
|
109
109
|
`:`
|
|
110
|
-
`)+(i.substring(1)||" "),r=!0,n=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:e,afterEmptyLine:n}}var
|
|
111
|
-
${n}`:n;else if(s||e.directives.docStart||!i)e.commentBefore=n;else if(
|
|
110
|
+
`)+(i.substring(1)||" "),r=!0,n=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:e,afterEmptyLine:n}}var Gh=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,n,s,i)=>{let o=ga(r);i?this.warnings.push(new ma.YAMLWarning(o,n,s)):this.errors.push(new ma.YAMLParseError(o,n,s))},this.directives=new r2.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:n,afterEmptyLine:s}=Ok(this.prelude);if(n){let i=e.contents;if(r)e.comment=e.comment?`${e.comment}
|
|
111
|
+
${n}`:n;else if(s||e.directives.docStart||!i)e.commentBefore=n;else if(Pk.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Pk.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${n}
|
|
112
112
|
${a}`:n}else{let o=i.commentBefore;i.commentBefore=o?`${n}
|
|
113
|
-
${o}`:n}}if(r){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
114
|
-
${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new
|
|
113
|
+
${o}`:n}}if(r){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ok(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(r,n)}*next(e){switch(t2.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,n,s)=>{let i=ga(e);i[0]+=r,this.onError(i,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=s2.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new ma.YAMLParseError(ga(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new ma.YAMLParseError(ga(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=i2.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
|
|
114
|
+
${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new ma.YAMLParseError(ga(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),s=new n2.Document(void 0,n);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,r,r],this.decorate(s,!1),yield s}}};Ik.Composer=Gh});var Rk=w(fl=>{"use strict";var o2=Vh(),a2=Wh(),c2=pa(),Ak=Qo();function u2(t,e=!0,r){if(t){let n=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(r)r(a,i,o);else throw new c2.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return a2.resolveFlowScalar(t,e,n);case"block-scalar":return o2.resolveBlockScalar({options:{strict:e}},t,n)}}return null}function l2(t,e){let{implicitKey:r=!1,indent:n,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Ak.stringifyString({type:o,value:t},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:n,source:`
|
|
115
115
|
`}];switch(a[0]){case"|":case">":{let u=a.indexOf(`
|
|
116
116
|
`),l=a.substring(0,u),d=a.substring(u+1)+`
|
|
117
|
-
`,f=[{type:"block-scalar-header",offset:i,indent:n,source:l}];return
|
|
118
|
-
`}),{type:"block-scalar",offset:i,indent:n,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:c};default:return{type:"scalar",offset:i,indent:n,source:a,end:c}}}function
|
|
117
|
+
`,f=[{type:"block-scalar-header",offset:i,indent:n,source:l}];return Nk(f,c)||f.push({type:"newline",offset:-1,indent:n,source:`
|
|
118
|
+
`}),{type:"block-scalar",offset:i,indent:n,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:c};default:return{type:"scalar",offset:i,indent:n,source:a,end:c}}}function d2(t,e,r={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=r,a="indent"in t?t.indent:null;if(n&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let u=t.props[0];if(u.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=u.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Ak.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":f2(t,c);break;case'"':Xh(t,c,"double-quoted-scalar");break;case"'":Xh(t,c,"single-quoted-scalar");break;default:Xh(t,c,"scalar")}}function f2(t,e){let r=e.indexOf(`
|
|
119
119
|
`),n=e.substring(0,r),s=e.substring(r+1)+`
|
|
120
|
-
`;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=n,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];
|
|
121
|
-
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function
|
|
122
|
-
`};delete t.items,Object.assign(t,{type:r,source:e,end:[s]});break}default:{let n="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:r,indent:n,source:e,end:s})}}}
|
|
120
|
+
`;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=n,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];Nk(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
121
|
+
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function Nk(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Xh(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let n=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of n)i.offset+=s;delete t.props,Object.assign(t,{type:r,source:e,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
|
|
122
|
+
`};delete t.items,Object.assign(t,{type:r,source:e,end:[s]});break}default:{let n="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:r,indent:n,source:e,end:s})}}}fl.createScalarToken=l2;fl.resolveAsScalar=u2;fl.setScalarValue=d2});var Mk=w(zk=>{"use strict";var p2=t=>"type"in t?hl(t):pl(t);function hl(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=hl(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=pl(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=pl(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=pl(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function pl({start:t,key:e,sep:r,value:n}){let s="";for(let i of t)s+=i.source;if(e&&(s+=hl(e)),r)for(let i of r)s+=i.source;return n&&(s+=hl(n)),s}zk.stringify=p2});var qk=w(Lk=>{"use strict";var Qh=Symbol("break visit"),h2=Symbol("skip children"),Ck=Symbol("remove item");function os(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),jk(Object.freeze([]),t,e)}os.BREAK=Qh;os.SKIP=h2;os.REMOVE=Ck;os.itemAtPath=(t,e)=>{let r=t;for(let[n,s]of e){let i=r?.[n];if(i&&"items"in i)r=i.items[s];else return}return r};os.parentCollection=(t,e)=>{let r=os.itemAtPath(t,e.slice(0,-1)),n=e[e.length-1][0],s=r?.[n];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function jk(t,e,r){let n=r(e,t);if(typeof n=="symbol")return n;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=jk(Object.freeze(t.concat([[s,o]])),i.items[o],r);if(typeof a=="number")o=a-1;else{if(a===Qh)return Qh;a===Ck&&(i.items.splice(o,1),o-=1)}}typeof n=="function"&&s==="key"&&(n=n(e,t))}}return typeof n=="function"?n(e,t):n}Lk.visit=os});var ml=w(_t=>{"use strict";var em=Rk(),m2=Mk(),g2=qk(),tm="\uFEFF",rm="",nm="",sm="",y2=t=>!!t&&"items"in t,_2=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function b2(t){switch(t){case tm:return"<BOM>";case rm:return"<DOC>";case nm:return"<FLOW_END>";case sm:return"<SCALAR>";default:return JSON.stringify(t)}}function w2(t){switch(t){case tm:return"byte-order-mark";case rm:return"doc-mode";case nm:return"flow-error-end";case sm:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
123
123
|
`:case`\r
|
|
124
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
125
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
126
|
-
\r `),
|
|
124
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}_t.createScalarToken=em.createScalarToken;_t.resolveAsScalar=em.resolveAsScalar;_t.setScalarValue=em.setScalarValue;_t.stringify=m2.stringify;_t.visit=g2.visit;_t.BOM=tm;_t.DOCUMENT=rm;_t.FLOW_END=nm;_t.SCALAR=sm;_t.isCollection=y2;_t.isScalar=_2;_t.prettyToken=b2;_t.tokenType=w2});var am=w(Zk=>{"use strict";var ya=ml();function sr(t){switch(t){case void 0:case" ":case`
|
|
125
|
+
`:case"\r":case" ":return!0;default:return!1}}var Dk=new Set("0123456789ABCDEFabcdef"),v2=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),gl=new Set(",[]{}"),x2=new Set(` ,[]{}
|
|
126
|
+
\r `),im=t=>!t||x2.has(t),om=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let n=this.next??"stream";for(;n&&(r||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
|
|
127
127
|
`?!0:r==="\r"?this.buffer[e+1]===`
|
|
128
128
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let n=0;for(;r===" ";)r=this.buffer[++n+e];if(r==="\r"){let s=this.buffer[n+e+1];if(s===`
|
|
129
129
|
`||!s&&!this.atEnd)return e+n+1}return r===`
|
|
130
|
-
`||n>=this.indentNext||!r&&!this.atEnd?e+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&
|
|
131
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
130
|
+
`||n>=this.indentNext||!r&&!this.atEnd?e+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&sr(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
131
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===ya.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,n=e.indexOf("#");for(;n!==-1;){let i=e[n-1];if(i===" "||i===" "){r=n-1;break}else n=e.indexOf("#",n+1)}for(;;){let i=e[r-1];if(i===" "||i===" ")r-=1;else break}let s=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield ya.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&sr(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!sr(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&sr(r)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(im),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,n=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=n=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&s[0]!=="#"||n===0&&(s.startsWith("---")||s.startsWith("..."))&&sr(s[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield ya.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(im),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||sr(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let i=0;for(;this.buffer[r-1-i]==="\\";)i+=1;if(i%2===0)break;r=this.buffer.indexOf('"',r+1)}let n=this.buffer.substring(0,r),s=n.indexOf(`
|
|
132
132
|
`,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=n.indexOf(`
|
|
133
|
-
`,i)}s!==-1&&(r=s-(n[s-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>
|
|
133
|
+
`,i)}s!==-1&&(r=s-(n[s-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>sr(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":r+=1;break;case`
|
|
134
134
|
`:e=i,r=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
135
135
|
`)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
|
136
136
|
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(n=this.buffer[s];n===" ";)n=this.buffer[++s];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
|
|
137
137
|
`;)n=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
|
|
138
|
-
`&&i>=this.pos&&i+1+r>a)e=i;else break}while(!0);return yield
|
|
138
|
+
`&&i>=this.pos&&i+1+r>a)e=i;else break}while(!0);return yield ya.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,n=this.pos-1,s;for(;s=this.buffer[++n];)if(s===":"){let i=this.buffer[n+1];if(sr(i)||e&&gl.has(i))break;r=n}else if(sr(s)){let i=this.buffer[n+1];if(s==="\r"&&(i===`
|
|
139
139
|
`?(n+=1,s=`
|
|
140
|
-
`,i=this.buffer[n+1]):r=n),i==="#"||e&&
|
|
141
|
-
`){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&
|
|
140
|
+
`,i=this.buffer[n+1]):r=n),i==="#"||e&&gl.has(i))break;if(s===`
|
|
141
|
+
`){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&gl.has(s))break;r=n}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ya.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(im),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(sr(n)||r&&gl.has(n)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!sr(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(v2.has(r))r=this.buffer[++e];else if(r==="%"&&Dk.has(this.buffer[e+1])&&Dk.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
142
142
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
143
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||e&&n===" ");let s=r-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=r),s}*pushUntil(e){let r=this.pos,n=this.buffer[r];for(;!e(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};
|
|
143
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||e&&n===" ");let s=r-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=r),s}*pushUntil(e){let r=this.pos,n=this.buffer[r];for(;!e(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};Zk.Lexer=om});var um=w(Uk=>{"use strict";var cm=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,n=this.lineStarts.length;for(;r<n;){let i=r+n>>1;this.lineStarts[i]<e?r=i+1:n=i}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let s=this.lineStarts[r-1];return{line:r,col:e-s+1}}}};Uk.LineCounter=cm});var dm=w(Wk=>{"use strict";var S2=ke("process"),Fk=ml(),k2=am();function hn(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function Bk(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Hk(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function yl(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function _i(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function _l(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function Vk(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!hn(e.start,"explicit-key-ind")&&!hn(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Hk(e.value)?e.value.end?_l(e.value.end,e.sep):e.value.end=e.sep:_l(e.start,e.sep),delete e.sep)}var lm=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new k2.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,r))yield*this.next(n);r||(yield*this.end())}*next(e){if(this.source=e,S2.env.LOG_TOKENS&&console.log("|",Fk.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=Fk.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let n=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in n?n.indent:0:r.type==="flow-collection"&&n.type==="document"&&(r.indent=0),r.type==="flow-collection"&&Vk(r),n.type){case"document":n.value=r;break;case"block-scalar":n.props.push(r);break;case"block-map":{let s=n.items[n.items.length-1];if(s.value){n.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=r;else{Object.assign(s,{key:r,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=n.items[n.items.length-1];s.value?n.items.push({start:[],value:r}):s.value=r;break}case"flow-collection":{let s=n.items[n.items.length-1];!s||s.value?n.items.push({start:[],key:r,sep:[]}):s.sep?s.value=r:Object.assign(s,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let s=r.items[r.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&Bk(s.start)===-1&&(r.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<r.indent))&&(n.type==="document"?n.end=s.start:n.items.push({start:s.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Bk(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=yl(this.peek(2)),n=_i(r),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
|
|
144
144
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
145
|
-
`,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){
|
|
145
|
+
`,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){_l(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,s=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&r.sep&&!r.value){let o=[];for(let a=0;a<r.sep.length;++a){let c=r.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||r.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):s||r.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(hn(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Hk(r.key)&&!hn(r.sep,"newline")){let o=_i(r.start),a=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else i.length>0?r.sep=r.sep.concat(i,this.sourceToken):r.sep.push(this.sourceToken);else if(hn(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=_i(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):hn(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||r.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!hn(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){_l(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||hn(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:s,sep:[]}):r.sep?this.stack.push(s):Object.assign(r,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=yl(n),i=_i(s);Vk(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
|
|
146
146
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
147
|
-
`,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=
|
|
148
|
-
`+r}function bm(t){let e=t.toLowerCase().replace(/[\s_-]/g,"");return V2[e]??e}function de(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function e$(t){let e=We(t,"flow config");return de({appId:Ke(e.appId),name:Ke(e.name),tags:e.tags!==void 0?n$(e.tags,"tags"):void 0,env:e.env!==void 0?s$(e.env,"env"):void 0,meta:e.meta!==void 0?K2(e.meta):void 0})}function K2(t){let e=We(t,"meta"),r;if(e.sourceEvents!==void 0){if(!Array.isArray(e.sourceEvents)||e.sourceEvents.length!==2)throw new me("meta.sourceEvents must be [firstSeq, lastSeq]");r=[Number(e.sourceEvents[0]),Number(e.sourceEvents[1])]}return de({recordedBy:Ke(e.recordedBy),sourceEvents:r,recordedAt:Ke(e.recordedAt),appFingerprint:Ke(e.appFingerprint)})}function mm(t,e){if(t==null)return[];if(!Array.isArray(t))throw new me(`${e} must be a YAML list`);return t.map(r=>J2(r))}function J2(t){if(typeof t=="string")return t$(t,void 0);if(t&&typeof t=="object"&&!Array.isArray(t)){let{anchors:e,...r}=t,n=Object.keys(r),s=n[0];if(n.length!==1||s===void 0)throw new me(`a step must have exactly one command key (plus optional "anchors"), got: ${n.join(", ")||"none"}`);let i=t$(s,r[s]);if(e!==void 0){if(i.kind!=="tapOn")throw new me(`"anchors" is only valid on tapOn steps, found on ${s}`);i.anchors=G2(e)}return i}throw new me(`invalid step: ${JSON.stringify(t)}`)}function t$(t,e){switch(t){case"launchApp":{if(e==null)return{kind:"launchApp"};if(Pt(e))return{kind:"launchApp",appId:String(e)};let r=We(e,t);return de({kind:"launchApp",appId:Ke(r.appId),clearState:_i(r.clearState),stopApp:_i(r.stopApp),arguments:r.arguments!==void 0?n$(r.arguments,"arguments"):void 0})}case"stopApp":return e==null?{kind:"stopApp"}:Pt(e)?{kind:"stopApp",appId:String(e)}:de({kind:"stopApp",appId:Ke(We(e,t).appId)});case"tapOn":case"longPressOn":{let r=t==="longPressOn";if(Pt(e))return de({kind:"tapOn",selector:{text:String(e)},longPress:r||void 0});let n=We(e,t),s=de({...pm(n),point:n.point!==void 0?bl(n.point):void 0});if(Object.keys(s).length===0)throw new me(`${t} needs a selector (text/id/role/point)`);return de({kind:"tapOn",selector:s,longPress:r||_i(n.longPress)?!0:void 0,repeat:qt(n.repeat),optional:_i(n.optional),timeoutMs:qt(n.timeoutMs??n.timeout)})}case"inputText":{if(!Pt(e))throw new me("inputText takes a string");return{kind:"inputText",text:String(e)}}case"eraseText":{if(e==null)return{kind:"eraseText",chars:50};let r=qt(e);if(r===void 0)throw new me("eraseText takes a number of characters");return{kind:"eraseText",chars:r}}case"pressKey":{if(!Pt(e))throw new me("pressKey takes a key name");return{kind:"pressKey",key:bm(String(e))}}case"hideKeyboard":return{kind:"hideKeyboard"};case"swipe":{let r=We(e,t),n=de({kind:"swipe",direction:r.direction!==void 0?r$(r.direction):void 0,start:r.start!==void 0?bl(r.start):void 0,end:r.end!==void 0?bl(r.end):void 0,durationMs:qt(r.durationMs??r.duration)});if(!n.direction&&!(n.start&&n.end))throw new me("swipe needs a direction or start+end points");return n}case"scroll":return{kind:"scroll"};case"scrollUntilVisible":{let r=We(e,t),n=r.element!==void 0?Pt(r.element)?{text:r.element}:We(r.element,"scrollUntilVisible.element"):r,s=pm(n);if(Object.keys(s).length===0)throw new me("scrollUntilVisible needs a selector (element/text/id)");return de({kind:"scrollUntilVisible",selector:s,direction:r.direction!==void 0?r$(r.direction):void 0,timeoutMs:qt(r.timeout??r.timeoutMs)})}case"assertVisible":case"assertNotVisible":{let r=t;if(Pt(e))return{kind:r,selector:{text:String(e)}};let n=We(e,t),s=pm(n);if(Object.keys(s).length===0)throw new me(`${t} needs a selector (text/id/role)`);return de({kind:r,selector:s,timeoutMs:qt(n.timeout??n.timeoutMs),optional:_i(n.optional)})}case"openLink":case"openUrl":{if(Pt(e))return{kind:"openLink",url:String(e)};let r=We(e,t),n=Ke(r.link??r.url);if(!n)throw new me(`${t} needs a url`);return{kind:"openLink",url:n}}case"back":return{kind:"back"};case"setOrientation":{let r=String(e).toUpperCase(),n=Qk[r];if(!n)throw new me(`invalid orientation ${JSON.stringify(e)} \u2014 expected one of ${Object.keys(Qk).join(", ")}`);return{kind:"setOrientation",orientation:n}}case"takeScreenshot":return e==null?{kind:"takeScreenshot"}:Pt(e)?{kind:"takeScreenshot",path:String(e)}:de({kind:"takeScreenshot",path:Ke(We(e,t).path)});case"waitForAnimationToEnd":{if(e==null)return{kind:"waitForAnimationToEnd"};let r=We(e,t);return de({kind:"waitForAnimationToEnd",timeoutMs:qt(r.timeout??r.timeoutMs)})}case"wait":{let r=Pt(e)?qt(e):qt(We(e,t).ms);if(r===void 0)throw new me("wait takes a duration in milliseconds");return{kind:"wait",ms:r}}case"runFlow":{if(Pt(e))return{kind:"runFlow",file:String(e)};let r=We(e,t),n=Ke(r.file);if(!n)throw new me("runFlow needs a file");return de({kind:"runFlow",file:n,env:r.env!==void 0?s$(r.env,"runFlow.env"):void 0})}case"repeat":{let r=We(e,t),n=qt(r.times);if(n===void 0)throw new me("repeat needs times");return{kind:"repeat",times:n,steps:mm(r.commands??r.steps,"repeat.commands")}}case"retry":{let r=We(e,t);return{kind:"retry",maxRetries:qt(r.maxRetries)??1,steps:mm(r.commands??r.steps,"retry.commands")}}case"simon.assertRoute":{if(!Pt(e))throw new me("simon.assertRoute takes a route string");return{kind:"simon.assertRoute",route:String(e)}}case"simon.note":{if(!Pt(e))throw new me("simon.note takes a text string");return{kind:"simon.note",text:String(e)}}default:throw new me(`unknown step: "${t}"`)}}function pm(t){return de({id:Ke(t.id),text:Ke(t.text),regex:_i(t.regex),role:Ke(t.role),index:qt(t.index)})}function G2(t){let e=We(t,"anchors");return de({id:Ke(e.id),label:Ke(e.label),text:Ke(e.text),role:Ke(e.role),point:e.point!==void 0?bl(e.point):void 0,route:Ke(e.route)})}function bl(t){let e=(r,n)=>{if(!Number.isFinite(r)||!Number.isFinite(n)||r<0||r>1||n<0||n>1)throw new me(`point ${JSON.stringify(t)} out of range \u2014 coordinates are normalized [0,1] (use "%" for percents)`);return[r,n]};if(Array.isArray(t)&&t.length===2)return e(Number(t[0]),Number(t[1]));if(typeof t=="string"){let r=t.split(",").map(n=>n.trim());if(r.length===2&&r[0]&&r[1]){let n=s=>s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return e(n(r[0]),n(r[1]))}}throw new me(`invalid point ${JSON.stringify(t)} \u2014 use "50%,80%" or [0.5, 0.8]`)}function r$(t){let e=String(t).toLowerCase();if(!W2.has(e))throw new me(`invalid direction ${JSON.stringify(t)}`);return e}function gm(t,e){return typeof t=="string"?t.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(r,n)=>e[n]??r):Array.isArray(t)?t.map(r=>gm(r,e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([r,n])=>[r,gm(n,e)])):t}function Y2(t){return de({appId:t.appId,name:t.name,tags:t.tags,env:t.env,meta:t.meta&&Object.keys(t.meta).length?de({...t.meta}):void 0})}function ym(t){switch(t.kind){case"launchApp":{let e=de({appId:t.appId,clearState:t.clearState,stopApp:t.stopApp,arguments:t.arguments});return Object.keys(e).length?{launchApp:e}:"launchApp"}case"stopApp":return t.appId!==void 0?{stopApp:t.appId}:"stopApp";case"tapOn":{let{point:e,...r}=t.selector,n=hm(r),s=de({point:e,longPress:t.longPress,repeat:t.repeat,optional:t.optional,timeout:t.timeoutMs});if(n.text!==void 0&&Object.keys(n).length===1&&Object.keys(s).length===0&&!t.anchors)return{tapOn:n.text};let i={tapOn:{...n,...s}};return t.anchors&&(i.anchors=de({...t.anchors})),i}case"inputText":return{inputText:t.text};case"eraseText":return t.chars===50?"eraseText":{eraseText:t.chars};case"pressKey":return{pressKey:t.key};case"hideKeyboard":return"hideKeyboard";case"swipe":return{swipe:de({direction:t.direction,start:t.start,end:t.end,duration:t.durationMs})};case"scroll":return"scroll";case"scrollUntilVisible":return{scrollUntilVisible:de({...hm(t.selector),direction:t.direction,timeout:t.timeoutMs})};case"assertVisible":case"assertNotVisible":{let e=de({...hm(t.selector),timeout:t.timeoutMs,optional:t.optional}),r=e.text!==void 0&&Object.keys(e).length===1;return{[t.kind]:r?e.text:e}}case"openLink":return{openLink:t.url};case"back":return"back";case"setOrientation":return{setOrientation:H2[t.orientation]};case"takeScreenshot":return t.path!==void 0?{takeScreenshot:t.path}:"takeScreenshot";case"waitForAnimationToEnd":return t.timeoutMs!==void 0?{waitForAnimationToEnd:{timeout:t.timeoutMs}}:"waitForAnimationToEnd";case"wait":return{wait:t.ms};case"runFlow":return t.env!==void 0?{runFlow:{file:t.file,env:t.env}}:{runFlow:t.file};case"repeat":return{repeat:{times:t.times,commands:t.steps.map(ym)}};case"retry":return{retry:{maxRetries:t.maxRetries,commands:t.steps.map(ym)}};case"simon.assertRoute":return{"simon.assertRoute":t.route};case"simon.note":return{"simon.note":t.text}}}function hm(t){return de({id:t.id,text:t.text,regex:t.regex,role:t.role,index:t.index})}function Pt(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function We(t,e){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new me(`${e} must be a mapping, got ${JSON.stringify(t)}`);return t}function n$(t,e){if(!Array.isArray(t))throw new me(`${e} must be a list`);return t.map(String)}function s$(t,e){let r=We(t,e);return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,String(s)]))}function Ke(t){return t==null?void 0:String(t)}function qt(t){if(t==null)return;let e=Number(t);if(Number.isNaN(e))throw new me(`expected a number, got ${JSON.stringify(t)}`);return e}function _i(t){return t===!0||t==="true"?!0:void 0}var ba,me,V2,Qk,H2,W2,vl=$(()=>{"use strict";ba=Mt(fm(),1),me=class extends Error{constructor(e){super(e),this.name="FlowParseError"}};V2={return:"enter",esc:"escape",del:"delete",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"},Qk={PORTRAIT:"portrait",UPSIDE_DOWN:"portrait_upside_down",PORTRAIT_UPSIDE_DOWN:"portrait_upside_down",LANDSCAPE_LEFT:"landscape_left",LANDSCAPE_RIGHT:"landscape_right"},H2={portrait:"PORTRAIT",portrait_upside_down:"UPSIDE_DOWN",landscape_left:"LANDSCAPE_LEFT",landscape_right:"LANDSCAPE_RIGHT"},W2=new Set(["up","down","left","right"])});import{randomUUID as X2}from"node:crypto";import{mkdir as i$,writeFile as o$}from"node:fs/promises";import{basename as Q2,dirname as xl,isAbsolute as f$,join as wm,resolve as p$}from"node:path";function a$(t){return t.config.name?t.config.name:t.file?Q2(t.file).replace(/\.ya?ml$/i,""):"flow"}function c$(t){return"optional"in t&&t.optional===!0}function u$(t){return wm(process.cwd(),".simon","artifacts",t)}function oL(t,e){let r=/\.[a-z0-9]+$/i.test(t)?t:`${t}.png`;return f$(r)?r:p$(e,r)}function l$(t){return t instanceof Error?t.message:String(t)}function d$(t){return new Promise(e=>setTimeout(e,t))}var eL,tL,rL,nL,sL,iL,mn,h$=$(()=>{"use strict";nn();vl();eL=800,tL=250,rL=2e3,nL=1e3,sL=400,iL={up:"down",down:"up",left:"right",right:"left"},mn=class{client;udid;flowDir;constructor(e){this.client=e.client,this.udid=e.udid,this.flowDir=e.flowDir}async run(e,r){let n=X2(),s={runId:n,flowName:a$(e),config:e.config,env:{...e.config.env,...r?.env},dir:this.flowDir??(e.file?xl(e.file):process.cwd())},i=Date.now(),o=[],a=!0;for(let[c,u]of e.steps.entries()){let l=await this.executeStep(u,c,s);if(o.push(l),!l.ok&&!c$(u)){a=!1,await this.captureFailureScreenshot(s,c);break}}return{flow:e,runId:n,pass:a,steps:o,startedAt:i,finishedAt:Date.now()}}async executeStep(e,r,n){let s=Date.now();try{let i=await this.dispatch(e,r,n);return de({step:e,index:r,ok:!0,resolvedBy:i,durationMs:Date.now()-s})}catch(i){return{step:e,index:r,ok:!1,error:l$(i),durationMs:Date.now()-s}}}async dispatch(e,r,n){switch(e.kind){case"launchApp":{let s=e.appId??n.config.appId;if(!s)throw new Error("launchApp: no appId on the step or in the flow config");e.clearState&&console.warn("[simon/flow] launchApp.clearState is not supported by the action API yet \u2014 launching without clearing"),await this.act(n,r,{type:"launchApp",appId:s,...e.arguments?{args:e.arguments}:{},...e.stopApp?{relaunch:!0}:{}});return}case"stopApp":{let s=e.appId??n.config.appId;if(!s)throw new Error("stopApp: no appId on the step or in the flow config");await this.act(n,r,{type:"stopApp",appId:s});return}case"tapOn":return this.runTapOn(e,r,n);case"inputText":await this.act(n,r,{type:"inputText",text:e.text});return;case"eraseText":await this.act(n,r,{type:"eraseText",chars:e.chars});return;case"pressKey":await this.act(n,r,{type:"key",key:e.key});return;case"hideKeyboard":console.warn("[simon/flow] hideKeyboard has no daemon action yet \u2014 skipping");return;case"swipe":await this.act(n,r,{type:"swipe",...e.direction?{direction:e.direction}:{},...e.start?{from:{x:e.start[0],y:e.start[1]}}:{},...e.end?{to:{x:e.end[0],y:e.end[1]}}:{},...e.durationMs!==void 0?{durationMs:e.durationMs}:{}});return;case"scroll":await this.act(n,r,{type:"swipe",direction:"up"});return;case"scrollUntilVisible":return this.runScrollUntilVisible(e,r,n);case"assertVisible":case"assertNotVisible":{let s=e.timeoutMs??(e.optional?7e3:17e3);await this.act(n,r,{type:"waitFor",selector:e.selector,timeoutMs:s,...e.kind==="assertNotVisible"?{gone:!0}:{}});return}case"openLink":await this.act(n,r,{type:"openUrl",url:e.url});return;case"back":console.warn("[simon/flow] back has no iOS equivalent \u2014 skipping");return;case"setOrientation":await this.act(n,r,{type:"orientation",orientation:e.orientation});return;case"takeScreenshot":{let s=await this.act(n,r,{type:"screenshot"});if(!s.screenshotBase64)throw new Error("screenshot action returned no image");let i=e.path?oL(e.path,n.dir):wm(u$(n.runId),`step-${r}.png`);await i$(xl(i),{recursive:!0}),await o$(i,Buffer.from(s.screenshotBase64,"base64"));return}case"waitForAnimationToEnd":return this.runWaitForAnimationToEnd(e.timeoutMs??rL);case"wait":await d$(e.ms);return;case"runFlow":{let s=f$(e.file)?e.file:p$(n.dir,e.file),i=await _r(s,{env:{...n.env,...e.env}}),o={runId:n.runId,flowName:a$(i),config:{...n.config,...i.config},env:{...n.env,...i.config.env,...e.env},dir:xl(s)},a=await this.runSteps(i.steps,o);if(a)throw new Error(`runFlow ${e.file}: step ${a.index} (${a.step.kind}) failed: ${a.error}`);return}case"repeat":{for(let s=0;s<e.times;s++){let i=await this.runSteps(e.steps,n);if(i)throw new Error(`repeat: iteration ${s+1}/${e.times} failed at step ${i.index} (${i.step.kind}): ${i.error}`)}return}case"retry":{let s="";for(let i=0;i<=e.maxRetries;i++){let o=await this.runSteps(e.steps,n);if(!o)return;s=`step ${o.index} (${o.step.kind}): ${o.error}`}throw new Error(`retry: still failing after ${e.maxRetries+1} attempts \u2014 ${s}`)}case"simon.assertRoute":console.warn(`[simon/flow] simon.assertRoute ${e.route}: no white-box channel available \u2014 skipping`);return;case"simon.note":return}}async runTapOn(e,r,n){let{point:s,...i}=e.selector,o=i.id!==void 0||i.text!==void 0||i.role!==void 0?i:void 0,a=[];o&&a.push({resolvedBy:"selector",selector:o});let c=e.anchors;c?.id&&a.push({resolvedBy:"id",selector:{id:c.id}}),c?.label&&a.push({resolvedBy:"label",selector:{text:c.label}}),c?.text&&a.push({resolvedBy:"text",selector:{text:c.text}});let u=c?.point??s;if(u&&a.push({resolvedBy:"point",point:u}),a.length===0)throw new Error("tapOn: no selector, anchors, or point to resolve");if(o){let p=e.timeoutMs??(e.optional?7e3:17e3);try{await this.act(n,r,{type:"waitFor",selector:o,timeoutMs:p})}catch{}}let l=e.repeat??1,d=new Set,f=[];for(let p of a){let m=JSON.stringify(p.selector??p.point);if(d.has(m))continue;d.add(m);let h={type:"tap",...p.selector?{selector:p.selector}:{},...p.point?{point:{x:p.point[0],y:p.point[1]}}:{},...e.longPress?{longPressMs:eL}:{}};try{for(let g=0;g<l;g++)await this.act(n,r,h);return p.resolvedBy}catch(g){f.push(`${p.resolvedBy}: ${l$(g)}`)}}throw new Error(`tapOn: every anchor facet failed \u2014 ${f.join("; ")}`)}async runScrollUntilVisible(e,r,n){let s=e.timeoutMs??17e3,i=Date.now()+s,o=iL[e.direction??"down"];for(;;)try{await this.act(n,r,{type:"waitFor",selector:e.selector,timeoutMs:nL});return}catch{if(Date.now()>=i)throw new Error(`scrollUntilVisible: ${JSON.stringify(e.selector)} not found within ${s}ms`);await this.act(n,r,{type:"swipe",direction:o,durationMs:sL})}}async runWaitForAnimationToEnd(e){let r=Date.now()+e,n;for(;Date.now()<r;){let s=await this.client.uiSnapshot(this.udid),i=JSON.stringify(Xn(s.root).map(o=>o.frame));if(n!==void 0&&i===n)return;n=i,await d$(tL)}}async runSteps(e,r){for(let[n,s]of e.entries()){let i=await this.executeStep(s,n,r);if(!i.ok&&!c$(s))return i}return null}async act(e,r,n){let s={kind:"flow",flowName:e.flowName,runId:e.runId,stepIndex:r},i=await this.client.action(this.udid,s,n);if(!i.ok)throw new Error(i.error??`${n.type} failed`);return i}async captureFailureScreenshot(e,r){try{let n=await this.act(e,r,{type:"screenshot"});if(!n.screenshotBase64)return;let s=wm(u$(e.runId),`failure-step-${r}.png`);await i$(xl(s),{recursive:!0}),await o$(s,Buffer.from(n.screenshotBase64,"base64"))}catch{}}}});function vm(t,e){let r=[...t].sort((u,l)=>u.seq-l.seq),n=e.appId??dL(r),s=[],i=r[0]?.seq;for(let u of r){if(i=u.seq,u.event.type==="agentVerdict")break;let l=aL(u.event,n);l&&JSON.stringify(s.at(-1))!==JSON.stringify(l)&&s.push(l)}let o=r[0],a=de({recordedBy:e.recordedBy,sourceEvents:o!==void 0&&i!==void 0?[o.seq,i]:void 0,recordedAt:e.recordedAt});return{config:de({appId:n,name:e.name,meta:Object.keys(a).length?a:void 0}),steps:s}}function bi(t,e){return wl(vm(t,e))}function aL(t,e){switch(t.type){case"launchApp":return de({kind:"launchApp",appId:t.appId===e?void 0:t.appId,arguments:t.args&&t.args.length?t.args:void 0});case"stopApp":return de({kind:"stopApp",appId:t.appId===e?void 0:t.appId});case"openUrl":return{kind:"openLink",url:t.url};case"tap":return m$(t.point,t.element,!1);case"longPress":return m$(t.point,t.element,!0);case"inputText":return{kind:"inputText",text:t.text};case"eraseText":return{kind:"eraseText",chars:t.chars};case"key":return{kind:"pressKey",key:t.key};case"button":return{kind:"simon.note",text:`device button: ${t.button}`};case"pinch":return{kind:"simon.note",text:`pinch at (${gn(t.center.x)}, ${gn(t.center.y)}) scale ${t.scale}`};case"swipe":return cL(t);case"orientation":return{kind:"setOrientation",orientation:t.orientation};case"assert":{let r=g$(t.assertion);return r?{kind:r.kind,selector:r.selector}:{kind:"simon.note",text:`assert ${t.pass?"passed":"failed"}: ${t.assertion}`}}case"waitFor":{if(!t.satisfied)return null;let r=g$(t.condition);return r?{kind:r.kind,selector:r.selector}:null}case"note":return{kind:"simon.note",text:t.text};case"screenshot":case"uiSnapshot":case"appLog":case"agentThought":case"installApp":case"flowStarted":case"flowFinished":case"deviceBooted":case"deviceShutdown":case"agentVerdict":return null}}function m$(t,e,r){let n=[gn(t.x),gn(t.y)],s=e?.id!==void 0?{id:e.id}:e?.label!==void 0?{text:e.label}:e?.text!==void 0?{text:e.text}:{point:n},i=de({id:e?.id,label:e?.label,text:e?.text,role:e?.role,point:n});return de({kind:"tapOn",selector:s,longPress:r?!0:void 0,anchors:i})}function cL(t){let e=t.to.x-t.from.x,r=t.to.y-t.from.y,n=Math.abs(e),s=Math.abs(r),i=Math.max(n,s),o=Math.min(n,s);return i>.15&&o<=i/3?{kind:"swipe",direction:n>=s?e>0?"right":"left":r>0?"down":"up"}:{kind:"swipe",start:[gn(t.from.x),gn(t.from.y)],end:[gn(t.to.x),gn(t.to.y)],durationMs:t.durationMs}}function g$(t){let e=t.trim(),r=/^(visible|notVisible)\s*:\s*(.+)$/s.exec(e);if(r){let i=lL(r[2]);return i?{kind:r[1]==="visible"?"assertVisible":"assertNotVisible",selector:i}:null}let n=/\sgone$/.test(e);n&&(e=e.replace(/\sgone$/,"").trim());let s=uL(e);return s?{kind:n?"assertNotVisible":"assertVisible",selector:s}:null}function uL(t){let e={},r=t.trim();for(;r.length>0;){let n=/^(id|text|role|index)=/.exec(r);if(!n)return null;if(r=r.slice(n[0].length),r.startsWith('"')){let s=/^"(?:[^"\\]|\\.)*"/.exec(r);if(!s)return null;let i=JSON.parse(s[0]);if(r=r.slice(s[0].length).trimStart(),r.startsWith("(regex)")&&(e.regex=!0,r=r.slice(7).trimStart()),n[1]==="id")e.id=i;else if(n[1]==="text")e.text=i;else return null}else{let s=/^\S+/.exec(r);if(!s)return null;if(r=r.slice(s[0].length).trimStart(),n[1]==="role")e.role=s[0];else if(n[1]==="index")e.index=Number(s[0]);else return null}}return e.id!==void 0||e.text!==void 0||e.role!==void 0?e:null}function lL(t){let e=t.trim();if(!e)return null;if(e.startsWith("{"))try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}return{text:e}}function dL(t){for(let e of t)if(e.event.type==="launchApp")return e.event.appId}function gn(t){return Math.round(t*1e4)/1e4}var y$=$(()=>{"use strict";vl()});function Sl(t){let e=[],r={};t.config.appId&&(r.appId=t.config.appId),t.config.name&&(r.name=t.config.name),t.config.tags?.length&&(r.tags=t.config.tags),t.config.env&&Object.keys(t.config.env).length>0&&(r.env=t.config.env);let n=t.steps.map(i=>$m(i,e)).filter(i=>i!==null),s=(0,Sm.stringify)(r).trimEnd()+`
|
|
147
|
+
`,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=yl(e),n=_i(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=yl(e),n=_i(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Wk.Parser=lm});var Xk=w(ba=>{"use strict";var Kk=Yh(),$2=la(),_a=pa(),E2=Jp(),T2=le(),P2=um(),Jk=dm();function Gk(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new P2.LineCounter||null,prettyErrors:e}}function O2(t,e={}){let{lineCounter:r,prettyErrors:n}=Gk(e),s=new Jk.Parser(r?.addNewLine),i=new Kk.Composer(e),o=Array.from(i.compose(s.parse(t)));if(n&&r)for(let a of o)a.errors.forEach(_a.prettifyError(t,r)),a.warnings.forEach(_a.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Yk(t,e={}){let{lineCounter:r,prettyErrors:n}=Gk(e),s=new Jk.Parser(r?.addNewLine),i=new Kk.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new _a.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(_a.prettifyError(t,r)),o.warnings.forEach(_a.prettifyError(t,r))),o}function I2(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let s=Yk(t,r);if(!s)return null;if(s.warnings.forEach(i=>E2.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:n},r))}function A2(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=r??e??{};if(!s)return}return T2.isDocument(t)&&!n?t.toString(r):new $2.Document(t,n,r).toString(r)}ba.parse=I2;ba.parseAllDocuments=O2;ba.parseDocument=Yk;ba.stringify=A2});var pm=w(ge=>{"use strict";var N2=Yh(),R2=la(),z2=Ah(),fm=pa(),M2=Ko(),mn=le(),C2=ln(),j2=Ze(),L2=fn(),q2=pn(),D2=ml(),Z2=am(),U2=um(),F2=dm(),bl=Xk(),Qk=Bo();ge.Composer=N2.Composer;ge.Document=R2.Document;ge.Schema=z2.Schema;ge.YAMLError=fm.YAMLError;ge.YAMLParseError=fm.YAMLParseError;ge.YAMLWarning=fm.YAMLWarning;ge.Alias=M2.Alias;ge.isAlias=mn.isAlias;ge.isCollection=mn.isCollection;ge.isDocument=mn.isDocument;ge.isMap=mn.isMap;ge.isNode=mn.isNode;ge.isPair=mn.isPair;ge.isScalar=mn.isScalar;ge.isSeq=mn.isSeq;ge.Pair=C2.Pair;ge.Scalar=j2.Scalar;ge.YAMLMap=L2.YAMLMap;ge.YAMLSeq=q2.YAMLSeq;ge.CST=D2;ge.Lexer=Z2.Lexer;ge.LineCounter=U2.LineCounter;ge.Parser=F2.Parser;ge.parse=bl.parse;ge.parseAllDocuments=bl.parseAllDocuments;ge.parseDocument=bl.parseDocument;ge.stringify=bl.stringify;ge.visit=Qk.visit;ge.visitAsync=Qk.visitAsync});import{readFile as B2}from"node:fs/promises";import{resolve as V2}from"node:path";function bm(t,e){let r=(0,wa.parseAllDocuments)(t);for(let c of r){let u=c.errors[0];if(u)throw new me(`invalid YAML: ${u.message}`)}let n=r.map(c=>c.toJS()).filter(c=>c!=null),s={},i=[];if(n.length===1)Array.isArray(n[0])?i=n[0]:s=t$(n[0]);else if(n.length===2)s=t$(n[0]),i=n[1];else if(n.length>2)throw new me(`expected at most 2 YAML documents (config, steps), got ${n.length}`);let o={...s.env,...e?.env},a=gm(ym(i,o),"steps");return de({config:s,steps:a,file:e?.file})}async function br(t,e){let r=V2(t),n=await B2(r,"utf8");return bm(n,{...e?.env?{env:e.env}:{},file:r})}function vl(t){let e={lineWidth:0,aliasDuplicateObjects:!1},r=(0,wa.stringify)(t.steps.map(_m),e),n=X2(t.config);return Object.keys(n).length===0?r:(0,wa.stringify)(n,e)+`---
|
|
148
|
+
`+r}function wm(t){let e=t.toLowerCase().replace(/[\s_-]/g,"");return H2[e]??e}function de(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function t$(t){let e=Ke(t,"flow config");return de({appId:Je(e.appId),name:Je(e.name),tags:e.tags!==void 0?s$(e.tags,"tags"):void 0,env:e.env!==void 0?i$(e.env,"env"):void 0,meta:e.meta!==void 0?J2(e.meta):void 0})}function J2(t){let e=Ke(t,"meta"),r;if(e.sourceEvents!==void 0){if(!Array.isArray(e.sourceEvents)||e.sourceEvents.length!==2)throw new me("meta.sourceEvents must be [firstSeq, lastSeq]");r=[Number(e.sourceEvents[0]),Number(e.sourceEvents[1])]}return de({recordedBy:Je(e.recordedBy),sourceEvents:r,recordedAt:Je(e.recordedAt),appFingerprint:Je(e.appFingerprint)})}function gm(t,e){if(t==null)return[];if(!Array.isArray(t))throw new me(`${e} must be a YAML list`);return t.map(r=>G2(r))}function G2(t){if(typeof t=="string")return r$(t,void 0);if(t&&typeof t=="object"&&!Array.isArray(t)){let{anchors:e,...r}=t,n=Object.keys(r),s=n[0];if(n.length!==1||s===void 0)throw new me(`a step must have exactly one command key (plus optional "anchors"), got: ${n.join(", ")||"none"}`);let i=r$(s,r[s]);if(e!==void 0){if(i.kind!=="tapOn")throw new me(`"anchors" is only valid on tapOn steps, found on ${s}`);i.anchors=Y2(e)}return i}throw new me(`invalid step: ${JSON.stringify(t)}`)}function r$(t,e){switch(t){case"launchApp":{if(e==null)return{kind:"launchApp"};if(Ot(e))return{kind:"launchApp",appId:String(e)};let r=Ke(e,t);return de({kind:"launchApp",appId:Je(r.appId),clearState:bi(r.clearState),stopApp:bi(r.stopApp),arguments:r.arguments!==void 0?s$(r.arguments,"arguments"):void 0})}case"stopApp":return e==null?{kind:"stopApp"}:Ot(e)?{kind:"stopApp",appId:String(e)}:de({kind:"stopApp",appId:Je(Ke(e,t).appId)});case"tapOn":case"longPressOn":{let r=t==="longPressOn";if(Ot(e))return de({kind:"tapOn",selector:{text:String(e)},longPress:r||void 0});let n=Ke(e,t),s=de({...hm(n),point:n.point!==void 0?wl(n.point):void 0});if(Object.keys(s).length===0)throw new me(`${t} needs a selector (text/id/role/point)`);return de({kind:"tapOn",selector:s,longPress:r||bi(n.longPress)?!0:void 0,repeat:Dt(n.repeat),optional:bi(n.optional),timeoutMs:Dt(n.timeoutMs??n.timeout)})}case"inputText":{if(!Ot(e))throw new me("inputText takes a string");return{kind:"inputText",text:String(e)}}case"eraseText":{if(e==null)return{kind:"eraseText",chars:50};let r=Dt(e);if(r===void 0)throw new me("eraseText takes a number of characters");return{kind:"eraseText",chars:r}}case"pressKey":{if(!Ot(e))throw new me("pressKey takes a key name");return{kind:"pressKey",key:wm(String(e))}}case"hideKeyboard":return{kind:"hideKeyboard"};case"swipe":{let r=Ke(e,t),n=de({kind:"swipe",direction:r.direction!==void 0?n$(r.direction):void 0,start:r.start!==void 0?wl(r.start):void 0,end:r.end!==void 0?wl(r.end):void 0,durationMs:Dt(r.durationMs??r.duration)});if(!n.direction&&!(n.start&&n.end))throw new me("swipe needs a direction or start+end points");return n}case"scroll":return{kind:"scroll"};case"scrollUntilVisible":{let r=Ke(e,t),n=r.element!==void 0?Ot(r.element)?{text:r.element}:Ke(r.element,"scrollUntilVisible.element"):r,s=hm(n);if(Object.keys(s).length===0)throw new me("scrollUntilVisible needs a selector (element/text/id)");return de({kind:"scrollUntilVisible",selector:s,direction:r.direction!==void 0?n$(r.direction):void 0,timeoutMs:Dt(r.timeout??r.timeoutMs)})}case"assertVisible":case"assertNotVisible":{let r=t;if(Ot(e))return{kind:r,selector:{text:String(e)}};let n=Ke(e,t),s=hm(n);if(Object.keys(s).length===0)throw new me(`${t} needs a selector (text/id/role)`);return de({kind:r,selector:s,timeoutMs:Dt(n.timeout??n.timeoutMs),optional:bi(n.optional)})}case"openLink":case"openUrl":{if(Ot(e))return{kind:"openLink",url:String(e)};let r=Ke(e,t),n=Je(r.link??r.url);if(!n)throw new me(`${t} needs a url`);return{kind:"openLink",url:n}}case"back":return{kind:"back"};case"setOrientation":{let r=String(e).toUpperCase(),n=e$[r];if(!n)throw new me(`invalid orientation ${JSON.stringify(e)} \u2014 expected one of ${Object.keys(e$).join(", ")}`);return{kind:"setOrientation",orientation:n}}case"takeScreenshot":return e==null?{kind:"takeScreenshot"}:Ot(e)?{kind:"takeScreenshot",path:String(e)}:de({kind:"takeScreenshot",path:Je(Ke(e,t).path)});case"waitForAnimationToEnd":{if(e==null)return{kind:"waitForAnimationToEnd"};let r=Ke(e,t);return de({kind:"waitForAnimationToEnd",timeoutMs:Dt(r.timeout??r.timeoutMs)})}case"wait":{let r=Ot(e)?Dt(e):Dt(Ke(e,t).ms);if(r===void 0)throw new me("wait takes a duration in milliseconds");return{kind:"wait",ms:r}}case"runFlow":{if(Ot(e))return{kind:"runFlow",file:String(e)};let r=Ke(e,t),n=Je(r.file);if(!n)throw new me("runFlow needs a file");return de({kind:"runFlow",file:n,env:r.env!==void 0?i$(r.env,"runFlow.env"):void 0})}case"repeat":{let r=Ke(e,t),n=Dt(r.times);if(n===void 0)throw new me("repeat needs times");return{kind:"repeat",times:n,steps:gm(r.commands??r.steps,"repeat.commands")}}case"retry":{let r=Ke(e,t);return{kind:"retry",maxRetries:Dt(r.maxRetries)??1,steps:gm(r.commands??r.steps,"retry.commands")}}case"simon.assertRoute":{if(!Ot(e))throw new me("simon.assertRoute takes a route string");return{kind:"simon.assertRoute",route:String(e)}}case"simon.note":{if(!Ot(e))throw new me("simon.note takes a text string");return{kind:"simon.note",text:String(e)}}default:throw new me(`unknown step: "${t}"`)}}function hm(t){return de({id:Je(t.id),text:Je(t.text),regex:bi(t.regex),role:Je(t.role),index:Dt(t.index)})}function Y2(t){let e=Ke(t,"anchors");return de({id:Je(e.id),label:Je(e.label),text:Je(e.text),role:Je(e.role),point:e.point!==void 0?wl(e.point):void 0,route:Je(e.route)})}function wl(t){let e=(r,n)=>{if(!Number.isFinite(r)||!Number.isFinite(n)||r<0||r>1||n<0||n>1)throw new me(`point ${JSON.stringify(t)} out of range \u2014 coordinates are normalized [0,1] (use "%" for percents)`);return[r,n]};if(Array.isArray(t)&&t.length===2)return e(Number(t[0]),Number(t[1]));if(typeof t=="string"){let r=t.split(",").map(n=>n.trim());if(r.length===2&&r[0]&&r[1]){let n=s=>s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return e(n(r[0]),n(r[1]))}}throw new me(`invalid point ${JSON.stringify(t)} \u2014 use "50%,80%" or [0.5, 0.8]`)}function n$(t){let e=String(t).toLowerCase();if(!K2.has(e))throw new me(`invalid direction ${JSON.stringify(t)}`);return e}function ym(t,e){return typeof t=="string"?t.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(r,n)=>e[n]??r):Array.isArray(t)?t.map(r=>ym(r,e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([r,n])=>[r,ym(n,e)])):t}function X2(t){return de({appId:t.appId,name:t.name,tags:t.tags,env:t.env,meta:t.meta&&Object.keys(t.meta).length?de({...t.meta}):void 0})}function _m(t){switch(t.kind){case"launchApp":{let e=de({appId:t.appId,clearState:t.clearState,stopApp:t.stopApp,arguments:t.arguments});return Object.keys(e).length?{launchApp:e}:"launchApp"}case"stopApp":return t.appId!==void 0?{stopApp:t.appId}:"stopApp";case"tapOn":{let{point:e,...r}=t.selector,n=mm(r),s=de({point:e,longPress:t.longPress,repeat:t.repeat,optional:t.optional,timeout:t.timeoutMs});if(n.text!==void 0&&Object.keys(n).length===1&&Object.keys(s).length===0&&!t.anchors)return{tapOn:n.text};let i={tapOn:{...n,...s}};return t.anchors&&(i.anchors=de({...t.anchors})),i}case"inputText":return{inputText:t.text};case"eraseText":return t.chars===50?"eraseText":{eraseText:t.chars};case"pressKey":return{pressKey:t.key};case"hideKeyboard":return"hideKeyboard";case"swipe":return{swipe:de({direction:t.direction,start:t.start,end:t.end,duration:t.durationMs})};case"scroll":return"scroll";case"scrollUntilVisible":return{scrollUntilVisible:de({...mm(t.selector),direction:t.direction,timeout:t.timeoutMs})};case"assertVisible":case"assertNotVisible":{let e=de({...mm(t.selector),timeout:t.timeoutMs,optional:t.optional}),r=e.text!==void 0&&Object.keys(e).length===1;return{[t.kind]:r?e.text:e}}case"openLink":return{openLink:t.url};case"back":return"back";case"setOrientation":return{setOrientation:W2[t.orientation]};case"takeScreenshot":return t.path!==void 0?{takeScreenshot:t.path}:"takeScreenshot";case"waitForAnimationToEnd":return t.timeoutMs!==void 0?{waitForAnimationToEnd:{timeout:t.timeoutMs}}:"waitForAnimationToEnd";case"wait":return{wait:t.ms};case"runFlow":return t.env!==void 0?{runFlow:{file:t.file,env:t.env}}:{runFlow:t.file};case"repeat":return{repeat:{times:t.times,commands:t.steps.map(_m)}};case"retry":return{retry:{maxRetries:t.maxRetries,commands:t.steps.map(_m)}};case"simon.assertRoute":return{"simon.assertRoute":t.route};case"simon.note":return{"simon.note":t.text}}}function mm(t){return de({id:t.id,text:t.text,regex:t.regex,role:t.role,index:t.index})}function Ot(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function Ke(t,e){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new me(`${e} must be a mapping, got ${JSON.stringify(t)}`);return t}function s$(t,e){if(!Array.isArray(t))throw new me(`${e} must be a list`);return t.map(String)}function i$(t,e){let r=Ke(t,e);return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,String(s)]))}function Je(t){return t==null?void 0:String(t)}function Dt(t){if(t==null)return;let e=Number(t);if(Number.isNaN(e))throw new me(`expected a number, got ${JSON.stringify(t)}`);return e}function bi(t){return t===!0||t==="true"?!0:void 0}var wa,me,H2,e$,W2,K2,xl=$(()=>{"use strict";wa=Ct(pm(),1),me=class extends Error{constructor(e){super(e),this.name="FlowParseError"}};H2={return:"enter",esc:"escape",del:"delete",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"},e$={PORTRAIT:"portrait",UPSIDE_DOWN:"portrait_upside_down",PORTRAIT_UPSIDE_DOWN:"portrait_upside_down",LANDSCAPE_LEFT:"landscape_left",LANDSCAPE_RIGHT:"landscape_right"},W2={portrait:"PORTRAIT",portrait_upside_down:"UPSIDE_DOWN",landscape_left:"LANDSCAPE_LEFT",landscape_right:"LANDSCAPE_RIGHT"},K2=new Set(["up","down","left","right"])});import{randomUUID as Q2}from"node:crypto";import{mkdir as o$,writeFile as a$}from"node:fs/promises";import{basename as eL,dirname as Sl,isAbsolute as p$,join as vm,resolve as h$}from"node:path";function c$(t){return t.config.name?t.config.name:t.file?eL(t.file).replace(/\.ya?ml$/i,""):"flow"}function u$(t){return"optional"in t&&t.optional===!0}function l$(t){return vm(process.cwd(),".simon","artifacts",t)}function aL(t,e){let r=/\.[a-z0-9]+$/i.test(t)?t:`${t}.png`;return p$(r)?r:h$(e,r)}function d$(t){return t instanceof Error?t.message:String(t)}function f$(t){return new Promise(e=>setTimeout(e,t))}var tL,rL,nL,sL,iL,oL,gn,m$=$(()=>{"use strict";sn();xl();tL=800,rL=250,nL=2e3,sL=1e3,iL=400,oL={up:"down",down:"up",left:"right",right:"left"},gn=class{client;udid;flowDir;constructor(e){this.client=e.client,this.udid=e.udid,this.flowDir=e.flowDir}async run(e,r){let n=Q2(),s={runId:n,flowName:c$(e),config:e.config,env:{...e.config.env,...r?.env},dir:this.flowDir??(e.file?Sl(e.file):process.cwd())},i=Date.now(),o=[],a=!0;for(let[c,u]of e.steps.entries()){let l=await this.executeStep(u,c,s);if(o.push(l),!l.ok&&!u$(u)){a=!1,await this.captureFailureScreenshot(s,c);break}}return{flow:e,runId:n,pass:a,steps:o,startedAt:i,finishedAt:Date.now()}}async executeStep(e,r,n){let s=Date.now();try{let i=await this.dispatch(e,r,n);return de({step:e,index:r,ok:!0,resolvedBy:i,durationMs:Date.now()-s})}catch(i){return{step:e,index:r,ok:!1,error:d$(i),durationMs:Date.now()-s}}}async dispatch(e,r,n){switch(e.kind){case"launchApp":{let s=e.appId??n.config.appId;if(!s)throw new Error("launchApp: no appId on the step or in the flow config");e.clearState&&console.warn("[simon/flow] launchApp.clearState is not supported by the action API yet \u2014 launching without clearing"),await this.act(n,r,{type:"launchApp",appId:s,...e.arguments?{args:e.arguments}:{},...e.stopApp?{relaunch:!0}:{}});return}case"stopApp":{let s=e.appId??n.config.appId;if(!s)throw new Error("stopApp: no appId on the step or in the flow config");await this.act(n,r,{type:"stopApp",appId:s});return}case"tapOn":return this.runTapOn(e,r,n);case"inputText":await this.act(n,r,{type:"inputText",text:e.text});return;case"eraseText":await this.act(n,r,{type:"eraseText",chars:e.chars});return;case"pressKey":await this.act(n,r,{type:"key",key:e.key});return;case"hideKeyboard":console.warn("[simon/flow] hideKeyboard has no daemon action yet \u2014 skipping");return;case"swipe":await this.act(n,r,{type:"swipe",...e.direction?{direction:e.direction}:{},...e.start?{from:{x:e.start[0],y:e.start[1]}}:{},...e.end?{to:{x:e.end[0],y:e.end[1]}}:{},...e.durationMs!==void 0?{durationMs:e.durationMs}:{}});return;case"scroll":await this.act(n,r,{type:"swipe",direction:"up"});return;case"scrollUntilVisible":return this.runScrollUntilVisible(e,r,n);case"assertVisible":case"assertNotVisible":{let s=e.timeoutMs??(e.optional?7e3:17e3);await this.act(n,r,{type:"waitFor",selector:e.selector,timeoutMs:s,...e.kind==="assertNotVisible"?{gone:!0}:{}});return}case"openLink":await this.act(n,r,{type:"openUrl",url:e.url});return;case"back":console.warn("[simon/flow] back has no iOS equivalent \u2014 skipping");return;case"setOrientation":await this.act(n,r,{type:"orientation",orientation:e.orientation});return;case"takeScreenshot":{let s=await this.act(n,r,{type:"screenshot"});if(!s.screenshotBase64)throw new Error("screenshot action returned no image");let i=e.path?aL(e.path,n.dir):vm(l$(n.runId),`step-${r}.png`);await o$(Sl(i),{recursive:!0}),await a$(i,Buffer.from(s.screenshotBase64,"base64"));return}case"waitForAnimationToEnd":return this.runWaitForAnimationToEnd(e.timeoutMs??nL);case"wait":await f$(e.ms);return;case"runFlow":{let s=p$(e.file)?e.file:h$(n.dir,e.file),i=await br(s,{env:{...n.env,...e.env}}),o={runId:n.runId,flowName:c$(i),config:{...n.config,...i.config},env:{...n.env,...i.config.env,...e.env},dir:Sl(s)},a=await this.runSteps(i.steps,o);if(a)throw new Error(`runFlow ${e.file}: step ${a.index} (${a.step.kind}) failed: ${a.error}`);return}case"repeat":{for(let s=0;s<e.times;s++){let i=await this.runSteps(e.steps,n);if(i)throw new Error(`repeat: iteration ${s+1}/${e.times} failed at step ${i.index} (${i.step.kind}): ${i.error}`)}return}case"retry":{let s="";for(let i=0;i<=e.maxRetries;i++){let o=await this.runSteps(e.steps,n);if(!o)return;s=`step ${o.index} (${o.step.kind}): ${o.error}`}throw new Error(`retry: still failing after ${e.maxRetries+1} attempts \u2014 ${s}`)}case"simon.assertRoute":console.warn(`[simon/flow] simon.assertRoute ${e.route}: no white-box channel available \u2014 skipping`);return;case"simon.note":return}}async runTapOn(e,r,n){let{point:s,...i}=e.selector,o=i.id!==void 0||i.text!==void 0||i.role!==void 0?i:void 0,a=[];o&&a.push({resolvedBy:"selector",selector:o});let c=e.anchors;c?.id&&a.push({resolvedBy:"id",selector:{id:c.id}}),c?.label&&a.push({resolvedBy:"label",selector:{text:c.label}}),c?.text&&a.push({resolvedBy:"text",selector:{text:c.text}});let u=c?.point??s;if(u&&a.push({resolvedBy:"point",point:u}),a.length===0)throw new Error("tapOn: no selector, anchors, or point to resolve");if(o){let p=e.timeoutMs??(e.optional?7e3:17e3);try{await this.act(n,r,{type:"waitFor",selector:o,timeoutMs:p})}catch{}}let l=e.repeat??1,d=new Set,f=[];for(let p of a){let m=JSON.stringify(p.selector??p.point);if(d.has(m))continue;d.add(m);let h={type:"tap",...p.selector?{selector:p.selector}:{},...p.point?{point:{x:p.point[0],y:p.point[1]}}:{},...e.longPress?{longPressMs:tL}:{}};try{for(let g=0;g<l;g++)await this.act(n,r,h);return p.resolvedBy}catch(g){f.push(`${p.resolvedBy}: ${d$(g)}`)}}throw new Error(`tapOn: every anchor facet failed \u2014 ${f.join("; ")}`)}async runScrollUntilVisible(e,r,n){let s=e.timeoutMs??17e3,i=Date.now()+s,o=oL[e.direction??"down"];for(;;)try{await this.act(n,r,{type:"waitFor",selector:e.selector,timeoutMs:sL});return}catch{if(Date.now()>=i)throw new Error(`scrollUntilVisible: ${JSON.stringify(e.selector)} not found within ${s}ms`);await this.act(n,r,{type:"swipe",direction:o,durationMs:iL})}}async runWaitForAnimationToEnd(e){let r=Date.now()+e,n;for(;Date.now()<r;){let s=await this.client.uiSnapshot(this.udid),i=JSON.stringify(Qn(s.root).map(o=>o.frame));if(n!==void 0&&i===n)return;n=i,await f$(rL)}}async runSteps(e,r){for(let[n,s]of e.entries()){let i=await this.executeStep(s,n,r);if(!i.ok&&!u$(s))return i}return null}async act(e,r,n){let s={kind:"flow",flowName:e.flowName,runId:e.runId,stepIndex:r},i=await this.client.action(this.udid,s,n);if(!i.ok)throw new Error(i.error??`${n.type} failed`);return i}async captureFailureScreenshot(e,r){try{let n=await this.act(e,r,{type:"screenshot"});if(!n.screenshotBase64)return;let s=vm(l$(e.runId),`failure-step-${r}.png`);await o$(Sl(s),{recursive:!0}),await a$(s,Buffer.from(n.screenshotBase64,"base64"))}catch{}}}});function xm(t,e){let r=[...t].sort((u,l)=>u.seq-l.seq),n=e.appId??fL(r),s=[],i=r[0]?.seq;for(let u of r){if(i=u.seq,u.event.type==="agentVerdict")break;let l=cL(u.event,n);l&&JSON.stringify(s.at(-1))!==JSON.stringify(l)&&s.push(l)}let o=r[0],a=de({recordedBy:e.recordedBy,sourceEvents:o!==void 0&&i!==void 0?[o.seq,i]:void 0,recordedAt:e.recordedAt});return{config:de({appId:n,name:e.name,meta:Object.keys(a).length?a:void 0}),steps:s}}function wi(t,e){return vl(xm(t,e))}function cL(t,e){switch(t.type){case"launchApp":return de({kind:"launchApp",appId:t.appId===e?void 0:t.appId,arguments:t.args&&t.args.length?t.args:void 0});case"stopApp":return de({kind:"stopApp",appId:t.appId===e?void 0:t.appId});case"openUrl":return{kind:"openLink",url:t.url};case"tap":return g$(t.point,t.element,!1);case"longPress":return g$(t.point,t.element,!0);case"inputText":return{kind:"inputText",text:t.text};case"eraseText":return{kind:"eraseText",chars:t.chars};case"key":return{kind:"pressKey",key:t.key};case"button":return{kind:"simon.note",text:`device button: ${t.button}`};case"pinch":return{kind:"simon.note",text:`pinch at (${yn(t.center.x)}, ${yn(t.center.y)}) scale ${t.scale}`};case"swipe":return uL(t);case"orientation":return{kind:"setOrientation",orientation:t.orientation};case"assert":{let r=y$(t.assertion);return r?{kind:r.kind,selector:r.selector}:{kind:"simon.note",text:`assert ${t.pass?"passed":"failed"}: ${t.assertion}`}}case"waitFor":{if(!t.satisfied)return null;let r=y$(t.condition);return r?{kind:r.kind,selector:r.selector}:null}case"note":return{kind:"simon.note",text:t.text};case"screenshot":case"uiSnapshot":case"appLog":case"agentThought":case"installApp":case"flowStarted":case"flowFinished":case"deviceBooted":case"deviceShutdown":case"agentVerdict":return null}}function g$(t,e,r){let n=[yn(t.x),yn(t.y)],s=e?.id!==void 0?{id:e.id}:e?.label!==void 0?{text:e.label}:e?.text!==void 0?{text:e.text}:{point:n},i=de({id:e?.id,label:e?.label,text:e?.text,role:e?.role,point:n});return de({kind:"tapOn",selector:s,longPress:r?!0:void 0,anchors:i})}function uL(t){let e=t.to.x-t.from.x,r=t.to.y-t.from.y,n=Math.abs(e),s=Math.abs(r),i=Math.max(n,s),o=Math.min(n,s);return i>.15&&o<=i/3?{kind:"swipe",direction:n>=s?e>0?"right":"left":r>0?"down":"up"}:{kind:"swipe",start:[yn(t.from.x),yn(t.from.y)],end:[yn(t.to.x),yn(t.to.y)],durationMs:t.durationMs}}function y$(t){let e=t.trim(),r=/^(visible|notVisible)\s*:\s*(.+)$/s.exec(e);if(r){let i=dL(r[2]);return i?{kind:r[1]==="visible"?"assertVisible":"assertNotVisible",selector:i}:null}let n=/\sgone$/.test(e);n&&(e=e.replace(/\sgone$/,"").trim());let s=lL(e);return s?{kind:n?"assertNotVisible":"assertVisible",selector:s}:null}function lL(t){let e={},r=t.trim();for(;r.length>0;){let n=/^(id|text|role|index)=/.exec(r);if(!n)return null;if(r=r.slice(n[0].length),r.startsWith('"')){let s=/^"(?:[^"\\]|\\.)*"/.exec(r);if(!s)return null;let i=JSON.parse(s[0]);if(r=r.slice(s[0].length).trimStart(),r.startsWith("(regex)")&&(e.regex=!0,r=r.slice(7).trimStart()),n[1]==="id")e.id=i;else if(n[1]==="text")e.text=i;else return null}else{let s=/^\S+/.exec(r);if(!s)return null;if(r=r.slice(s[0].length).trimStart(),n[1]==="role")e.role=s[0];else if(n[1]==="index")e.index=Number(s[0]);else return null}}return e.id!==void 0||e.text!==void 0||e.role!==void 0?e:null}function dL(t){let e=t.trim();if(!e)return null;if(e.startsWith("{"))try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}return{text:e}}function fL(t){for(let e of t)if(e.event.type==="launchApp")return e.event.appId}function yn(t){return Math.round(t*1e4)/1e4}var _$=$(()=>{"use strict";xl()});function kl(t){let e=[],r={};t.config.appId&&(r.appId=t.config.appId),t.config.name&&(r.name=t.config.name),t.config.tags?.length&&(r.tags=t.config.tags),t.config.env&&Object.keys(t.config.env).length>0&&(r.env=t.config.env);let n=t.steps.map(i=>Em(i,e)).filter(i=>i!==null),s=(0,km.stringify)(r).trimEnd()+`
|
|
149
149
|
---
|
|
150
|
-
`+(0,
|
|
150
|
+
`+(0,km.stringify)(n);return e.length>0&&(s+=`
|
|
151
151
|
# not exported (simon-only): ${[...new Set(e)].join(", ")}
|
|
152
|
-
`),s}function km(t){return`${Math.round(t[0]*100)}%,${Math.round(t[1]*100)}%`}function xm(t,e){if(t.point&&t.id===void 0&&t.text===void 0)return{point:km(t.point)};let r={};return t.id!==void 0&&(r.id=t.id),t.text!==void 0&&(r.text=t.text),t.index!==void 0&&(r.index=t.index),Object.keys(r).length===0?(e.push("empty selector"),null):r}function $m(t,e){switch(t.kind){case"launchApp":{let r={};return t.appId&&(r.appId=t.appId),t.clearState&&(r.clearState=!0),t.stopApp!==void 0&&(r.stopApp=t.stopApp),Object.keys(r).length===0?"launchApp":{launchApp:r}}case"stopApp":return t.appId?{stopApp:t.appId}:"stopApp";case"tapOn":{let r=xm(t.selector,e);if(r===null)return null;let n=typeof r=="string"?{text:r}:{...r};if(t.longPress)return{longPressOn:n};t.optional&&(n.optional=!0);let s=Object.keys(n);return s.length===1&&s[0]==="text"?{tapOn:n.text}:{tapOn:n}}case"inputText":return{inputText:t.text};case"eraseText":return{eraseText:t.chars};case"pressKey":{let r=fL[t.key];return r?{pressKey:r}:(e.push(`pressKey ${t.key}`),null)}case"hideKeyboard":return"hideKeyboard";case"swipe":{let r={};return t.direction&&(r.direction=t.direction.toUpperCase()),t.start&&(r.start=km(t.start)),t.end&&(r.end=km(t.end)),t.durationMs&&(r.duration=t.durationMs),{swipe:r}}case"scroll":return"scroll";case"scrollUntilVisible":{let r=xm(t.selector,e);return r===null?null:{scrollUntilVisible:{element:r,...t.direction?{direction:t.direction.toUpperCase()}:{},...t.timeoutMs?{timeout:t.timeoutMs}:{}}}}case"assertVisible":case"assertNotVisible":{let r=xm(t.selector,e);if(r===null)return null;let n=typeof r=="string"?{text:r}:{...r};t.timeoutMs&&(n.timeout=t.timeoutMs),t.optional&&(n.optional=!0);let s=Object.keys(n);return s.length===1&&s[0]==="text"?{[t.kind]:n.text}:{[t.kind]:n}}case"openLink":return{openLink:t.url};case"back":return"back";case"setOrientation":return e.push("setOrientation"),null;case"takeScreenshot":return t.path?{takeScreenshot:t.path}:"takeScreenshot";case"waitForAnimationToEnd":return t.timeoutMs!==void 0?{waitForAnimationToEnd:{timeout:t.timeoutMs}}:"waitForAnimationToEnd";case"wait":return{waitForAnimationToEnd:{timeout:t.ms}};case"runFlow":return t.env?{runFlow:{file:t.file,env:t.env}}:{runFlow:t.file};case"repeat":return{repeat:{times:t.times,commands:t.steps.map(r=>$m(r,e)).filter(r=>r!==null)}};case"retry":return{retry:{maxRetries:t.maxRetries,commands:t.steps.map(r=>$m(r,e)).filter(r=>r!==null)}};case"simon.assertRoute":case"simon.note":return e.push(t.kind),null}}var Sm,fL,_$=$(()=>{"use strict";Sm=Mt(fm(),1);fL={enter:"Enter",backspace:"Backspace",home:"Home"}});var b$={};Bn(b$,{FlowParseError:()=>me,FlowRunner:()=>mn,compileFlow:()=>vm,compileFlowYaml:()=>bi,exportMaestroYaml:()=>Sl,loadFlow:()=>_r,normalizeKey:()=>bm,parseFlow:()=>_m,serializeFlow:()=>wl});var wa=$(()=>{"use strict";vl();h$();y$();_$()});var se,sg,z,wr,Va=$(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(se||(se={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(sg||(sg={}));z=se.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wr=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}}});var T,vq,bt,Ql=$(()=>{Va();T=se.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vq=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),bt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,se.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};bt.create=t=>new bt(t)});var xq,Br,ig=$(()=>{Ql();Va();xq=(t,e)=>{let r;switch(t.code){case T.invalid_type:t.received===z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,se.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${se.joinValues(t.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${se.joinValues(t.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${se.joinValues(t.options)}, received '${t.received}'`;break;case T.invalid_arguments:r="Invalid function arguments";break;case T.invalid_return_type:r="Invalid function return type";break;case T.invalid_date:r="Invalid date";break;case T.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:se.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case T.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case T.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case T.custom:r="Invalid input";break;case T.invalid_intersection_types:r="Intersection results could not be merged";break;case T.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=e.defaultError,se.assertNever(t)}return{message:r}},Br=xq});function Sq(t){hE=t}function Hi(){return hE}var hE,ed=$(()=>{ig();hE=Br});function N(t,e){let r=Hi(),n=Ha({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Br?void 0:Br].filter(s=>!!s)});t.common.issues.push(n)}var Ha,kq,et,V,ys,ot,td,rd,kn,Wi,og=$(()=>{ed();ig();Ha=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},kq=[];et=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return V;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return V;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},V=Object.freeze({status:"aborted"}),ys=t=>({status:"dirty",value:t}),ot=t=>({status:"valid",value:t}),td=t=>t.status==="aborted",rd=t=>t.status==="dirty",kn=t=>t.status==="valid",Wi=t=>typeof Promise<"u"&&t instanceof Promise});var mE=$(()=>{});var q,gE=$(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(q||(q={}))});function Y(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}function wE(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Zq(t){return new RegExp(`^${wE(t)}$`)}function vE(t){let e=`${bE}T${wE(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Uq(t,e){return!!((e==="v4"||!e)&&zq.test(t)||(e==="v6"||!e)&&Cq.test(t))}function Fq(t,e){if(!Iq.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Bq(t,e){return!!((e==="v4"||!e)&&Mq.test(t)||(e==="v6"||!e)&&jq.test(t))}function Vq(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Ki(t){if(t instanceof vt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=wt.create(Ki(n))}return new vt({...t._def,shape:()=>e})}else return t instanceof Wr?new Wr({...t._def,type:Ki(t.element)}):t instanceof wt?wt.create(Ki(t.unwrap())):t instanceof xr?xr.create(Ki(t.unwrap())):t instanceof vr?vr.create(t.items.map(e=>Ki(e))):t}function cg(t,e){let r=wr(t),n=wr(e);if(t===e)return{valid:!0,data:t};if(r===z.object&&n===z.object){let s=se.objectKeys(e),i=se.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=cg(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===z.array&&n===z.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=cg(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===z.date&&n===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function xE(t,e){return new Ps({values:t,typeName:O.ZodEnum,...Y(e)})}function _E(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function SE(t,e={},r){return t?En.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=_E(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=_E(e,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):En.create()}var Bt,yE,ee,$q,Eq,Tq,Pq,Oq,Iq,Aq,Nq,Rq,ag,zq,Mq,Cq,jq,Lq,qq,bE,Dq,$n,_s,bs,ws,vs,Ji,xs,Ss,En,Hr,sr,Gi,Wr,vt,ks,Vr,nd,$s,vr,sd,Yi,Xi,id,Es,Ts,Ps,Os,Tn,Vt,wt,xr,Is,As,Qi,Hq,Wa,Ka,Ns,Wq,O,Kq,kE,$E,Jq,Gq,EE,Yq,Xq,Qq,eD,tD,rD,nD,sD,iD,ug,oD,aD,cD,uD,lD,dD,fD,pD,hD,mD,gD,yD,_D,bD,wD,vD,xD,SD,kD,$D,ED,TD,PD,OD,TE=$(()=>{Ql();ed();gE();og();Va();Bt=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},yE=(t,e)=>{if(kn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new bt(t.common.issues);return this._error=r,this._error}}};ee=class{get description(){return this._def.description}_getType(e){return wr(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:wr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new et,ctx:{common:e.parent.common,data:e.data,parsedType:wr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Wi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wr(e)},s=this._parseSync({data:e,path:n.path,parent:n});return yE(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wr(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return kn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>kn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Wi(s)?s:Promise.resolve(s));return yE(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:T.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Vt({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return wt.create(this,this._def)}nullable(){return xr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Wr.create(this)}promise(){return Tn.create(this,this._def)}or(e){return ks.create([this,e],this._def)}and(e){return $s.create(this,e,this._def)}transform(e){return new Vt({...Y(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Is({...Y(this._def),innerType:this,defaultValue:r,typeName:O.ZodDefault})}brand(){return new Wa({typeName:O.ZodBranded,type:this,...Y(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new As({...Y(this._def),innerType:this,catchValue:r,typeName:O.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ka.create(this,e)}readonly(){return Ns.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$q=/^c[^\s-]{8,}$/i,Eq=/^[0-9a-z]+$/,Tq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Pq=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Oq=/^[a-z0-9_-]{21}$/i,Iq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Aq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Nq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Rq="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",zq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Cq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,jq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Lq=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qq=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bE="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Dq=new RegExp(`^${bE}$`);$n=class t extends ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.string,received:i.parsedType}),V}let n=new et,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?N(s,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&N(s,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Nq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ag||(ag=new RegExp(Rq,"u")),ag.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Pq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Oq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"nanoid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")$q.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Eq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Tq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:T.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:T.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?vE(i).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Dq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Zq(i).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Aq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"duration",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Uq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Fq(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"jwt",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Bq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cidr",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Lq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?qq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64url",code:T.invalid_string,message:i.message}),n.dirty()):se.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:T.invalid_string,...q.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...q.errToObj(r)})}nonempty(e){return this.min(1,q.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};$n.create=t=>new $n({checks:[],typeName:O.ZodString,coerce:t?.coerce??!1,...Y(t)});_s=class t extends ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.number,received:i.parsedType}),V}let n,s=new et;for(let i of this._def.checks)i.kind==="int"?se.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:T.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Vq(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_finite,message:i.message}),s.dirty()):se.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,q.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&se.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};_s.create=t=>new _s({checks:[],typeName:O.ZodNumber,coerce:t?.coerce||!1,...Y(t)});bs=class t extends ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let n,s=new et;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):se.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return N(r,{code:T.invalid_type,expected:z.bigint,received:r.parsedType}),V}gte(e,r){return this.setLimit("min",e,!0,q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,q.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:q.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};bs.create=t=>new bs({checks:[],typeName:O.ZodBigInt,coerce:t?.coerce??!1,...Y(t)});ws=class extends ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.boolean,received:n.parsedType}),V}return ot(e.data)}};ws.create=t=>new ws({typeName:O.ZodBoolean,coerce:t?.coerce||!1,...Y(t)});vs=class t extends ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.date,received:i.parsedType}),V}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_date}),V}let n=new et,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):se.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:q.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};vs.create=t=>new vs({checks:[],coerce:t?.coerce||!1,typeName:O.ZodDate,...Y(t)});Ji=class extends ee{_parse(e){if(this._getType(e)!==z.symbol){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.symbol,received:n.parsedType}),V}return ot(e.data)}};Ji.create=t=>new Ji({typeName:O.ZodSymbol,...Y(t)});xs=class extends ee{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.undefined,received:n.parsedType}),V}return ot(e.data)}};xs.create=t=>new xs({typeName:O.ZodUndefined,...Y(t)});Ss=class extends ee{_parse(e){if(this._getType(e)!==z.null){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.null,received:n.parsedType}),V}return ot(e.data)}};Ss.create=t=>new Ss({typeName:O.ZodNull,...Y(t)});En=class extends ee{constructor(){super(...arguments),this._any=!0}_parse(e){return ot(e.data)}};En.create=t=>new En({typeName:O.ZodAny,...Y(t)});Hr=class extends ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ot(e.data)}};Hr.create=t=>new Hr({typeName:O.ZodUnknown,...Y(t)});sr=class extends ee{_parse(e){let r=this._getOrReturnCtx(e);return N(r,{code:T.invalid_type,expected:z.never,received:r.parsedType}),V}};sr.create=t=>new sr({typeName:O.ZodNever,...Y(t)});Gi=class extends ee{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.void,received:n.parsedType}),V}return ot(e.data)}};Gi.create=t=>new Gi({typeName:O.ZodVoid,...Y(t)});Wr=class t extends ee{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==z.array)return N(r,{code:T.invalid_type,expected:z.array,received:r.parsedType}),V;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(N(r,{code:o?T.too_big:T.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(N(r,{code:T.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(N(r,{code:T.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new Bt(r,o,r.path,a)))).then(o=>et.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new Bt(r,o,r.path,a)));return et.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:q.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:q.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:q.toString(r)}})}nonempty(e){return this.min(1,e)}};Wr.create=(t,e)=>new Wr({type:t,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...Y(e)});vt=class t extends ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=se.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==z.object){let u=this._getOrReturnCtx(e);return N(u,{code:T.invalid_type,expected:z.object,received:u.parsedType}),V}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof sr&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Bt(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof sr){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(N(s,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Bt(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>et.mergeObjectSync(n,u)):et.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return q.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:q.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of se.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of se.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ki(this)}partial(e){let r={};for(let n of se.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of se.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof wt;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return xE(se.objectKeys(this.shape))}};vt.create=(t,e)=>new vt({shape:()=>t,unknownKeys:"strip",catchall:sr.create(),typeName:O.ZodObject,...Y(e)});vt.strictCreate=(t,e)=>new vt({shape:()=>t,unknownKeys:"strict",catchall:sr.create(),typeName:O.ZodObject,...Y(e)});vt.lazycreate=(t,e)=>new vt({shape:t,unknownKeys:"strip",catchall:sr.create(),typeName:O.ZodObject,...Y(e)});ks=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new bt(a.ctx.common.issues));return N(r,{code:T.invalid_union,unionErrors:o}),V}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new bt(c));return N(r,{code:T.invalid_union,unionErrors:a}),V}}get options(){return this._def.options}};ks.create=(t,e)=>new ks({options:t,typeName:O.ZodUnion,...Y(e)});Vr=t=>t instanceof Es?Vr(t.schema):t instanceof Vt?Vr(t.innerType()):t instanceof Ts?[t.value]:t instanceof Ps?t.options:t instanceof Os?se.objectValues(t.enum):t instanceof Is?Vr(t._def.innerType):t instanceof xs?[void 0]:t instanceof Ss?[null]:t instanceof wt?[void 0,...Vr(t.unwrap())]:t instanceof xr?[null,...Vr(t.unwrap())]:t instanceof Wa||t instanceof Ns?Vr(t.unwrap()):t instanceof As?Vr(t._def.innerType):[],nd=class t extends ee{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return N(r,{code:T.invalid_type,expected:z.object,received:r.parsedType}),V;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(N(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let o=Vr(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...Y(n)})}};$s=class extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(td(i)||td(o))return V;let a=cg(i.value,o.value);return a.valid?((rd(i)||rd(o))&&r.dirty(),{status:r.value,value:a.data}):(N(n,{code:T.invalid_intersection_types}),V)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};$s.create=(t,e,r)=>new $s({left:t,right:e,typeName:O.ZodIntersection,...Y(r)});vr=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return N(n,{code:T.invalid_type,expected:z.array,received:n.parsedType}),V;if(n.data.length<this._def.items.length)return N(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Bt(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>et.mergeArray(r,o)):et.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};vr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new vr({items:t,typeName:O.ZodTuple,rest:null,...Y(e)})};sd=class t extends ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return N(n,{code:T.invalid_type,expected:z.object,received:n.parsedType}),V;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new Bt(n,a,n.path,a)),value:o._parse(new Bt(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?et.mergeObjectAsync(r,s):et.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ee?new t({keyType:e,valueType:r,typeName:O.ZodRecord,...Y(n)}):new t({keyType:$n.create(),valueType:e,typeName:O.ZodRecord,...Y(r)})}},Yi=class extends ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return N(n,{code:T.invalid_type,expected:z.map,received:n.parsedType}),V;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new Bt(n,a,n.path,[u,"key"])),value:i._parse(new Bt(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return V;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return V;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};Yi.create=(t,e,r)=>new Yi({valueType:e,keyType:t,typeName:O.ZodMap,...Y(r)});Xi=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return N(n,{code:T.invalid_type,expected:z.set,received:n.parsedType}),V;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(N(n,{code:T.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(N(n,{code:T.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return V;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new Bt(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:q.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Xi.create=(t,e)=>new Xi({valueType:t,minSize:null,maxSize:null,typeName:O.ZodSet,...Y(e)});id=class t extends ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.function)return N(r,{code:T.invalid_type,expected:z.function,received:r.parsedType}),V;function n(a,c){return Ha({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Hi(),Br].filter(u=>!!u),issueData:{code:T.invalid_arguments,argumentsError:c}})}function s(a,c){return Ha({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Hi(),Br].filter(u=>!!u),issueData:{code:T.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Tn){let a=this;return ot(async function(...c){let u=new bt([]),l=await a._def.args.parseAsync(c,i).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(p=>{throw u.addIssue(s(d,p)),u})})}else{let a=this;return ot(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new bt([n(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new bt([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:vr.create(e).rest(Hr.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||vr.create([]).rest(Hr.create()),returns:r||Hr.create(),typeName:O.ZodFunction,...Y(n)})}},Es=class extends ee{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Es.create=(t,e)=>new Es({getter:t,typeName:O.ZodLazy,...Y(e)});Ts=class extends ee{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return N(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ts.create=(t,e)=>new Ts({value:t,typeName:O.ZodLiteral,...Y(e)});Ps=class t extends ee{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{expected:se.joinValues(n),received:r.parsedType,code:T.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{received:r.data,code:T.invalid_enum_value,options:n}),V}return ot(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Ps.create=xE;Os=class extends ee{_parse(e){let r=se.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){let s=se.objectValues(r);return N(n,{expected:se.joinValues(s),received:n.parsedType,code:T.invalid_type}),V}if(this._cache||(this._cache=new Set(se.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=se.objectValues(r);return N(n,{received:n.data,code:T.invalid_enum_value,options:s}),V}return ot(e.data)}get enum(){return this._def.values}};Os.create=(t,e)=>new Os({values:t,typeName:O.ZodNativeEnum,...Y(e)});Tn=class extends ee{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.promise&&r.common.async===!1)return N(r,{code:T.invalid_type,expected:z.promise,received:r.parsedType}),V;let n=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return ot(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Tn.create=(t,e)=>new Tn({type:t,typeName:O.ZodPromise,...Y(e)});Vt=class extends ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{N(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return V;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?V:c.status==="dirty"?ys(c.value):r.value==="dirty"?ys(c.value):c});{if(r.value==="aborted")return V;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?V:a.status==="dirty"?ys(a.value):r.value==="dirty"?ys(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?V:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?V:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kn(o))return V;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>kn(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):V);se.assertNever(s)}};Vt.create=(t,e,r)=>new Vt({schema:t,typeName:O.ZodEffects,effect:e,...Y(r)});Vt.createWithPreprocess=(t,e,r)=>new Vt({schema:e,effect:{type:"preprocess",transform:t},typeName:O.ZodEffects,...Y(r)});wt=class extends ee{_parse(e){return this._getType(e)===z.undefined?ot(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};wt.create=(t,e)=>new wt({innerType:t,typeName:O.ZodOptional,...Y(e)});xr=class extends ee{_parse(e){return this._getType(e)===z.null?ot(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(t,e)=>new xr({innerType:t,typeName:O.ZodNullable,...Y(e)});Is=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Is.create=(t,e)=>new Is({innerType:t,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});As=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new bt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new bt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};As.create=(t,e)=>new As({innerType:t,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});Qi=class extends ee{_parse(e){if(this._getType(e)!==z.nan){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.nan,received:n.parsedType}),V}return{status:"valid",value:e.data}}};Qi.create=t=>new Qi({typeName:O.ZodNaN,...Y(t)});Hq=Symbol("zod_brand"),Wa=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ka=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?V:i.status==="dirty"?(r.dirty(),ys(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?V:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:O.ZodPipeline})}},Ns=class extends ee{_parse(e){let r=this._def.innerType._parse(e),n=s=>(kn(s)&&(s.value=Object.freeze(s.value)),s);return Wi(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Ns.create=(t,e)=>new Ns({innerType:t,typeName:O.ZodReadonly,...Y(e)});Wq={object:vt.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(O||(O={}));Kq=(t,e={message:`Input not instance of ${t.name}`})=>SE(r=>r instanceof t,e),kE=$n.create,$E=_s.create,Jq=Qi.create,Gq=bs.create,EE=ws.create,Yq=vs.create,Xq=Ji.create,Qq=xs.create,eD=Ss.create,tD=En.create,rD=Hr.create,nD=sr.create,sD=Gi.create,iD=Wr.create,ug=vt.create,oD=vt.strictCreate,aD=ks.create,cD=nd.create,uD=$s.create,lD=vr.create,dD=sd.create,fD=Yi.create,pD=Xi.create,hD=id.create,mD=Es.create,gD=Ts.create,yD=Ps.create,_D=Os.create,bD=Tn.create,wD=Vt.create,vD=wt.create,xD=xr.create,SD=Vt.createWithPreprocess,kD=Ka.create,$D=()=>kE().optional(),ED=()=>$E().optional(),TD=()=>EE().optional(),PD={string:t=>$n.create({...t,coerce:!0}),number:t=>_s.create({...t,coerce:!0}),boolean:t=>ws.create({...t,coerce:!0}),bigint:t=>bs.create({...t,coerce:!0}),date:t=>vs.create({...t,coerce:!0})},OD=V});var Me={};Bn(Me,{BRAND:()=>Hq,DIRTY:()=>ys,EMPTY_PATH:()=>kq,INVALID:()=>V,NEVER:()=>OD,OK:()=>ot,ParseStatus:()=>et,Schema:()=>ee,ZodAny:()=>En,ZodArray:()=>Wr,ZodBigInt:()=>bs,ZodBoolean:()=>ws,ZodBranded:()=>Wa,ZodCatch:()=>As,ZodDate:()=>vs,ZodDefault:()=>Is,ZodDiscriminatedUnion:()=>nd,ZodEffects:()=>Vt,ZodEnum:()=>Ps,ZodError:()=>bt,ZodFirstPartyTypeKind:()=>O,ZodFunction:()=>id,ZodIntersection:()=>$s,ZodIssueCode:()=>T,ZodLazy:()=>Es,ZodLiteral:()=>Ts,ZodMap:()=>Yi,ZodNaN:()=>Qi,ZodNativeEnum:()=>Os,ZodNever:()=>sr,ZodNull:()=>Ss,ZodNullable:()=>xr,ZodNumber:()=>_s,ZodObject:()=>vt,ZodOptional:()=>wt,ZodParsedType:()=>z,ZodPipeline:()=>Ka,ZodPromise:()=>Tn,ZodReadonly:()=>Ns,ZodRecord:()=>sd,ZodSchema:()=>ee,ZodSet:()=>Xi,ZodString:()=>$n,ZodSymbol:()=>Ji,ZodTransformer:()=>Vt,ZodTuple:()=>vr,ZodType:()=>ee,ZodUndefined:()=>xs,ZodUnion:()=>ks,ZodUnknown:()=>Hr,ZodVoid:()=>Gi,addIssueToContext:()=>N,any:()=>tD,array:()=>iD,bigint:()=>Gq,boolean:()=>EE,coerce:()=>PD,custom:()=>SE,date:()=>Yq,datetimeRegex:()=>vE,defaultErrorMap:()=>Br,discriminatedUnion:()=>cD,effect:()=>wD,enum:()=>yD,function:()=>hD,getErrorMap:()=>Hi,getParsedType:()=>wr,instanceof:()=>Kq,intersection:()=>uD,isAborted:()=>td,isAsync:()=>Wi,isDirty:()=>rd,isValid:()=>kn,late:()=>Wq,lazy:()=>mD,literal:()=>gD,makeIssue:()=>Ha,map:()=>fD,nan:()=>Jq,nativeEnum:()=>_D,never:()=>nD,null:()=>eD,nullable:()=>xD,number:()=>$E,object:()=>ug,objectUtil:()=>sg,oboolean:()=>TD,onumber:()=>ED,optional:()=>vD,ostring:()=>$D,pipeline:()=>kD,preprocess:()=>SD,promise:()=>bD,quotelessJson:()=>vq,record:()=>dD,set:()=>pD,setErrorMap:()=>Sq,strictObject:()=>oD,string:()=>kE,symbol:()=>Xq,transformer:()=>wD,tuple:()=>lD,undefined:()=>Qq,union:()=>aD,unknown:()=>rD,util:()=>se,void:()=>sD});var od=$(()=>{ed();og();mE();Va();TE();Ql()});var Ja=$(()=>{od()});function S(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in o.prototype)l in a||Object.defineProperty(a,l,{value:o.prototype[l].bind(a)});a._zod.constr=o,a._zod.def=c}let s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var c;let u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}function Nt(t){return t&&Object.assign(ad,t),ad}var AD,ND,Kr,ad,eo=$(()=>{AD=Object.freeze({status:"aborted"});ND=Symbol("zod_brand"),Kr=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ad={}});var ie={};Bn(ie,{BIGINT_FORMAT_RANGES:()=>OE,Class:()=>dg,NUMBER_FORMAT_RANGES:()=>_g,aborted:()=>zs,allowsEval:()=>mg,assert:()=>jD,assertEqual:()=>RD,assertIs:()=>MD,assertNever:()=>CD,assertNotEqual:()=>zD,assignProp:()=>hg,cached:()=>Xa,captureStackTrace:()=>ud,cleanEnum:()=>GD,cleanRegex:()=>ec,clone:()=>Rt,createTransparentProxy:()=>FD,defineLazy:()=>ve,esc:()=>Rs,escapeRegex:()=>Pn,extend:()=>HD,finalizeIssue:()=>ir,floatSafeRemainder:()=>pg,getElementAtPath:()=>LD,getEnumValues:()=>Ya,getLengthableOrigin:()=>tc,getParsedType:()=>UD,getSizableOrigin:()=>IE,isObject:()=>to,isPlainObject:()=>ro,issue:()=>bg,joinValues:()=>cd,jsonStringifyReplacer:()=>fg,merge:()=>WD,normalizeParams:()=>H,nullish:()=>Qa,numKeys:()=>ZD,omit:()=>VD,optionalKeys:()=>yg,partial:()=>KD,pick:()=>BD,prefixIssues:()=>Sr,primitiveTypes:()=>PE,promiseAllObject:()=>qD,propertyKeyTypes:()=>gg,randomString:()=>DD,required:()=>JD,stringifyPrimitive:()=>ld,unwrapMessage:()=>Ga});function RD(t){return t}function zD(t){return t}function MD(t){}function CD(t){throw new Error}function jD(t){}function Ya(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function cd(t,e="|"){return t.map(r=>ld(r)).join(e)}function fg(t,e){return typeof e=="bigint"?e.toString():e}function Xa(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Qa(t){return t==null}function ec(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function pg(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function ve(t,e,r){Object.defineProperty(t,e,{get(){{let s=r();return t[e]=s,s}throw new Error("cached value already set")},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function hg(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function LD(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function qD(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let s={};for(let i=0;i<e.length;i++)s[e[i]]=n[i];return s})}function DD(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Rs(t){return JSON.stringify(t)}function to(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ro(t){if(to(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(to(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ZD(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}function Pn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function H(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function FD(t){let e;return new Proxy({},{get(r,n,s){return e??(e=t()),Reflect.get(e,n,s)},set(r,n,s,i){return e??(e=t()),Reflect.set(e,n,s,i)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,s){return e??(e=t()),Reflect.defineProperty(e,n,s)}})}function ld(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function yg(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function BD(t,e){let r={},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return Rt(t,{...t._zod.def,shape:r,checks:[]})}function VD(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return Rt(t,{...t._zod.def,shape:r,checks:[]})}function HD(t,e){if(!ro(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return hg(this,"shape",n),n},checks:[]};return Rt(t,r)}function WD(t,e){return Rt(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return hg(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function KD(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in n))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=t?new t({type:"optional",innerType:n[i]}):n[i])}else for(let i in n)s[i]=t?new t({type:"optional",innerType:n[i]}):n[i];return Rt(e,{...e._zod.def,shape:s,checks:[]})}function JD(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:n[i]}))}else for(let i in n)s[i]=new t({type:"nonoptional",innerType:n[i]});return Rt(e,{...e._zod.def,shape:s,checks:[]})}function zs(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Sr(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Ga(t){return typeof t=="string"?t:t?.message}function ir(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=Ga(t.inst?._zod.def?.error?.(t))??Ga(e?.error?.(t))??Ga(r.customError?.(t))??Ga(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function IE(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function tc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function bg(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function GD(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var ud,mg,UD,gg,PE,_g,OE,dg,kr=$(()=>{ud=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};mg=Xa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});UD=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},gg=new Set(["string","number","symbol"]),PE=new Set(["string","number","bigint","boolean","symbol","undefined"]);_g={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},OE={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};dg=class{constructor(...e){}}});function wg(t,e=r=>r.message){let r={},n=[];for(let s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function vg(t,e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>s({issues:a}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({issues:o.issues});else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(t),n}var AE,dd,rc,xg=$(()=>{eo();kr();AE=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,fg,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},dd=S("$ZodError",AE),rc=S("$ZodError",AE,{Parent:Error})});var Sg,kg,$g,Eg,Tg,Ms,Pg,Cs,Og=$(()=>{eo();xg();kr();Sg=t=>(e,r,n,s)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Kr;if(o.issues.length){let a=new(s?.Err??t)(o.issues.map(c=>ir(c,i,Nt())));throw ud(a,s?.callee),a}return o.value},kg=Sg(rc),$g=t=>async(e,r,n,s)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(s?.Err??t)(o.issues.map(c=>ir(c,i,Nt())));throw ud(a,s?.callee),a}return o.value},Eg=$g(rc),Tg=t=>(e,r,n)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Kr;return i.issues.length?{success:!1,error:new(t??dd)(i.issues.map(o=>ir(o,s,Nt())))}:{success:!0,data:i.value}},Ms=Tg(rc),Pg=t=>async(e,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>ir(o,s,Nt())))}:{success:!0,data:i.value}},Cs=Pg(rc)});function ZE(){return new RegExp(XD,"u")}function YE(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function XE(t){return new RegExp(`^${YE(t)}$`)}function QE(t){let e=YE({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${JE}T(?:${n})$`)}var NE,RE,zE,ME,CE,jE,LE,qE,Ig,DE,XD,UE,FE,BE,VE,HE,Ag,WE,KE,JE,GE,eT,tT,rT,nT,sT,iT,oT,pd=$(()=>{NE=/^[cC][^\s-]{8,}$/,RE=/^[0-9a-z]+$/,zE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ME=/^[0-9a-vA-V]{20}$/,CE=/^[A-Za-z0-9]{27}$/,jE=/^[a-zA-Z0-9_-]{21}$/,LE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ig=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,DE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,XD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";UE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,BE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,VE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,HE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ag=/^[A-Za-z0-9_-]*$/,WE=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,KE=/^\+(?:[0-9]){6,14}[0-9]$/,JE="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",GE=new RegExp(`^${JE}$`);eT=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},tT=/^\d+$/,rT=/^-?\d+(?:\.\d+)?/i,nT=/true|false/i,sT=/null/i,iT=/^[^A-Z]*$/,oT=/^[^a-z]*$/});var tt,aT,Ng,Rg,cT,uT,lT,dT,fT,nc,pT,hT,mT,gT,yT,_T,bT,hd=$(()=>{eo();pd();kr();tt=S("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),aT={number:"number",bigint:"bigint",object:"date"},Ng=S("$ZodCheckLessThan",(t,e)=>{tt.init(t,e);let r=aT[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Rg=S("$ZodCheckGreaterThan",(t,e)=>{tt.init(t,e);let r=aT[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),cT=S("$ZodCheckMultipleOf",(t,e)=>{tt.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):pg(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),uT=S("$ZodCheckNumberFormat",(t,e)=>{tt.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,i]=_g[e.format];t._zod.onattach.push(o=>{let a=o._zod.bag;a.format=e.format,a.minimum=s,a.maximum=i,r&&(a.pattern=tT)}),t._zod.check=o=>{let a=o.value;if(r){if(!Number.isInteger(a)){o.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<s&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>i&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inst:t})}}),lT=S("$ZodCheckMaxLength",(t,e)=>{var r;tt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Qa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let s=n.value;if(s.length<=e.maximum)return;let o=tc(s);n.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),dT=S("$ZodCheckMinLength",(t,e)=>{var r;tt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Qa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let s=n.value;if(s.length>=e.minimum)return;let o=tc(s);n.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),fT=S("$ZodCheckLengthEquals",(t,e)=>{var r;tt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Qa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{let s=n.value,i=s.length;if(i===e.length)return;let o=tc(s),a=i>e.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),nc=S("$ZodCheckStringFormat",(t,e)=>{var r,n;tt.init(t,e),t._zod.onattach.push(s=>{let i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),pT=S("$ZodCheckRegex",(t,e)=>{nc.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),hT=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=iT),nc.init(t,e)}),mT=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=oT),nc.init(t,e)}),gT=S("$ZodCheckIncludes",(t,e)=>{tt.init(t,e);let r=Pn(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{let i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),yT=S("$ZodCheckStartsWith",(t,e)=>{tt.init(t,e);let r=new RegExp(`^${Pn(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),_T=S("$ZodCheckEndsWith",(t,e)=>{tt.init(t,e);let r=new RegExp(`.*${Pn(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),bT=S("$ZodCheckOverwrite",(t,e)=>{tt.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}})});var md,zg=$(()=>{md=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
152
|
+
`),s}function $m(t){return`${Math.round(t[0]*100)}%,${Math.round(t[1]*100)}%`}function Sm(t,e){if(t.point&&t.id===void 0&&t.text===void 0)return{point:$m(t.point)};let r={};return t.id!==void 0&&(r.id=t.id),t.text!==void 0&&(r.text=t.text),t.index!==void 0&&(r.index=t.index),Object.keys(r).length===0?(e.push("empty selector"),null):r}function Em(t,e){switch(t.kind){case"launchApp":{let r={};return t.appId&&(r.appId=t.appId),t.clearState&&(r.clearState=!0),t.stopApp!==void 0&&(r.stopApp=t.stopApp),Object.keys(r).length===0?"launchApp":{launchApp:r}}case"stopApp":return t.appId?{stopApp:t.appId}:"stopApp";case"tapOn":{let r=Sm(t.selector,e);if(r===null)return null;let n=typeof r=="string"?{text:r}:{...r};if(t.longPress)return{longPressOn:n};t.optional&&(n.optional=!0);let s=Object.keys(n);return s.length===1&&s[0]==="text"?{tapOn:n.text}:{tapOn:n}}case"inputText":return{inputText:t.text};case"eraseText":return{eraseText:t.chars};case"pressKey":{let r=pL[t.key];return r?{pressKey:r}:(e.push(`pressKey ${t.key}`),null)}case"hideKeyboard":return"hideKeyboard";case"swipe":{let r={};return t.direction&&(r.direction=t.direction.toUpperCase()),t.start&&(r.start=$m(t.start)),t.end&&(r.end=$m(t.end)),t.durationMs&&(r.duration=t.durationMs),{swipe:r}}case"scroll":return"scroll";case"scrollUntilVisible":{let r=Sm(t.selector,e);return r===null?null:{scrollUntilVisible:{element:r,...t.direction?{direction:t.direction.toUpperCase()}:{},...t.timeoutMs?{timeout:t.timeoutMs}:{}}}}case"assertVisible":case"assertNotVisible":{let r=Sm(t.selector,e);if(r===null)return null;let n=typeof r=="string"?{text:r}:{...r};t.timeoutMs&&(n.timeout=t.timeoutMs),t.optional&&(n.optional=!0);let s=Object.keys(n);return s.length===1&&s[0]==="text"?{[t.kind]:n.text}:{[t.kind]:n}}case"openLink":return{openLink:t.url};case"back":return"back";case"setOrientation":return e.push("setOrientation"),null;case"takeScreenshot":return t.path?{takeScreenshot:t.path}:"takeScreenshot";case"waitForAnimationToEnd":return t.timeoutMs!==void 0?{waitForAnimationToEnd:{timeout:t.timeoutMs}}:"waitForAnimationToEnd";case"wait":return{waitForAnimationToEnd:{timeout:t.ms}};case"runFlow":return t.env?{runFlow:{file:t.file,env:t.env}}:{runFlow:t.file};case"repeat":return{repeat:{times:t.times,commands:t.steps.map(r=>Em(r,e)).filter(r=>r!==null)}};case"retry":return{retry:{maxRetries:t.maxRetries,commands:t.steps.map(r=>Em(r,e)).filter(r=>r!==null)}};case"simon.assertRoute":case"simon.note":return e.push(t.kind),null}}var km,pL,b$=$(()=>{"use strict";km=Ct(pm(),1);pL={enter:"Enter",backspace:"Backspace",home:"Home"}});var w$={};Vn(w$,{FlowParseError:()=>me,FlowRunner:()=>gn,compileFlow:()=>xm,compileFlowYaml:()=>wi,exportMaestroYaml:()=>kl,loadFlow:()=>br,normalizeKey:()=>wm,parseFlow:()=>bm,serializeFlow:()=>vl});var va=$(()=>{"use strict";xl();m$();_$();b$()});var se,ig,z,vr,Ha=$(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(se||(se={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ig||(ig={}));z=se.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vr=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}}});var T,xq,wt,ed=$(()=>{Ha();T=se.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),xq=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),wt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,se.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};wt.create=t=>new wt(t)});var Sq,Vr,og=$(()=>{ed();Ha();Sq=(t,e)=>{let r;switch(t.code){case T.invalid_type:t.received===z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,se.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${se.joinValues(t.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${se.joinValues(t.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${se.joinValues(t.options)}, received '${t.received}'`;break;case T.invalid_arguments:r="Invalid function arguments";break;case T.invalid_return_type:r="Invalid function return type";break;case T.invalid_date:r="Invalid date";break;case T.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:se.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case T.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case T.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case T.custom:r="Invalid input";break;case T.invalid_intersection_types:r="Intersection results could not be merged";break;case T.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=e.defaultError,se.assertNever(t)}return{message:r}},Vr=Sq});function kq(t){mE=t}function Wi(){return mE}var mE,td=$(()=>{og();mE=Vr});function N(t,e){let r=Wi(),n=Wa({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Vr?void 0:Vr].filter(s=>!!s)});t.common.issues.push(n)}var Wa,$q,tt,V,_s,at,rd,nd,$n,Ki,ag=$(()=>{td();og();Wa=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},$q=[];tt=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return V;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return V;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},V=Object.freeze({status:"aborted"}),_s=t=>({status:"dirty",value:t}),at=t=>({status:"valid",value:t}),rd=t=>t.status==="aborted",nd=t=>t.status==="dirty",$n=t=>t.status==="valid",Ki=t=>typeof Promise<"u"&&t instanceof Promise});var gE=$(()=>{});var q,yE=$(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(q||(q={}))});function Y(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}function vE(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Uq(t){return new RegExp(`^${vE(t)}$`)}function xE(t){let e=`${wE}T${vE(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Fq(t,e){return!!((e==="v4"||!e)&&Mq.test(t)||(e==="v6"||!e)&&jq.test(t))}function Bq(t,e){if(!Aq.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Vq(t,e){return!!((e==="v4"||!e)&&Cq.test(t)||(e==="v6"||!e)&&Lq.test(t))}function Hq(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Ji(t){if(t instanceof xt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=vt.create(Ji(n))}return new xt({...t._def,shape:()=>e})}else return t instanceof Kr?new Kr({...t._def,type:Ji(t.element)}):t instanceof vt?vt.create(Ji(t.unwrap())):t instanceof Sr?Sr.create(Ji(t.unwrap())):t instanceof xr?xr.create(t.items.map(e=>Ji(e))):t}function ug(t,e){let r=vr(t),n=vr(e);if(t===e)return{valid:!0,data:t};if(r===z.object&&n===z.object){let s=se.objectKeys(e),i=se.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=ug(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===z.array&&n===z.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=ug(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===z.date&&n===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function SE(t,e){return new Os({values:t,typeName:O.ZodEnum,...Y(e)})}function bE(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function kE(t,e={},r){return t?Tn.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=bE(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=bE(e,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):Tn.create()}var Vt,_E,ee,Eq,Tq,Pq,Oq,Iq,Aq,Nq,Rq,zq,cg,Mq,Cq,jq,Lq,qq,Dq,wE,Zq,En,bs,ws,vs,xs,Gi,Ss,ks,Tn,Wr,ir,Yi,Kr,xt,$s,Hr,sd,Es,xr,id,Xi,Qi,od,Ts,Ps,Os,Is,Pn,Ht,vt,Sr,As,Ns,eo,Wq,Ka,Ja,Rs,Kq,O,Jq,$E,EE,Gq,Yq,TE,Xq,Qq,eD,tD,rD,nD,sD,iD,oD,lg,aD,cD,uD,lD,dD,fD,pD,hD,mD,gD,yD,_D,bD,wD,vD,xD,SD,kD,$D,ED,TD,PD,OD,ID,PE=$(()=>{ed();td();yE();ag();Ha();Vt=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},_E=(t,e)=>{if($n(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new wt(t.common.issues);return this._error=r,this._error}}};ee=class{get description(){return this._def.description}_getType(e){return vr(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new tt,ctx:{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ki(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},s=this._parseSync({data:e,path:n.path,parent:n});return _E(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return $n(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>$n(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ki(s)?s:Promise.resolve(s));return _E(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:T.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Ht({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return vt.create(this,this._def)}nullable(){return Sr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Kr.create(this)}promise(){return Pn.create(this,this._def)}or(e){return $s.create([this,e],this._def)}and(e){return Es.create(this,e,this._def)}transform(e){return new Ht({...Y(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new As({...Y(this._def),innerType:this,defaultValue:r,typeName:O.ZodDefault})}brand(){return new Ka({typeName:O.ZodBranded,type:this,...Y(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ns({...Y(this._def),innerType:this,catchValue:r,typeName:O.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ja.create(this,e)}readonly(){return Rs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Eq=/^c[^\s-]{8,}$/i,Tq=/^[0-9a-z]+$/,Pq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Oq=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Iq=/^[a-z0-9_-]{21}$/i,Aq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Nq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Rq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zq="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Mq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,jq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qq=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dq=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wE="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Zq=new RegExp(`^${wE}$`);En=class t extends ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.string,received:i.parsedType}),V}let n=new tt,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?N(s,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&N(s,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Rq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")cg||(cg=new RegExp(zq,"u")),cg.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Oq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Iq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"nanoid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Eq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Tq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Pq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:T.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:T.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:T.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?xE(i).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Zq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Uq(i).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:T.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Nq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"duration",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Fq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Bq(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"jwt",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Vq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cidr",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?qq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64",code:T.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Dq.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64url",code:T.invalid_string,message:i.message}),n.dirty()):se.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:T.invalid_string,...q.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...q.errToObj(r)})}nonempty(e){return this.min(1,q.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};En.create=t=>new En({checks:[],typeName:O.ZodString,coerce:t?.coerce??!1,...Y(t)});bs=class t extends ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.number,received:i.parsedType}),V}let n,s=new tt;for(let i of this._def.checks)i.kind==="int"?se.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:T.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Hq(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_finite,message:i.message}),s.dirty()):se.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,q.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&se.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};bs.create=t=>new bs({checks:[],typeName:O.ZodNumber,coerce:t?.coerce||!1,...Y(t)});ws=class t extends ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let n,s=new tt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),N(n,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):se.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return N(r,{code:T.invalid_type,expected:z.bigint,received:r.parsedType}),V}gte(e,r){return this.setLimit("min",e,!0,q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,q.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:q.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ws.create=t=>new ws({checks:[],typeName:O.ZodBigInt,coerce:t?.coerce??!1,...Y(t)});vs=class extends ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.boolean,received:n.parsedType}),V}return at(e.data)}};vs.create=t=>new vs({typeName:O.ZodBoolean,coerce:t?.coerce||!1,...Y(t)});xs=class t extends ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_type,expected:z.date,received:i.parsedType}),V}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return N(i,{code:T.invalid_date}),V}let n=new tt,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:T.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):se.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:q.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};xs.create=t=>new xs({checks:[],coerce:t?.coerce||!1,typeName:O.ZodDate,...Y(t)});Gi=class extends ee{_parse(e){if(this._getType(e)!==z.symbol){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.symbol,received:n.parsedType}),V}return at(e.data)}};Gi.create=t=>new Gi({typeName:O.ZodSymbol,...Y(t)});Ss=class extends ee{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.undefined,received:n.parsedType}),V}return at(e.data)}};Ss.create=t=>new Ss({typeName:O.ZodUndefined,...Y(t)});ks=class extends ee{_parse(e){if(this._getType(e)!==z.null){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.null,received:n.parsedType}),V}return at(e.data)}};ks.create=t=>new ks({typeName:O.ZodNull,...Y(t)});Tn=class extends ee{constructor(){super(...arguments),this._any=!0}_parse(e){return at(e.data)}};Tn.create=t=>new Tn({typeName:O.ZodAny,...Y(t)});Wr=class extends ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return at(e.data)}};Wr.create=t=>new Wr({typeName:O.ZodUnknown,...Y(t)});ir=class extends ee{_parse(e){let r=this._getOrReturnCtx(e);return N(r,{code:T.invalid_type,expected:z.never,received:r.parsedType}),V}};ir.create=t=>new ir({typeName:O.ZodNever,...Y(t)});Yi=class extends ee{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.void,received:n.parsedType}),V}return at(e.data)}};Yi.create=t=>new Yi({typeName:O.ZodVoid,...Y(t)});Kr=class t extends ee{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==z.array)return N(r,{code:T.invalid_type,expected:z.array,received:r.parsedType}),V;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(N(r,{code:o?T.too_big:T.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(N(r,{code:T.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(N(r,{code:T.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new Vt(r,o,r.path,a)))).then(o=>tt.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new Vt(r,o,r.path,a)));return tt.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:q.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:q.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:q.toString(r)}})}nonempty(e){return this.min(1,e)}};Kr.create=(t,e)=>new Kr({type:t,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...Y(e)});xt=class t extends ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=se.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==z.object){let u=this._getOrReturnCtx(e);return N(u,{code:T.invalid_type,expected:z.object,received:u.parsedType}),V}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof ir&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Vt(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof ir){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(N(s,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Vt(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>tt.mergeObjectSync(n,u)):tt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return q.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:q.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of se.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of se.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ji(this)}partial(e){let r={};for(let n of se.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of se.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof vt;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return SE(se.objectKeys(this.shape))}};xt.create=(t,e)=>new xt({shape:()=>t,unknownKeys:"strip",catchall:ir.create(),typeName:O.ZodObject,...Y(e)});xt.strictCreate=(t,e)=>new xt({shape:()=>t,unknownKeys:"strict",catchall:ir.create(),typeName:O.ZodObject,...Y(e)});xt.lazycreate=(t,e)=>new xt({shape:t,unknownKeys:"strip",catchall:ir.create(),typeName:O.ZodObject,...Y(e)});$s=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new wt(a.ctx.common.issues));return N(r,{code:T.invalid_union,unionErrors:o}),V}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new wt(c));return N(r,{code:T.invalid_union,unionErrors:a}),V}}get options(){return this._def.options}};$s.create=(t,e)=>new $s({options:t,typeName:O.ZodUnion,...Y(e)});Hr=t=>t instanceof Ts?Hr(t.schema):t instanceof Ht?Hr(t.innerType()):t instanceof Ps?[t.value]:t instanceof Os?t.options:t instanceof Is?se.objectValues(t.enum):t instanceof As?Hr(t._def.innerType):t instanceof Ss?[void 0]:t instanceof ks?[null]:t instanceof vt?[void 0,...Hr(t.unwrap())]:t instanceof Sr?[null,...Hr(t.unwrap())]:t instanceof Ka||t instanceof Rs?Hr(t.unwrap()):t instanceof Ns?Hr(t._def.innerType):[],sd=class t extends ee{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return N(r,{code:T.invalid_type,expected:z.object,received:r.parsedType}),V;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(N(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let o=Hr(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...Y(n)})}};Es=class extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(rd(i)||rd(o))return V;let a=ug(i.value,o.value);return a.valid?((nd(i)||nd(o))&&r.dirty(),{status:r.value,value:a.data}):(N(n,{code:T.invalid_intersection_types}),V)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Es.create=(t,e,r)=>new Es({left:t,right:e,typeName:O.ZodIntersection,...Y(r)});xr=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return N(n,{code:T.invalid_type,expected:z.array,received:n.parsedType}),V;if(n.data.length<this._def.items.length)return N(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Vt(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>tt.mergeArray(r,o)):tt.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};xr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xr({items:t,typeName:O.ZodTuple,rest:null,...Y(e)})};id=class t extends ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return N(n,{code:T.invalid_type,expected:z.object,received:n.parsedType}),V;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new Vt(n,a,n.path,a)),value:o._parse(new Vt(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?tt.mergeObjectAsync(r,s):tt.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ee?new t({keyType:e,valueType:r,typeName:O.ZodRecord,...Y(n)}):new t({keyType:En.create(),valueType:e,typeName:O.ZodRecord,...Y(r)})}},Xi=class extends ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return N(n,{code:T.invalid_type,expected:z.map,received:n.parsedType}),V;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new Vt(n,a,n.path,[u,"key"])),value:i._parse(new Vt(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return V;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return V;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};Xi.create=(t,e,r)=>new Xi({valueType:e,keyType:t,typeName:O.ZodMap,...Y(r)});Qi=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return N(n,{code:T.invalid_type,expected:z.set,received:n.parsedType}),V;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(N(n,{code:T.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(N(n,{code:T.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return V;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new Vt(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:q.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Qi.create=(t,e)=>new Qi({valueType:t,minSize:null,maxSize:null,typeName:O.ZodSet,...Y(e)});od=class t extends ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.function)return N(r,{code:T.invalid_type,expected:z.function,received:r.parsedType}),V;function n(a,c){return Wa({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wi(),Vr].filter(u=>!!u),issueData:{code:T.invalid_arguments,argumentsError:c}})}function s(a,c){return Wa({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wi(),Vr].filter(u=>!!u),issueData:{code:T.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Pn){let a=this;return at(async function(...c){let u=new wt([]),l=await a._def.args.parseAsync(c,i).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(p=>{throw u.addIssue(s(d,p)),u})})}else{let a=this;return at(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new wt([n(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new wt([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:xr.create(e).rest(Wr.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||xr.create([]).rest(Wr.create()),returns:r||Wr.create(),typeName:O.ZodFunction,...Y(n)})}},Ts=class extends ee{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ts.create=(t,e)=>new Ts({getter:t,typeName:O.ZodLazy,...Y(e)});Ps=class extends ee{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return N(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ps.create=(t,e)=>new Ps({value:t,typeName:O.ZodLiteral,...Y(e)});Os=class t extends ee{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{expected:se.joinValues(n),received:r.parsedType,code:T.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{received:r.data,code:T.invalid_enum_value,options:n}),V}return at(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Os.create=SE;Is=class extends ee{_parse(e){let r=se.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){let s=se.objectValues(r);return N(n,{expected:se.joinValues(s),received:n.parsedType,code:T.invalid_type}),V}if(this._cache||(this._cache=new Set(se.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=se.objectValues(r);return N(n,{received:n.data,code:T.invalid_enum_value,options:s}),V}return at(e.data)}get enum(){return this._def.values}};Is.create=(t,e)=>new Is({values:t,typeName:O.ZodNativeEnum,...Y(e)});Pn=class extends ee{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.promise&&r.common.async===!1)return N(r,{code:T.invalid_type,expected:z.promise,received:r.parsedType}),V;let n=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return at(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Pn.create=(t,e)=>new Pn({type:t,typeName:O.ZodPromise,...Y(e)});Ht=class extends ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{N(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return V;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?V:c.status==="dirty"?_s(c.value):r.value==="dirty"?_s(c.value):c});{if(r.value==="aborted")return V;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?V:a.status==="dirty"?_s(a.value):r.value==="dirty"?_s(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?V:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?V:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$n(o))return V;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>$n(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):V);se.assertNever(s)}};Ht.create=(t,e,r)=>new Ht({schema:t,typeName:O.ZodEffects,effect:e,...Y(r)});Ht.createWithPreprocess=(t,e,r)=>new Ht({schema:e,effect:{type:"preprocess",transform:t},typeName:O.ZodEffects,...Y(r)});vt=class extends ee{_parse(e){return this._getType(e)===z.undefined?at(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vt.create=(t,e)=>new vt({innerType:t,typeName:O.ZodOptional,...Y(e)});Sr=class extends ee{_parse(e){return this._getType(e)===z.null?at(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Sr.create=(t,e)=>new Sr({innerType:t,typeName:O.ZodNullable,...Y(e)});As=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};As.create=(t,e)=>new As({innerType:t,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});Ns=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ki(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new wt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new wt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ns.create=(t,e)=>new Ns({innerType:t,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});eo=class extends ee{_parse(e){if(this._getType(e)!==z.nan){let n=this._getOrReturnCtx(e);return N(n,{code:T.invalid_type,expected:z.nan,received:n.parsedType}),V}return{status:"valid",value:e.data}}};eo.create=t=>new eo({typeName:O.ZodNaN,...Y(t)});Wq=Symbol("zod_brand"),Ka=class extends ee{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ja=class t extends ee{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?V:i.status==="dirty"?(r.dirty(),_s(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?V:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:O.ZodPipeline})}},Rs=class extends ee{_parse(e){let r=this._def.innerType._parse(e),n=s=>($n(s)&&(s.value=Object.freeze(s.value)),s);return Ki(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Rs.create=(t,e)=>new Rs({innerType:t,typeName:O.ZodReadonly,...Y(e)});Kq={object:xt.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(O||(O={}));Jq=(t,e={message:`Input not instance of ${t.name}`})=>kE(r=>r instanceof t,e),$E=En.create,EE=bs.create,Gq=eo.create,Yq=ws.create,TE=vs.create,Xq=xs.create,Qq=Gi.create,eD=Ss.create,tD=ks.create,rD=Tn.create,nD=Wr.create,sD=ir.create,iD=Yi.create,oD=Kr.create,lg=xt.create,aD=xt.strictCreate,cD=$s.create,uD=sd.create,lD=Es.create,dD=xr.create,fD=id.create,pD=Xi.create,hD=Qi.create,mD=od.create,gD=Ts.create,yD=Ps.create,_D=Os.create,bD=Is.create,wD=Pn.create,vD=Ht.create,xD=vt.create,SD=Sr.create,kD=Ht.createWithPreprocess,$D=Ja.create,ED=()=>$E().optional(),TD=()=>EE().optional(),PD=()=>TE().optional(),OD={string:t=>En.create({...t,coerce:!0}),number:t=>bs.create({...t,coerce:!0}),boolean:t=>vs.create({...t,coerce:!0}),bigint:t=>ws.create({...t,coerce:!0}),date:t=>xs.create({...t,coerce:!0})},ID=V});var Ce={};Vn(Ce,{BRAND:()=>Wq,DIRTY:()=>_s,EMPTY_PATH:()=>$q,INVALID:()=>V,NEVER:()=>ID,OK:()=>at,ParseStatus:()=>tt,Schema:()=>ee,ZodAny:()=>Tn,ZodArray:()=>Kr,ZodBigInt:()=>ws,ZodBoolean:()=>vs,ZodBranded:()=>Ka,ZodCatch:()=>Ns,ZodDate:()=>xs,ZodDefault:()=>As,ZodDiscriminatedUnion:()=>sd,ZodEffects:()=>Ht,ZodEnum:()=>Os,ZodError:()=>wt,ZodFirstPartyTypeKind:()=>O,ZodFunction:()=>od,ZodIntersection:()=>Es,ZodIssueCode:()=>T,ZodLazy:()=>Ts,ZodLiteral:()=>Ps,ZodMap:()=>Xi,ZodNaN:()=>eo,ZodNativeEnum:()=>Is,ZodNever:()=>ir,ZodNull:()=>ks,ZodNullable:()=>Sr,ZodNumber:()=>bs,ZodObject:()=>xt,ZodOptional:()=>vt,ZodParsedType:()=>z,ZodPipeline:()=>Ja,ZodPromise:()=>Pn,ZodReadonly:()=>Rs,ZodRecord:()=>id,ZodSchema:()=>ee,ZodSet:()=>Qi,ZodString:()=>En,ZodSymbol:()=>Gi,ZodTransformer:()=>Ht,ZodTuple:()=>xr,ZodType:()=>ee,ZodUndefined:()=>Ss,ZodUnion:()=>$s,ZodUnknown:()=>Wr,ZodVoid:()=>Yi,addIssueToContext:()=>N,any:()=>rD,array:()=>oD,bigint:()=>Yq,boolean:()=>TE,coerce:()=>OD,custom:()=>kE,date:()=>Xq,datetimeRegex:()=>xE,defaultErrorMap:()=>Vr,discriminatedUnion:()=>uD,effect:()=>vD,enum:()=>_D,function:()=>mD,getErrorMap:()=>Wi,getParsedType:()=>vr,instanceof:()=>Jq,intersection:()=>lD,isAborted:()=>rd,isAsync:()=>Ki,isDirty:()=>nd,isValid:()=>$n,late:()=>Kq,lazy:()=>gD,literal:()=>yD,makeIssue:()=>Wa,map:()=>pD,nan:()=>Gq,nativeEnum:()=>bD,never:()=>sD,null:()=>tD,nullable:()=>SD,number:()=>EE,object:()=>lg,objectUtil:()=>ig,oboolean:()=>PD,onumber:()=>TD,optional:()=>xD,ostring:()=>ED,pipeline:()=>$D,preprocess:()=>kD,promise:()=>wD,quotelessJson:()=>xq,record:()=>fD,set:()=>hD,setErrorMap:()=>kq,strictObject:()=>aD,string:()=>$E,symbol:()=>Qq,transformer:()=>vD,tuple:()=>dD,undefined:()=>eD,union:()=>cD,unknown:()=>nD,util:()=>se,void:()=>iD});var ad=$(()=>{td();ag();gE();Ha();PE();ed()});var Ga=$(()=>{ad()});function S(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in o.prototype)l in a||Object.defineProperty(a,l,{value:o.prototype[l].bind(a)});a._zod.constr=o,a._zod.def=c}let s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(a){var c;let u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}function Rt(t){return t&&Object.assign(cd,t),cd}var ND,RD,Jr,cd,to=$(()=>{ND=Object.freeze({status:"aborted"});RD=Symbol("zod_brand"),Jr=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},cd={}});var ie={};Vn(ie,{BIGINT_FORMAT_RANGES:()=>IE,Class:()=>fg,NUMBER_FORMAT_RANGES:()=>bg,aborted:()=>Ms,allowsEval:()=>gg,assert:()=>LD,assertEqual:()=>zD,assertIs:()=>CD,assertNever:()=>jD,assertNotEqual:()=>MD,assignProp:()=>mg,cached:()=>Qa,captureStackTrace:()=>ld,cleanEnum:()=>YD,cleanRegex:()=>tc,clone:()=>zt,createTransparentProxy:()=>BD,defineLazy:()=>ve,esc:()=>zs,escapeRegex:()=>On,extend:()=>WD,finalizeIssue:()=>or,floatSafeRemainder:()=>hg,getElementAtPath:()=>qD,getEnumValues:()=>Xa,getLengthableOrigin:()=>rc,getParsedType:()=>FD,getSizableOrigin:()=>AE,isObject:()=>ro,isPlainObject:()=>no,issue:()=>wg,joinValues:()=>ud,jsonStringifyReplacer:()=>pg,merge:()=>KD,normalizeParams:()=>H,nullish:()=>ec,numKeys:()=>UD,omit:()=>HD,optionalKeys:()=>_g,partial:()=>JD,pick:()=>VD,prefixIssues:()=>kr,primitiveTypes:()=>OE,promiseAllObject:()=>DD,propertyKeyTypes:()=>yg,randomString:()=>ZD,required:()=>GD,stringifyPrimitive:()=>dd,unwrapMessage:()=>Ya});function zD(t){return t}function MD(t){return t}function CD(t){}function jD(t){throw new Error}function LD(t){}function Xa(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function ud(t,e="|"){return t.map(r=>dd(r)).join(e)}function pg(t,e){return typeof e=="bigint"?e.toString():e}function Qa(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ec(t){return t==null}function tc(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function hg(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function ve(t,e,r){Object.defineProperty(t,e,{get(){{let s=r();return t[e]=s,s}throw new Error("cached value already set")},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function mg(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function qD(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function DD(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let s={};for(let i=0;i<e.length;i++)s[e[i]]=n[i];return s})}function ZD(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function zs(t){return JSON.stringify(t)}function ro(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function no(t){if(ro(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(ro(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function UD(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}function On(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function H(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function BD(t){let e;return new Proxy({},{get(r,n,s){return e??(e=t()),Reflect.get(e,n,s)},set(r,n,s,i){return e??(e=t()),Reflect.set(e,n,s,i)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,s){return e??(e=t()),Reflect.defineProperty(e,n,s)}})}function dd(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function _g(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function VD(t,e){let r={},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return zt(t,{...t._zod.def,shape:r,checks:[]})}function HD(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return zt(t,{...t._zod.def,shape:r,checks:[]})}function WD(t,e){if(!no(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return mg(this,"shape",n),n},checks:[]};return zt(t,r)}function KD(t,e){return zt(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return mg(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function JD(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in n))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=t?new t({type:"optional",innerType:n[i]}):n[i])}else for(let i in n)s[i]=t?new t({type:"optional",innerType:n[i]}):n[i];return zt(e,{...e._zod.def,shape:s,checks:[]})}function GD(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:n[i]}))}else for(let i in n)s[i]=new t({type:"nonoptional",innerType:n[i]});return zt(e,{...e._zod.def,shape:s,checks:[]})}function Ms(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function kr(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Ya(t){return typeof t=="string"?t:t?.message}function or(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=Ya(t.inst?._zod.def?.error?.(t))??Ya(e?.error?.(t))??Ya(r.customError?.(t))??Ya(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function AE(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function rc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function wg(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function YD(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var ld,gg,FD,yg,OE,bg,IE,fg,$r=$(()=>{ld=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};gg=Qa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});FD=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},yg=new Set(["string","number","symbol"]),OE=new Set(["string","number","bigint","boolean","symbol","undefined"]);bg={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},IE={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};fg=class{constructor(...e){}}});function vg(t,e=r=>r.message){let r={},n=[];for(let s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function xg(t,e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>s({issues:a}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({issues:o.issues});else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(t),n}var NE,fd,nc,Sg=$(()=>{to();$r();NE=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,pg,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},fd=S("$ZodError",NE),nc=S("$ZodError",NE,{Parent:Error})});var kg,$g,Eg,Tg,Pg,Cs,Og,js,Ig=$(()=>{to();Sg();$r();kg=t=>(e,r,n,s)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Jr;if(o.issues.length){let a=new(s?.Err??t)(o.issues.map(c=>or(c,i,Rt())));throw ld(a,s?.callee),a}return o.value},$g=kg(nc),Eg=t=>async(e,r,n,s)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(s?.Err??t)(o.issues.map(c=>or(c,i,Rt())));throw ld(a,s?.callee),a}return o.value},Tg=Eg(nc),Pg=t=>(e,r,n)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Jr;return i.issues.length?{success:!1,error:new(t??fd)(i.issues.map(o=>or(o,s,Rt())))}:{success:!0,data:i.value}},Cs=Pg(nc),Og=t=>async(e,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>or(o,s,Rt())))}:{success:!0,data:i.value}},js=Og(nc)});function UE(){return new RegExp(QD,"u")}function XE(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function QE(t){return new RegExp(`^${XE(t)}$`)}function eT(t){let e=XE({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${GE}T(?:${n})$`)}var RE,zE,ME,CE,jE,LE,qE,DE,Ag,ZE,QD,FE,BE,VE,HE,WE,Ng,KE,JE,GE,YE,tT,rT,nT,sT,iT,oT,aT,hd=$(()=>{RE=/^[cC][^\s-]{8,}$/,zE=/^[0-9a-z]+$/,ME=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,CE=/^[0-9a-vA-V]{20}$/,jE=/^[A-Za-z0-9]{27}$/,LE=/^[a-zA-Z0-9_-]{21}$/,qE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,DE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ag=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,ZE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";FE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,BE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,VE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,HE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,WE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ng=/^[A-Za-z0-9_-]*$/,KE=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,JE=/^\+(?:[0-9]){6,14}[0-9]$/,GE="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",YE=new RegExp(`^${GE}$`);tT=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},rT=/^\d+$/,nT=/^-?\d+(?:\.\d+)?/i,sT=/true|false/i,iT=/null/i,oT=/^[^A-Z]*$/,aT=/^[^a-z]*$/});var rt,cT,Rg,zg,uT,lT,dT,fT,pT,sc,hT,mT,gT,yT,_T,bT,wT,md=$(()=>{to();hd();$r();rt=S("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),cT={number:"number",bigint:"bigint",object:"date"},Rg=S("$ZodCheckLessThan",(t,e)=>{rt.init(t,e);let r=cT[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),zg=S("$ZodCheckGreaterThan",(t,e)=>{rt.init(t,e);let r=cT[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),uT=S("$ZodCheckMultipleOf",(t,e)=>{rt.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):hg(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),lT=S("$ZodCheckNumberFormat",(t,e)=>{rt.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,i]=bg[e.format];t._zod.onattach.push(o=>{let a=o._zod.bag;a.format=e.format,a.minimum=s,a.maximum=i,r&&(a.pattern=rT)}),t._zod.check=o=>{let a=o.value;if(r){if(!Number.isInteger(a)){o.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<s&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>i&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inst:t})}}),dT=S("$ZodCheckMaxLength",(t,e)=>{var r;rt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!ec(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let s=n.value;if(s.length<=e.maximum)return;let o=rc(s);n.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),fT=S("$ZodCheckMinLength",(t,e)=>{var r;rt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!ec(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let s=n.value;if(s.length>=e.minimum)return;let o=rc(s);n.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),pT=S("$ZodCheckLengthEquals",(t,e)=>{var r;rt.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!ec(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{let s=n.value,i=s.length;if(i===e.length)return;let o=rc(s),a=i>e.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),sc=S("$ZodCheckStringFormat",(t,e)=>{var r,n;rt.init(t,e),t._zod.onattach.push(s=>{let i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),hT=S("$ZodCheckRegex",(t,e)=>{sc.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),mT=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=oT),sc.init(t,e)}),gT=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=aT),sc.init(t,e)}),yT=S("$ZodCheckIncludes",(t,e)=>{rt.init(t,e);let r=On(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{let i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),_T=S("$ZodCheckStartsWith",(t,e)=>{rt.init(t,e);let r=new RegExp(`^${On(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),bT=S("$ZodCheckEndsWith",(t,e)=>{rt.init(t,e);let r=new RegExp(`.*${On(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),wT=S("$ZodCheckOverwrite",(t,e)=>{rt.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}})});var gd,Mg=$(()=>{gd=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
153
153
|
`).filter(o=>o),s=Math.min(...n.map(o=>o.length-o.trimStart().length)),i=n.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(let o of i)this.content.push(o)}compile(){let e=Function,r=this?.args,s=[...(this?.content??[""]).map(i=>` ${i}`)];return new e(...r,s.join(`
|
|
154
|
-
`))}}});var
|
|
154
|
+
`))}}});var xT,Cg=$(()=>{xT={major:4,minor:0,patch:0}});function CT(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}function eZ(t){if(!Ng.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return CT(r)}function tZ(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}function ST(t,e,r){t.issues.length&&e.issues.push(...kr(r,t.issues)),e.value[r]=t.value}function yd(t,e,r){t.issues.length&&e.issues.push(...kr(r,t.issues)),e.value[r]=t.value}function kT(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...kr(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}function $T(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>or(i,n,Rt())))}),e}function jg(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(no(t)&&no(e)){let r=Object.keys(e),n=Object.keys(t).filter(i=>r.indexOf(i)!==-1),s={...t,...e};for(let i of n){let o=jg(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let s=t[n],i=e[n],o=jg(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ET(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ms(t))return t;let n=jg(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}function TT(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}function PT(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function OT(t,e,r){return Ms(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}function IT(t){return t.value=Object.freeze(t.value),t}function AT(t,e,r,n){if(!t){let 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),e.issues.push(wg(s))}}var _e,ic,xe,Lg,qg,Dg,Zg,Ug,Fg,Bg,Vg,Hg,Wg,Kg,NT,RT,zT,MT,Jg,Gg,Yg,Xg,Qg,ey,ty,ry,_d,ny,sy,iy,oy,ay,cy,bd,wd,uy,ly,dy,fy,py,hy,my,gy,yy,_y,by,wy,vy,xy,Sy,jT=$(()=>{md();to();Mg();Ig();hd();$r();Cg();$r();_e=S("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=xT;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let s of n)for(let i of s._zod.onattach)i(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let s=(i,o,a)=>{let c=Ms(i),u;for(let l of o){if(l._zod.def.when){if(!l._zod.def.when(i))continue}else if(c)continue;let d=i.issues.length,f=l._zod.check(i);if(f instanceof Promise&&a?.async===!1)throw new Jr;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,i.issues.length!==d&&(c||(c=Ms(i,d)))});else{if(i.issues.length===d)continue;c||(c=Ms(i,d))}}return u?u.then(()=>i):i};t._zod.run=(i,o)=>{let a=t._zod.parse(i,o);if(a instanceof Promise){if(o.async===!1)throw new Jr;return a.then(c=>s(c,n,o))}return s(a,n,o)}}t["~standard"]={validate:s=>{try{let i=Cs(t,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return js(t,s).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),ic=S("$ZodString",(t,e)=>{_e.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??tT(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),xe=S("$ZodStringFormat",(t,e)=>{sc.init(t,e),ic.init(t,e)}),Lg=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=DE),xe.init(t,e)}),qg=S("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ag(n))}else e.pattern??(e.pattern=Ag());xe.init(t,e)}),Dg=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=ZE),xe.init(t,e)}),Zg=S("$ZodURL",(t,e)=>{xe.init(t,e),t._zod.check=r=>{try{let n=r.value,s=new URL(n),i=s.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:KE.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&i.endsWith("/")?r.value=i.slice(0,-1):r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Ug=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=UE()),xe.init(t,e)}),Fg=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=LE),xe.init(t,e)}),Bg=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=RE),xe.init(t,e)}),Vg=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=zE),xe.init(t,e)}),Hg=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=ME),xe.init(t,e)}),Wg=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=CE),xe.init(t,e)}),Kg=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=jE),xe.init(t,e)}),NT=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=eT(e)),xe.init(t,e)}),RT=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=YE),xe.init(t,e)}),zT=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=QE(e)),xe.init(t,e)}),MT=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=qE),xe.init(t,e)}),Jg=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=FE),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Gg=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=BE),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Yg=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=VE),xe.init(t,e)}),Xg=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=HE),xe.init(t,e),t._zod.check=r=>{let[n,s]=r.value.split("/");try{if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});Qg=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=WE),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{CT(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});ey=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Ng),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{eZ(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),ty=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=JE),xe.init(t,e)});ry=S("$ZodJWT",(t,e)=>{xe.init(t,e),t._zod.check=r=>{tZ(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),_d=S("$ZodNumber",(t,e)=>{_e.init(t,e),t._zod.pattern=t._zod.bag.pattern??nT,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),r}}),ny=S("$ZodNumber",(t,e)=>{lT.init(t,e),_d.init(t,e)}),sy=S("$ZodBoolean",(t,e)=>{_e.init(t,e),t._zod.pattern=sT,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),iy=S("$ZodNull",(t,e)=>{_e.init(t,e),t._zod.pattern=iT,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}}),oy=S("$ZodUnknown",(t,e)=>{_e.init(t,e),t._zod.parse=r=>r}),ay=S("$ZodNever",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});cy=S("$ZodArray",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);let i=[];for(let o=0;o<s.length;o++){let a=s[o],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(u=>ST(u,r,o))):ST(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});bd=S("$ZodObject",(t,e)=>{_e.init(t,e);let r=Qa(()=>{let d=Object.keys(e.shape);for(let p of d)if(!(e.shape[p]instanceof _e))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);let f=_g(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(f)}});ve(t._zod,"propValues",()=>{let d=e.shape,f={};for(let p in d){let m=d[p]._zod;if(m.values){f[p]??(f[p]=new Set);for(let h of m.values)f[p].add(h)}}return f});let n=d=>{let f=new gd(["shape","payload","ctx"]),p=r.value,m=_=>{let v=zs(_);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};f.write("const input = payload.value;");let h=Object.create(null),g=0;for(let _ of p.keys)h[_]=`key_${g++}`;f.write("const newResult = {}");for(let _ of p.keys)if(p.optionalKeys.has(_)){let v=h[_];f.write(`const ${v} = ${m(_)};`);let k=zs(_);f.write(`
|
|
155
155
|
if (${v}.issues.length) {
|
|
156
156
|
if (input[${k}] === undefined) {
|
|
157
157
|
if (${k} in input) {
|
|
@@ -173,55 +173,55 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
|
|
173
173
|
`)}else{let v=h[_];f.write(`const ${v} = ${m(_)};`),f.write(`
|
|
174
174
|
if (${v}.issues.length) payload.issues = payload.issues.concat(${v}.issues.map(iss => ({
|
|
175
175
|
...iss,
|
|
176
|
-
path: iss.path ? [${
|
|
177
|
-
})));`),f.write(`newResult[${Rs(_)}] = ${v}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let y=f.compile();return(_,v)=>y(d,_,v)},s,i=to,o=!ad.jitless,c=o&&mg.value,u=e.catchall,l;t._zod.parse=(d,f)=>{l??(l=r.value);let p=d.value;if(!i(p))return d.issues.push({expected:"object",code:"invalid_type",input:p,inst:t}),d;let m=[];if(o&&c&&f?.async===!1&&f.jitless!==!0)s||(s=n(e.shape)),d=s(d,f);else{d.value={};let v=l.shape;for(let k of l.keys){let E=v[k],C=E._zod.run({value:p[k],issues:[]},f),B=E._zod.optin==="optional"&&E._zod.optout==="optional";C instanceof Promise?m.push(C.then(R=>B?ST(R,d,k,p):gd(R,d,k))):B?ST(C,d,k,p):gd(C,d,k)}}if(!u)return m.length?Promise.all(m).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,_=y.def.type;for(let v of Object.keys(p)){if(g.has(v))continue;if(_==="never"){h.push(v);continue}let k=y.run({value:p[v],issues:[]},f);k instanceof Promise?m.push(k.then(E=>gd(E,d,v))):gd(k,d,v)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:p,inst:t}),m.length?Promise.all(m).then(()=>d):d}});bd=S("$ZodUnion",(t,e)=>{_e.init(t,e),ve(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ve(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ve(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ve(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ec(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1,i=[];for(let o of e.options){let a=o._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}return s?Promise.all(i).then(o=>kT(o,r,t,n)):kT(i,r,t,n)}}),cy=S("$ZodDiscriminatedUnion",(t,e)=>{bd.init(t,e);let r=t._zod.parse;ve(t._zod,"propValues",()=>{let s={};for(let i of e.options){let o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let[a,c]of Object.entries(o)){s[a]||(s[a]=new Set);for(let u of c)s[a].add(u)}}return s});let n=Xa(()=>{let s=e.options,i=new Map;for(let o of s){let a=o._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,o)}}return i});t._zod.parse=(s,i)=>{let o=s.value;if(!to(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),s;let a=n.value.get(o?.[e.discriminator]);return a?a._zod.run(s,i):e.unionFallback?r(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[e.discriminator],inst:t}),s)}}),uy=S("$ZodIntersection",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>$T(r,c,u)):$T(r,i,o)}});ly=S("$ZodRecord",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!ro(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;let i=[];if(e.keyType._zod.values){let o=e.keyType._zod.values;r.value={};for(let c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?i.push(u.then(l=>{l.issues.length&&r.issues.push(...Sr(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Sr(c,u.issues)),r.value[c]=u.value)}let a;for(let c in s)o.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(let o of Reflect.ownKeys(s)){if(o==="__proto__")continue;let a=e.keyType._zod.run({value:o,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>ir(u,n,Nt())),input:o,path:[o],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:s[o],issues:[]},n);c instanceof Promise?i.push(c.then(u=>{u.issues.length&&r.issues.push(...Sr(o,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Sr(o,c.issues)),r.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>r):r}}),dy=S("$ZodEnum",(t,e)=>{_e.init(t,e);let r=Ya(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>gg.has(typeof n)).map(n=>typeof n=="string"?Pn(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{let i=n.value;return t._zod.values.has(i)||n.issues.push({code:"invalid_value",values:r,input:i,inst:t}),n}}),fy=S("$ZodLiteral",(t,e)=>{_e.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Pn(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),py=S("$ZodTransform",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(r.value=o,r));if(s instanceof Promise)throw new Kr;return r.value=s,r}}),hy=S("$ZodOptional",(t,e)=>{_e.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ve(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ve(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${ec(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),my=S("$ZodNullable",(t,e)=>{_e.init(t,e),ve(t._zod,"optin",()=>e.innerType._zod.optin),ve(t._zod,"optout",()=>e.innerType._zod.optout),ve(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${ec(r.source)}|null)$`):void 0}),ve(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),gy=S("$ZodDefault",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>ET(i,e)):ET(s,e)}});yy=S("$ZodPrefault",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),_y=S("$ZodNonOptional",(t,e)=>{_e.init(t,e),ve(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>TT(i,t)):TT(s,t)}});by=S("$ZodCatch",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"optout",()=>e.innerType._zod.optout),ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>ir(o,n,Nt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>ir(i,n,Nt()))},input:r.value}),r.issues=[]),r)}}),wy=S("$ZodPipe",(t,e)=>{_e.init(t,e),ve(t._zod,"values",()=>e.in._zod.values),ve(t._zod,"optin",()=>e.in._zod.optin),ve(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>PT(i,e,n)):PT(s,e,n)}});vy=S("$ZodReadonly",(t,e)=>{_e.init(t,e),ve(t._zod,"propValues",()=>e.innerType._zod.propValues),ve(t._zod,"values",()=>e.innerType._zod.values),ve(t._zod,"optin",()=>e.innerType._zod.optin),ve(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(OT):OT(s)}});xy=S("$ZodCustom",(t,e)=>{tt.init(t,e),_e.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>IT(i,r,n,t));IT(s,r,n,t)}})});function jT(){return{localeError:rZ()}}var tZ,rZ,LT=$(()=>{kr();tZ=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},rZ=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${tZ(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${ld(n.values[0])}`:`Invalid option: expected one of ${cd(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=e(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=e(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${cd(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}}});var wd=$(()=>{});function qT(){return new ic}var nZ,sZ,ic,On,ky=$(()=>{nZ=Symbol("ZodOutput"),sZ=Symbol("ZodInput"),ic=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,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,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};On=qT()});function $y(t,e){return new t({type:"string",...H(e)})}function Ey(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...H(e)})}function vd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...H(e)})}function Ty(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...H(e)})}function Py(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...H(e)})}function Oy(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...H(e)})}function Iy(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...H(e)})}function Ay(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...H(e)})}function Ny(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...H(e)})}function Ry(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...H(e)})}function zy(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...H(e)})}function My(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...H(e)})}function Cy(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...H(e)})}function jy(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...H(e)})}function Ly(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...H(e)})}function qy(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...H(e)})}function Dy(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...H(e)})}function Zy(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...H(e)})}function Uy(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...H(e)})}function Fy(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...H(e)})}function By(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...H(e)})}function Vy(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...H(e)})}function Hy(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...H(e)})}function DT(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...H(e)})}function ZT(t,e){return new t({type:"string",format:"date",check:"string_format",...H(e)})}function UT(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...H(e)})}function FT(t,e){return new t({type:"string",format:"duration",check:"string_format",...H(e)})}function Wy(t,e){return new t({type:"number",checks:[],...H(e)})}function Ky(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...H(e)})}function Jy(t,e){return new t({type:"boolean",...H(e)})}function Gy(t,e){return new t({type:"null",...H(e)})}function Yy(t){return new t({type:"unknown"})}function Xy(t,e){return new t({type:"never",...H(e)})}function xd(t,e){return new Ng({check:"less_than",...H(e),value:t,inclusive:!1})}function oc(t,e){return new Ng({check:"less_than",...H(e),value:t,inclusive:!0})}function Sd(t,e){return new Rg({check:"greater_than",...H(e),value:t,inclusive:!1})}function ac(t,e){return new Rg({check:"greater_than",...H(e),value:t,inclusive:!0})}function kd(t,e){return new cT({check:"multiple_of",...H(e),value:t})}function $d(t,e){return new lT({check:"max_length",...H(e),maximum:t})}function no(t,e){return new dT({check:"min_length",...H(e),minimum:t})}function Ed(t,e){return new fT({check:"length_equals",...H(e),length:t})}function Qy(t,e){return new pT({check:"string_format",format:"regex",...H(e),pattern:t})}function e_(t){return new hT({check:"string_format",format:"lowercase",...H(t)})}function t_(t){return new mT({check:"string_format",format:"uppercase",...H(t)})}function r_(t,e){return new gT({check:"string_format",format:"includes",...H(e),includes:t})}function n_(t,e){return new yT({check:"string_format",format:"starts_with",...H(e),prefix:t})}function s_(t,e){return new _T({check:"string_format",format:"ends_with",...H(e),suffix:t})}function js(t){return new bT({check:"overwrite",tx:t})}function i_(t){return js(e=>e.normalize(t))}function o_(){return js(t=>t.trim())}function a_(){return js(t=>t.toLowerCase())}function c_(){return js(t=>t.toUpperCase())}function BT(t,e,r){return new t({type:"array",element:e,...H(r)})}function u_(t,e,r){let n=H(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function l_(t,e,r){return new t({type:"custom",check:"custom",fn:e,...H(r)})}var VT=$(()=>{hd();kr()});var HT=$(()=>{});function d_(t,e){if(t instanceof ic){let n=new Td(e),s={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let i={},o={registry:t,uri:e?.uri,defs:s};for(let a of t._idmap.entries()){let[c,u]=a;i[c]=n.emit(u,{...e,external:o})}if(Object.keys(s).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[a]:s}}return{schemas:i}}let r=new Td(e);return r.process(t),r.emit(t,e)}function Be(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let s=t._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 Be(s.element,r);case"object":{for(let i in s.shape)if(Be(s.shape[i],r))return!0;return!1}case"union":{for(let i of s.options)if(Be(i,r))return!0;return!1}case"intersection":return Be(s.left,r)||Be(s.right,r);case"tuple":{for(let i of s.items)if(Be(i,r))return!0;return!!(s.rest&&Be(s.rest,r))}case"record":return Be(s.keyType,r)||Be(s.valueType,r);case"map":return Be(s.keyType,r)||Be(s.valueType,r);case"set":return Be(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Be(s.innerType,r);case"lazy":return Be(s.getter(),r);case"default":return Be(s.innerType,r);case"prefault":return Be(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Be(s.in,r)||Be(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var Td,WT=$(()=>{ky();kr();Td=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??On,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},f=e._zod.parent;if(f)a.ref=f,this.process(f,d),this.seen.get(f).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let m=p;m.type="string";let{minimum:h,maximum:g,format:y,patterns:_,contentEncoding:v}=e._zod.bag;if(typeof h=="number"&&(m.minLength=h),typeof g=="number"&&(m.maxLength=g),y&&(m.format=i[y]??y,m.format===""&&delete m.format),v&&(m.contentEncoding=v),_&&_.size>0){let k=[..._];k.length===1?m.pattern=k[0].source:k.length>1&&(a.schema.allOf=[...k.map(E=>({...this.target==="draft-7"?{type:"string"}:{},pattern:E.source}))])}break}case"number":{let m=p,{minimum:h,maximum:g,format:y,multipleOf:_,exclusiveMaximum:v,exclusiveMinimum:k}=e._zod.bag;typeof y=="string"&&y.includes("int")?m.type="integer":m.type="number",typeof k=="number"&&(m.exclusiveMinimum=k),typeof h=="number"&&(m.minimum=h,typeof k=="number"&&(k>=h?delete m.minimum:delete m.exclusiveMinimum)),typeof v=="number"&&(m.exclusiveMaximum=v),typeof g=="number"&&(m.maximum=g,typeof v=="number"&&(v<=g?delete m.maximum:delete m.exclusiveMaximum)),typeof _=="number"&&(m.multipleOf=_);break}case"boolean":{let m=p;m.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":{p.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":{p.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let m=p,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(m.minItems=h),typeof g=="number"&&(m.maxItems=g),m.type="array",m.items=this.process(s.element,{...d,path:[...d.path,"items"]});break}case"object":{let m=p;m.type="object",m.properties={};let h=s.shape;for(let _ in h)m.properties[_]=this.process(h[_],{...d,path:[...d.path,"properties",_]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(_=>{let v=s.shape[_]._zod;return this.io==="input"?v.optin===void 0:v.optout===void 0}));y.size>0&&(m.required=Array.from(y)),s.catchall?._zod.def.type==="never"?m.additionalProperties=!1:s.catchall?s.catchall&&(m.additionalProperties=this.process(s.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(m.additionalProperties=!1);break}case"union":{let m=p;m.anyOf=s.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let m=p,h=this.process(s.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(s.right,{...d,path:[...d.path,"allOf",1]}),y=v=>"allOf"in v&&Object.keys(v).length===1,_=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];m.allOf=_;break}case"tuple":{let m=p;m.type="array";let h=s.items.map((_,v)=>this.process(_,{...d,path:[...d.path,"prefixItems",v]}));if(this.target==="draft-2020-12"?m.prefixItems=h:m.items=h,s.rest){let _=this.process(s.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?m.items=_:m.additionalItems=_}s.rest&&(m.items=this.process(s.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(m.minItems=g),typeof y=="number"&&(m.maxItems=y);break}case"record":{let m=p;m.type="object",m.propertyNames=this.process(s.keyType,{...d,path:[...d.path,"propertyNames"]}),m.additionalProperties=this.process(s.valueType,{...d,path:[...d.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":{let m=p,h=Ya(s.entries);h.every(g=>typeof g=="number")&&(m.type="number"),h.every(g=>typeof g=="string")&&(m.type="string"),m.enum=h;break}case"literal":{let m=p,h=[];for(let 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");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];m.type=g===null?"null":typeof g,m.const=g}else h.every(g=>typeof g=="number")&&(m.type="number"),h.every(g=>typeof g=="string")&&(m.type="string"),h.every(g=>typeof g=="boolean")&&(m.type="string"),h.every(g=>g===null)&&(m.type="null"),m.enum=h;break}case"file":{let m=p,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:_}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),_?_.length===1?(h.contentMediaType=_[0],Object.assign(m,h)):m.anyOf=_.map(v=>({...h,contentMediaType:v})):Object.assign(m,h);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let m=this.process(s.innerType,d);p.anyOf=[m,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"success":{let m=p;m.type="boolean";break}case"default":{this.process(s.innerType,d),a.ref=s.innerType,p.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,d),a.ref=s.innerType,this.io==="input"&&(p._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,d),a.ref=s.innerType;let m;try{m=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=m;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let m=p,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");m.type="string",m.pattern=h.source;break}case"pipe":{let m=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(m,d),a.ref=m;break}case"readonly":{this.process(s.innerType,d),a.ref=s.innerType,p.readOnly=!0;break}case"promise":{this.process(s.innerType,d),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"lazy":{let m=e._zod.innerType;this.process(m,d),a.ref=m;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&Be(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(_=>_);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===s)return{ref:"#"};let p=`#/${d}/`,m=l[1].schema.id??`__schema${this.counter++}`;return{defId:m,ref:p+m}},o=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:f,defId:p}=i(l);d.def={...d.schema},p&&(d.defId=p);let m=d.schema;for(let h in m)delete m[h];m.$ref=f};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
176
|
+
path: iss.path ? [${zs(_)}, ...iss.path] : [${zs(_)}]
|
|
177
|
+
})));`),f.write(`newResult[${zs(_)}] = ${v}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let y=f.compile();return(_,v)=>y(d,_,v)},s,i=ro,o=!cd.jitless,c=o&&gg.value,u=e.catchall,l;t._zod.parse=(d,f)=>{l??(l=r.value);let p=d.value;if(!i(p))return d.issues.push({expected:"object",code:"invalid_type",input:p,inst:t}),d;let m=[];if(o&&c&&f?.async===!1&&f.jitless!==!0)s||(s=n(e.shape)),d=s(d,f);else{d.value={};let v=l.shape;for(let k of l.keys){let E=v[k],C=E._zod.run({value:p[k],issues:[]},f),B=E._zod.optin==="optional"&&E._zod.optout==="optional";C instanceof Promise?m.push(C.then(R=>B?kT(R,d,k,p):yd(R,d,k))):B?kT(C,d,k,p):yd(C,d,k)}}if(!u)return m.length?Promise.all(m).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,_=y.def.type;for(let v of Object.keys(p)){if(g.has(v))continue;if(_==="never"){h.push(v);continue}let k=y.run({value:p[v],issues:[]},f);k instanceof Promise?m.push(k.then(E=>yd(E,d,v))):yd(k,d,v)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:p,inst:t}),m.length?Promise.all(m).then(()=>d):d}});wd=S("$ZodUnion",(t,e)=>{_e.init(t,e),ve(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ve(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ve(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ve(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>tc(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1,i=[];for(let o of e.options){let a=o._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}return s?Promise.all(i).then(o=>$T(o,r,t,n)):$T(i,r,t,n)}}),uy=S("$ZodDiscriminatedUnion",(t,e)=>{wd.init(t,e);let r=t._zod.parse;ve(t._zod,"propValues",()=>{let s={};for(let i of e.options){let o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let[a,c]of Object.entries(o)){s[a]||(s[a]=new Set);for(let u of c)s[a].add(u)}}return s});let n=Qa(()=>{let s=e.options,i=new Map;for(let o of s){let a=o._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,o)}}return i});t._zod.parse=(s,i)=>{let o=s.value;if(!ro(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),s;let a=n.value.get(o?.[e.discriminator]);return a?a._zod.run(s,i):e.unionFallback?r(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[e.discriminator],inst:t}),s)}}),ly=S("$ZodIntersection",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>ET(r,c,u)):ET(r,i,o)}});dy=S("$ZodRecord",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!no(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;let i=[];if(e.keyType._zod.values){let o=e.keyType._zod.values;r.value={};for(let c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?i.push(u.then(l=>{l.issues.length&&r.issues.push(...kr(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...kr(c,u.issues)),r.value[c]=u.value)}let a;for(let c in s)o.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(let o of Reflect.ownKeys(s)){if(o==="__proto__")continue;let a=e.keyType._zod.run({value:o,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>or(u,n,Rt())),input:o,path:[o],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:s[o],issues:[]},n);c instanceof Promise?i.push(c.then(u=>{u.issues.length&&r.issues.push(...kr(o,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...kr(o,c.issues)),r.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>r):r}}),fy=S("$ZodEnum",(t,e)=>{_e.init(t,e);let r=Xa(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>yg.has(typeof n)).map(n=>typeof n=="string"?On(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{let i=n.value;return t._zod.values.has(i)||n.issues.push({code:"invalid_value",values:r,input:i,inst:t}),n}}),py=S("$ZodLiteral",(t,e)=>{_e.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?On(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),hy=S("$ZodTransform",(t,e)=>{_e.init(t,e),t._zod.parse=(r,n)=>{let s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(r.value=o,r));if(s instanceof Promise)throw new Jr;return r.value=s,r}}),my=S("$ZodOptional",(t,e)=>{_e.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ve(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ve(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${tc(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),gy=S("$ZodNullable",(t,e)=>{_e.init(t,e),ve(t._zod,"optin",()=>e.innerType._zod.optin),ve(t._zod,"optout",()=>e.innerType._zod.optout),ve(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${tc(r.source)}|null)$`):void 0}),ve(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),yy=S("$ZodDefault",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>TT(i,e)):TT(s,e)}});_y=S("$ZodPrefault",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),by=S("$ZodNonOptional",(t,e)=>{_e.init(t,e),ve(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>PT(i,t)):PT(s,t)}});wy=S("$ZodCatch",(t,e)=>{_e.init(t,e),t._zod.optin="optional",ve(t._zod,"optout",()=>e.innerType._zod.optout),ve(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>or(o,n,Rt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>or(i,n,Rt()))},input:r.value}),r.issues=[]),r)}}),vy=S("$ZodPipe",(t,e)=>{_e.init(t,e),ve(t._zod,"values",()=>e.in._zod.values),ve(t._zod,"optin",()=>e.in._zod.optin),ve(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>OT(i,e,n)):OT(s,e,n)}});xy=S("$ZodReadonly",(t,e)=>{_e.init(t,e),ve(t._zod,"propValues",()=>e.innerType._zod.propValues),ve(t._zod,"values",()=>e.innerType._zod.values),ve(t._zod,"optin",()=>e.innerType._zod.optin),ve(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(IT):IT(s)}});Sy=S("$ZodCustom",(t,e)=>{rt.init(t,e),_e.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>AT(i,r,n,t));AT(s,r,n,t)}})});function LT(){return{localeError:nZ()}}var rZ,nZ,qT=$(()=>{$r();rZ=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},nZ=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${rZ(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${dd(n.values[0])}`:`Invalid option: expected one of ${ud(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=e(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=e(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${ud(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}}});var vd=$(()=>{});function DT(){return new oc}var sZ,iZ,oc,In,$y=$(()=>{sZ=Symbol("ZodOutput"),iZ=Symbol("ZodInput"),oc=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,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,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};In=DT()});function Ey(t,e){return new t({type:"string",...H(e)})}function Ty(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...H(e)})}function xd(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...H(e)})}function Py(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...H(e)})}function Oy(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...H(e)})}function Iy(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...H(e)})}function Ay(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...H(e)})}function Ny(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...H(e)})}function Ry(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...H(e)})}function zy(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...H(e)})}function My(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...H(e)})}function Cy(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...H(e)})}function jy(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...H(e)})}function Ly(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...H(e)})}function qy(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...H(e)})}function Dy(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...H(e)})}function Zy(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...H(e)})}function Uy(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...H(e)})}function Fy(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...H(e)})}function By(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...H(e)})}function Vy(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...H(e)})}function Hy(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...H(e)})}function Wy(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...H(e)})}function ZT(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...H(e)})}function UT(t,e){return new t({type:"string",format:"date",check:"string_format",...H(e)})}function FT(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...H(e)})}function BT(t,e){return new t({type:"string",format:"duration",check:"string_format",...H(e)})}function Ky(t,e){return new t({type:"number",checks:[],...H(e)})}function Jy(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...H(e)})}function Gy(t,e){return new t({type:"boolean",...H(e)})}function Yy(t,e){return new t({type:"null",...H(e)})}function Xy(t){return new t({type:"unknown"})}function Qy(t,e){return new t({type:"never",...H(e)})}function Sd(t,e){return new Rg({check:"less_than",...H(e),value:t,inclusive:!1})}function ac(t,e){return new Rg({check:"less_than",...H(e),value:t,inclusive:!0})}function kd(t,e){return new zg({check:"greater_than",...H(e),value:t,inclusive:!1})}function cc(t,e){return new zg({check:"greater_than",...H(e),value:t,inclusive:!0})}function $d(t,e){return new uT({check:"multiple_of",...H(e),value:t})}function Ed(t,e){return new dT({check:"max_length",...H(e),maximum:t})}function so(t,e){return new fT({check:"min_length",...H(e),minimum:t})}function Td(t,e){return new pT({check:"length_equals",...H(e),length:t})}function e_(t,e){return new hT({check:"string_format",format:"regex",...H(e),pattern:t})}function t_(t){return new mT({check:"string_format",format:"lowercase",...H(t)})}function r_(t){return new gT({check:"string_format",format:"uppercase",...H(t)})}function n_(t,e){return new yT({check:"string_format",format:"includes",...H(e),includes:t})}function s_(t,e){return new _T({check:"string_format",format:"starts_with",...H(e),prefix:t})}function i_(t,e){return new bT({check:"string_format",format:"ends_with",...H(e),suffix:t})}function Ls(t){return new wT({check:"overwrite",tx:t})}function o_(t){return Ls(e=>e.normalize(t))}function a_(){return Ls(t=>t.trim())}function c_(){return Ls(t=>t.toLowerCase())}function u_(){return Ls(t=>t.toUpperCase())}function VT(t,e,r){return new t({type:"array",element:e,...H(r)})}function l_(t,e,r){let n=H(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function d_(t,e,r){return new t({type:"custom",check:"custom",fn:e,...H(r)})}var HT=$(()=>{md();$r()});var WT=$(()=>{});function f_(t,e){if(t instanceof oc){let n=new Pd(e),s={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let i={},o={registry:t,uri:e?.uri,defs:s};for(let a of t._idmap.entries()){let[c,u]=a;i[c]=n.emit(u,{...e,external:o})}if(Object.keys(s).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[a]:s}}return{schemas:i}}let r=new Pd(e);return r.process(t),r.emit(t,e)}function Ve(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let s=t._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 Ve(s.element,r);case"object":{for(let i in s.shape)if(Ve(s.shape[i],r))return!0;return!1}case"union":{for(let i of s.options)if(Ve(i,r))return!0;return!1}case"intersection":return Ve(s.left,r)||Ve(s.right,r);case"tuple":{for(let i of s.items)if(Ve(i,r))return!0;return!!(s.rest&&Ve(s.rest,r))}case"record":return Ve(s.keyType,r)||Ve(s.valueType,r);case"map":return Ve(s.keyType,r)||Ve(s.valueType,r);case"set":return Ve(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ve(s.innerType,r);case"lazy":return Ve(s.getter(),r);case"default":return Ve(s.innerType,r);case"prefault":return Ve(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ve(s.in,r)||Ve(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var Pd,KT=$(()=>{$y();$r();Pd=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??In,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},f=e._zod.parent;if(f)a.ref=f,this.process(f,d),this.seen.get(f).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let m=p;m.type="string";let{minimum:h,maximum:g,format:y,patterns:_,contentEncoding:v}=e._zod.bag;if(typeof h=="number"&&(m.minLength=h),typeof g=="number"&&(m.maxLength=g),y&&(m.format=i[y]??y,m.format===""&&delete m.format),v&&(m.contentEncoding=v),_&&_.size>0){let k=[..._];k.length===1?m.pattern=k[0].source:k.length>1&&(a.schema.allOf=[...k.map(E=>({...this.target==="draft-7"?{type:"string"}:{},pattern:E.source}))])}break}case"number":{let m=p,{minimum:h,maximum:g,format:y,multipleOf:_,exclusiveMaximum:v,exclusiveMinimum:k}=e._zod.bag;typeof y=="string"&&y.includes("int")?m.type="integer":m.type="number",typeof k=="number"&&(m.exclusiveMinimum=k),typeof h=="number"&&(m.minimum=h,typeof k=="number"&&(k>=h?delete m.minimum:delete m.exclusiveMinimum)),typeof v=="number"&&(m.exclusiveMaximum=v),typeof g=="number"&&(m.maximum=g,typeof v=="number"&&(v<=g?delete m.maximum:delete m.exclusiveMaximum)),typeof _=="number"&&(m.multipleOf=_);break}case"boolean":{let m=p;m.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":{p.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":{p.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let m=p,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(m.minItems=h),typeof g=="number"&&(m.maxItems=g),m.type="array",m.items=this.process(s.element,{...d,path:[...d.path,"items"]});break}case"object":{let m=p;m.type="object",m.properties={};let h=s.shape;for(let _ in h)m.properties[_]=this.process(h[_],{...d,path:[...d.path,"properties",_]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(_=>{let v=s.shape[_]._zod;return this.io==="input"?v.optin===void 0:v.optout===void 0}));y.size>0&&(m.required=Array.from(y)),s.catchall?._zod.def.type==="never"?m.additionalProperties=!1:s.catchall?s.catchall&&(m.additionalProperties=this.process(s.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(m.additionalProperties=!1);break}case"union":{let m=p;m.anyOf=s.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let m=p,h=this.process(s.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(s.right,{...d,path:[...d.path,"allOf",1]}),y=v=>"allOf"in v&&Object.keys(v).length===1,_=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];m.allOf=_;break}case"tuple":{let m=p;m.type="array";let h=s.items.map((_,v)=>this.process(_,{...d,path:[...d.path,"prefixItems",v]}));if(this.target==="draft-2020-12"?m.prefixItems=h:m.items=h,s.rest){let _=this.process(s.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?m.items=_:m.additionalItems=_}s.rest&&(m.items=this.process(s.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(m.minItems=g),typeof y=="number"&&(m.maxItems=y);break}case"record":{let m=p;m.type="object",m.propertyNames=this.process(s.keyType,{...d,path:[...d.path,"propertyNames"]}),m.additionalProperties=this.process(s.valueType,{...d,path:[...d.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":{let m=p,h=Xa(s.entries);h.every(g=>typeof g=="number")&&(m.type="number"),h.every(g=>typeof g=="string")&&(m.type="string"),m.enum=h;break}case"literal":{let m=p,h=[];for(let 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");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];m.type=g===null?"null":typeof g,m.const=g}else h.every(g=>typeof g=="number")&&(m.type="number"),h.every(g=>typeof g=="string")&&(m.type="string"),h.every(g=>typeof g=="boolean")&&(m.type="string"),h.every(g=>g===null)&&(m.type="null"),m.enum=h;break}case"file":{let m=p,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:_}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),_?_.length===1?(h.contentMediaType=_[0],Object.assign(m,h)):m.anyOf=_.map(v=>({...h,contentMediaType:v})):Object.assign(m,h);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let m=this.process(s.innerType,d);p.anyOf=[m,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"success":{let m=p;m.type="boolean";break}case"default":{this.process(s.innerType,d),a.ref=s.innerType,p.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,d),a.ref=s.innerType,this.io==="input"&&(p._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,d),a.ref=s.innerType;let m;try{m=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=m;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let m=p,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");m.type="string",m.pattern=h.source;break}case"pipe":{let m=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(m,d),a.ref=m;break}case"readonly":{this.process(s.innerType,d),a.ref=s.innerType,p.readOnly=!0;break}case"promise":{this.process(s.innerType,d),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"lazy":{let m=e._zod.innerType;this.process(m,d),a.ref=m;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&Ve(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(_=>_);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===s)return{ref:"#"};let p=`#/${d}/`,m=l[1].schema.id??`__schema${this.counter++}`;return{defId:m,ref:p+m}},o=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:f,defId:p}=i(l);d.def={...d.schema},p&&(d.defId=p);let m=d.schema;for(let h in m)delete m[h];m.$ref=f};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
178
178
|
|
|
179
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){o(l);continue}if(n.external){let p=n.external.registry.get(l[0])?.id;if(e!==l[0]&&p){o(l);continue}}if(this.metadataRegistry.get(l[0])?.id){o(l);continue}if(d.cycle){o(l);continue}if(d.count>1&&n.reused==="ref"){o(l);continue}}let a=(l,d)=>{let f=this.seen.get(l),p=f.def??f.schema,m={...p};if(f.ref===null)return;let h=f.ref;if(f.ref=null,h){a(h,d);let g=this.seen.get(h).schema;g.$ref&&d.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(g)):(Object.assign(p,g),Object.assign(p,m))}f.isParent||this.override({zodSchema:l,jsonSchema:p,path:f.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let 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){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}});var KT=$(()=>{});var dt=$(()=>{eo();Og();xg();CT();hd();Mg();kr();pd();wd();ky();zg();HT();VT();WT();KT()});var f_=$(()=>{dt()});function p_(t,e){let r={type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},...ie.normalizeParams(e)};return new DZ(r)}var qZ,DZ,JT=$(()=>{dt();dt();f_();qZ=S("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");_e.init(t,e),t.def=e,t.parse=(r,n)=>kg(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Ms(t,r,n),t.parseAsync=async(r,n)=>Eg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Cs(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Rt(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)}),DZ=S("ZodMiniObject",(t,e)=>{_d.init(t,e),qZ.init(t,e),ie.defineLazy(t,"shape",()=>e.shape)})});var GT=$(()=>{});var YT=$(()=>{});var XT=$(()=>{});var QT=$(()=>{dt();f_();JT();GT();dt();wd();YT();XT()});var eP=$(()=>{QT()});var h_=$(()=>{eP()});function Ht(t){return!!t._zod}function qs(t){let e=Object.values(t);if(e.length===0)return p_({});let r=e.every(Ht),n=e.every(s=>!Ht(s));if(r)return p_(t);if(n)return ug(t);throw new Error("Mixed Zod versions detected in object shape.")}function In(t,e){return Ht(t)?Ms(t,e):t.safeParse(e)}async function Pd(t,e){return Ht(t)?await Cs(t,e):await t.safeParseAsync(e)}function An(t){if(!t)return;let e;if(Ht(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function so(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return qs(t)}}if(Ht(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Od(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function rP(t){return t.description}function nP(t){if(Ht(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Id(t){if(Ht(t)){let i=t._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var cc=$(()=>{Ja();h_()});var m_=$(()=>{dt()});var uc={};Bn(uc,{ZodISODate:()=>iP,ZodISODateTime:()=>sP,ZodISODuration:()=>aP,ZodISOTime:()=>oP,date:()=>y_,datetime:()=>g_,duration:()=>b_,time:()=>__});function g_(t){return DT(sP,t)}function y_(t){return ZT(iP,t)}function __(t){return UT(oP,t)}function b_(t){return FT(aP,t)}var sP,iP,oP,aP,w_=$(()=>{dt();v_();sP=S("ZodISODateTime",(t,e)=>{AT.init(t,e),Oe.init(t,e)});iP=S("ZodISODate",(t,e)=>{NT.init(t,e),Oe.init(t,e)});oP=S("ZodISOTime",(t,e)=>{RT.init(t,e),Oe.init(t,e)});aP=S("ZodISODuration",(t,e)=>{zT.init(t,e),Oe.init(t,e)})});var cP,dQ,lc,x_=$(()=>{dt();dt();cP=(t,e)=>{dd.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>vg(t,r)},flatten:{value:r=>wg(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},dQ=S("ZodError",cP),lc=S("ZodError",cP,{Parent:Error})});var uP,lP,dP,fP,S_=$(()=>{dt();x_();uP=Sg(lc),lP=$g(lc),dP=Tg(lc),fP=Pg(lc)});function x(t){return $y(GZ,t)}function ye(t){return Wy(yP,t)}function hP(t){return Ky(hU,t)}function Ye(t){return Jy(mU,t)}function _P(t){return Gy(gU,t)}function Ie(){return Yy(yU)}function bU(t){return Xy(_U,t)}function oe(t,e){return BT(wU,t,e)}function M(t,e){let r={type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},...ie.normalizeParams(e)};return new bP(r)}function ft(t,e){return new bP({type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},catchall:Ie(),...ie.normalizeParams(e)})}function $e(t,e){return new wP({type:"union",options:t,...ie.normalizeParams(e)})}function E_(t,e,r){return new vU({type:"union",options:e,discriminator:t,...ie.normalizeParams(r)})}function Nd(t,e){return new xU({type:"intersection",left:t,right:e})}function Se(t,e,r){return new SU({type:"record",keyType:t,valueType:e,...ie.normalizeParams(r)})}function xt(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new k_({type:"enum",entries:r,...ie.normalizeParams(e)})}function Z(t,e){return new kU({type:"literal",values:Array.isArray(t)?t:[t],...ie.normalizeParams(e)})}function vP(t){return new $U({type:"transform",transform:t})}function Ae(t){return new xP({type:"optional",innerType:t})}function mP(t){return new EU({type:"nullable",innerType:t})}function PU(t,e){return new TU({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}function IU(t,e){return new OU({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}function AU(t,e){return new SP({type:"nonoptional",innerType:t,...ie.normalizeParams(e)})}function RU(t,e){return new NU({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}function $_(t,e){return new zU({type:"pipe",in:t,out:e})}function CU(t){return new MU({type:"readonly",innerType:t})}function jU(t){let e=new tt({check:"custom"});return e._zod.check=t,e}function $P(t,e){return u_(kP,t??(()=>!0),e)}function LU(t,e={}){return l_(kP,t,e)}function qU(t){let e=jU(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ie.issue(n,r.value,e._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(ie.issue(s))}},t(r.value,r)));return e}function T_(t,e){return $_(vP(t),e)}var Ce,gP,GZ,Oe,YZ,pP,Ad,XZ,QZ,eU,tU,rU,nU,sU,iU,oU,aU,cU,uU,lU,dU,fU,pU,yP,hU,mU,gU,yU,_U,wU,bP,wP,vU,xU,SU,k_,kU,$U,xP,EU,TU,OU,SP,NU,zU,MU,kP,v_=$(()=>{dt();dt();m_();w_();S_();Ce=S("ZodType",(t,e)=>(_e.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Rt(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>uP(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>dP(t,r,n),t.parseAsync=async(r,n)=>lP(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>fP(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(LU(r,n)),t.superRefine=r=>t.check(qU(r)),t.overwrite=r=>t.check(js(r)),t.optional=()=>Ae(t),t.nullable=()=>mP(t),t.nullish=()=>Ae(mP(t)),t.nonoptional=r=>AU(t,r),t.array=()=>oe(t),t.or=r=>$e([t,r]),t.and=r=>Nd(t,r),t.transform=r=>$_(t,vP(r)),t.default=r=>PU(t,r),t.prefault=r=>IU(t,r),t.catch=r=>RU(t,r),t.pipe=r=>$_(t,r),t.readonly=()=>CU(t),t.describe=r=>{let n=t.clone();return On.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return On.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return On.get(t);let n=t.clone();return On.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),gP=S("_ZodString",(t,e)=>{sc.init(t,e),Ce.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Qy(...n)),t.includes=(...n)=>t.check(r_(...n)),t.startsWith=(...n)=>t.check(n_(...n)),t.endsWith=(...n)=>t.check(s_(...n)),t.min=(...n)=>t.check(no(...n)),t.max=(...n)=>t.check($d(...n)),t.length=(...n)=>t.check(Ed(...n)),t.nonempty=(...n)=>t.check(no(1,...n)),t.lowercase=n=>t.check(e_(n)),t.uppercase=n=>t.check(t_(n)),t.trim=()=>t.check(o_()),t.normalize=(...n)=>t.check(i_(...n)),t.toLowerCase=()=>t.check(a_()),t.toUpperCase=()=>t.check(c_())}),GZ=S("ZodString",(t,e)=>{sc.init(t,e),gP.init(t,e),t.email=r=>t.check(Ey(YZ,r)),t.url=r=>t.check(Ay(XZ,r)),t.jwt=r=>t.check(Hy(pU,r)),t.emoji=r=>t.check(Ny(QZ,r)),t.guid=r=>t.check(vd(pP,r)),t.uuid=r=>t.check(Ty(Ad,r)),t.uuidv4=r=>t.check(Py(Ad,r)),t.uuidv6=r=>t.check(Oy(Ad,r)),t.uuidv7=r=>t.check(Iy(Ad,r)),t.nanoid=r=>t.check(Ry(eU,r)),t.guid=r=>t.check(vd(pP,r)),t.cuid=r=>t.check(zy(tU,r)),t.cuid2=r=>t.check(My(rU,r)),t.ulid=r=>t.check(Cy(nU,r)),t.base64=r=>t.check(Fy(lU,r)),t.base64url=r=>t.check(By(dU,r)),t.xid=r=>t.check(jy(sU,r)),t.ksuid=r=>t.check(Ly(iU,r)),t.ipv4=r=>t.check(qy(oU,r)),t.ipv6=r=>t.check(Dy(aU,r)),t.cidrv4=r=>t.check(Zy(cU,r)),t.cidrv6=r=>t.check(Uy(uU,r)),t.e164=r=>t.check(Vy(fU,r)),t.datetime=r=>t.check(g_(r)),t.date=r=>t.check(y_(r)),t.time=r=>t.check(__(r)),t.duration=r=>t.check(b_(r))});Oe=S("ZodStringFormat",(t,e)=>{xe.init(t,e),gP.init(t,e)}),YZ=S("ZodEmail",(t,e)=>{qg.init(t,e),Oe.init(t,e)}),pP=S("ZodGUID",(t,e)=>{jg.init(t,e),Oe.init(t,e)}),Ad=S("ZodUUID",(t,e)=>{Lg.init(t,e),Oe.init(t,e)}),XZ=S("ZodURL",(t,e)=>{Dg.init(t,e),Oe.init(t,e)}),QZ=S("ZodEmoji",(t,e)=>{Zg.init(t,e),Oe.init(t,e)}),eU=S("ZodNanoID",(t,e)=>{Ug.init(t,e),Oe.init(t,e)}),tU=S("ZodCUID",(t,e)=>{Fg.init(t,e),Oe.init(t,e)}),rU=S("ZodCUID2",(t,e)=>{Bg.init(t,e),Oe.init(t,e)}),nU=S("ZodULID",(t,e)=>{Vg.init(t,e),Oe.init(t,e)}),sU=S("ZodXID",(t,e)=>{Hg.init(t,e),Oe.init(t,e)}),iU=S("ZodKSUID",(t,e)=>{Wg.init(t,e),Oe.init(t,e)}),oU=S("ZodIPv4",(t,e)=>{Kg.init(t,e),Oe.init(t,e)}),aU=S("ZodIPv6",(t,e)=>{Jg.init(t,e),Oe.init(t,e)}),cU=S("ZodCIDRv4",(t,e)=>{Gg.init(t,e),Oe.init(t,e)}),uU=S("ZodCIDRv6",(t,e)=>{Yg.init(t,e),Oe.init(t,e)}),lU=S("ZodBase64",(t,e)=>{Xg.init(t,e),Oe.init(t,e)}),dU=S("ZodBase64URL",(t,e)=>{Qg.init(t,e),Oe.init(t,e)}),fU=S("ZodE164",(t,e)=>{ey.init(t,e),Oe.init(t,e)}),pU=S("ZodJWT",(t,e)=>{ty.init(t,e),Oe.init(t,e)}),yP=S("ZodNumber",(t,e)=>{yd.init(t,e),Ce.init(t,e),t.gt=(n,s)=>t.check(Sd(n,s)),t.gte=(n,s)=>t.check(ac(n,s)),t.min=(n,s)=>t.check(ac(n,s)),t.lt=(n,s)=>t.check(xd(n,s)),t.lte=(n,s)=>t.check(oc(n,s)),t.max=(n,s)=>t.check(oc(n,s)),t.int=n=>t.check(hP(n)),t.safe=n=>t.check(hP(n)),t.positive=n=>t.check(Sd(0,n)),t.nonnegative=n=>t.check(ac(0,n)),t.negative=n=>t.check(xd(0,n)),t.nonpositive=n=>t.check(oc(0,n)),t.multipleOf=(n,s)=>t.check(kd(n,s)),t.step=(n,s)=>t.check(kd(n,s)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});hU=S("ZodNumberFormat",(t,e)=>{ry.init(t,e),yP.init(t,e)});mU=S("ZodBoolean",(t,e)=>{ny.init(t,e),Ce.init(t,e)});gU=S("ZodNull",(t,e)=>{sy.init(t,e),Ce.init(t,e)});yU=S("ZodUnknown",(t,e)=>{iy.init(t,e),Ce.init(t,e)});_U=S("ZodNever",(t,e)=>{oy.init(t,e),Ce.init(t,e)});wU=S("ZodArray",(t,e)=>{ay.init(t,e),Ce.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(no(r,n)),t.nonempty=r=>t.check(no(1,r)),t.max=(r,n)=>t.check($d(r,n)),t.length=(r,n)=>t.check(Ed(r,n)),t.unwrap=()=>t.element});bP=S("ZodObject",(t,e)=>{_d.init(t,e),Ce.init(t,e),ie.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>xt(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ie()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ie()}),t.strict=()=>t.clone({...t._zod.def,catchall:bU()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ie.extend(t,r),t.merge=r=>ie.merge(t,r),t.pick=r=>ie.pick(t,r),t.omit=r=>ie.omit(t,r),t.partial=(...r)=>ie.partial(xP,t,r[0]),t.required=(...r)=>ie.required(SP,t,r[0])});wP=S("ZodUnion",(t,e)=>{bd.init(t,e),Ce.init(t,e),t.options=e.options});vU=S("ZodDiscriminatedUnion",(t,e)=>{wP.init(t,e),cy.init(t,e)});xU=S("ZodIntersection",(t,e)=>{uy.init(t,e),Ce.init(t,e)});SU=S("ZodRecord",(t,e)=>{ly.init(t,e),Ce.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});k_=S("ZodEnum",(t,e)=>{dy.init(t,e),Ce.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{let i={};for(let o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new k_({...e,checks:[],...ie.normalizeParams(s),entries:i})},t.exclude=(n,s)=>{let i={...e.entries};for(let o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new k_({...e,checks:[],...ie.normalizeParams(s),entries:i})}});kU=S("ZodLiteral",(t,e)=>{fy.init(t,e),Ce.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});$U=S("ZodTransform",(t,e)=>{py.init(t,e),Ce.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=i=>{if(typeof i=="string")r.issues.push(ie.issue(i,r.value,e));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!0),r.issues.push(ie.issue(o))}};let s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});xP=S("ZodOptional",(t,e)=>{hy.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType});EU=S("ZodNullable",(t,e)=>{my.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType});TU=S("ZodDefault",(t,e)=>{gy.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});OU=S("ZodPrefault",(t,e)=>{yy.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType});SP=S("ZodNonOptional",(t,e)=>{_y.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType});NU=S("ZodCatch",(t,e)=>{by.init(t,e),Ce.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});zU=S("ZodPipe",(t,e)=>{wy.init(t,e),Ce.init(t,e),t.in=e.in,t.out=e.out});MU=S("ZodReadonly",(t,e)=>{vy.init(t,e),Ce.init(t,e)});kP=S("ZodCustom",(t,e)=>{xy.init(t,e),Ce.init(t,e)})});var EP=$(()=>{});var TP=$(()=>{});var PP=$(()=>{dt();v_();m_();x_();S_();EP();dt();LT();wd();w_();TP();Nt(jT())});var OP=$(()=>{PP()});var IP=$(()=>{OP()});function WP(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function KP(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var O_,AP,Nn,zd,Ve,NP,RP,TQ,UU,FU,I_,zt,dc,zP,rt,Wt,Kt,nt,Md,MP,A_,CP,jP,N_,fc,F,R_,LP,qP,PQ,Cd,BU,jd,VU,pc,io,DP,HU,WU,KU,JU,GU,YU,z_,XU,QU,M_,Ld,eF,tF,qd,rF,hc,mc,nF,gc,oo,sF,yc,Dd,Zd,Ud,OQ,Fd,Bd,Vd,ZP,UP,FP,C_,BP,_c,ao,VP,iF,Hd,oF,Wd,aF,j_,cF,Kd,uF,lF,dF,fF,pF,hF,mF,gF,yF,_F,Jd,bF,wF,Gd,L_,q_,D_,vF,xF,SF,Z_,kF,$F,EF,TF,PF,HP,Yd,OF,Xd,IQ,IF,co,AF,AQ,bc,NF,U_,RF,zF,MF,CF,jF,LF,qF,Rd,DF,ZF,UF,wc,F_,FF,BF,VF,HF,WF,KF,JF,GF,YF,XF,QF,e4,t4,r4,n4,s4,i4,o4,uo,a4,c4,u4,Qd,l4,d4,f4,B_,p4,NQ,RQ,zQ,MQ,CQ,jQ,D,P_,lo=$(()=>{IP();O_="2025-11-25",AP=[O_,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Nn="io.modelcontextprotocol/related-task",zd="2.0",Ve=$P(t=>t!==null&&(typeof t=="object"||typeof t=="function")),NP=$e([x(),ye().int()]),RP=x(),TQ=ft({ttl:ye().optional(),pollInterval:ye().optional()}),UU=M({ttl:ye().optional()}),FU=M({taskId:x()}),I_=ft({progressToken:NP.optional(),[Nn]:FU.optional()}),zt=M({_meta:I_.optional()}),dc=zt.extend({task:UU.optional()}),zP=t=>dc.safeParse(t).success,rt=M({method:x(),params:zt.loose().optional()}),Wt=M({_meta:I_.optional()}),Kt=M({method:x(),params:Wt.loose().optional()}),nt=ft({_meta:I_.optional()}),Md=$e([x(),ye().int()]),MP=M({jsonrpc:Z(zd),id:Md,...rt.shape}).strict(),A_=t=>MP.safeParse(t).success,CP=M({jsonrpc:Z(zd),...Kt.shape}).strict(),jP=t=>CP.safeParse(t).success,N_=M({jsonrpc:Z(zd),id:Md,result:nt}).strict(),fc=t=>N_.safeParse(t).success;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(F||(F={}));R_=M({jsonrpc:Z(zd),id:Md.optional(),error:M({code:ye().int(),message:x(),data:Ie().optional()})}).strict(),LP=t=>R_.safeParse(t).success,qP=$e([MP,CP,N_,R_]),PQ=$e([N_,R_]),Cd=nt.strict(),BU=Wt.extend({requestId:Md.optional(),reason:x().optional()}),jd=Kt.extend({method:Z("notifications/cancelled"),params:BU}),VU=M({src:x(),mimeType:x().optional(),sizes:oe(x()).optional(),theme:xt(["light","dark"]).optional()}),pc=M({icons:oe(VU).optional()}),io=M({name:x(),title:x().optional()}),DP=io.extend({...io.shape,...pc.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),HU=Nd(M({applyDefaults:Ye().optional()}),Se(x(),Ie())),WU=T_(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Nd(M({form:HU.optional(),url:Ve.optional()}),Se(x(),Ie()).optional())),KU=ft({list:Ve.optional(),cancel:Ve.optional(),requests:ft({sampling:ft({createMessage:Ve.optional()}).optional(),elicitation:ft({create:Ve.optional()}).optional()}).optional()}),JU=ft({list:Ve.optional(),cancel:Ve.optional(),requests:ft({tools:ft({call:Ve.optional()}).optional()}).optional()}),GU=M({experimental:Se(x(),Ve).optional(),sampling:M({context:Ve.optional(),tools:Ve.optional()}).optional(),elicitation:WU.optional(),roots:M({listChanged:Ye().optional()}).optional(),tasks:KU.optional(),extensions:Se(x(),Ve).optional()}),YU=zt.extend({protocolVersion:x(),capabilities:GU,clientInfo:DP}),z_=rt.extend({method:Z("initialize"),params:YU}),XU=M({experimental:Se(x(),Ve).optional(),logging:Ve.optional(),completions:Ve.optional(),prompts:M({listChanged:Ye().optional()}).optional(),resources:M({subscribe:Ye().optional(),listChanged:Ye().optional()}).optional(),tools:M({listChanged:Ye().optional()}).optional(),tasks:JU.optional(),extensions:Se(x(),Ve).optional()}),QU=nt.extend({protocolVersion:x(),capabilities:XU,serverInfo:DP,instructions:x().optional()}),M_=Kt.extend({method:Z("notifications/initialized"),params:Wt.optional()}),Ld=rt.extend({method:Z("ping"),params:zt.optional()}),eF=M({progress:ye(),total:Ae(ye()),message:Ae(x())}),tF=M({...Wt.shape,...eF.shape,progressToken:NP}),qd=Kt.extend({method:Z("notifications/progress"),params:tF}),rF=zt.extend({cursor:RP.optional()}),hc=rt.extend({params:rF.optional()}),mc=nt.extend({nextCursor:RP.optional()}),nF=xt(["working","input_required","completed","failed","cancelled"]),gc=M({taskId:x(),status:nF,ttl:$e([ye(),_P()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Ae(ye()),statusMessage:Ae(x())}),oo=nt.extend({task:gc}),sF=Wt.merge(gc),yc=Kt.extend({method:Z("notifications/tasks/status"),params:sF}),Dd=rt.extend({method:Z("tasks/get"),params:zt.extend({taskId:x()})}),Zd=nt.merge(gc),Ud=rt.extend({method:Z("tasks/result"),params:zt.extend({taskId:x()})}),OQ=nt.loose(),Fd=hc.extend({method:Z("tasks/list")}),Bd=mc.extend({tasks:oe(gc)}),Vd=rt.extend({method:Z("tasks/cancel"),params:zt.extend({taskId:x()})}),ZP=nt.merge(gc),UP=M({uri:x(),mimeType:Ae(x()),_meta:Se(x(),Ie()).optional()}),FP=UP.extend({text:x()}),C_=x().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),BP=UP.extend({blob:C_}),_c=xt(["user","assistant"]),ao=M({audience:oe(_c).optional(),priority:ye().min(0).max(1).optional(),lastModified:uc.datetime({offset:!0}).optional()}),VP=M({...io.shape,...pc.shape,uri:x(),description:Ae(x()),mimeType:Ae(x()),size:Ae(ye()),annotations:ao.optional(),_meta:Ae(ft({}))}),iF=M({...io.shape,...pc.shape,uriTemplate:x(),description:Ae(x()),mimeType:Ae(x()),annotations:ao.optional(),_meta:Ae(ft({}))}),Hd=hc.extend({method:Z("resources/list")}),oF=mc.extend({resources:oe(VP)}),Wd=hc.extend({method:Z("resources/templates/list")}),aF=mc.extend({resourceTemplates:oe(iF)}),j_=zt.extend({uri:x()}),cF=j_,Kd=rt.extend({method:Z("resources/read"),params:cF}),uF=nt.extend({contents:oe($e([FP,BP]))}),lF=Kt.extend({method:Z("notifications/resources/list_changed"),params:Wt.optional()}),dF=j_,fF=rt.extend({method:Z("resources/subscribe"),params:dF}),pF=j_,hF=rt.extend({method:Z("resources/unsubscribe"),params:pF}),mF=Wt.extend({uri:x()}),gF=Kt.extend({method:Z("notifications/resources/updated"),params:mF}),yF=M({name:x(),description:Ae(x()),required:Ae(Ye())}),_F=M({...io.shape,...pc.shape,description:Ae(x()),arguments:Ae(oe(yF)),_meta:Ae(ft({}))}),Jd=hc.extend({method:Z("prompts/list")}),bF=mc.extend({prompts:oe(_F)}),wF=zt.extend({name:x(),arguments:Se(x(),x()).optional()}),Gd=rt.extend({method:Z("prompts/get"),params:wF}),L_=M({type:Z("text"),text:x(),annotations:ao.optional(),_meta:Se(x(),Ie()).optional()}),q_=M({type:Z("image"),data:C_,mimeType:x(),annotations:ao.optional(),_meta:Se(x(),Ie()).optional()}),D_=M({type:Z("audio"),data:C_,mimeType:x(),annotations:ao.optional(),_meta:Se(x(),Ie()).optional()}),vF=M({type:Z("tool_use"),name:x(),id:x(),input:Se(x(),Ie()),_meta:Se(x(),Ie()).optional()}),xF=M({type:Z("resource"),resource:$e([FP,BP]),annotations:ao.optional(),_meta:Se(x(),Ie()).optional()}),SF=VP.extend({type:Z("resource_link")}),Z_=$e([L_,q_,D_,SF,xF]),kF=M({role:_c,content:Z_}),$F=nt.extend({description:x().optional(),messages:oe(kF)}),EF=Kt.extend({method:Z("notifications/prompts/list_changed"),params:Wt.optional()}),TF=M({title:x().optional(),readOnlyHint:Ye().optional(),destructiveHint:Ye().optional(),idempotentHint:Ye().optional(),openWorldHint:Ye().optional()}),PF=M({taskSupport:xt(["required","optional","forbidden"]).optional()}),HP=M({...io.shape,...pc.shape,description:x().optional(),inputSchema:M({type:Z("object"),properties:Se(x(),Ve).optional(),required:oe(x()).optional()}).catchall(Ie()),outputSchema:M({type:Z("object"),properties:Se(x(),Ve).optional(),required:oe(x()).optional()}).catchall(Ie()).optional(),annotations:TF.optional(),execution:PF.optional(),_meta:Se(x(),Ie()).optional()}),Yd=hc.extend({method:Z("tools/list")}),OF=mc.extend({tools:oe(HP)}),Xd=nt.extend({content:oe(Z_).default([]),structuredContent:Se(x(),Ie()).optional(),isError:Ye().optional()}),IQ=Xd.or(nt.extend({toolResult:Ie()})),IF=dc.extend({name:x(),arguments:Se(x(),Ie()).optional()}),co=rt.extend({method:Z("tools/call"),params:IF}),AF=Kt.extend({method:Z("notifications/tools/list_changed"),params:Wt.optional()}),AQ=M({autoRefresh:Ye().default(!0),debounceMs:ye().int().nonnegative().default(300)}),bc=xt(["debug","info","notice","warning","error","critical","alert","emergency"]),NF=zt.extend({level:bc}),U_=rt.extend({method:Z("logging/setLevel"),params:NF}),RF=Wt.extend({level:bc,logger:x().optional(),data:Ie()}),zF=Kt.extend({method:Z("notifications/message"),params:RF}),MF=M({name:x().optional()}),CF=M({hints:oe(MF).optional(),costPriority:ye().min(0).max(1).optional(),speedPriority:ye().min(0).max(1).optional(),intelligencePriority:ye().min(0).max(1).optional()}),jF=M({mode:xt(["auto","required","none"]).optional()}),LF=M({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:oe(Z_).default([]),structuredContent:M({}).loose().optional(),isError:Ye().optional(),_meta:Se(x(),Ie()).optional()}),qF=E_("type",[L_,q_,D_]),Rd=E_("type",[L_,q_,D_,vF,LF]),DF=M({role:_c,content:$e([Rd,oe(Rd)]),_meta:Se(x(),Ie()).optional()}),ZF=dc.extend({messages:oe(DF),modelPreferences:CF.optional(),systemPrompt:x().optional(),includeContext:xt(["none","thisServer","allServers"]).optional(),temperature:ye().optional(),maxTokens:ye().int(),stopSequences:oe(x()).optional(),metadata:Ve.optional(),tools:oe(HP).optional(),toolChoice:jF.optional()}),UF=rt.extend({method:Z("sampling/createMessage"),params:ZF}),wc=nt.extend({model:x(),stopReason:Ae(xt(["endTurn","stopSequence","maxTokens"]).or(x())),role:_c,content:qF}),F_=nt.extend({model:x(),stopReason:Ae(xt(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:_c,content:$e([Rd,oe(Rd)])}),FF=M({type:Z("boolean"),title:x().optional(),description:x().optional(),default:Ye().optional()}),BF=M({type:Z("string"),title:x().optional(),description:x().optional(),minLength:ye().optional(),maxLength:ye().optional(),format:xt(["email","uri","date","date-time"]).optional(),default:x().optional()}),VF=M({type:xt(["number","integer"]),title:x().optional(),description:x().optional(),minimum:ye().optional(),maximum:ye().optional(),default:ye().optional()}),HF=M({type:Z("string"),title:x().optional(),description:x().optional(),enum:oe(x()),default:x().optional()}),WF=M({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:oe(M({const:x(),title:x()})),default:x().optional()}),KF=M({type:Z("string"),title:x().optional(),description:x().optional(),enum:oe(x()),enumNames:oe(x()).optional(),default:x().optional()}),JF=$e([HF,WF]),GF=M({type:Z("array"),title:x().optional(),description:x().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:M({type:Z("string"),enum:oe(x())}),default:oe(x()).optional()}),YF=M({type:Z("array"),title:x().optional(),description:x().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:M({anyOf:oe(M({const:x(),title:x()}))}),default:oe(x()).optional()}),XF=$e([GF,YF]),QF=$e([KF,JF,XF]),e4=$e([QF,FF,BF,VF]),t4=dc.extend({mode:Z("form").optional(),message:x(),requestedSchema:M({type:Z("object"),properties:Se(x(),e4),required:oe(x()).optional()})}),r4=dc.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),n4=$e([t4,r4]),s4=rt.extend({method:Z("elicitation/create"),params:n4}),i4=Wt.extend({elicitationId:x()}),o4=Kt.extend({method:Z("notifications/elicitation/complete"),params:i4}),uo=nt.extend({action:xt(["accept","decline","cancel"]),content:T_(t=>t===null?void 0:t,Se(x(),$e([x(),ye(),Ye(),oe(x())])).optional())}),a4=M({type:Z("ref/resource"),uri:x()}),c4=M({type:Z("ref/prompt"),name:x()}),u4=zt.extend({ref:$e([c4,a4]),argument:M({name:x(),value:x()}),context:M({arguments:Se(x(),x()).optional()}).optional()}),Qd=rt.extend({method:Z("completion/complete"),params:u4});l4=nt.extend({completion:ft({values:oe(x()).max(100),total:Ae(ye().int()),hasMore:Ae(Ye())})}),d4=M({uri:x().startsWith("file://"),name:x().optional(),_meta:Se(x(),Ie()).optional()}),f4=rt.extend({method:Z("roots/list"),params:zt.optional()}),B_=nt.extend({roots:oe(d4)}),p4=Kt.extend({method:Z("notifications/roots/list_changed"),params:Wt.optional()}),NQ=$e([Ld,z_,Qd,U_,Gd,Jd,Hd,Wd,Kd,fF,hF,co,Yd,Dd,Ud,Fd,Vd]),RQ=$e([jd,qd,M_,p4,yc]),zQ=$e([Cd,wc,F_,uo,B_,Zd,Bd,oo]),MQ=$e([Ld,UF,s4,f4,Dd,Ud,Fd,Vd]),CQ=$e([jd,qd,zF,gF,lF,AF,EF,yc,o4]),jQ=$e([Cd,QU,l4,$F,bF,oF,aF,uF,Xd,OF,Zd,Bd,oo]),D=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===F.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new P_(s.elicitations,r)}return new t(e,r,n)}},P_=class extends D{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}});function Rn(t){return t==="completed"||t==="failed"||t==="cancelled"}var JP=$(()=>{});var YP,GP,XP,ef=$(()=>{YP=Symbol("Let zodToJsonSchema decide on which parser to use"),GP={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},XP=t=>typeof t=="string"?{...GP,name:t}:{...GP,...t}});var QP,V_=$(()=>{ef();QP=t=>{let e=XP(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}}});function H_(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ae(t,e,r,n,s){t[e]=r,H_(t,e,n,s)}var zn=$(()=>{});var tf,rf=$(()=>{tf=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")}});function Ne(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?tf(e,t.currentPath):e.join("/")}}var Jt=$(()=>{rf()});function e1(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==O.ZodAny&&(r.items=W(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ae(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ae(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ae(r,"minItems",t.exactLength.value,t.exactLength.message,e),ae(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}var W_=$(()=>{Ja();zn();Ze()});function t1(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ae(r,"minimum",n.value,n.message,e):ae(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ae(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ae(r,"maximum",n.value,n.message,e):ae(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ae(r,"maximum",n.value,n.message,e));break;case"multipleOf":ae(r,"multipleOf",n.value,n.message,e);break}return r}var K_=$(()=>{zn()});function r1(){return{type:"boolean"}}var J_=$(()=>{});function nf(t,e){return W(t.type._def,e)}var sf=$(()=>{Ze()});var n1,G_=$(()=>{Ze();n1=(t,e)=>W(t.innerType._def,e)});function Y_(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,i)=>Y_(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return h4(t,e)}}var h4,X_=$(()=>{zn();h4=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ae(r,"minimum",n.value,n.message,e);break;case"max":ae(r,"maximum",n.value,n.message,e);break}return r}});function s1(t,e){return{...W(t.innerType._def,e),default:t.defaultValue()}}var Q_=$(()=>{Ze()});function i1(t,e){return e.effectStrategy==="input"?W(t.schema._def,e):Ne(e)}var eb=$(()=>{Ze();Jt()});function o1(t){return{type:"string",enum:Array.from(t.values)}}var tb=$(()=>{});function a1(t,e){let r=[W(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),W(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(m4(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:a,...c}=i;o=c}else n=void 0;s.push(o)}}),s.length?{allOf:s,...n}:void 0}var m4,rb=$(()=>{Ze();m4=t=>"type"in t&&t.type==="string"?!1:"allOf"in t});function c1(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var nb=$(()=>{});function of(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":ar(r,"email",n.message,e);break;case"format:idn-email":ar(r,"idn-email",n.message,e);break;case"pattern:zod":pt(r,or.email,n.message,e);break}break;case"url":ar(r,"uri",n.message,e);break;case"uuid":ar(r,"uuid",n.message,e);break;case"regex":pt(r,n.regex,n.message,e);break;case"cuid":pt(r,or.cuid,n.message,e);break;case"cuid2":pt(r,or.cuid2,n.message,e);break;case"startsWith":pt(r,RegExp(`^${ib(n.value,e)}`),n.message,e);break;case"endsWith":pt(r,RegExp(`${ib(n.value,e)}$`),n.message,e);break;case"datetime":ar(r,"date-time",n.message,e);break;case"date":ar(r,"date",n.message,e);break;case"time":ar(r,"time",n.message,e);break;case"duration":ar(r,"duration",n.message,e);break;case"length":ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{pt(r,RegExp(ib(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ar(r,"ipv4",n.message,e),n.version!=="v4"&&ar(r,"ipv6",n.message,e);break}case"base64url":pt(r,or.base64url,n.message,e);break;case"jwt":pt(r,or.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&pt(r,or.ipv4Cidr,n.message,e),n.version!=="v4"&&pt(r,or.ipv6Cidr,n.message,e);break}case"emoji":pt(r,or.emoji(),n.message,e);break;case"ulid":{pt(r,or.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ar(r,"binary",n.message,e);break}case"contentEncoding:base64":{ae(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{pt(r,or.base64,n.message,e);break}}break}case"nanoid":pt(r,or.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function ib(t,e){return e.patternStrategy==="escape"?y4(t):t}function y4(t){let e="";for(let r=0;r<t.length;r++)g4.has(t[r])||(e+="\\"),e+=t[r];return e}function ar(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.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,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ae(t,"format",e,r,n)}function pt(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.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:u1(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ae(t,"pattern",u1(e,n),r,n)}function u1(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,s="",i=!1,o=!1,a=!1;for(let c=0;c<n.length;c++){if(i){s+=n[c],i=!1;continue}if(r.i){if(o){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
179
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){o(l);continue}if(n.external){let p=n.external.registry.get(l[0])?.id;if(e!==l[0]&&p){o(l);continue}}if(this.metadataRegistry.get(l[0])?.id){o(l);continue}if(d.cycle){o(l);continue}if(d.count>1&&n.reused==="ref"){o(l);continue}}let a=(l,d)=>{let f=this.seen.get(l),p=f.def??f.schema,m={...p};if(f.ref===null)return;let h=f.ref;if(f.ref=null,h){a(h,d);let g=this.seen.get(h).schema;g.$ref&&d.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(g)):(Object.assign(p,g),Object.assign(p,m))}f.isParent||this.override({zodSchema:l,jsonSchema:p,path:f.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let 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){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}});var JT=$(()=>{});var ft=$(()=>{to();Ig();Sg();jT();md();Cg();$r();hd();vd();$y();Mg();WT();HT();KT();JT()});var p_=$(()=>{ft()});function h_(t,e){let r={type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},...ie.normalizeParams(e)};return new ZZ(r)}var DZ,ZZ,GT=$(()=>{ft();ft();p_();DZ=S("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");_e.init(t,e),t.def=e,t.parse=(r,n)=>$g(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Cs(t,r,n),t.parseAsync=async(r,n)=>Tg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>js(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>zt(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)}),ZZ=S("ZodMiniObject",(t,e)=>{bd.init(t,e),DZ.init(t,e),ie.defineLazy(t,"shape",()=>e.shape)})});var YT=$(()=>{});var XT=$(()=>{});var QT=$(()=>{});var eP=$(()=>{ft();p_();GT();YT();ft();vd();XT();QT()});var tP=$(()=>{eP()});var m_=$(()=>{tP()});function Wt(t){return!!t._zod}function Ds(t){let e=Object.values(t);if(e.length===0)return h_({});let r=e.every(Wt),n=e.every(s=>!Wt(s));if(r)return h_(t);if(n)return lg(t);throw new Error("Mixed Zod versions detected in object shape.")}function An(t,e){return Wt(t)?Cs(t,e):t.safeParse(e)}async function Od(t,e){return Wt(t)?await js(t,e):await t.safeParseAsync(e)}function Nn(t){if(!t)return;let e;if(Wt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function io(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return Ds(t)}}if(Wt(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Id(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function nP(t){return t.description}function sP(t){if(Wt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Ad(t){if(Wt(t)){let i=t._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var uc=$(()=>{Ga();m_()});var g_=$(()=>{ft()});var lc={};Vn(lc,{ZodISODate:()=>oP,ZodISODateTime:()=>iP,ZodISODuration:()=>cP,ZodISOTime:()=>aP,date:()=>__,datetime:()=>y_,duration:()=>w_,time:()=>b_});function y_(t){return ZT(iP,t)}function __(t){return UT(oP,t)}function b_(t){return FT(aP,t)}function w_(t){return BT(cP,t)}var iP,oP,aP,cP,v_=$(()=>{ft();x_();iP=S("ZodISODateTime",(t,e)=>{NT.init(t,e),Ie.init(t,e)});oP=S("ZodISODate",(t,e)=>{RT.init(t,e),Ie.init(t,e)});aP=S("ZodISOTime",(t,e)=>{zT.init(t,e),Ie.init(t,e)});cP=S("ZodISODuration",(t,e)=>{MT.init(t,e),Ie.init(t,e)})});var uP,pQ,dc,S_=$(()=>{ft();ft();uP=(t,e)=>{fd.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>xg(t,r)},flatten:{value:r=>vg(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},pQ=S("ZodError",uP),dc=S("ZodError",uP,{Parent:Error})});var lP,dP,fP,pP,k_=$(()=>{ft();S_();lP=kg(dc),dP=Eg(dc),fP=Pg(dc),pP=Og(dc)});function x(t){return Ey(YZ,t)}function ye(t){return Ky(_P,t)}function mP(t){return Jy(mU,t)}function Xe(t){return Gy(gU,t)}function bP(t){return Yy(yU,t)}function Ae(){return Xy(_U)}function wU(t){return Qy(bU,t)}function oe(t,e){return VT(vU,t,e)}function M(t,e){let r={type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},...ie.normalizeParams(e)};return new wP(r)}function pt(t,e){return new wP({type:"object",get shape(){return ie.assignProp(this,"shape",{...t}),this.shape},catchall:Ae(),...ie.normalizeParams(e)})}function $e(t,e){return new vP({type:"union",options:t,...ie.normalizeParams(e)})}function T_(t,e,r){return new xU({type:"union",options:e,discriminator:t,...ie.normalizeParams(r)})}function Rd(t,e){return new SU({type:"intersection",left:t,right:e})}function Se(t,e,r){return new kU({type:"record",keyType:t,valueType:e,...ie.normalizeParams(r)})}function St(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new $_({type:"enum",entries:r,...ie.normalizeParams(e)})}function Z(t,e){return new $U({type:"literal",values:Array.isArray(t)?t:[t],...ie.normalizeParams(e)})}function xP(t){return new EU({type:"transform",transform:t})}function Ne(t){return new SP({type:"optional",innerType:t})}function gP(t){return new TU({type:"nullable",innerType:t})}function OU(t,e){return new PU({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}function AU(t,e){return new IU({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}function NU(t,e){return new kP({type:"nonoptional",innerType:t,...ie.normalizeParams(e)})}function zU(t,e){return new RU({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}function E_(t,e){return new MU({type:"pipe",in:t,out:e})}function jU(t){return new CU({type:"readonly",innerType:t})}function LU(t){let e=new rt({check:"custom"});return e._zod.check=t,e}function EP(t,e){return l_($P,t??(()=>!0),e)}function qU(t,e={}){return d_($P,t,e)}function DU(t){let e=LU(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ie.issue(n,r.value,e._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(ie.issue(s))}},t(r.value,r)));return e}function P_(t,e){return E_(xP(t),e)}var je,yP,YZ,Ie,XZ,hP,Nd,QZ,eU,tU,rU,nU,sU,iU,oU,aU,cU,uU,lU,dU,fU,pU,hU,_P,mU,gU,yU,_U,bU,vU,wP,vP,xU,SU,kU,$_,$U,EU,SP,TU,PU,IU,kP,RU,MU,CU,$P,x_=$(()=>{ft();ft();g_();v_();k_();je=S("ZodType",(t,e)=>(_e.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>zt(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>lP(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>fP(t,r,n),t.parseAsync=async(r,n)=>dP(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>pP(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(qU(r,n)),t.superRefine=r=>t.check(DU(r)),t.overwrite=r=>t.check(Ls(r)),t.optional=()=>Ne(t),t.nullable=()=>gP(t),t.nullish=()=>Ne(gP(t)),t.nonoptional=r=>NU(t,r),t.array=()=>oe(t),t.or=r=>$e([t,r]),t.and=r=>Rd(t,r),t.transform=r=>E_(t,xP(r)),t.default=r=>OU(t,r),t.prefault=r=>AU(t,r),t.catch=r=>zU(t,r),t.pipe=r=>E_(t,r),t.readonly=()=>jU(t),t.describe=r=>{let n=t.clone();return In.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return In.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return In.get(t);let n=t.clone();return In.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),yP=S("_ZodString",(t,e)=>{ic.init(t,e),je.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(e_(...n)),t.includes=(...n)=>t.check(n_(...n)),t.startsWith=(...n)=>t.check(s_(...n)),t.endsWith=(...n)=>t.check(i_(...n)),t.min=(...n)=>t.check(so(...n)),t.max=(...n)=>t.check(Ed(...n)),t.length=(...n)=>t.check(Td(...n)),t.nonempty=(...n)=>t.check(so(1,...n)),t.lowercase=n=>t.check(t_(n)),t.uppercase=n=>t.check(r_(n)),t.trim=()=>t.check(a_()),t.normalize=(...n)=>t.check(o_(...n)),t.toLowerCase=()=>t.check(c_()),t.toUpperCase=()=>t.check(u_())}),YZ=S("ZodString",(t,e)=>{ic.init(t,e),yP.init(t,e),t.email=r=>t.check(Ty(XZ,r)),t.url=r=>t.check(Ny(QZ,r)),t.jwt=r=>t.check(Wy(hU,r)),t.emoji=r=>t.check(Ry(eU,r)),t.guid=r=>t.check(xd(hP,r)),t.uuid=r=>t.check(Py(Nd,r)),t.uuidv4=r=>t.check(Oy(Nd,r)),t.uuidv6=r=>t.check(Iy(Nd,r)),t.uuidv7=r=>t.check(Ay(Nd,r)),t.nanoid=r=>t.check(zy(tU,r)),t.guid=r=>t.check(xd(hP,r)),t.cuid=r=>t.check(My(rU,r)),t.cuid2=r=>t.check(Cy(nU,r)),t.ulid=r=>t.check(jy(sU,r)),t.base64=r=>t.check(By(dU,r)),t.base64url=r=>t.check(Vy(fU,r)),t.xid=r=>t.check(Ly(iU,r)),t.ksuid=r=>t.check(qy(oU,r)),t.ipv4=r=>t.check(Dy(aU,r)),t.ipv6=r=>t.check(Zy(cU,r)),t.cidrv4=r=>t.check(Uy(uU,r)),t.cidrv6=r=>t.check(Fy(lU,r)),t.e164=r=>t.check(Hy(pU,r)),t.datetime=r=>t.check(y_(r)),t.date=r=>t.check(__(r)),t.time=r=>t.check(b_(r)),t.duration=r=>t.check(w_(r))});Ie=S("ZodStringFormat",(t,e)=>{xe.init(t,e),yP.init(t,e)}),XZ=S("ZodEmail",(t,e)=>{Dg.init(t,e),Ie.init(t,e)}),hP=S("ZodGUID",(t,e)=>{Lg.init(t,e),Ie.init(t,e)}),Nd=S("ZodUUID",(t,e)=>{qg.init(t,e),Ie.init(t,e)}),QZ=S("ZodURL",(t,e)=>{Zg.init(t,e),Ie.init(t,e)}),eU=S("ZodEmoji",(t,e)=>{Ug.init(t,e),Ie.init(t,e)}),tU=S("ZodNanoID",(t,e)=>{Fg.init(t,e),Ie.init(t,e)}),rU=S("ZodCUID",(t,e)=>{Bg.init(t,e),Ie.init(t,e)}),nU=S("ZodCUID2",(t,e)=>{Vg.init(t,e),Ie.init(t,e)}),sU=S("ZodULID",(t,e)=>{Hg.init(t,e),Ie.init(t,e)}),iU=S("ZodXID",(t,e)=>{Wg.init(t,e),Ie.init(t,e)}),oU=S("ZodKSUID",(t,e)=>{Kg.init(t,e),Ie.init(t,e)}),aU=S("ZodIPv4",(t,e)=>{Jg.init(t,e),Ie.init(t,e)}),cU=S("ZodIPv6",(t,e)=>{Gg.init(t,e),Ie.init(t,e)}),uU=S("ZodCIDRv4",(t,e)=>{Yg.init(t,e),Ie.init(t,e)}),lU=S("ZodCIDRv6",(t,e)=>{Xg.init(t,e),Ie.init(t,e)}),dU=S("ZodBase64",(t,e)=>{Qg.init(t,e),Ie.init(t,e)}),fU=S("ZodBase64URL",(t,e)=>{ey.init(t,e),Ie.init(t,e)}),pU=S("ZodE164",(t,e)=>{ty.init(t,e),Ie.init(t,e)}),hU=S("ZodJWT",(t,e)=>{ry.init(t,e),Ie.init(t,e)}),_P=S("ZodNumber",(t,e)=>{_d.init(t,e),je.init(t,e),t.gt=(n,s)=>t.check(kd(n,s)),t.gte=(n,s)=>t.check(cc(n,s)),t.min=(n,s)=>t.check(cc(n,s)),t.lt=(n,s)=>t.check(Sd(n,s)),t.lte=(n,s)=>t.check(ac(n,s)),t.max=(n,s)=>t.check(ac(n,s)),t.int=n=>t.check(mP(n)),t.safe=n=>t.check(mP(n)),t.positive=n=>t.check(kd(0,n)),t.nonnegative=n=>t.check(cc(0,n)),t.negative=n=>t.check(Sd(0,n)),t.nonpositive=n=>t.check(ac(0,n)),t.multipleOf=(n,s)=>t.check($d(n,s)),t.step=(n,s)=>t.check($d(n,s)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});mU=S("ZodNumberFormat",(t,e)=>{ny.init(t,e),_P.init(t,e)});gU=S("ZodBoolean",(t,e)=>{sy.init(t,e),je.init(t,e)});yU=S("ZodNull",(t,e)=>{iy.init(t,e),je.init(t,e)});_U=S("ZodUnknown",(t,e)=>{oy.init(t,e),je.init(t,e)});bU=S("ZodNever",(t,e)=>{ay.init(t,e),je.init(t,e)});vU=S("ZodArray",(t,e)=>{cy.init(t,e),je.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(so(r,n)),t.nonempty=r=>t.check(so(1,r)),t.max=(r,n)=>t.check(Ed(r,n)),t.length=(r,n)=>t.check(Td(r,n)),t.unwrap=()=>t.element});wP=S("ZodObject",(t,e)=>{bd.init(t,e),je.init(t,e),ie.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>St(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ae()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ae()}),t.strict=()=>t.clone({...t._zod.def,catchall:wU()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ie.extend(t,r),t.merge=r=>ie.merge(t,r),t.pick=r=>ie.pick(t,r),t.omit=r=>ie.omit(t,r),t.partial=(...r)=>ie.partial(SP,t,r[0]),t.required=(...r)=>ie.required(kP,t,r[0])});vP=S("ZodUnion",(t,e)=>{wd.init(t,e),je.init(t,e),t.options=e.options});xU=S("ZodDiscriminatedUnion",(t,e)=>{vP.init(t,e),uy.init(t,e)});SU=S("ZodIntersection",(t,e)=>{ly.init(t,e),je.init(t,e)});kU=S("ZodRecord",(t,e)=>{dy.init(t,e),je.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});$_=S("ZodEnum",(t,e)=>{fy.init(t,e),je.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{let i={};for(let o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new $_({...e,checks:[],...ie.normalizeParams(s),entries:i})},t.exclude=(n,s)=>{let i={...e.entries};for(let o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new $_({...e,checks:[],...ie.normalizeParams(s),entries:i})}});$U=S("ZodLiteral",(t,e)=>{py.init(t,e),je.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});EU=S("ZodTransform",(t,e)=>{hy.init(t,e),je.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=i=>{if(typeof i=="string")r.issues.push(ie.issue(i,r.value,e));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!0),r.issues.push(ie.issue(o))}};let s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});SP=S("ZodOptional",(t,e)=>{my.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType});TU=S("ZodNullable",(t,e)=>{gy.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType});PU=S("ZodDefault",(t,e)=>{yy.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});IU=S("ZodPrefault",(t,e)=>{_y.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType});kP=S("ZodNonOptional",(t,e)=>{by.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType});RU=S("ZodCatch",(t,e)=>{wy.init(t,e),je.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});MU=S("ZodPipe",(t,e)=>{vy.init(t,e),je.init(t,e),t.in=e.in,t.out=e.out});CU=S("ZodReadonly",(t,e)=>{xy.init(t,e),je.init(t,e)});$P=S("ZodCustom",(t,e)=>{Sy.init(t,e),je.init(t,e)})});var TP=$(()=>{});var PP=$(()=>{});var OP=$(()=>{ft();x_();g_();S_();k_();TP();ft();qT();vd();v_();PP();Rt(LT())});var IP=$(()=>{OP()});var AP=$(()=>{IP()});function KP(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function JP(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var I_,NP,Rn,Md,He,RP,zP,OQ,FU,BU,A_,Mt,fc,MP,nt,Kt,Jt,st,Cd,CP,N_,jP,LP,R_,pc,F,z_,qP,DP,IQ,jd,VU,Ld,HU,hc,oo,ZP,WU,KU,JU,GU,YU,XU,M_,QU,eF,C_,qd,tF,rF,Dd,nF,mc,gc,sF,yc,ao,iF,_c,Zd,Ud,Fd,AQ,Bd,Vd,Hd,UP,FP,BP,j_,VP,bc,co,HP,oF,Wd,aF,Kd,cF,L_,uF,Jd,lF,dF,fF,pF,hF,mF,gF,yF,_F,bF,Gd,wF,vF,Yd,q_,D_,Z_,xF,SF,kF,U_,$F,EF,TF,PF,OF,WP,Xd,IF,Qd,NQ,AF,uo,NF,RQ,wc,RF,F_,zF,MF,CF,jF,LF,qF,DF,zd,ZF,UF,FF,vc,B_,BF,VF,HF,WF,KF,JF,GF,YF,XF,QF,e4,t4,r4,n4,s4,i4,o4,a4,lo,c4,u4,l4,ef,d4,f4,p4,V_,h4,zQ,MQ,CQ,jQ,LQ,qQ,D,O_,fo=$(()=>{AP();I_="2025-11-25",NP=[I_,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Rn="io.modelcontextprotocol/related-task",Md="2.0",He=EP(t=>t!==null&&(typeof t=="object"||typeof t=="function")),RP=$e([x(),ye().int()]),zP=x(),OQ=pt({ttl:ye().optional(),pollInterval:ye().optional()}),FU=M({ttl:ye().optional()}),BU=M({taskId:x()}),A_=pt({progressToken:RP.optional(),[Rn]:BU.optional()}),Mt=M({_meta:A_.optional()}),fc=Mt.extend({task:FU.optional()}),MP=t=>fc.safeParse(t).success,nt=M({method:x(),params:Mt.loose().optional()}),Kt=M({_meta:A_.optional()}),Jt=M({method:x(),params:Kt.loose().optional()}),st=pt({_meta:A_.optional()}),Cd=$e([x(),ye().int()]),CP=M({jsonrpc:Z(Md),id:Cd,...nt.shape}).strict(),N_=t=>CP.safeParse(t).success,jP=M({jsonrpc:Z(Md),...Jt.shape}).strict(),LP=t=>jP.safeParse(t).success,R_=M({jsonrpc:Z(Md),id:Cd,result:st}).strict(),pc=t=>R_.safeParse(t).success;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(F||(F={}));z_=M({jsonrpc:Z(Md),id:Cd.optional(),error:M({code:ye().int(),message:x(),data:Ae().optional()})}).strict(),qP=t=>z_.safeParse(t).success,DP=$e([CP,jP,R_,z_]),IQ=$e([R_,z_]),jd=st.strict(),VU=Kt.extend({requestId:Cd.optional(),reason:x().optional()}),Ld=Jt.extend({method:Z("notifications/cancelled"),params:VU}),HU=M({src:x(),mimeType:x().optional(),sizes:oe(x()).optional(),theme:St(["light","dark"]).optional()}),hc=M({icons:oe(HU).optional()}),oo=M({name:x(),title:x().optional()}),ZP=oo.extend({...oo.shape,...hc.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),WU=Rd(M({applyDefaults:Xe().optional()}),Se(x(),Ae())),KU=P_(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Rd(M({form:WU.optional(),url:He.optional()}),Se(x(),Ae()).optional())),JU=pt({list:He.optional(),cancel:He.optional(),requests:pt({sampling:pt({createMessage:He.optional()}).optional(),elicitation:pt({create:He.optional()}).optional()}).optional()}),GU=pt({list:He.optional(),cancel:He.optional(),requests:pt({tools:pt({call:He.optional()}).optional()}).optional()}),YU=M({experimental:Se(x(),He).optional(),sampling:M({context:He.optional(),tools:He.optional()}).optional(),elicitation:KU.optional(),roots:M({listChanged:Xe().optional()}).optional(),tasks:JU.optional(),extensions:Se(x(),He).optional()}),XU=Mt.extend({protocolVersion:x(),capabilities:YU,clientInfo:ZP}),M_=nt.extend({method:Z("initialize"),params:XU}),QU=M({experimental:Se(x(),He).optional(),logging:He.optional(),completions:He.optional(),prompts:M({listChanged:Xe().optional()}).optional(),resources:M({subscribe:Xe().optional(),listChanged:Xe().optional()}).optional(),tools:M({listChanged:Xe().optional()}).optional(),tasks:GU.optional(),extensions:Se(x(),He).optional()}),eF=st.extend({protocolVersion:x(),capabilities:QU,serverInfo:ZP,instructions:x().optional()}),C_=Jt.extend({method:Z("notifications/initialized"),params:Kt.optional()}),qd=nt.extend({method:Z("ping"),params:Mt.optional()}),tF=M({progress:ye(),total:Ne(ye()),message:Ne(x())}),rF=M({...Kt.shape,...tF.shape,progressToken:RP}),Dd=Jt.extend({method:Z("notifications/progress"),params:rF}),nF=Mt.extend({cursor:zP.optional()}),mc=nt.extend({params:nF.optional()}),gc=st.extend({nextCursor:zP.optional()}),sF=St(["working","input_required","completed","failed","cancelled"]),yc=M({taskId:x(),status:sF,ttl:$e([ye(),bP()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Ne(ye()),statusMessage:Ne(x())}),ao=st.extend({task:yc}),iF=Kt.merge(yc),_c=Jt.extend({method:Z("notifications/tasks/status"),params:iF}),Zd=nt.extend({method:Z("tasks/get"),params:Mt.extend({taskId:x()})}),Ud=st.merge(yc),Fd=nt.extend({method:Z("tasks/result"),params:Mt.extend({taskId:x()})}),AQ=st.loose(),Bd=mc.extend({method:Z("tasks/list")}),Vd=gc.extend({tasks:oe(yc)}),Hd=nt.extend({method:Z("tasks/cancel"),params:Mt.extend({taskId:x()})}),UP=st.merge(yc),FP=M({uri:x(),mimeType:Ne(x()),_meta:Se(x(),Ae()).optional()}),BP=FP.extend({text:x()}),j_=x().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),VP=FP.extend({blob:j_}),bc=St(["user","assistant"]),co=M({audience:oe(bc).optional(),priority:ye().min(0).max(1).optional(),lastModified:lc.datetime({offset:!0}).optional()}),HP=M({...oo.shape,...hc.shape,uri:x(),description:Ne(x()),mimeType:Ne(x()),size:Ne(ye()),annotations:co.optional(),_meta:Ne(pt({}))}),oF=M({...oo.shape,...hc.shape,uriTemplate:x(),description:Ne(x()),mimeType:Ne(x()),annotations:co.optional(),_meta:Ne(pt({}))}),Wd=mc.extend({method:Z("resources/list")}),aF=gc.extend({resources:oe(HP)}),Kd=mc.extend({method:Z("resources/templates/list")}),cF=gc.extend({resourceTemplates:oe(oF)}),L_=Mt.extend({uri:x()}),uF=L_,Jd=nt.extend({method:Z("resources/read"),params:uF}),lF=st.extend({contents:oe($e([BP,VP]))}),dF=Jt.extend({method:Z("notifications/resources/list_changed"),params:Kt.optional()}),fF=L_,pF=nt.extend({method:Z("resources/subscribe"),params:fF}),hF=L_,mF=nt.extend({method:Z("resources/unsubscribe"),params:hF}),gF=Kt.extend({uri:x()}),yF=Jt.extend({method:Z("notifications/resources/updated"),params:gF}),_F=M({name:x(),description:Ne(x()),required:Ne(Xe())}),bF=M({...oo.shape,...hc.shape,description:Ne(x()),arguments:Ne(oe(_F)),_meta:Ne(pt({}))}),Gd=mc.extend({method:Z("prompts/list")}),wF=gc.extend({prompts:oe(bF)}),vF=Mt.extend({name:x(),arguments:Se(x(),x()).optional()}),Yd=nt.extend({method:Z("prompts/get"),params:vF}),q_=M({type:Z("text"),text:x(),annotations:co.optional(),_meta:Se(x(),Ae()).optional()}),D_=M({type:Z("image"),data:j_,mimeType:x(),annotations:co.optional(),_meta:Se(x(),Ae()).optional()}),Z_=M({type:Z("audio"),data:j_,mimeType:x(),annotations:co.optional(),_meta:Se(x(),Ae()).optional()}),xF=M({type:Z("tool_use"),name:x(),id:x(),input:Se(x(),Ae()),_meta:Se(x(),Ae()).optional()}),SF=M({type:Z("resource"),resource:$e([BP,VP]),annotations:co.optional(),_meta:Se(x(),Ae()).optional()}),kF=HP.extend({type:Z("resource_link")}),U_=$e([q_,D_,Z_,kF,SF]),$F=M({role:bc,content:U_}),EF=st.extend({description:x().optional(),messages:oe($F)}),TF=Jt.extend({method:Z("notifications/prompts/list_changed"),params:Kt.optional()}),PF=M({title:x().optional(),readOnlyHint:Xe().optional(),destructiveHint:Xe().optional(),idempotentHint:Xe().optional(),openWorldHint:Xe().optional()}),OF=M({taskSupport:St(["required","optional","forbidden"]).optional()}),WP=M({...oo.shape,...hc.shape,description:x().optional(),inputSchema:M({type:Z("object"),properties:Se(x(),He).optional(),required:oe(x()).optional()}).catchall(Ae()),outputSchema:M({type:Z("object"),properties:Se(x(),He).optional(),required:oe(x()).optional()}).catchall(Ae()).optional(),annotations:PF.optional(),execution:OF.optional(),_meta:Se(x(),Ae()).optional()}),Xd=mc.extend({method:Z("tools/list")}),IF=gc.extend({tools:oe(WP)}),Qd=st.extend({content:oe(U_).default([]),structuredContent:Se(x(),Ae()).optional(),isError:Xe().optional()}),NQ=Qd.or(st.extend({toolResult:Ae()})),AF=fc.extend({name:x(),arguments:Se(x(),Ae()).optional()}),uo=nt.extend({method:Z("tools/call"),params:AF}),NF=Jt.extend({method:Z("notifications/tools/list_changed"),params:Kt.optional()}),RQ=M({autoRefresh:Xe().default(!0),debounceMs:ye().int().nonnegative().default(300)}),wc=St(["debug","info","notice","warning","error","critical","alert","emergency"]),RF=Mt.extend({level:wc}),F_=nt.extend({method:Z("logging/setLevel"),params:RF}),zF=Kt.extend({level:wc,logger:x().optional(),data:Ae()}),MF=Jt.extend({method:Z("notifications/message"),params:zF}),CF=M({name:x().optional()}),jF=M({hints:oe(CF).optional(),costPriority:ye().min(0).max(1).optional(),speedPriority:ye().min(0).max(1).optional(),intelligencePriority:ye().min(0).max(1).optional()}),LF=M({mode:St(["auto","required","none"]).optional()}),qF=M({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:oe(U_).default([]),structuredContent:M({}).loose().optional(),isError:Xe().optional(),_meta:Se(x(),Ae()).optional()}),DF=T_("type",[q_,D_,Z_]),zd=T_("type",[q_,D_,Z_,xF,qF]),ZF=M({role:bc,content:$e([zd,oe(zd)]),_meta:Se(x(),Ae()).optional()}),UF=fc.extend({messages:oe(ZF),modelPreferences:jF.optional(),systemPrompt:x().optional(),includeContext:St(["none","thisServer","allServers"]).optional(),temperature:ye().optional(),maxTokens:ye().int(),stopSequences:oe(x()).optional(),metadata:He.optional(),tools:oe(WP).optional(),toolChoice:LF.optional()}),FF=nt.extend({method:Z("sampling/createMessage"),params:UF}),vc=st.extend({model:x(),stopReason:Ne(St(["endTurn","stopSequence","maxTokens"]).or(x())),role:bc,content:DF}),B_=st.extend({model:x(),stopReason:Ne(St(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:bc,content:$e([zd,oe(zd)])}),BF=M({type:Z("boolean"),title:x().optional(),description:x().optional(),default:Xe().optional()}),VF=M({type:Z("string"),title:x().optional(),description:x().optional(),minLength:ye().optional(),maxLength:ye().optional(),format:St(["email","uri","date","date-time"]).optional(),default:x().optional()}),HF=M({type:St(["number","integer"]),title:x().optional(),description:x().optional(),minimum:ye().optional(),maximum:ye().optional(),default:ye().optional()}),WF=M({type:Z("string"),title:x().optional(),description:x().optional(),enum:oe(x()),default:x().optional()}),KF=M({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:oe(M({const:x(),title:x()})),default:x().optional()}),JF=M({type:Z("string"),title:x().optional(),description:x().optional(),enum:oe(x()),enumNames:oe(x()).optional(),default:x().optional()}),GF=$e([WF,KF]),YF=M({type:Z("array"),title:x().optional(),description:x().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:M({type:Z("string"),enum:oe(x())}),default:oe(x()).optional()}),XF=M({type:Z("array"),title:x().optional(),description:x().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:M({anyOf:oe(M({const:x(),title:x()}))}),default:oe(x()).optional()}),QF=$e([YF,XF]),e4=$e([JF,GF,QF]),t4=$e([e4,BF,VF,HF]),r4=fc.extend({mode:Z("form").optional(),message:x(),requestedSchema:M({type:Z("object"),properties:Se(x(),t4),required:oe(x()).optional()})}),n4=fc.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),s4=$e([r4,n4]),i4=nt.extend({method:Z("elicitation/create"),params:s4}),o4=Kt.extend({elicitationId:x()}),a4=Jt.extend({method:Z("notifications/elicitation/complete"),params:o4}),lo=st.extend({action:St(["accept","decline","cancel"]),content:P_(t=>t===null?void 0:t,Se(x(),$e([x(),ye(),Xe(),oe(x())])).optional())}),c4=M({type:Z("ref/resource"),uri:x()}),u4=M({type:Z("ref/prompt"),name:x()}),l4=Mt.extend({ref:$e([u4,c4]),argument:M({name:x(),value:x()}),context:M({arguments:Se(x(),x()).optional()}).optional()}),ef=nt.extend({method:Z("completion/complete"),params:l4});d4=st.extend({completion:pt({values:oe(x()).max(100),total:Ne(ye().int()),hasMore:Ne(Xe())})}),f4=M({uri:x().startsWith("file://"),name:x().optional(),_meta:Se(x(),Ae()).optional()}),p4=nt.extend({method:Z("roots/list"),params:Mt.optional()}),V_=st.extend({roots:oe(f4)}),h4=Jt.extend({method:Z("notifications/roots/list_changed"),params:Kt.optional()}),zQ=$e([qd,M_,ef,F_,Yd,Gd,Wd,Kd,Jd,pF,mF,uo,Xd,Zd,Fd,Bd,Hd]),MQ=$e([Ld,Dd,C_,h4,_c]),CQ=$e([jd,vc,B_,lo,V_,Ud,Vd,ao]),jQ=$e([qd,FF,i4,p4,Zd,Fd,Bd,Hd]),LQ=$e([Ld,Dd,MF,yF,dF,NF,TF,_c,a4]),qQ=$e([jd,eF,d4,EF,wF,aF,cF,lF,Qd,IF,Ud,Vd,ao]),D=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===F.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new O_(s.elicitations,r)}return new t(e,r,n)}},O_=class extends D{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}});function zn(t){return t==="completed"||t==="failed"||t==="cancelled"}var GP=$(()=>{});var XP,YP,QP,tf=$(()=>{XP=Symbol("Let zodToJsonSchema decide on which parser to use"),YP={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},QP=t=>typeof t=="string"?{...YP,name:t}:{...YP,...t}});var e1,H_=$(()=>{tf();e1=t=>{let e=QP(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}}});function W_(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ae(t,e,r,n,s){t[e]=r,W_(t,e,n,s)}var Mn=$(()=>{});var rf,nf=$(()=>{rf=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")}});function Re(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?rf(e,t.currentPath):e.join("/")}}var Gt=$(()=>{nf()});function t1(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==O.ZodAny&&(r.items=W(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ae(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ae(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ae(r,"minItems",t.exactLength.value,t.exactLength.message,e),ae(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}var K_=$(()=>{Ga();Mn();Ue()});function r1(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ae(r,"minimum",n.value,n.message,e):ae(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ae(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ae(r,"maximum",n.value,n.message,e):ae(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ae(r,"maximum",n.value,n.message,e));break;case"multipleOf":ae(r,"multipleOf",n.value,n.message,e);break}return r}var J_=$(()=>{Mn()});function n1(){return{type:"boolean"}}var G_=$(()=>{});function sf(t,e){return W(t.type._def,e)}var of=$(()=>{Ue()});var s1,Y_=$(()=>{Ue();s1=(t,e)=>W(t.innerType._def,e)});function X_(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,i)=>X_(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return m4(t,e)}}var m4,Q_=$(()=>{Mn();m4=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ae(r,"minimum",n.value,n.message,e);break;case"max":ae(r,"maximum",n.value,n.message,e);break}return r}});function i1(t,e){return{...W(t.innerType._def,e),default:t.defaultValue()}}var eb=$(()=>{Ue()});function o1(t,e){return e.effectStrategy==="input"?W(t.schema._def,e):Re(e)}var tb=$(()=>{Ue();Gt()});function a1(t){return{type:"string",enum:Array.from(t.values)}}var rb=$(()=>{});function c1(t,e){let r=[W(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),W(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(g4(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:a,...c}=i;o=c}else n=void 0;s.push(o)}}),s.length?{allOf:s,...n}:void 0}var g4,nb=$(()=>{Ue();g4=t=>"type"in t&&t.type==="string"?!1:"allOf"in t});function u1(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var sb=$(()=>{});function af(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":cr(r,"email",n.message,e);break;case"format:idn-email":cr(r,"idn-email",n.message,e);break;case"pattern:zod":ht(r,ar.email,n.message,e);break}break;case"url":cr(r,"uri",n.message,e);break;case"uuid":cr(r,"uuid",n.message,e);break;case"regex":ht(r,n.regex,n.message,e);break;case"cuid":ht(r,ar.cuid,n.message,e);break;case"cuid2":ht(r,ar.cuid2,n.message,e);break;case"startsWith":ht(r,RegExp(`^${ob(n.value,e)}`),n.message,e);break;case"endsWith":ht(r,RegExp(`${ob(n.value,e)}$`),n.message,e);break;case"datetime":cr(r,"date-time",n.message,e);break;case"date":cr(r,"date",n.message,e);break;case"time":cr(r,"time",n.message,e);break;case"duration":cr(r,"duration",n.message,e);break;case"length":ae(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ae(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{ht(r,RegExp(ob(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&cr(r,"ipv4",n.message,e),n.version!=="v4"&&cr(r,"ipv6",n.message,e);break}case"base64url":ht(r,ar.base64url,n.message,e);break;case"jwt":ht(r,ar.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&ht(r,ar.ipv4Cidr,n.message,e),n.version!=="v4"&&ht(r,ar.ipv6Cidr,n.message,e);break}case"emoji":ht(r,ar.emoji(),n.message,e);break;case"ulid":{ht(r,ar.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{cr(r,"binary",n.message,e);break}case"contentEncoding:base64":{ae(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{ht(r,ar.base64,n.message,e);break}}break}case"nanoid":ht(r,ar.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function ob(t,e){return e.patternStrategy==="escape"?_4(t):t}function _4(t){let e="";for(let r=0;r<t.length;r++)y4.has(t[r])||(e+="\\"),e+=t[r];return e}function cr(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.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,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ae(t,"format",e,r,n)}function ht(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.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:l1(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ae(t,"pattern",l1(e,n),r,n)}function l1(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,s="",i=!1,o=!1,a=!1;for(let c=0;c<n.length;c++){if(i){s+=n[c],i=!1;continue}if(r.i){if(o){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
180
180
|
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
181
181
|
]))`;continue}}if(r.s&&n[c]==="."){s+=o?`${n[c]}\r
|
|
182
182
|
`:`[${n[c]}\r
|
|
183
|
-
]`;continue}s+=n[c],n[c]==="\\"?i=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(o=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}var sb,or,g4,af=$(()=>{zn();or={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:()=>(sb===void 0&&(sb=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),sb),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};g4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function cf(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===O.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Ne(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===O.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=of(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===O.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===O.ZodBranded&&t.keyType._def.type._def.typeName===O.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=nf(t.keyType._def,e);return{...r,propertyNames:s}}}return r}var uf=$(()=>{Ja();Ze();af();sf();Jt()});function l1(t,e){if(e.mapStrategy==="record")return cf(t,e);let r=W(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ne(e),n=W(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ne(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}var ob=$(()=>{Ze();uf();Jt()});function d1(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}var ab=$(()=>{});function f1(t){return t.target==="openAi"?void 0:{not:Ne({...t,currentPath:[...t.currentPath,"not"]})}}var cb=$(()=>{Jt()});function p1(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var ub=$(()=>{});function m1(t,e){if(e.target==="openApi3")return h1(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in vc&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=vc[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,a)=>a.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return h1(t,e)}var vc,h1,lf=$(()=>{Ze();vc={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};h1=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>W(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0}});function g1(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:vc[t.innerType._def.typeName],nullable:!0}:{type:[vc[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=W(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=W(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}var lb=$(()=>{Ze();lf()});function y1(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",H_(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ae(r,"minimum",n.value,n.message,e):ae(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ae(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ae(r,"maximum",n.value,n.message,e):ae(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ae(r,"maximum",n.value,n.message,e));break;case"multipleOf":ae(r,"multipleOf",n.value,n.message,e);break}return r}var db=$(()=>{zn()});function _1(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},s=[],i=t.shape();for(let a in i){let c=i[a];if(c===void 0||c._def===void 0)continue;let u=b4(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=W(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||s.push(a))}s.length&&(n.required=s);let o=_4(t,e);return o!==void 0&&(n.additionalProperties=o),n}function _4(t,e){if(t.catchall._def.typeName!=="ZodNever")return W(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function b4(t){try{return t.isOptional()}catch{return!0}}var fb=$(()=>{Ze()});var b1,pb=$(()=>{Ze();Jt();b1=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return W(t.innerType._def,e);let r=W(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ne(e)},r]}:Ne(e)}});var w1,hb=$(()=>{Ze();w1=(t,e)=>{if(e.pipeStrategy==="input")return W(t.in._def,e);if(e.pipeStrategy==="output")return W(t.out._def,e);let r=W(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=W(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}}});function v1(t,e){return W(t.type._def,e)}var mb=$(()=>{Ze()});function x1(t,e){let n={type:"array",uniqueItems:!0,items:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ae(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ae(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}var gb=$(()=>{zn();Ze()});function S1(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>W(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:W(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>W(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}var yb=$(()=>{Ze()});function k1(t){return{not:Ne(t)}}var _b=$(()=>{Jt()});function $1(t){return Ne(t)}var bb=$(()=>{Jt()});var E1,wb=$(()=>{Ze();E1=(t,e)=>W(t.innerType._def,e)});var T1,vb=$(()=>{Ja();Jt();W_();K_();J_();sf();G_();X_();Q_();eb();tb();rb();nb();ob();ab();cb();ub();lb();db();fb();pb();hb();mb();uf();gb();af();yb();_b();lf();bb();wb();T1=(t,e,r)=>{switch(e){case O.ZodString:return of(t,r);case O.ZodNumber:return y1(t,r);case O.ZodObject:return _1(t,r);case O.ZodBigInt:return t1(t,r);case O.ZodBoolean:return r1();case O.ZodDate:return Y_(t,r);case O.ZodUndefined:return k1(r);case O.ZodNull:return p1(r);case O.ZodArray:return e1(t,r);case O.ZodUnion:case O.ZodDiscriminatedUnion:return m1(t,r);case O.ZodIntersection:return a1(t,r);case O.ZodTuple:return S1(t,r);case O.ZodRecord:return cf(t,r);case O.ZodLiteral:return c1(t,r);case O.ZodEnum:return o1(t);case O.ZodNativeEnum:return d1(t);case O.ZodNullable:return g1(t,r);case O.ZodOptional:return b1(t,r);case O.ZodMap:return l1(t,r);case O.ZodSet:return x1(t,r);case O.ZodLazy:return()=>t.getter()._def;case O.ZodPromise:return v1(t,r);case O.ZodNaN:case O.ZodNever:return f1(r);case O.ZodEffects:return i1(t,r);case O.ZodAny:return Ne(r);case O.ZodUnknown:return $1(r);case O.ZodDefault:return s1(t,r);case O.ZodBranded:return nf(t,r);case O.ZodReadonly:return E1(t,r);case O.ZodCatch:return n1(t,r);case O.ZodPipeline:return w1(t,r);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return(n=>{})(e)}}});function W(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==YP)return a}if(n&&!r){let a=w4(n,e);if(a!==void 0)return a}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=T1(t,t.typeName,e),o=typeof i=="function"?W(i(),e):i;if(o&&v4(t,e,o),e.postProcess){let a=e.postProcess(o,t,e);return s.jsonSchema=o,a}return s.jsonSchema=o,o}var w4,v4,Ze=$(()=>{ef();vb();rf();Jt();w4=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:tf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Ne(e)):e.$refStrategy==="seen"?Ne(e):void 0}},v4=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r)});var P1=$(()=>{});var xb,Sb=$(()=>{Ze();V_();Jt();xb=(t,e)=>{let r=QP(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:W(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ne(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=W(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Ne(r),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=s===void 0?n?{...i,[r.definitionPath]:n}:i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:i}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var O1=$(()=>{ef();V_();zn();rf();Ze();P1();Jt();W_();K_();J_();sf();G_();X_();Q_();eb();tb();rb();nb();ob();ab();cb();ub();lb();db();fb();pb();hb();mb();wb();uf();gb();af();yb();_b();lf();bb();vb();Sb();Sb()});function x4(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function kb(t,e){return Ht(t)?d_(t,{target:x4(e?.target),io:e?.pipeStrategy??"input"}):xb(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function $b(t){let r=An(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Id(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Eb(t,e){let r=In(t,e);if(!r.success)throw r.error;return r.data}var Tb=$(()=>{h_();cc();O1()});function I1(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function A1(t,e){let r={...t};for(let n in e){let s=n,i=e[s];if(i===void 0)continue;let o=r[s];I1(o)&&I1(i)?r[s]={...o,...i}:r[s]=i}return r}var S4,df,N1=$(()=>{cc();lo();JP();Tb();S4=6e4,df=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(jd,r=>{this._oncancel(r)}),this.setNotificationHandler(qd,r=>{this._onprogress(r)}),this.setRequestHandler(Ld,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Dd,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new D(F.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Ud,async(r,n)=>{let s=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new D(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let o=await this._taskStore.getTask(i,n.sessionId);if(!o)throw new D(F.InvalidParams,`Task not found: ${i}`);if(!Rn(o.status))return await this._waitForTaskUpdate(i,n.signal),await s();if(Rn(o.status)){let a=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...a,_meta:{...a._meta,[Nn]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(Fd,async(r,n)=>{try{let{tasks:s,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:i,_meta:{}}}catch(s){throw new D(F.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Vd,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new D(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(Rn(s.status))throw new D(F.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(s){throw s instanceof D?s:new D(F.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),D.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=i=>{n?.(i),this._onerror(i)};let s=this._transport?.onmessage;this._transport.onmessage=(i,o)=>{s?.(i,o),fc(i)||LP(i)?this._onresponse(i):A_(i)?this._onrequest(i,o):jP(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=D.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,i=e.params?._meta?.[Nn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:F.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):s?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let a=zP(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,u={signal:o.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(o.signal.aborted)return;let d={relatedRequestId:e.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(o.signal.aborted)throw new D(F.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:e.id};i&&!p.relatedTask&&(p.relatedTask={taskId:i});let m=p.relatedTask?.taskId??i;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(o.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)},async l=>{if(o.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:F.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===o&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,s=Number(r),i=this._progressHandlers.get(s);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let o=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),o(c);return}i(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),fc(e))n(e);else{let o=new D(e.error.code,e.error.message,e.error.data);n(o)}return}let s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(fc(e)&&e.result&&typeof e.result=="object"){let o=e.result;if(o.task&&typeof o.task=="object"){let a=o.task;typeof a.taskId=="string"&&(i=!0,this._taskProgressTokens.set(a.taskId,r))}}if(i||this._progressHandlers.delete(r),fc(e))s(e);else{let o=D.fromError(e.error.code,e.error.message,e.error.data);s(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(o){yield{type:"error",error:o instanceof D?o:new D(F.InternalError,String(o))}}return}let i;try{let o=await this.request(e,oo,n);if(o.task)i=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new D(F.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:a},Rn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:a.status==="failed"?yield{type:"error",error:new D(F.InternalError,`Task ${i} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new D(F.InternalError,`Task ${i} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof D?o:new D(F.InternalError,String(o))}}}request(e,r,n){let{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){d(_);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Nn]:c}});let m=_=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(_)}},{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));let v=_ instanceof D?_:new D(F.RequestTimeout,String(_));l(v)};this._responseHandlers.set(f,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let v=In(r,_.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??S4,g=()=>m(D.fromError(F.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let _=v=>{let k=this._responseHandlers.get(f);k?k(v):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,_),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(f),l(v)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o}).catch(_=>{this._cleanupTimeout(f),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Zd,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Bd,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},ZP,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Nn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Nn]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[Nn]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(e,r){let n=$b(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,i)=>{let o=Eb(e,s);return Promise.resolve(r(o,i))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=$b(e);this._notificationHandlers.set(n,s=>{let i=Eb(e,s);return Promise.resolve(r(i))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let s of n)if(s.type==="request"&&A_(s.message)){let i=s.message.id,o=this._requestResolvers.get(i);o?(o(new D(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new D(F.InvalidRequest,"Request cancelled"));return}let o=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(o),i(new D(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{let i=await n.getTask(s,r);if(!i)throw new D(F.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(s,i,o)=>{await n.storeTaskResult(s,i,o,r);let a=await n.getTask(s,r);if(a){let c=yc.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Rn(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,i,o)=>{let a=await n.getTask(s,r);if(!a)throw new D(F.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Rn(a.status))throw new D(F.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,i,o,r);let c=await n.getTask(s,r);if(c){let u=yc.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Rn(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}});var kc=w(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.regexpCode=he.getEsmExportName=he.getProperty=he.safeStringify=he.stringify=he.strConcat=he.addCodeArg=he.str=he._=he.nil=he._Code=he.Name=he.IDENTIFIER=he._CodeOrName=void 0;var xc=class{};he._CodeOrName=xc;he.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ds=class extends xc{constructor(e){if(super(),!he.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};he.Name=Ds;var Gt=class extends xc{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Ds&&(r[n.str]=(r[n.str]||0)+1),r),{})}};he._Code=Gt;he.nil=new Gt("");function R1(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Ob(r,e[n]),r.push(t[++n]);return new Gt(r)}he._=R1;var Pb=new Gt("+");function z1(t,...e){let r=[Sc(t[0])],n=0;for(;n<e.length;)r.push(Pb),Ob(r,e[n]),r.push(Pb,Sc(t[++n]));return k4(r),new Gt(r)}he.str=z1;function Ob(t,e){e instanceof Gt?t.push(...e._items):e instanceof Ds?t.push(e):t.push(T4(e))}he.addCodeArg=Ob;function k4(t){let e=1;for(;e<t.length-1;){if(t[e]===Pb){let r=$4(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function $4(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Ds||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Ds))return`"${t}${e.slice(1)}`}function E4(t,e){return e.emptyStr()?t:t.emptyStr()?e:z1`${t}${e}`}he.strConcat=E4;function T4(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Sc(Array.isArray(t)?t.join(","):t)}function P4(t){return new Gt(Sc(t))}he.stringify=P4;function Sc(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}he.safeStringify=Sc;function O4(t){return typeof t=="string"&&he.IDENTIFIER.test(t)?new Gt(`.${t}`):R1`[${t}]`}he.getProperty=O4;function I4(t){if(typeof t=="string"&&he.IDENTIFIER.test(t))return new Gt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}he.getEsmExportName=I4;function A4(t){return new Gt(t.toString())}he.regexpCode=A4});var Nb=w(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.ValueScope=kt.ValueScopeName=kt.Scope=kt.varKinds=kt.UsedValueState=void 0;var St=kc(),Ib=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},ff;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(ff||(kt.UsedValueState=ff={}));kt.varKinds={const:new St.Name("const"),let:new St.Name("let"),var:new St.Name("var")};var pf=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof St.Name?e:this.name(e)}name(e){return new St.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};kt.Scope=pf;var hf=class extends St.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,St._)`.${new St.Name(r)}[${n}]`}};kt.ValueScopeName=hf;var N4=(0,St._)`\n`,Ab=class extends pf{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?N4:St.nil}}get(){return this._scope}name(e){return new hf(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:i}=s,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[i];if(a){let l=a.get(o);if(l)return l}else a=this._values[i]=new Map;a.set(o,s);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=r.ref,s.setValue(r,{property:i,itemIndex:u}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,St._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let i=St.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,ff.Started);let l=r(u);if(l){let d=this.opts.es5?kt.varKinds.var:kt.varKinds.const;i=(0,St._)`${i}${d} ${u} = ${l};${this.opts._n}`}else if(l=s?.(u))i=(0,St._)`${i}${l}${this.opts._n}`;else throw new Ib(u);c.set(u,ff.Completed)})}return i}};kt.ValueScope=Ab});var te=w(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.or=re.and=re.not=re.CodeGen=re.operators=re.varKinds=re.ValueScopeName=re.ValueScope=re.Scope=re.Name=re.regexpCode=re.stringify=re.getProperty=re.nil=re.strConcat=re.str=re._=void 0;var ce=kc(),cr=Nb(),Mn=kc();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return Mn._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return Mn.str}});Object.defineProperty(re,"strConcat",{enumerable:!0,get:function(){return Mn.strConcat}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return Mn.nil}});Object.defineProperty(re,"getProperty",{enumerable:!0,get:function(){return Mn.getProperty}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return Mn.stringify}});Object.defineProperty(re,"regexpCode",{enumerable:!0,get:function(){return Mn.regexpCode}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return Mn.Name}});var _f=Nb();Object.defineProperty(re,"Scope",{enumerable:!0,get:function(){return _f.Scope}});Object.defineProperty(re,"ValueScope",{enumerable:!0,get:function(){return _f.ValueScope}});Object.defineProperty(re,"ValueScopeName",{enumerable:!0,get:function(){return _f.ValueScopeName}});Object.defineProperty(re,"varKinds",{enumerable:!0,get:function(){return _f.varKinds}});re.operators={GT:new ce._Code(">"),GTE:new ce._Code(">="),LT:new ce._Code("<"),LTE:new ce._Code("<="),EQ:new ce._Code("==="),NEQ:new ce._Code("!=="),NOT:new ce._Code("!"),OR:new ce._Code("||"),AND:new ce._Code("&&"),ADD:new ce._Code("+")};var Jr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Rb=class extends Jr{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?cr.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=po(this.rhs,e,r)),this}get names(){return this.rhs instanceof ce._CodeOrName?this.rhs.names:{}}},mf=class extends Jr{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ce.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=po(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ce.Name?{}:{...this.lhs.names};return yf(e,this.rhs)}},zb=class extends mf{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Mb=class extends Jr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Cb=class extends Jr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},jb=class extends Jr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Lb=class extends Jr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=po(this.code,e,r),this}get names(){return this.code instanceof ce._CodeOrName?this.code.names:{}}},$c=class extends Jr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let i=n[s];i.optimizeNames(e,r)||(R4(e,i.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Fs(e,r.names),{})}},Gr=class extends $c{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},qb=class extends $c{},fo=class extends Gr{};fo.kind="else";var Zs=class t extends Gr{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new fo(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(M1(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=po(this.condition,e,r),this}get names(){let e=super.names;return yf(e,this.condition),this.else&&Fs(e,this.else.names),e}};Zs.kind="if";var Us=class extends Gr{};Us.kind="for";var Db=class extends Us{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=po(this.iteration,e,r),this}get names(){return Fs(super.names,this.iteration.names)}},Zb=class extends Us{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?cr.varKinds.var:this.varKind,{name:n,from:s,to:i}=this;return`for(${r} ${n}=${s}; ${n}<${i}; ${n}++)`+super.render(e)}get names(){let e=yf(super.names,this.from);return yf(e,this.to)}},gf=class extends Us{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=po(this.iterable,e,r),this}get names(){return Fs(super.names,this.iterable.names)}},Ec=class extends Gr{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Ec.kind="func";var Tc=class extends $c{render(e){return"return "+super.render(e)}};Tc.kind="return";var Ub=class extends Gr{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Fs(e,this.catch.names),this.finally&&Fs(e,this.finally.names),e}},Pc=class extends Gr{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Pc.kind="catch";var Oc=class extends Gr{render(e){return"finally"+super.render(e)}};Oc.kind="finally";var Fb=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
184
|
-
`:""},this._extScope=e,this._scope=new cr.Scope({parent:e}),this._nodes=[new qb]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let i=this._scope.toName(r);return n!==void 0&&s&&(this._constants[i.str]=n),this._leafNode(new Rb(e,i,n)),i}const(e,r,n){return this._def(cr.varKinds.const,e,r,n)}let(e,r,n){return this._def(cr.varKinds.let,e,r,n)}var(e,r,n){return this._def(cr.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new mf(e,r,n))}add(e,r){return this._leafNode(new zb(e,re.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ce.nil&&this._leafNode(new Lb(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,ce.addCodeArg)(r,s));return r.push("}"),new ce._Code(r)}if(e,r,n){if(this._blockNode(new Zs(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Zs(e))}else(){return this._elseNode(new fo)}endIf(){return this._endBlockNode(Zs,fo)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Db(e),r)}forRange(e,r,n,s,i=this.opts.es5?cr.varKinds.var:cr.varKinds.let){let o=this._scope.toName(e);return this._for(new Zb(i,o,r,n),()=>s(o))}forOf(e,r,n,s=cr.varKinds.const){let i=this._scope.toName(e);if(this.opts.es5){let o=r instanceof ce.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ce._)`${o}.length`,a=>{this.var(i,(0,ce._)`${o}[${a}]`),n(i)})}return this._for(new gf("of",s,i,r),()=>n(i))}forIn(e,r,n,s=this.opts.es5?cr.varKinds.var:cr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ce._)`Object.keys(${r})`,n);let i=this._scope.toName(e);return this._for(new gf("in",s,i,r),()=>n(i))}endFor(){return this._endBlockNode(Us)}label(e){return this._leafNode(new Mb(e))}break(e){return this._leafNode(new Cb(e))}return(e){let r=new Tc;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Tc)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Ub;if(this._blockNode(s),this.code(e),r){let i=this.name("e");this._currNode=s.catch=new Pc(i),r(i)}return n&&(this._currNode=s.finally=new Oc,this.code(n)),this._endBlockNode(Pc,Oc)}throw(e){return this._leafNode(new jb(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ce.nil,n,s){return this._blockNode(new Ec(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Ec)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Zs))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};re.CodeGen=Fb;function Fs(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function yf(t,e){return e instanceof ce._CodeOrName?Fs(t,e.names):t}function po(t,e,r){if(t instanceof ce.Name)return n(t);if(!s(t))return t;return new ce._Code(t._items.reduce((i,o)=>(o instanceof ce.Name&&(o=n(o)),o instanceof ce._Code?i.push(...o._items):i.push(o),i),[]));function n(i){let o=r[i.str];return o===void 0||e[i.str]!==1?i:(delete e[i.str],o)}function s(i){return i instanceof ce._Code&&i._items.some(o=>o instanceof ce.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function R4(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function M1(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ce._)`!${Bb(t)}`}re.not=M1;var z4=C1(re.operators.AND);function M4(...t){return t.reduce(z4)}re.and=M4;var C4=C1(re.operators.OR);function j4(...t){return t.reduce(C4)}re.or=j4;function C1(t){return(e,r)=>e===ce.nil?r:r===ce.nil?e:(0,ce._)`${Bb(e)} ${t} ${Bb(r)}`}function Bb(t){return t instanceof ce.Name?t:(0,ce._)`(${t})`}});var fe=w(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.checkStrictMode=ne.getErrorPath=ne.Type=ne.useFunc=ne.setEvaluated=ne.evaluatedPropsToName=ne.mergeEvaluated=ne.eachItem=ne.unescapeJsonPointer=ne.escapeJsonPointer=ne.escapeFragment=ne.unescapeFragment=ne.schemaRefOrVal=ne.schemaHasRulesButRef=ne.schemaHasRules=ne.checkUnknownRules=ne.alwaysValidSchema=ne.toHash=void 0;var we=te(),L4=kc();function q4(t){let e={};for(let r of t)e[r]=!0;return e}ne.toHash=q4;function D4(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(q1(t,e),!D1(e,t.self.RULES.all))}ne.alwaysValidSchema=D4;function q1(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let i in e)s[i]||F1(t,`unknown keyword: "${i}"`)}ne.checkUnknownRules=q1;function D1(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ne.schemaHasRules=D1;function Z4(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ne.schemaHasRulesButRef=Z4;function U4({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${t}${e}${(0,we.getProperty)(n)}`}ne.schemaRefOrVal=U4;function F4(t){return Z1(decodeURIComponent(t))}ne.unescapeFragment=F4;function B4(t){return encodeURIComponent(Hb(t))}ne.escapeFragment=B4;function Hb(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ne.escapeJsonPointer=Hb;function Z1(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ne.unescapeJsonPointer=Z1;function V4(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ne.eachItem=V4;function j1({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,i,o,a)=>{let c=o===void 0?i:o instanceof we.Name?(i instanceof we.Name?t(s,i,o):e(s,i,o),o):i instanceof we.Name?(e(s,o,i),i):r(i,o);return a===we.Name&&!(c instanceof we.Name)?n(s,c):c}}ne.mergeEvaluated={props:j1({mergeNames:(t,e,r)=>t.if((0,we._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,we._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,we._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,we._)`${r} || {}`),Wb(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:U1}),items:j1({mergeNames:(t,e,r)=>t.if((0,we._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,we._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,we._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,we._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function U1(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,we._)`{}`);return e!==void 0&&Wb(t,r,e),r}ne.evaluatedPropsToName=U1;function Wb(t,e,r){Object.keys(r).forEach(n=>t.assign((0,we._)`${e}${(0,we.getProperty)(n)}`,!0))}ne.setEvaluated=Wb;var L1={};function H4(t,e){return t.scopeValue("func",{ref:e,code:L1[e.code]||(L1[e.code]=new L4._Code(e.code))})}ne.useFunc=H4;var Vb;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vb||(ne.Type=Vb={}));function W4(t,e,r){if(t instanceof we.Name){let n=e===Vb.Num;return r?n?(0,we._)`"[" + ${t} + "]"`:(0,we._)`"['" + ${t} + "']"`:n?(0,we._)`"/" + ${t}`:(0,we._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(t).toString():"/"+Hb(t)}ne.getErrorPath=W4;function F1(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ne.checkStrictMode=F1});var Yr=w(Kb=>{"use strict";Object.defineProperty(Kb,"__esModule",{value:!0});var at=te(),K4={data:new at.Name("data"),valCxt:new at.Name("valCxt"),instancePath:new at.Name("instancePath"),parentData:new at.Name("parentData"),parentDataProperty:new at.Name("parentDataProperty"),rootData:new at.Name("rootData"),dynamicAnchors:new at.Name("dynamicAnchors"),vErrors:new at.Name("vErrors"),errors:new at.Name("errors"),this:new at.Name("this"),self:new at.Name("self"),scope:new at.Name("scope"),json:new at.Name("json"),jsonPos:new at.Name("jsonPos"),jsonLen:new at.Name("jsonLen"),jsonPart:new at.Name("jsonPart")};Kb.default=K4});var Ic=w(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.extendErrors=ct.resetErrorsCount=ct.reportExtraError=ct.reportError=ct.keyword$DataError=ct.keywordError=void 0;var pe=te(),bf=fe(),ht=Yr();ct.keywordError={message:({keyword:t})=>(0,pe.str)`must pass "${t}" keyword validation`};ct.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,pe.str)`"${t}" keyword must be ${e} ($data)`:(0,pe.str)`"${t}" keyword is invalid ($data)`};function J4(t,e=ct.keywordError,r,n){let{it:s}=t,{gen:i,compositeRule:o,allErrors:a}=s,c=H1(t,e,r);n??(o||a)?B1(i,c):V1(s,(0,pe._)`[${c}]`)}ct.reportError=J4;function G4(t,e=ct.keywordError,r){let{it:n}=t,{gen:s,compositeRule:i,allErrors:o}=n,a=H1(t,e,r);B1(s,a),i||o||V1(n,ht.default.vErrors)}ct.reportExtraError=G4;function Y4(t,e){t.assign(ht.default.errors,e),t.if((0,pe._)`${ht.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,pe._)`${ht.default.vErrors}.length`,e),()=>t.assign(ht.default.vErrors,null)))}ct.resetErrorsCount=Y4;function X4({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:i}){if(s===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",s,ht.default.errors,a=>{t.const(o,(0,pe._)`${ht.default.vErrors}[${a}]`),t.if((0,pe._)`${o}.instancePath === undefined`,()=>t.assign((0,pe._)`${o}.instancePath`,(0,pe.strConcat)(ht.default.instancePath,i.errorPath))),t.assign((0,pe._)`${o}.schemaPath`,(0,pe.str)`${i.errSchemaPath}/${e}`),i.opts.verbose&&(t.assign((0,pe._)`${o}.schema`,r),t.assign((0,pe._)`${o}.data`,n))})}ct.extendErrors=X4;function B1(t,e){let r=t.const("err",e);t.if((0,pe._)`${ht.default.vErrors} === null`,()=>t.assign(ht.default.vErrors,(0,pe._)`[${r}]`),(0,pe._)`${ht.default.vErrors}.push(${r})`),t.code((0,pe._)`${ht.default.errors}++`)}function V1(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,pe._)`new ${t.ValidationError}(${e})`):(r.assign((0,pe._)`${n}.errors`,e),r.return(!1))}var Bs={keyword:new pe.Name("keyword"),schemaPath:new pe.Name("schemaPath"),params:new pe.Name("params"),propertyName:new pe.Name("propertyName"),message:new pe.Name("message"),schema:new pe.Name("schema"),parentSchema:new pe.Name("parentSchema")};function H1(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,pe._)`{}`:Q4(t,e,r)}function Q4(t,e,r={}){let{gen:n,it:s}=t,i=[eB(s,r),tB(t,r)];return rB(t,e,i),n.object(...i)}function eB({errorPath:t},{instancePath:e}){let r=e?(0,pe.str)`${t}${(0,bf.getErrorPath)(e,bf.Type.Str)}`:t;return[ht.default.instancePath,(0,pe.strConcat)(ht.default.instancePath,r)]}function tB({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,pe.str)`${e}/${t}`;return r&&(s=(0,pe.str)`${s}${(0,bf.getErrorPath)(r,bf.Type.Str)}`),[Bs.schemaPath,s]}function rB(t,{params:e,message:r},n){let{keyword:s,data:i,schemaValue:o,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Bs.keyword,s],[Bs.params,typeof e=="function"?e(t):e||(0,pe._)`{}`]),c.messages&&n.push([Bs.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Bs.schema,o],[Bs.parentSchema,(0,pe._)`${l}${d}`],[ht.default.data,i]),u&&n.push([Bs.propertyName,u])}});var K1=w(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.boolOrEmptySchema=ho.topBoolOrEmptySchema=void 0;var nB=Ic(),sB=te(),iB=Yr(),oB={message:"boolean schema is false"};function aB(t){let{gen:e,schema:r,validateName:n}=t;r===!1?W1(t,!1):typeof r=="object"&&r.$async===!0?e.return(iB.default.data):(e.assign((0,sB._)`${n}.errors`,null),e.return(!0))}ho.topBoolOrEmptySchema=aB;function cB(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),W1(t)):r.var(e,!0)}ho.boolOrEmptySchema=cB;function W1(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,nB.reportError)(s,oB,void 0,e)}});var Jb=w(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.getRules=mo.isJSONType=void 0;var uB=["string","number","integer","boolean","null","object","array"],lB=new Set(uB);function dB(t){return typeof t=="string"&&lB.has(t)}mo.isJSONType=dB;function fB(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}mo.getRules=fB});var Gb=w(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.shouldUseRule=Cn.shouldUseGroup=Cn.schemaHasRulesForType=void 0;function pB({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&J1(t,n)}Cn.schemaHasRulesForType=pB;function J1(t,e){return e.rules.some(r=>G1(t,r))}Cn.shouldUseGroup=J1;function G1(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Cn.shouldUseRule=G1});var Ac=w(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.reportTypeError=ut.checkDataTypes=ut.checkDataType=ut.coerceAndCheckDataType=ut.getJSONTypes=ut.getSchemaTypes=ut.DataType=void 0;var hB=Jb(),mB=Gb(),gB=Ic(),X=te(),Y1=fe(),go;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(go||(ut.DataType=go={}));function yB(t){let e=X1(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}ut.getSchemaTypes=yB;function X1(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(hB.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}ut.getJSONTypes=X1;function _B(t,e){let{gen:r,data:n,opts:s}=t,i=bB(e,s.coerceTypes),o=e.length>0&&!(i.length===0&&e.length===1&&(0,mB.schemaHasRulesForType)(t,e[0]));if(o){let a=Xb(e,n,s.strictNumbers,go.Wrong);r.if(a,()=>{i.length?wB(t,e,i):Qb(t)})}return o}ut.coerceAndCheckDataType=_B;var Q1=new Set(["string","number","integer","boolean","null"]);function bB(t,e){return e?t.filter(r=>Q1.has(r)||e==="array"&&r==="array"):[]}function wB(t,e,r){let{gen:n,data:s,opts:i}=t,o=n.let("dataType",(0,X._)`typeof ${s}`),a=n.let("coerced",(0,X._)`undefined`);i.coerceTypes==="array"&&n.if((0,X._)`${o} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,X._)`${s}[0]`).assign(o,(0,X._)`typeof ${s}`).if(Xb(e,s,i.strictNumbers),()=>n.assign(a,s))),n.if((0,X._)`${a} !== undefined`);for(let u of r)(Q1.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);n.else(),Qb(t),n.endIf(),n.if((0,X._)`${a} !== undefined`,()=>{n.assign(s,a),vB(t,a)});function c(u){switch(u){case"string":n.elseIf((0,X._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,X._)`"" + ${s}`).elseIf((0,X._)`${s} === null`).assign(a,(0,X._)`""`);return;case"number":n.elseIf((0,X._)`${o} == "boolean" || ${s} === null
|
|
183
|
+
]`;continue}s+=n[c],n[c]==="\\"?i=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(o=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}var ib,ar,y4,cf=$(()=>{Mn();ar={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:()=>(ib===void 0&&(ib=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ib),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};y4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function uf(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===O.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Re(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===O.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=af(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===O.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===O.ZodBranded&&t.keyType._def.type._def.typeName===O.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=sf(t.keyType._def,e);return{...r,propertyNames:s}}}return r}var lf=$(()=>{Ga();Ue();cf();of();Gt()});function d1(t,e){if(e.mapStrategy==="record")return uf(t,e);let r=W(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Re(e),n=W(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Re(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}var ab=$(()=>{Ue();lf();Gt()});function f1(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}var cb=$(()=>{});function p1(t){return t.target==="openAi"?void 0:{not:Re({...t,currentPath:[...t.currentPath,"not"]})}}var ub=$(()=>{Gt()});function h1(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var lb=$(()=>{});function g1(t,e){if(e.target==="openApi3")return m1(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in xc&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=xc[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,a)=>a.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return m1(t,e)}var xc,m1,df=$(()=>{Ue();xc={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};m1=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>W(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0}});function y1(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:xc[t.innerType._def.typeName],nullable:!0}:{type:[xc[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=W(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=W(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}var db=$(()=>{Ue();df()});function _1(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",W_(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ae(r,"minimum",n.value,n.message,e):ae(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ae(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ae(r,"maximum",n.value,n.message,e):ae(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ae(r,"maximum",n.value,n.message,e));break;case"multipleOf":ae(r,"multipleOf",n.value,n.message,e);break}return r}var fb=$(()=>{Mn()});function b1(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},s=[],i=t.shape();for(let a in i){let c=i[a];if(c===void 0||c._def===void 0)continue;let u=w4(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=W(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||s.push(a))}s.length&&(n.required=s);let o=b4(t,e);return o!==void 0&&(n.additionalProperties=o),n}function b4(t,e){if(t.catchall._def.typeName!=="ZodNever")return W(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function w4(t){try{return t.isOptional()}catch{return!0}}var pb=$(()=>{Ue()});var w1,hb=$(()=>{Ue();Gt();w1=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return W(t.innerType._def,e);let r=W(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Re(e)},r]}:Re(e)}});var v1,mb=$(()=>{Ue();v1=(t,e)=>{if(e.pipeStrategy==="input")return W(t.in._def,e);if(e.pipeStrategy==="output")return W(t.out._def,e);let r=W(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=W(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}}});function x1(t,e){return W(t.type._def,e)}var gb=$(()=>{Ue()});function S1(t,e){let n={type:"array",uniqueItems:!0,items:W(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ae(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ae(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}var yb=$(()=>{Mn();Ue()});function k1(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>W(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:W(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>W(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}var _b=$(()=>{Ue()});function $1(t){return{not:Re(t)}}var bb=$(()=>{Gt()});function E1(t){return Re(t)}var wb=$(()=>{Gt()});var T1,vb=$(()=>{Ue();T1=(t,e)=>W(t.innerType._def,e)});var P1,xb=$(()=>{Ga();Gt();K_();J_();G_();of();Y_();Q_();eb();tb();rb();nb();sb();ab();cb();ub();lb();db();fb();pb();hb();mb();gb();lf();yb();cf();_b();bb();df();wb();vb();P1=(t,e,r)=>{switch(e){case O.ZodString:return af(t,r);case O.ZodNumber:return _1(t,r);case O.ZodObject:return b1(t,r);case O.ZodBigInt:return r1(t,r);case O.ZodBoolean:return n1();case O.ZodDate:return X_(t,r);case O.ZodUndefined:return $1(r);case O.ZodNull:return h1(r);case O.ZodArray:return t1(t,r);case O.ZodUnion:case O.ZodDiscriminatedUnion:return g1(t,r);case O.ZodIntersection:return c1(t,r);case O.ZodTuple:return k1(t,r);case O.ZodRecord:return uf(t,r);case O.ZodLiteral:return u1(t,r);case O.ZodEnum:return a1(t);case O.ZodNativeEnum:return f1(t);case O.ZodNullable:return y1(t,r);case O.ZodOptional:return w1(t,r);case O.ZodMap:return d1(t,r);case O.ZodSet:return S1(t,r);case O.ZodLazy:return()=>t.getter()._def;case O.ZodPromise:return x1(t,r);case O.ZodNaN:case O.ZodNever:return p1(r);case O.ZodEffects:return o1(t,r);case O.ZodAny:return Re(r);case O.ZodUnknown:return E1(r);case O.ZodDefault:return i1(t,r);case O.ZodBranded:return sf(t,r);case O.ZodReadonly:return T1(t,r);case O.ZodCatch:return s1(t,r);case O.ZodPipeline:return v1(t,r);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return(n=>{})(e)}}});function W(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==XP)return a}if(n&&!r){let a=v4(n,e);if(a!==void 0)return a}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=P1(t,t.typeName,e),o=typeof i=="function"?W(i(),e):i;if(o&&x4(t,e,o),e.postProcess){let a=e.postProcess(o,t,e);return s.jsonSchema=o,a}return s.jsonSchema=o,o}var v4,x4,Ue=$(()=>{tf();xb();nf();Gt();v4=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:rf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Re(e)):e.$refStrategy==="seen"?Re(e):void 0}},x4=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r)});var O1=$(()=>{});var Sb,kb=$(()=>{Ue();H_();Gt();Sb=(t,e)=>{let r=e1(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:W(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Re(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=W(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Re(r),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=s===void 0?n?{...i,[r.definitionPath]:n}:i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:i}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var I1=$(()=>{tf();H_();Mn();nf();Ue();O1();Gt();K_();J_();G_();of();Y_();Q_();eb();tb();rb();nb();sb();ab();cb();ub();lb();db();fb();pb();hb();mb();gb();vb();lf();yb();cf();_b();bb();df();wb();xb();kb();kb()});function S4(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function $b(t,e){return Wt(t)?f_(t,{target:S4(e?.target),io:e?.pipeStrategy??"input"}):Sb(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Eb(t){let r=Nn(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ad(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Tb(t,e){let r=An(t,e);if(!r.success)throw r.error;return r.data}var Pb=$(()=>{m_();uc();I1()});function A1(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function N1(t,e){let r={...t};for(let n in e){let s=n,i=e[s];if(i===void 0)continue;let o=r[s];A1(o)&&A1(i)?r[s]={...o,...i}:r[s]=i}return r}var k4,ff,R1=$(()=>{uc();fo();GP();Pb();k4=6e4,ff=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ld,r=>{this._oncancel(r)}),this.setNotificationHandler(Dd,r=>{this._onprogress(r)}),this.setRequestHandler(qd,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Zd,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new D(F.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Fd,async(r,n)=>{let s=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new D(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let o=await this._taskStore.getTask(i,n.sessionId);if(!o)throw new D(F.InvalidParams,`Task not found: ${i}`);if(!zn(o.status))return await this._waitForTaskUpdate(i,n.signal),await s();if(zn(o.status)){let a=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...a,_meta:{...a._meta,[Rn]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(Bd,async(r,n)=>{try{let{tasks:s,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:i,_meta:{}}}catch(s){throw new D(F.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Hd,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new D(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(zn(s.status))throw new D(F.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(s){throw s instanceof D?s:new D(F.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),D.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=i=>{n?.(i),this._onerror(i)};let s=this._transport?.onmessage;this._transport.onmessage=(i,o)=>{s?.(i,o),pc(i)||qP(i)?this._onresponse(i):N_(i)?this._onrequest(i,o):LP(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=D.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,i=e.params?._meta?.[Rn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:F.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):s?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let a=MP(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,u={signal:o.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(o.signal.aborted)return;let d={relatedRequestId:e.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(o.signal.aborted)throw new D(F.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:e.id};i&&!p.relatedTask&&(p.relatedTask={taskId:i});let m=p.relatedTask?.taskId??i;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(o.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)},async l=>{if(o.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:F.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===o&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,s=Number(r),i=this._progressHandlers.get(s);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let o=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),o(c);return}i(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),pc(e))n(e);else{let o=new D(e.error.code,e.error.message,e.error.data);n(o)}return}let s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(pc(e)&&e.result&&typeof e.result=="object"){let o=e.result;if(o.task&&typeof o.task=="object"){let a=o.task;typeof a.taskId=="string"&&(i=!0,this._taskProgressTokens.set(a.taskId,r))}}if(i||this._progressHandlers.delete(r),pc(e))s(e);else{let o=D.fromError(e.error.code,e.error.message,e.error.data);s(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(o){yield{type:"error",error:o instanceof D?o:new D(F.InternalError,String(o))}}return}let i;try{let o=await this.request(e,ao,n);if(o.task)i=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new D(F.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:a},zn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:a.status==="failed"?yield{type:"error",error:new D(F.InternalError,`Task ${i} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new D(F.InternalError,`Task ${i} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof D?o:new D(F.InternalError,String(o))}}}request(e,r,n){let{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){d(_);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Rn]:c}});let m=_=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(_)}},{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));let v=_ instanceof D?_:new D(F.RequestTimeout,String(_));l(v)};this._responseHandlers.set(f,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let v=An(r,_.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??k4,g=()=>m(D.fromError(F.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let _=v=>{let k=this._responseHandlers.get(f);k?k(v):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,_),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(f),l(v)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:o}).catch(_=>{this._cleanupTimeout(f),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ud,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Vd,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},UP,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Rn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Rn]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[Rn]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(e,r){let n=Eb(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,i)=>{let o=Tb(e,s);return Promise.resolve(r(o,i))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Eb(e);this._notificationHandlers.set(n,s=>{let i=Tb(e,s);return Promise.resolve(r(i))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let s of n)if(s.type==="request"&&N_(s.message)){let i=s.message.id,o=this._requestResolvers.get(i);o?(o(new D(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new D(F.InvalidRequest,"Request cancelled"));return}let o=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(o),i(new D(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{let i=await n.getTask(s,r);if(!i)throw new D(F.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(s,i,o)=>{await n.storeTaskResult(s,i,o,r);let a=await n.getTask(s,r);if(a){let c=_c.parse({method:"notifications/tasks/status",params:a});await this.notification(c),zn(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,i,o)=>{let a=await n.getTask(s,r);if(!a)throw new D(F.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(zn(a.status))throw new D(F.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,i,o,r);let c=await n.getTask(s,r);if(c){let u=_c.parse({method:"notifications/tasks/status",params:c});await this.notification(u),zn(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}});var $c=w(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.regexpCode=he.getEsmExportName=he.getProperty=he.safeStringify=he.stringify=he.strConcat=he.addCodeArg=he.str=he._=he.nil=he._Code=he.Name=he.IDENTIFIER=he._CodeOrName=void 0;var Sc=class{};he._CodeOrName=Sc;he.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Zs=class extends Sc{constructor(e){if(super(),!he.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};he.Name=Zs;var Yt=class extends Sc{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Zs&&(r[n.str]=(r[n.str]||0)+1),r),{})}};he._Code=Yt;he.nil=new Yt("");function z1(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Ib(r,e[n]),r.push(t[++n]);return new Yt(r)}he._=z1;var Ob=new Yt("+");function M1(t,...e){let r=[kc(t[0])],n=0;for(;n<e.length;)r.push(Ob),Ib(r,e[n]),r.push(Ob,kc(t[++n]));return $4(r),new Yt(r)}he.str=M1;function Ib(t,e){e instanceof Yt?t.push(...e._items):e instanceof Zs?t.push(e):t.push(P4(e))}he.addCodeArg=Ib;function $4(t){let e=1;for(;e<t.length-1;){if(t[e]===Ob){let r=E4(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function E4(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Zs||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Zs))return`"${t}${e.slice(1)}`}function T4(t,e){return e.emptyStr()?t:t.emptyStr()?e:M1`${t}${e}`}he.strConcat=T4;function P4(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:kc(Array.isArray(t)?t.join(","):t)}function O4(t){return new Yt(kc(t))}he.stringify=O4;function kc(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}he.safeStringify=kc;function I4(t){return typeof t=="string"&&he.IDENTIFIER.test(t)?new Yt(`.${t}`):z1`[${t}]`}he.getProperty=I4;function A4(t){if(typeof t=="string"&&he.IDENTIFIER.test(t))return new Yt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}he.getEsmExportName=A4;function N4(t){return new Yt(t.toString())}he.regexpCode=N4});var Rb=w($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.ValueScope=$t.ValueScopeName=$t.Scope=$t.varKinds=$t.UsedValueState=void 0;var kt=$c(),Ab=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},pf;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(pf||($t.UsedValueState=pf={}));$t.varKinds={const:new kt.Name("const"),let:new kt.Name("let"),var:new kt.Name("var")};var hf=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof kt.Name?e:this.name(e)}name(e){return new kt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};$t.Scope=hf;var mf=class extends kt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,kt._)`.${new kt.Name(r)}[${n}]`}};$t.ValueScopeName=mf;var R4=(0,kt._)`\n`,Nb=class extends hf{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?R4:kt.nil}}get(){return this._scope}name(e){return new mf(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:i}=s,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[i];if(a){let l=a.get(o);if(l)return l}else a=this._values[i]=new Map;a.set(o,s);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=r.ref,s.setValue(r,{property:i,itemIndex:u}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,kt._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let i=kt.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,pf.Started);let l=r(u);if(l){let d=this.opts.es5?$t.varKinds.var:$t.varKinds.const;i=(0,kt._)`${i}${d} ${u} = ${l};${this.opts._n}`}else if(l=s?.(u))i=(0,kt._)`${i}${l}${this.opts._n}`;else throw new Ab(u);c.set(u,pf.Completed)})}return i}};$t.ValueScope=Nb});var te=w(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.or=re.and=re.not=re.CodeGen=re.operators=re.varKinds=re.ValueScopeName=re.ValueScope=re.Scope=re.Name=re.regexpCode=re.stringify=re.getProperty=re.nil=re.strConcat=re.str=re._=void 0;var ce=$c(),ur=Rb(),Cn=$c();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return Cn._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return Cn.str}});Object.defineProperty(re,"strConcat",{enumerable:!0,get:function(){return Cn.strConcat}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return Cn.nil}});Object.defineProperty(re,"getProperty",{enumerable:!0,get:function(){return Cn.getProperty}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return Cn.stringify}});Object.defineProperty(re,"regexpCode",{enumerable:!0,get:function(){return Cn.regexpCode}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return Cn.Name}});var bf=Rb();Object.defineProperty(re,"Scope",{enumerable:!0,get:function(){return bf.Scope}});Object.defineProperty(re,"ValueScope",{enumerable:!0,get:function(){return bf.ValueScope}});Object.defineProperty(re,"ValueScopeName",{enumerable:!0,get:function(){return bf.ValueScopeName}});Object.defineProperty(re,"varKinds",{enumerable:!0,get:function(){return bf.varKinds}});re.operators={GT:new ce._Code(">"),GTE:new ce._Code(">="),LT:new ce._Code("<"),LTE:new ce._Code("<="),EQ:new ce._Code("==="),NEQ:new ce._Code("!=="),NOT:new ce._Code("!"),OR:new ce._Code("||"),AND:new ce._Code("&&"),ADD:new ce._Code("+")};var Gr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},zb=class extends Gr{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?ur.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ho(this.rhs,e,r)),this}get names(){return this.rhs instanceof ce._CodeOrName?this.rhs.names:{}}},gf=class extends Gr{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ce.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ho(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ce.Name?{}:{...this.lhs.names};return _f(e,this.rhs)}},Mb=class extends gf{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Cb=class extends Gr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},jb=class extends Gr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Lb=class extends Gr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},qb=class extends Gr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ho(this.code,e,r),this}get names(){return this.code instanceof ce._CodeOrName?this.code.names:{}}},Ec=class extends Gr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let i=n[s];i.optimizeNames(e,r)||(z4(e,i.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Bs(e,r.names),{})}},Yr=class extends Ec{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Db=class extends Ec{},po=class extends Yr{};po.kind="else";var Us=class t extends Yr{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new po(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(C1(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ho(this.condition,e,r),this}get names(){let e=super.names;return _f(e,this.condition),this.else&&Bs(e,this.else.names),e}};Us.kind="if";var Fs=class extends Yr{};Fs.kind="for";var Zb=class extends Fs{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ho(this.iteration,e,r),this}get names(){return Bs(super.names,this.iteration.names)}},Ub=class extends Fs{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?ur.varKinds.var:this.varKind,{name:n,from:s,to:i}=this;return`for(${r} ${n}=${s}; ${n}<${i}; ${n}++)`+super.render(e)}get names(){let e=_f(super.names,this.from);return _f(e,this.to)}},yf=class extends Fs{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ho(this.iterable,e,r),this}get names(){return Bs(super.names,this.iterable.names)}},Tc=class extends Yr{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Tc.kind="func";var Pc=class extends Ec{render(e){return"return "+super.render(e)}};Pc.kind="return";var Fb=class extends Yr{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Bs(e,this.catch.names),this.finally&&Bs(e,this.finally.names),e}},Oc=class extends Yr{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Oc.kind="catch";var Ic=class extends Yr{render(e){return"finally"+super.render(e)}};Ic.kind="finally";var Bb=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
184
|
+
`:""},this._extScope=e,this._scope=new ur.Scope({parent:e}),this._nodes=[new Db]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let i=this._scope.toName(r);return n!==void 0&&s&&(this._constants[i.str]=n),this._leafNode(new zb(e,i,n)),i}const(e,r,n){return this._def(ur.varKinds.const,e,r,n)}let(e,r,n){return this._def(ur.varKinds.let,e,r,n)}var(e,r,n){return this._def(ur.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new gf(e,r,n))}add(e,r){return this._leafNode(new Mb(e,re.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ce.nil&&this._leafNode(new qb(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,ce.addCodeArg)(r,s));return r.push("}"),new ce._Code(r)}if(e,r,n){if(this._blockNode(new Us(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Us(e))}else(){return this._elseNode(new po)}endIf(){return this._endBlockNode(Us,po)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Zb(e),r)}forRange(e,r,n,s,i=this.opts.es5?ur.varKinds.var:ur.varKinds.let){let o=this._scope.toName(e);return this._for(new Ub(i,o,r,n),()=>s(o))}forOf(e,r,n,s=ur.varKinds.const){let i=this._scope.toName(e);if(this.opts.es5){let o=r instanceof ce.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ce._)`${o}.length`,a=>{this.var(i,(0,ce._)`${o}[${a}]`),n(i)})}return this._for(new yf("of",s,i,r),()=>n(i))}forIn(e,r,n,s=this.opts.es5?ur.varKinds.var:ur.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ce._)`Object.keys(${r})`,n);let i=this._scope.toName(e);return this._for(new yf("in",s,i,r),()=>n(i))}endFor(){return this._endBlockNode(Fs)}label(e){return this._leafNode(new Cb(e))}break(e){return this._leafNode(new jb(e))}return(e){let r=new Pc;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Pc)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Fb;if(this._blockNode(s),this.code(e),r){let i=this.name("e");this._currNode=s.catch=new Oc(i),r(i)}return n&&(this._currNode=s.finally=new Ic,this.code(n)),this._endBlockNode(Oc,Ic)}throw(e){return this._leafNode(new Lb(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ce.nil,n,s){return this._blockNode(new Tc(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Tc)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Us))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};re.CodeGen=Bb;function Bs(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function _f(t,e){return e instanceof ce._CodeOrName?Bs(t,e.names):t}function ho(t,e,r){if(t instanceof ce.Name)return n(t);if(!s(t))return t;return new ce._Code(t._items.reduce((i,o)=>(o instanceof ce.Name&&(o=n(o)),o instanceof ce._Code?i.push(...o._items):i.push(o),i),[]));function n(i){let o=r[i.str];return o===void 0||e[i.str]!==1?i:(delete e[i.str],o)}function s(i){return i instanceof ce._Code&&i._items.some(o=>o instanceof ce.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function z4(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function C1(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ce._)`!${Vb(t)}`}re.not=C1;var M4=j1(re.operators.AND);function C4(...t){return t.reduce(M4)}re.and=C4;var j4=j1(re.operators.OR);function L4(...t){return t.reduce(j4)}re.or=L4;function j1(t){return(e,r)=>e===ce.nil?r:r===ce.nil?e:(0,ce._)`${Vb(e)} ${t} ${Vb(r)}`}function Vb(t){return t instanceof ce.Name?t:(0,ce._)`(${t})`}});var fe=w(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.checkStrictMode=ne.getErrorPath=ne.Type=ne.useFunc=ne.setEvaluated=ne.evaluatedPropsToName=ne.mergeEvaluated=ne.eachItem=ne.unescapeJsonPointer=ne.escapeJsonPointer=ne.escapeFragment=ne.unescapeFragment=ne.schemaRefOrVal=ne.schemaHasRulesButRef=ne.schemaHasRules=ne.checkUnknownRules=ne.alwaysValidSchema=ne.toHash=void 0;var we=te(),q4=$c();function D4(t){let e={};for(let r of t)e[r]=!0;return e}ne.toHash=D4;function Z4(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(D1(t,e),!Z1(e,t.self.RULES.all))}ne.alwaysValidSchema=Z4;function D1(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let i in e)s[i]||B1(t,`unknown keyword: "${i}"`)}ne.checkUnknownRules=D1;function Z1(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ne.schemaHasRules=Z1;function U4(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ne.schemaHasRulesButRef=U4;function F4({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${t}${e}${(0,we.getProperty)(n)}`}ne.schemaRefOrVal=F4;function B4(t){return U1(decodeURIComponent(t))}ne.unescapeFragment=B4;function V4(t){return encodeURIComponent(Wb(t))}ne.escapeFragment=V4;function Wb(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ne.escapeJsonPointer=Wb;function U1(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ne.unescapeJsonPointer=U1;function H4(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ne.eachItem=H4;function L1({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,i,o,a)=>{let c=o===void 0?i:o instanceof we.Name?(i instanceof we.Name?t(s,i,o):e(s,i,o),o):i instanceof we.Name?(e(s,o,i),i):r(i,o);return a===we.Name&&!(c instanceof we.Name)?n(s,c):c}}ne.mergeEvaluated={props:L1({mergeNames:(t,e,r)=>t.if((0,we._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,we._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,we._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,we._)`${r} || {}`),Kb(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:F1}),items:L1({mergeNames:(t,e,r)=>t.if((0,we._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,we._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,we._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,we._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function F1(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,we._)`{}`);return e!==void 0&&Kb(t,r,e),r}ne.evaluatedPropsToName=F1;function Kb(t,e,r){Object.keys(r).forEach(n=>t.assign((0,we._)`${e}${(0,we.getProperty)(n)}`,!0))}ne.setEvaluated=Kb;var q1={};function W4(t,e){return t.scopeValue("func",{ref:e,code:q1[e.code]||(q1[e.code]=new q4._Code(e.code))})}ne.useFunc=W4;var Hb;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Hb||(ne.Type=Hb={}));function K4(t,e,r){if(t instanceof we.Name){let n=e===Hb.Num;return r?n?(0,we._)`"[" + ${t} + "]"`:(0,we._)`"['" + ${t} + "']"`:n?(0,we._)`"/" + ${t}`:(0,we._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(t).toString():"/"+Wb(t)}ne.getErrorPath=K4;function B1(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ne.checkStrictMode=B1});var Xr=w(Jb=>{"use strict";Object.defineProperty(Jb,"__esModule",{value:!0});var ct=te(),J4={data:new ct.Name("data"),valCxt:new ct.Name("valCxt"),instancePath:new ct.Name("instancePath"),parentData:new ct.Name("parentData"),parentDataProperty:new ct.Name("parentDataProperty"),rootData:new ct.Name("rootData"),dynamicAnchors:new ct.Name("dynamicAnchors"),vErrors:new ct.Name("vErrors"),errors:new ct.Name("errors"),this:new ct.Name("this"),self:new ct.Name("self"),scope:new ct.Name("scope"),json:new ct.Name("json"),jsonPos:new ct.Name("jsonPos"),jsonLen:new ct.Name("jsonLen"),jsonPart:new ct.Name("jsonPart")};Jb.default=J4});var Ac=w(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.extendErrors=ut.resetErrorsCount=ut.reportExtraError=ut.reportError=ut.keyword$DataError=ut.keywordError=void 0;var pe=te(),wf=fe(),mt=Xr();ut.keywordError={message:({keyword:t})=>(0,pe.str)`must pass "${t}" keyword validation`};ut.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,pe.str)`"${t}" keyword must be ${e} ($data)`:(0,pe.str)`"${t}" keyword is invalid ($data)`};function G4(t,e=ut.keywordError,r,n){let{it:s}=t,{gen:i,compositeRule:o,allErrors:a}=s,c=W1(t,e,r);n??(o||a)?V1(i,c):H1(s,(0,pe._)`[${c}]`)}ut.reportError=G4;function Y4(t,e=ut.keywordError,r){let{it:n}=t,{gen:s,compositeRule:i,allErrors:o}=n,a=W1(t,e,r);V1(s,a),i||o||H1(n,mt.default.vErrors)}ut.reportExtraError=Y4;function X4(t,e){t.assign(mt.default.errors,e),t.if((0,pe._)`${mt.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,pe._)`${mt.default.vErrors}.length`,e),()=>t.assign(mt.default.vErrors,null)))}ut.resetErrorsCount=X4;function Q4({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:i}){if(s===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",s,mt.default.errors,a=>{t.const(o,(0,pe._)`${mt.default.vErrors}[${a}]`),t.if((0,pe._)`${o}.instancePath === undefined`,()=>t.assign((0,pe._)`${o}.instancePath`,(0,pe.strConcat)(mt.default.instancePath,i.errorPath))),t.assign((0,pe._)`${o}.schemaPath`,(0,pe.str)`${i.errSchemaPath}/${e}`),i.opts.verbose&&(t.assign((0,pe._)`${o}.schema`,r),t.assign((0,pe._)`${o}.data`,n))})}ut.extendErrors=Q4;function V1(t,e){let r=t.const("err",e);t.if((0,pe._)`${mt.default.vErrors} === null`,()=>t.assign(mt.default.vErrors,(0,pe._)`[${r}]`),(0,pe._)`${mt.default.vErrors}.push(${r})`),t.code((0,pe._)`${mt.default.errors}++`)}function H1(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,pe._)`new ${t.ValidationError}(${e})`):(r.assign((0,pe._)`${n}.errors`,e),r.return(!1))}var Vs={keyword:new pe.Name("keyword"),schemaPath:new pe.Name("schemaPath"),params:new pe.Name("params"),propertyName:new pe.Name("propertyName"),message:new pe.Name("message"),schema:new pe.Name("schema"),parentSchema:new pe.Name("parentSchema")};function W1(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,pe._)`{}`:eB(t,e,r)}function eB(t,e,r={}){let{gen:n,it:s}=t,i=[tB(s,r),rB(t,r)];return nB(t,e,i),n.object(...i)}function tB({errorPath:t},{instancePath:e}){let r=e?(0,pe.str)`${t}${(0,wf.getErrorPath)(e,wf.Type.Str)}`:t;return[mt.default.instancePath,(0,pe.strConcat)(mt.default.instancePath,r)]}function rB({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,pe.str)`${e}/${t}`;return r&&(s=(0,pe.str)`${s}${(0,wf.getErrorPath)(r,wf.Type.Str)}`),[Vs.schemaPath,s]}function nB(t,{params:e,message:r},n){let{keyword:s,data:i,schemaValue:o,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Vs.keyword,s],[Vs.params,typeof e=="function"?e(t):e||(0,pe._)`{}`]),c.messages&&n.push([Vs.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Vs.schema,o],[Vs.parentSchema,(0,pe._)`${l}${d}`],[mt.default.data,i]),u&&n.push([Vs.propertyName,u])}});var J1=w(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.boolOrEmptySchema=mo.topBoolOrEmptySchema=void 0;var sB=Ac(),iB=te(),oB=Xr(),aB={message:"boolean schema is false"};function cB(t){let{gen:e,schema:r,validateName:n}=t;r===!1?K1(t,!1):typeof r=="object"&&r.$async===!0?e.return(oB.default.data):(e.assign((0,iB._)`${n}.errors`,null),e.return(!0))}mo.topBoolOrEmptySchema=cB;function uB(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),K1(t)):r.var(e,!0)}mo.boolOrEmptySchema=uB;function K1(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,sB.reportError)(s,aB,void 0,e)}});var Gb=w(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.getRules=go.isJSONType=void 0;var lB=["string","number","integer","boolean","null","object","array"],dB=new Set(lB);function fB(t){return typeof t=="string"&&dB.has(t)}go.isJSONType=fB;function pB(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}go.getRules=pB});var Yb=w(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.shouldUseRule=jn.shouldUseGroup=jn.schemaHasRulesForType=void 0;function hB({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&G1(t,n)}jn.schemaHasRulesForType=hB;function G1(t,e){return e.rules.some(r=>Y1(t,r))}jn.shouldUseGroup=G1;function Y1(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}jn.shouldUseRule=Y1});var Nc=w(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.reportTypeError=lt.checkDataTypes=lt.checkDataType=lt.coerceAndCheckDataType=lt.getJSONTypes=lt.getSchemaTypes=lt.DataType=void 0;var mB=Gb(),gB=Yb(),yB=Ac(),X=te(),X1=fe(),yo;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(yo||(lt.DataType=yo={}));function _B(t){let e=Q1(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}lt.getSchemaTypes=_B;function Q1(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(mB.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}lt.getJSONTypes=Q1;function bB(t,e){let{gen:r,data:n,opts:s}=t,i=wB(e,s.coerceTypes),o=e.length>0&&!(i.length===0&&e.length===1&&(0,gB.schemaHasRulesForType)(t,e[0]));if(o){let a=Qb(e,n,s.strictNumbers,yo.Wrong);r.if(a,()=>{i.length?vB(t,e,i):ew(t)})}return o}lt.coerceAndCheckDataType=bB;var eO=new Set(["string","number","integer","boolean","null"]);function wB(t,e){return e?t.filter(r=>eO.has(r)||e==="array"&&r==="array"):[]}function vB(t,e,r){let{gen:n,data:s,opts:i}=t,o=n.let("dataType",(0,X._)`typeof ${s}`),a=n.let("coerced",(0,X._)`undefined`);i.coerceTypes==="array"&&n.if((0,X._)`${o} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,X._)`${s}[0]`).assign(o,(0,X._)`typeof ${s}`).if(Qb(e,s,i.strictNumbers),()=>n.assign(a,s))),n.if((0,X._)`${a} !== undefined`);for(let u of r)(eO.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);n.else(),ew(t),n.endIf(),n.if((0,X._)`${a} !== undefined`,()=>{n.assign(s,a),xB(t,a)});function c(u){switch(u){case"string":n.elseIf((0,X._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,X._)`"" + ${s}`).elseIf((0,X._)`${s} === null`).assign(a,(0,X._)`""`);return;case"number":n.elseIf((0,X._)`${o} == "boolean" || ${s} === null
|
|
185
185
|
|| (${o} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,X._)`+${s}`);return;case"integer":n.elseIf((0,X._)`${o} === "boolean" || ${s} === null
|
|
186
186
|
|| (${o} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,X._)`+${s}`);return;case"boolean":n.elseIf((0,X._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,X._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,X._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,X._)`${o} === "string" || ${o} === "number"
|
|
187
|
-
|| ${o} === "boolean" || ${s} === null`).assign(a,(0,X._)`[${s}]`)}}}function vB({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,X._)`${e} !== undefined`,()=>t.assign((0,X._)`${e}[${r}]`,n))}function Yb(t,e,r,n=go.Correct){let s=n===go.Correct?X.operators.EQ:X.operators.NEQ,i;switch(t){case"null":return(0,X._)`${e} ${s} null`;case"array":i=(0,X._)`Array.isArray(${e})`;break;case"object":i=(0,X._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":i=o((0,X._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":i=o();break;default:return(0,X._)`typeof ${e} ${s} ${t}`}return n===go.Correct?i:(0,X.not)(i);function o(a=X.nil){return(0,X.and)((0,X._)`typeof ${e} == "number"`,a,r?(0,X._)`isFinite(${e})`:X.nil)}}ut.checkDataType=Yb;function Xb(t,e,r,n){if(t.length===1)return Yb(t[0],e,r,n);let s,i=(0,Y1.toHash)(t);if(i.array&&i.object){let o=(0,X._)`typeof ${e} != "object"`;s=i.null?o:(0,X._)`!${e} || ${o}`,delete i.null,delete i.array,delete i.object}else s=X.nil;i.number&&delete i.integer;for(let o in i)s=(0,X.and)(s,Yb(o,e,r,n));return s}ut.checkDataTypes=Xb;var xB={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,X._)`{type: ${t}}`:(0,X._)`{type: ${e}}`};function Qb(t){let e=SB(t);(0,gB.reportError)(e,xB)}ut.reportTypeError=Qb;function SB(t){let{gen:e,data:r,schema:n}=t,s=(0,Y1.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var tO=w(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});wf.assignDefaults=void 0;var yo=te(),kB=fe();function $B(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)eO(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,i)=>eO(t,i,s.default))}wf.assignDefaults=$B;function eO(t,e,r){let{gen:n,compositeRule:s,data:i,opts:o}=t;if(r===void 0)return;let a=(0,yo._)`${i}${(0,yo.getProperty)(e)}`;if(s){(0,kB.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,yo._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,yo._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,yo._)`${a} = ${(0,yo.stringify)(r)}`)}});var Yt=w(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.validateUnion=be.validateArray=be.usePattern=be.callValidateCode=be.schemaProperties=be.allSchemaProperties=be.noPropertyInData=be.propertyInData=be.isOwnProperty=be.hasPropFunc=be.reportMissingProp=be.checkMissingProp=be.checkReportMissingProp=void 0;var Ee=te(),ew=fe(),jn=Yr(),EB=fe();function TB(t,e){let{gen:r,data:n,it:s}=t;r.if(rw(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Ee._)`${e}`},!0),t.error()})}be.checkReportMissingProp=TB;function PB({gen:t,data:e,it:{opts:r}},n,s){return(0,Ee.or)(...n.map(i=>(0,Ee.and)(rw(t,e,i,r.ownProperties),(0,Ee._)`${s} = ${i}`)))}be.checkMissingProp=PB;function OB(t,e){t.setParams({missingProperty:e},!0),t.error()}be.reportMissingProp=OB;function rO(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ee._)`Object.prototype.hasOwnProperty`})}be.hasPropFunc=rO;function tw(t,e,r){return(0,Ee._)`${rO(t)}.call(${e}, ${r})`}be.isOwnProperty=tw;function IB(t,e,r,n){let s=(0,Ee._)`${e}${(0,Ee.getProperty)(r)} !== undefined`;return n?(0,Ee._)`${s} && ${tw(t,e,r)}`:s}be.propertyInData=IB;function rw(t,e,r,n){let s=(0,Ee._)`${e}${(0,Ee.getProperty)(r)} === undefined`;return n?(0,Ee.or)(s,(0,Ee.not)(tw(t,e,r))):s}be.noPropertyInData=rw;function nO(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}be.allSchemaProperties=nO;function AB(t,e){return nO(e).filter(r=>!(0,ew.alwaysValidSchema)(t,e[r]))}be.schemaProperties=AB;function NB({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:i},it:o},a,c,u){let l=u?(0,Ee._)`${t}, ${e}, ${n}${s}`:e,d=[[jn.default.instancePath,(0,Ee.strConcat)(jn.default.instancePath,i)],[jn.default.parentData,o.parentData],[jn.default.parentDataProperty,o.parentDataProperty],[jn.default.rootData,jn.default.rootData]];o.opts.dynamicRef&&d.push([jn.default.dynamicAnchors,jn.default.dynamicAnchors]);let f=(0,Ee._)`${l}, ${r.object(...d)}`;return c!==Ee.nil?(0,Ee._)`${a}.call(${c}, ${f})`:(0,Ee._)`${a}(${f})`}be.callValidateCode=NB;var RB=(0,Ee._)`new RegExp`;function zB({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,i=s(r,n);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Ee._)`${s.code==="new RegExp"?RB:(0,EB.useFunc)(t,s)}(${r}, ${n})`})}be.usePattern=zB;function MB(t){let{gen:e,data:r,keyword:n,it:s}=t,i=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(i,!0),o(()=>e.break()),i;function o(a){let c=e.const("len",(0,Ee._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:ew.Type.Num},i),e.if((0,Ee.not)(i),a)})}}be.validateArray=MB;function CB(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,ew.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(o,(0,Ee._)`${o} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,Ee.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}be.validateUnion=CB});var oO=w($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.validateKeywordUsage=$r.validSchemaType=$r.funcKeywordCode=$r.macroKeywordCode=void 0;var mt=te(),Vs=Yr(),jB=Yt(),LB=Ic();function qB(t,e){let{gen:r,keyword:n,schema:s,parentSchema:i,it:o}=t,a=e.macro.call(o.self,s,i,o),c=iO(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:mt.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}$r.macroKeywordCode=qB;function DB(t,e){var r;let{gen:n,keyword:s,schema:i,parentSchema:o,$data:a,it:c}=t;UB(c,e);let u=!a&&e.compile?e.compile.call(c.self,i,o,c):e.validate,l=iO(n,s,u),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&sO(t),g(()=>t.error());else{let y=e.async?p():m();e.modifying&&sO(t),g(()=>ZB(t,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,mt._)`await `),_=>n.assign(d,!1).if((0,mt._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,mt._)`${_}.errors`),()=>n.throw(_))),y}function m(){let y=(0,mt._)`${l}.errors`;return n.assign(y,null),h(mt.nil),y}function h(y=e.async?(0,mt._)`await `:mt.nil){let _=c.opts.passContext?Vs.default.this:Vs.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,mt._)`${y}${(0,jB.callValidateCode)(t,l,_,v)}`,e.modifying)}function g(y){var _;n.if((0,mt.not)((_=e.valid)!==null&&_!==void 0?_:d),y)}}$r.funcKeywordCode=DB;function sO(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,mt._)`${n.parentData}[${n.parentDataProperty}]`))}function ZB(t,e){let{gen:r}=t;r.if((0,mt._)`Array.isArray(${e})`,()=>{r.assign(Vs.default.vErrors,(0,mt._)`${Vs.default.vErrors} === null ? ${e} : ${Vs.default.vErrors}.concat(${e})`).assign(Vs.default.errors,(0,mt._)`${Vs.default.vErrors}.length`),(0,LB.extendErrors)(t)},()=>t.error())}function UB({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function iO(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,mt.stringify)(r)})}function FB(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}$r.validSchemaType=FB;function BB({schema:t,opts:e,self:r,errSchemaPath:n},s,i){if(Array.isArray(s.keyword)?!s.keyword.includes(i):s.keyword!==i)throw new Error("ajv implementation error");let o=s.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[i])){let c=`keyword "${i}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}$r.validateKeywordUsage=BB});var cO=w(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.extendSubschemaMode=Ln.extendSubschemaData=Ln.getSubschema=void 0;var Er=te(),aO=fe();function VB(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:i,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Er._)`${t.schemaPath}${(0,Er.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Er._)`${t.schemaPath}${(0,Er.getProperty)(e)}${(0,Er.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,aO.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||i===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:o,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}Ln.getSubschema=VB;function HB(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:i,propertyName:o}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,f=a.let("data",(0,Er._)`${e.data}${(0,Er.getProperty)(r)}`,!0);c(f),t.errorPath=(0,Er.str)`${u}${(0,aO.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Er._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let u=s instanceof Er.Name?s:a.let("data",s,!0);c(u),o!==void 0&&(t.propertyName=o)}i&&(t.dataTypes=i);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Ln.extendSubschemaData=HB;function WB(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:i}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),i!==void 0&&(t.allErrors=i),t.jtdDiscriminator=e,t.jtdMetadata=r}Ln.extendSubschemaMode=WB});var nw=w((Qre,uO)=>{"use strict";uO.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,i;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[s]))return!1;for(s=n;s--!==0;){var o=i[s];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var dO=w((ene,lO)=>{"use strict";var qn=lO.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};vf(e,n,s,t,"",t)};qn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};qn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};qn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};qn.skipKeywords={default:!0,enum:!0,const:!0,required:!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};function vf(t,e,r,n,s,i,o,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,i,o,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in qn.arrayKeywords)for(var f=0;f<d.length;f++)vf(t,e,r,d[f],s+"/"+l+"/"+f,i,s,l,n,f)}else if(l in qn.propsKeywords){if(d&&typeof d=="object")for(var p in d)vf(t,e,r,d[p],s+"/"+l+"/"+KB(p),i,s,l,n,p)}else(l in qn.keywords||t.allKeys&&!(l in qn.skipKeywords))&&vf(t,e,r,d,s+"/"+l,i,s,l,n)}r(n,s,i,o,a,c,u)}}function KB(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Nc=w($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.getSchemaRefs=$t.resolveUrl=$t.normalizeId=$t._getFullPath=$t.getFullPath=$t.inlineRef=void 0;var JB=fe(),GB=nw(),YB=dO(),XB=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function QB(t,e=!0){return typeof t=="boolean"?!0:e===!0?!sw(t):e?fO(t)<=e:!1}$t.inlineRef=QB;var e9=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function sw(t){for(let e in t){if(e9.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(sw)||typeof r=="object"&&sw(r))return!0}return!1}function fO(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!XB.has(r)&&(typeof t[r]=="object"&&(0,JB.eachItem)(t[r],n=>e+=fO(n)),e===1/0))return 1/0}return e}function pO(t,e="",r){r!==!1&&(e=_o(e));let n=t.parse(e);return hO(t,n)}$t.getFullPath=pO;function hO(t,e){return t.serialize(e).split("#")[0]+"#"}$t._getFullPath=hO;var t9=/#\/?$/;function _o(t){return t?t.replace(t9,""):""}$t.normalizeId=_o;function r9(t,e,r){return r=_o(r),t.resolve(e,r)}$t.resolveUrl=r9;var n9=/^[a-z_][-a-z0-9._]*$/i;function s9(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=_o(t[r]||e),i={"":s},o=pO(n,s,!1),a={},c=new Set;return YB(t,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=o+f,g=i[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),i[f]=g;function y(v){let k=this.opts.uriResolver.resolve;if(v=_o(g?k(g,v):v),c.has(v))throw l(v);c.add(v);let E=this.refs[v];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?u(d,E.schema,v):v!==_o(h)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=h),v}function _(v){if(typeof v=="string"){if(!n9.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function u(d,f,p){if(f!==void 0&&!GB(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}$t.getSchemaRefs=s9});var Mc=w(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.getData=Dn.KeywordCxt=Dn.validateFunctionCode=void 0;var bO=K1(),mO=Ac(),ow=Gb(),xf=Ac(),i9=tO(),zc=oO(),iw=cO(),U=te(),G=Yr(),o9=Nc(),Xr=fe(),Rc=Ic();function a9(t){if(xO(t)&&(SO(t),vO(t))){l9(t);return}wO(t,()=>(0,bO.topBoolOrEmptySchema)(t))}Dn.validateFunctionCode=a9;function wO({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},i){s.code.es5?t.func(e,(0,U._)`${G.default.data}, ${G.default.valCxt}`,n.$async,()=>{t.code((0,U._)`"use strict"; ${gO(r,s)}`),u9(t,s),t.code(i)}):t.func(e,(0,U._)`${G.default.data}, ${c9(s)}`,n.$async,()=>t.code(gO(r,s)).code(i))}function c9(t){return(0,U._)`{${G.default.instancePath}="", ${G.default.parentData}, ${G.default.parentDataProperty}, ${G.default.rootData}=${G.default.data}${t.dynamicRef?(0,U._)`, ${G.default.dynamicAnchors}={}`:U.nil}}={}`}function u9(t,e){t.if(G.default.valCxt,()=>{t.var(G.default.instancePath,(0,U._)`${G.default.valCxt}.${G.default.instancePath}`),t.var(G.default.parentData,(0,U._)`${G.default.valCxt}.${G.default.parentData}`),t.var(G.default.parentDataProperty,(0,U._)`${G.default.valCxt}.${G.default.parentDataProperty}`),t.var(G.default.rootData,(0,U._)`${G.default.valCxt}.${G.default.rootData}`),e.dynamicRef&&t.var(G.default.dynamicAnchors,(0,U._)`${G.default.valCxt}.${G.default.dynamicAnchors}`)},()=>{t.var(G.default.instancePath,(0,U._)`""`),t.var(G.default.parentData,(0,U._)`undefined`),t.var(G.default.parentDataProperty,(0,U._)`undefined`),t.var(G.default.rootData,G.default.data),e.dynamicRef&&t.var(G.default.dynamicAnchors,(0,U._)`{}`)})}function l9(t){let{schema:e,opts:r,gen:n}=t;wO(t,()=>{r.$comment&&e.$comment&&$O(t),m9(t),n.let(G.default.vErrors,null),n.let(G.default.errors,0),r.unevaluated&&d9(t),kO(t),_9(t)})}function d9(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,U._)`${r}.evaluated`),e.if((0,U._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,U._)`${t.evaluated}.props`,(0,U._)`undefined`)),e.if((0,U._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,U._)`${t.evaluated}.items`,(0,U._)`undefined`))}function gO(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,U._)`/*# sourceURL=${r} */`:U.nil}function f9(t,e){if(xO(t)&&(SO(t),vO(t))){p9(t,e);return}(0,bO.boolOrEmptySchema)(t,e)}function vO({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function xO(t){return typeof t.schema!="boolean"}function p9(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&$O(t),g9(t),y9(t);let i=n.const("_errs",G.default.errors);kO(t,i),n.var(e,(0,U._)`${i} === ${G.default.errors}`)}function SO(t){(0,Xr.checkUnknownRules)(t),h9(t)}function kO(t,e){if(t.opts.jtd)return yO(t,[],!1,e);let r=(0,mO.getSchemaTypes)(t.schema),n=(0,mO.coerceAndCheckDataType)(t,r);yO(t,r,!n,e)}function h9(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Xr.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function m9(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Xr.checkStrictMode)(t,"default is ignored in the schema root")}function g9(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,o9.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function y9(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function $O({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let i=r.$comment;if(s.$comment===!0)t.code((0,U._)`${G.default.self}.logger.log(${i})`);else if(typeof s.$comment=="function"){let o=(0,U.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,U._)`${G.default.self}.opts.$comment(${i}, ${o}, ${a}.schema)`)}}function _9(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:i}=t;r.$async?e.if((0,U._)`${G.default.errors} === 0`,()=>e.return(G.default.data),()=>e.throw((0,U._)`new ${s}(${G.default.vErrors})`)):(e.assign((0,U._)`${n}.errors`,G.default.vErrors),i.unevaluated&&b9(t),e.return((0,U._)`${G.default.errors} === 0`))}function b9({gen:t,evaluated:e,props:r,items:n}){r instanceof U.Name&&t.assign((0,U._)`${e}.props`,r),n instanceof U.Name&&t.assign((0,U._)`${e}.items`,n)}function yO(t,e,r,n){let{gen:s,schema:i,data:o,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Xr.schemaHasRulesButRef)(i,l))){s.block(()=>TO(t,"$ref",l.all.$ref.definition));return}c.jtd||w9(t,e),s.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,ow.shouldUseGroup)(i,f)&&(f.type?(s.if((0,xf.checkDataType)(f.type,o,c.strictNumbers)),_O(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,xf.reportTypeError)(t)),s.endIf()):_O(t,f),a||s.if((0,U._)`${G.default.errors} === ${n||0}`))}}function _O(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,i9.assignDefaults)(t,e.type),r.block(()=>{for(let i of e.rules)(0,ow.shouldUseRule)(n,i)&&TO(t,i.keyword,i.definition,e.type)})}function w9(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(v9(t,e),t.opts.allowUnionTypes||x9(t,e),S9(t,t.dataTypes))}function v9(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{EO(t.dataTypes,r)||aw(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),$9(t,e)}}function x9(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&aw(t,"use allowUnionTypes to allow union type keyword")}function S9(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,ow.shouldUseRule)(t.schema,s)){let{type:i}=s.definition;i.length&&!i.some(o=>k9(e,o))&&aw(t,`missing type "${i.join(",")}" for keyword "${n}"`)}}}function k9(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function EO(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function $9(t,e){let r=[];for(let n of t.dataTypes)EO(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function aw(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Xr.checkStrictMode)(t,e,t.opts.strictTypes)}var Sf=class{constructor(e,r,n){if((0,zc.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Xr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",PO(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,zc.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",G.default.errors))}result(e,r,n){this.failResult((0,U.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,U.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,U._)`${r} !== undefined && (${(0,U.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Rc.reportExtraError:Rc.reportError)(this,this.def.error,r)}$dataError(){(0,Rc.reportError)(this,this.def.$dataError||Rc.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Rc.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=U.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=U.nil,r=U.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:i,def:o}=this;n.if((0,U.or)((0,U._)`${s} === undefined`,r)),e!==U.nil&&n.assign(e,!0),(i.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==U.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:i}=this;return(0,U.or)(o(),a());function o(){if(n.length){if(!(r instanceof U.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,U._)`${(0,xf.checkDataTypes)(c,r,i.opts.strictNumbers,xf.DataType.Wrong)}`}return U.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,U._)`!${c}(${r})`}return U.nil}}subschema(e,r){let n=(0,iw.getSubschema)(this.it,e);(0,iw.extendSubschemaData)(n,this.it,e),(0,iw.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return f9(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Xr.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Xr.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,U.Name)),!0}};Dn.KeywordCxt=Sf;function TO(t,e,r,n){let s=new Sf(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,zc.funcKeywordCode)(s,r):"macro"in r?(0,zc.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,zc.funcKeywordCode)(s,r)}var E9=/^\/(?:[^~]|~0|~1)*$/,T9=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function PO(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,i;if(t==="")return G.default.rootData;if(t[0]==="/"){if(!E9.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,i=G.default.rootData}else{let u=T9.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(s=u[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(i=r[e-l],!s)return i}let o=i,a=s.split("/");for(let u of a)u&&(i=(0,U._)`${i}${(0,U.getProperty)((0,Xr.unescapeJsonPointer)(u))}`,o=(0,U._)`${o} && ${i}`);return o;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Dn.getData=PO});var kf=w(uw=>{"use strict";Object.defineProperty(uw,"__esModule",{value:!0});var cw=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};uw.default=cw});var Cc=w(fw=>{"use strict";Object.defineProperty(fw,"__esModule",{value:!0});var lw=Nc(),dw=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,lw.resolveUrl)(e,r,n),this.missingSchema=(0,lw.normalizeId)((0,lw.getFullPath)(e,this.missingRef))}};fw.default=dw});var Ef=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.resolveSchema=Xt.getCompilingSchema=Xt.resolveRef=Xt.compileSchema=Xt.SchemaEnv=void 0;var ur=te(),P9=kf(),Hs=Yr(),lr=Nc(),OO=fe(),O9=Mc(),bo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,lr.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Xt.SchemaEnv=bo;function hw(t){let e=IO.call(this,t);if(e)return e;let r=(0,lr.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:i}=this.opts,o=new ur.CodeGen(this.scope,{es5:n,lines:s,ownProperties:i}),a;t.$async&&(a=o.scopeValue("Error",{ref:P9.default,code:(0,ur._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let u={gen:o,allErrors:this.opts.allErrors,data:Hs.default.data,parentData:Hs.default.parentData,parentDataProperty:Hs.default.parentDataProperty,dataNames:[Hs.default.data],dataPathArr:[ur.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,ur.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:ur.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ur._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,O9.validateFunctionCode)(u),o.optimize(this.opts.code.optimize);let d=o.toString();l=`${o.scopeRefs(Hs.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${Hs.default.self}`,`${Hs.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof ur.Name?void 0:m,items:h instanceof ur.Name?void 0:h,dynamicProps:m instanceof ur.Name,dynamicItems:h instanceof ur.Name},p.source&&(p.source.evaluated=(0,ur.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Xt.compileSchema=hw;function I9(t,e,r){var n;r=(0,lr.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let i=R9.call(this,t,r);if(i===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(i=new bo({schema:o,schemaId:a,root:t,baseId:e}))}if(i!==void 0)return t.refs[r]=A9.call(this,i)}Xt.resolveRef=I9;function A9(t){return(0,lr.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:hw.call(this,t)}function IO(t){for(let e of this._compilations)if(N9(e,t))return e}Xt.getCompilingSchema=IO;function N9(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function R9(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||$f.call(this,t,e)}function $f(t,e){let r=this.opts.uriResolver.parse(e),n=(0,lr._getFullPath)(this.opts.uriResolver,r),s=(0,lr.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return pw.call(this,r,t);let i=(0,lr.normalizeId)(n),o=this.refs[i]||this.schemas[i];if(typeof o=="string"){let a=$f.call(this,t,o);return typeof a?.schema!="object"?void 0:pw.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||hw.call(this,o),i===(0,lr.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,u=a[c];return u&&(s=(0,lr.resolveUrl)(this.opts.uriResolver,s,u)),new bo({schema:a,schemaId:c,root:t,baseId:s})}return pw.call(this,r,o)}}Xt.resolveSchema=$f;var z9=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pw(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,OO.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!z9.has(a)&&u&&(e=(0,lr.resolveUrl)(this.opts.uriResolver,e,u))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,OO.schemaHasRulesButRef)(r,this.RULES)){let a=(0,lr.resolveUrl)(this.opts.uriResolver,e,r.$ref);i=$f.call(this,n,a)}let{schemaId:o}=this.opts;if(i=i||new bo({schema:r,schemaId:o,root:n,baseId:e}),i.schema!==i.root.schema)return i}});var AO=w((one,M9)=>{M9.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var yw=w((ane,jO)=>{"use strict";var C9=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),RO=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),mw=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),zO=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),j9=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function gw(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var L9=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function NO(t){return t.length=0,!0}function q9(t,e,r){if(t.length){let n=gw(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function D9(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],i=!1,o=!1,a=q9;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(i===!0&&(o=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(i=!0),n.push(":");continue}else if(u==="%"){if(!a(s,n,r))break;a=NO}else{s.push(u);continue}}return s.length&&(a===NO?r.zone=s.join(""):o?n.push(s.join("")):n.push(gw(s))),r.address=n.join(""),r}function MO(t){if(Z9(t,":")<2)return{host:t,isIPV6:!1};let e=D9(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Z9(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function U9(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var F9={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},B9=/[@/?#:]/g,V9=/[@/?#]/g;function CO(t,e){let r=e?V9:B9;return r.lastIndex=0,t.replace(r,n=>F9[n])}function H9(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(mw(s)){let i=s.toUpperCase(),o=String.fromCharCode(parseInt(i,16));e&&zO(o)?r+=o:r+="%"+i,n+=2;continue}}r+=t[n]}return r}function W9(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(mw(n)){let s=n.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&zO(i)?e+=i:e+="%"+s,r+=2;continue}}j9(t[r])?e+=t[r]:e+=escape(t[r])}return e}function K9(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(mw(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function J9(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!RO(r)){let n=MO(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=CO(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}jO.exports={nonSimpleDomain:L9,recomposeAuthority:J9,reescapeHostDelimiters:CO,normalizePercentEncoding:H9,normalizePathEncoding:W9,escapePreservingEscapes:K9,removeDotSegments:U9,isIPv4:RO,isUUID:C9,normalizeIPv6:MO,stringArrayToHexStripped:gw}});var UO=w((cne,ZO)=>{"use strict";var{isUUID:G9}=yw(),Y9=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,X9=["http","https","ws","wss","urn","urn:uuid"];function Q9(t){return X9.indexOf(t)!==-1}function _w(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function LO(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function qO(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function eV(t){return t.secure=_w(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function tV(t){if((t.port===(_w(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function rV(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Y9);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,i=bw(s);t.path=void 0,i&&(t=i.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function nV(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,i=bw(s);i&&(t=i.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function sV(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!G9(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function iV(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var DO={scheme:"http",domainHost:!0,parse:LO,serialize:qO},oV={scheme:"https",domainHost:DO.domainHost,parse:LO,serialize:qO},Tf={scheme:"ws",domainHost:!0,parse:eV,serialize:tV},aV={scheme:"wss",domainHost:Tf.domainHost,parse:Tf.parse,serialize:Tf.serialize},cV={scheme:"urn",parse:rV,serialize:nV,skipNormalize:!0},uV={scheme:"urn:uuid",parse:sV,serialize:iV,skipNormalize:!0},Pf={http:DO,https:oV,ws:Tf,wss:aV,urn:cV,"urn:uuid":uV};Object.setPrototypeOf(Pf,null);function bw(t){return t&&(Pf[t]||Pf[t.toLowerCase()])||void 0}ZO.exports={wsIsSecure:_w,SCHEMES:Pf,isValidSchemeName:Q9,getSchemeHandler:bw}});var KO=w((une,Of)=>{"use strict";var{normalizeIPv6:lV,removeDotSegments:jc,recomposeAuthority:dV,normalizePercentEncoding:fV,normalizePathEncoding:pV,escapePreservingEscapes:hV,reescapeHostDelimiters:mV,isIPv4:gV,nonSimpleDomain:yV}=yw(),{SCHEMES:_V,getSchemeHandler:BO}=UO();function bV(t,e){return typeof t=="string"?t=kV(t,e):typeof t=="object"&&(t=wo(Ws(t,e),e)),t}function wV(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=VO(wo(t,n),wo(e,n),n,!0);return n.skipEscape=!0,Ws(s,n)}function VO(t,e,r,n){let s={};return n||(t=wo(Ws(t,r),r),e=wo(Ws(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=jc(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=jc(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=jc(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=jc(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function vV(t,e,r){let n=FO(t,r),s=FO(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function Ws(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],i=BO(n.scheme||r.scheme);i&&i.serialize&&i.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=fV(r.path):(r.path=hV(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let o=dV(r);if(o!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(o),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!i||!i.absolutePath)&&(a=jc(a)),o===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var xV=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function SV(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function HO(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1,i=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let o=t.match(xV);if(o){n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]);let a=SV(n,o);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(gV(n.host)===!1){let l=lV(n.host);n.host=l.host.toLowerCase(),i=l.isIPV6}else i=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=BO(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&i===!1&&yV(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=mV(unescape(n.host),i))),n.path&&(n.path=pV(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function wo(t,e){return HO(t,e).parsed}function kV(t,e){return WO(t,e).normalized}function WO(t,e){let{parsed:r,malformedAuthorityOrPort:n}=HO(t,e);return{normalized:n?t:Ws(r,e),malformedAuthorityOrPort:n}}function FO(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=WO(t,e);return n?void 0:r}if(typeof t=="object")return Ws(t,e)}var ww={SCHEMES:_V,normalize:bV,resolve:wV,resolveComponent:VO,equal:vV,serialize:Ws,parse:wo};Of.exports=ww;Of.exports.default=ww;Of.exports.fastUri=ww});var GO=w(vw=>{"use strict";Object.defineProperty(vw,"__esModule",{value:!0});var JO=KO();JO.code='require("ajv/dist/runtime/uri").default';vw.default=JO});var sI=w(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.CodeGen=st.Name=st.nil=st.stringify=st.str=st._=st.KeywordCxt=void 0;var $V=Mc();Object.defineProperty(st,"KeywordCxt",{enumerable:!0,get:function(){return $V.KeywordCxt}});var vo=te();Object.defineProperty(st,"_",{enumerable:!0,get:function(){return vo._}});Object.defineProperty(st,"str",{enumerable:!0,get:function(){return vo.str}});Object.defineProperty(st,"stringify",{enumerable:!0,get:function(){return vo.stringify}});Object.defineProperty(st,"nil",{enumerable:!0,get:function(){return vo.nil}});Object.defineProperty(st,"Name",{enumerable:!0,get:function(){return vo.Name}});Object.defineProperty(st,"CodeGen",{enumerable:!0,get:function(){return vo.CodeGen}});var EV=kf(),tI=Cc(),TV=Jb(),Lc=Ef(),PV=te(),qc=Nc(),If=Ac(),Sw=fe(),YO=AO(),OV=GO(),rI=(t,e)=>new RegExp(t,e);rI.code="new RegExp";var IV=["removeAdditional","useDefaults","coerceTypes"],AV=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),NV={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},RV={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},XO=200;function zV(t){var e,r,n,s,i,o,a,c,u,l,d,f,p,m,h,g,y,_,v,k,E,C,B,R,ue;let I=t.strict,K=(e=t.code)===null||e===void 0?void 0:e.optimize,J=K===!0||K===void 0?1:K||0,Re=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:rI,qe=(s=t.uriResolver)!==null&&s!==void 0?s:OV.default;return{strictSchema:(o=(i=t.strictSchema)!==null&&i!==void 0?i:I)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:I)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:I)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:I)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:I)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:J,regExp:Re}:{optimize:J,regExp:Re},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:XO,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:XO,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(k=t.schemaId)!==null&&k!==void 0?k:"$id",addUsedSchema:(E=t.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(C=t.validateSchema)!==null&&C!==void 0?C:!0,validateFormats:(B=t.validateFormats)!==null&&B!==void 0?B:!0,unicodeRegExp:(R=t.unicodeRegExp)!==null&&R!==void 0?R:!0,int32range:(ue=t.int32range)!==null&&ue!==void 0?ue:!0,uriResolver:qe}}var Dc=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...zV(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new PV.ValueScope({scope:{},prefixes:AV,es5:r,lines:n}),this.logger=DV(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,TV.getRules)(),QO.call(this,NV,e,"NOT SUPPORTED"),QO.call(this,RV,e,"DEPRECATED","warn"),this._metaOpts=LV.call(this),e.formats&&CV.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&jV.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),MV.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=YO;n==="id"&&(s={...YO},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(l,d){await i.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||o.call(this,f)}async function i(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},!0)}async function o(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof tI.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),o.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await i.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,s);return this}let i;if(typeof e=="object"){let{schemaId:o}=this.opts;if(i=e[o],i!==void 0&&typeof i!="string")throw new Error(`schema ${o} must be string`)}return r=(0,qc.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return s}getSchema(e){let r;for(;typeof(r=eI.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new Lc.SchemaEnv({schema:{},schemaId:n});if(r=Lc.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=eI.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,qc.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(UV.call(this,n,r),!r)return(0,Sw.eachItem)(n,i=>xw.call(this,i)),this;BV.call(this,r);let s={...r,type:(0,If.getJSONTypes)(r.type),schemaType:(0,If.getJSONTypes)(r.schemaType)};return(0,Sw.eachItem)(n,s.type.length===0?i=>xw.call(this,i,s):i=>s.type.forEach(o=>xw.call(this,i,s,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(i=>i.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,i)=>s+r+i)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let i=s.split("/").slice(1),o=e;for(let a of i)o=o[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=o[a];u&&l&&(o[a]=nI(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,i=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,qc.normalizeId)(o||n);let u=qc.getSchemaRefs.call(this,e,n);return c=new Lc.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Lc.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Lc.compileSchema.call(this,e)}finally{this.opts=r}}};Dc.ValidationError=EV.default;Dc.MissingRefError=tI.default;st.default=Dc;function QO(t,e,r,n="error"){for(let s in t){let i=s;i in e&&this.logger[n](`${r}: option ${s}. ${t[i]}`)}}function eI(t){return t=(0,qc.normalizeId)(t),this.schemas[t]||this.refs[t]}function MV(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function CV(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function jV(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function LV(){let t={...this.opts};for(let e of IV)delete t[e];return t}var qV={log(){},warn(){},error(){}};function DV(t){if(t===!1)return qV;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var ZV=/^[a-z_$][a-z0-9_$:-]*$/i;function UV(t,e){let{RULES:r}=this;if((0,Sw.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!ZV.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function xw(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,o=s?i.post:i.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},i.rules.push(o)),i.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,If.getJSONTypes)(e.type),schemaType:(0,If.getJSONTypes)(e.schemaType)}};e.before?FV.call(this,o,a,e.before):o.rules.push(a),i.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function FV(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function BV(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=nI(e)),t.validateSchema=this.compile(e,!0))}var VV={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function nI(t){return{anyOf:[t,VV]}}});var iI=w(kw=>{"use strict";Object.defineProperty(kw,"__esModule",{value:!0});var HV={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};kw.default=HV});var uI=w(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.callRef=Ks.getValidate=void 0;var WV=Cc(),oI=Yt(),Et=te(),xo=Yr(),aI=Ef(),Af=fe(),KV={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:i,validateName:o,opts:a,self:c}=n,{root:u}=i;if((r==="#"||r==="#/")&&s===u.baseId)return d();let l=aI.resolveRef.call(c,u,s,r);if(l===void 0)throw new WV.default(n.opts.uriResolver,s,r);if(l instanceof aI.SchemaEnv)return f(l);return p(l);function d(){if(i===u)return Nf(t,o,i,i.$async);let m=e.scopeValue("root",{ref:u});return Nf(t,(0,Et._)`${m}.validate`,u,u.$async)}function f(m){let h=cI(t,m);Nf(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Et.stringify)(m)}:{ref:m}),g=e.name("valid"),y=t.subschema({schema:m,dataTypes:[],schemaPath:Et.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function cI(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Et._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Ks.getValidate=cI;function Nf(t,e,r,n){let{gen:s,it:i}=t,{allErrors:o,schemaEnv:a,opts:c}=i,u=c.passContext?xo.default.this:Et.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Et._)`await ${(0,oI.callValidateCode)(t,e,u)}`),p(e),o||s.assign(m,!0)},h=>{s.if((0,Et._)`!(${h} instanceof ${i.ValidationError})`,()=>s.throw(h)),f(h),o||s.assign(m,!1)}),t.ok(m)}function d(){t.result((0,oI.callValidateCode)(t,e,u),()=>p(e),()=>f(e))}function f(m){let h=(0,Et._)`${m}.errors`;s.assign(xo.default.vErrors,(0,Et._)`${xo.default.vErrors} === null ? ${h} : ${xo.default.vErrors}.concat(${h})`),s.assign(xo.default.errors,(0,Et._)`${xo.default.vErrors}.length`)}function p(m){var h;if(!i.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(i.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(i.props=Af.mergeEvaluated.props(s,g.props,i.props));else{let y=s.var("props",(0,Et._)`${m}.evaluated.props`);i.props=Af.mergeEvaluated.props(s,y,i.props,Et.Name)}if(i.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(i.items=Af.mergeEvaluated.items(s,g.items,i.items));else{let y=s.var("items",(0,Et._)`${m}.evaluated.items`);i.items=Af.mergeEvaluated.items(s,y,i.items,Et.Name)}}}Ks.callRef=Nf;Ks.default=KV});var lI=w($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});var JV=iI(),GV=uI(),YV=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",JV.default,GV.default];$w.default=YV});var dI=w(Ew=>{"use strict";Object.defineProperty(Ew,"__esModule",{value:!0});var Rf=te(),Zn=Rf.operators,zf={maximum:{okStr:"<=",ok:Zn.LTE,fail:Zn.GT},minimum:{okStr:">=",ok:Zn.GTE,fail:Zn.LT},exclusiveMaximum:{okStr:"<",ok:Zn.LT,fail:Zn.GTE},exclusiveMinimum:{okStr:">",ok:Zn.GT,fail:Zn.LTE}},XV={message:({keyword:t,schemaCode:e})=>(0,Rf.str)`must be ${zf[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Rf._)`{comparison: ${zf[t].okStr}, limit: ${e}}`},QV={keyword:Object.keys(zf),type:"number",schemaType:"number",$data:!0,error:XV,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Rf._)`${r} ${zf[e].fail} ${n} || isNaN(${r})`)}};Ew.default=QV});var fI=w(Tw=>{"use strict";Object.defineProperty(Tw,"__esModule",{value:!0});var Zc=te(),e6={message:({schemaCode:t})=>(0,Zc.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Zc._)`{multipleOf: ${t}}`},t6={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:e6,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,i=s.opts.multipleOfPrecision,o=e.let("res"),a=i?(0,Zc._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:(0,Zc._)`${o} !== parseInt(${o})`;t.fail$data((0,Zc._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};Tw.default=t6});var hI=w(Pw=>{"use strict";Object.defineProperty(Pw,"__esModule",{value:!0});function pI(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}Pw.default=pI;pI.code='require("ajv/dist/runtime/ucs2length").default'});var mI=w(Ow=>{"use strict";Object.defineProperty(Ow,"__esModule",{value:!0});var Js=te(),r6=fe(),n6=hI(),s6={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Js.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Js._)`{limit: ${t}}`},i6={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:s6,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,i=e==="maxLength"?Js.operators.GT:Js.operators.LT,o=s.opts.unicode===!1?(0,Js._)`${r}.length`:(0,Js._)`${(0,r6.useFunc)(t.gen,n6.default)}(${r})`;t.fail$data((0,Js._)`${o} ${i} ${n}`)}};Ow.default=i6});var gI=w(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});var o6=Yt(),a6=fe(),So=te(),c6={message:({schemaCode:t})=>(0,So.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,So._)`{pattern: ${t}}`},u6={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:c6,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:i,it:o}=t,a=o.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=o.opts.code,u=c.code==="new RegExp"?(0,So._)`new RegExp`:(0,a6.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,So._)`${u}(${i}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,So._)`!${l}`)}else{let c=(0,o6.usePattern)(t,s);t.fail$data((0,So._)`!${c}.test(${r})`)}}};Iw.default=u6});var yI=w(Aw=>{"use strict";Object.defineProperty(Aw,"__esModule",{value:!0});var Uc=te(),l6={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Uc.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Uc._)`{limit: ${t}}`},d6={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:l6,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Uc.operators.GT:Uc.operators.LT;t.fail$data((0,Uc._)`Object.keys(${r}).length ${s} ${n}`)}};Aw.default=d6});var _I=w(Nw=>{"use strict";Object.defineProperty(Nw,"__esModule",{value:!0});var Fc=Yt(),Bc=te(),f6=fe(),p6={message:({params:{missingProperty:t}})=>(0,Bc.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Bc._)`{missingProperty: ${t}}`},h6={keyword:"required",type:"object",schemaType:"array",$data:!0,error:p6,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:i,it:o}=t,{opts:a}=o;if(!i&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?u():l(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,f6.checkStrictMode)(o,y,o.opts.strictRequired)}}function u(){if(c||i)t.block$data(Bc.nil,d);else for(let p of r)(0,Fc.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||i){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Fc.checkMissingProp)(t,r,p)),(0,Fc.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Fc.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,Fc.propertyInData)(e,s,p,a.ownProperties)),e.if((0,Bc.not)(m),()=>{t.error(),e.break()})},Bc.nil)}}};Nw.default=h6});var bI=w(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});var Vc=te(),m6={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Vc.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Vc._)`{limit: ${t}}`},g6={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:m6,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Vc.operators.GT:Vc.operators.LT;t.fail$data((0,Vc._)`${r}.length ${s} ${n}`)}};Rw.default=g6});var Mf=w(zw=>{"use strict";Object.defineProperty(zw,"__esModule",{value:!0});var wI=nw();wI.code='require("ajv/dist/runtime/equal").default';zw.default=wI});var vI=w(Cw=>{"use strict";Object.defineProperty(Cw,"__esModule",{value:!0});var Mw=Ac(),it=te(),y6=fe(),_6=Mf(),b6={message:({params:{i:t,j:e}})=>(0,it.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,it._)`{i: ${t}, j: ${e}}`},w6={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:b6,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:i,schemaCode:o,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),u=i.items?(0,Mw.getSchemaTypes)(i.items):[];t.block$data(c,l,(0,it._)`${o} === false`),t.ok(c);function l(){let m=e.let("i",(0,it._)`${r}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,it._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=e.name("item"),y=(0,Mw.checkDataTypes)(u,g,a.opts.strictNumbers,Mw.DataType.Wrong),_=e.const("indices",(0,it._)`{}`);e.for((0,it._)`;${m}--;`,()=>{e.let(g,(0,it._)`${r}[${m}]`),e.if(y,(0,it._)`continue`),u.length>1&&e.if((0,it._)`typeof ${g} == "string"`,(0,it._)`${g} += "_"`),e.if((0,it._)`typeof ${_}[${g}] == "number"`,()=>{e.assign(h,(0,it._)`${_}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,it._)`${_}[${g}] = ${m}`)})}function p(m,h){let g=(0,y6.useFunc)(e,_6.default),y=e.name("outer");e.label(y).for((0,it._)`;${m}--;`,()=>e.for((0,it._)`${h} = ${m}; ${h}--;`,()=>e.if((0,it._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Cw.default=w6});var xI=w(Lw=>{"use strict";Object.defineProperty(Lw,"__esModule",{value:!0});var jw=te(),v6=fe(),x6=Mf(),S6={message:"must be equal to constant",params:({schemaCode:t})=>(0,jw._)`{allowedValue: ${t}}`},k6={keyword:"const",$data:!0,error:S6,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:i}=t;n||i&&typeof i=="object"?t.fail$data((0,jw._)`!${(0,v6.useFunc)(e,x6.default)}(${r}, ${s})`):t.fail((0,jw._)`${i} !== ${r}`)}};Lw.default=k6});var SI=w(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});var Hc=te(),$6=fe(),E6=Mf(),T6={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Hc._)`{allowedValues: ${t}}`},P6={keyword:"enum",schemaType:"array",$data:!0,error:T6,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:i,it:o}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=o.opts.loopEnum,c,u=()=>c??(c=(0,$6.useFunc)(e,E6.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",i);l=(0,Hc.or)(...s.map((m,h)=>f(p,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",i,p=>e.if((0,Hc._)`${u()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function f(p,m){let h=s[m];return typeof h=="object"&&h!==null?(0,Hc._)`${u()}(${r}, ${p}[${m}])`:(0,Hc._)`${r} === ${h}`}}};qw.default=P6});var kI=w(Dw=>{"use strict";Object.defineProperty(Dw,"__esModule",{value:!0});var O6=dI(),I6=fI(),A6=mI(),N6=gI(),R6=yI(),z6=_I(),M6=bI(),C6=vI(),j6=xI(),L6=SI(),q6=[O6.default,I6.default,A6.default,N6.default,R6.default,z6.default,M6.default,C6.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},j6.default,L6.default];Dw.default=q6});var Uw=w(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.validateAdditionalItems=void 0;var Gs=te(),Zw=fe(),D6={message:({params:{len:t}})=>(0,Gs.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Gs._)`{limit: ${t}}`},Z6={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:D6,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Zw.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}$I(t,n)}};function $I(t,e){let{gen:r,schema:n,data:s,keyword:i,it:o}=t;o.items=!0;let a=r.const("len",(0,Gs._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Gs._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Zw.alwaysValidSchema)(o,n)){let u=r.var("valid",(0,Gs._)`${a} <= ${e.length}`);r.if((0,Gs.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:i,dataProp:l,dataPropType:Zw.Type.Num},u),o.allErrors||r.if((0,Gs.not)(u),()=>r.break())})}}Wc.validateAdditionalItems=$I;Wc.default=Z6});var Fw=w(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.validateTuple=void 0;var EI=te(),Cf=fe(),U6=Yt(),F6={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return TI(t,"additionalItems",e);r.items=!0,!(0,Cf.alwaysValidSchema)(r,e)&&t.ok((0,U6.validateArray)(t))}};function TI(t,e,r=t.schema){let{gen:n,parentSchema:s,data:i,keyword:o,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Cf.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,EI._)`${i}.length`);r.forEach((d,f)=>{(0,Cf.alwaysValidSchema)(a,d)||(n.if((0,EI._)`${u} > ${f}`,()=>t.subschema({keyword:o,schemaProp:f,dataProp:f},c)),t.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let g=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Cf.checkStrictMode)(a,g,f.strictTuples)}}}Kc.validateTuple=TI;Kc.default=F6});var PI=w(Bw=>{"use strict";Object.defineProperty(Bw,"__esModule",{value:!0});var B6=Fw(),V6={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,B6.validateTuple)(t,"items")};Bw.default=V6});var II=w(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});var OI=te(),H6=fe(),W6=Yt(),K6=Uw(),J6={message:({params:{len:t}})=>(0,OI.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,OI._)`{limit: ${t}}`},G6={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:J6,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,H6.alwaysValidSchema)(n,e)&&(s?(0,K6.validateAdditionalItems)(t,s):t.ok((0,W6.validateArray)(t)))}};Vw.default=G6});var AI=w(Hw=>{"use strict";Object.defineProperty(Hw,"__esModule",{value:!0});var Qt=te(),jf=fe(),Y6={message:({params:{min:t,max:e}})=>e===void 0?(0,Qt.str)`must contain at least ${t} valid item(s)`:(0,Qt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Qt._)`{minContains: ${t}}`:(0,Qt._)`{minContains: ${t}, maxContains: ${e}}`},X6={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Y6,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:i}=t,o,a,{minContains:c,maxContains:u}=n;i.opts.next?(o=c===void 0?1:c,a=u):o=1;let l=e.const("len",(0,Qt._)`${s}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,jf.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,jf.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,jf.alwaysValidSchema)(i,r)){let h=(0,Qt._)`${l} >= ${o}`;a!==void 0&&(h=(0,Qt._)`${h} && ${l} <= ${a}`),t.pass(h);return}i.items=!0;let d=e.name("valid");a===void 0&&o===1?p(d,()=>e.if(d,()=>e.break())):o===0?(e.let(d,!0),a!==void 0&&e.if((0,Qt._)`${s}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),g=e.let("count",0);p(h,()=>e.if(h,()=>m(g)))}function p(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:jf.Type.Num,compositeRule:!0},h),g()})}function m(h){e.code((0,Qt._)`${h}++`),a===void 0?e.if((0,Qt._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,Qt._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,Qt._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};Hw.default=X6});var zI=w(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.validateSchemaDeps=Tr.validatePropertyDeps=Tr.error=void 0;var Ww=te(),Q6=fe(),Jc=Yt();Tr.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Ww.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Ww._)`{property: ${t},
|
|
187
|
+
|| ${o} === "boolean" || ${s} === null`).assign(a,(0,X._)`[${s}]`)}}}function xB({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,X._)`${e} !== undefined`,()=>t.assign((0,X._)`${e}[${r}]`,n))}function Xb(t,e,r,n=yo.Correct){let s=n===yo.Correct?X.operators.EQ:X.operators.NEQ,i;switch(t){case"null":return(0,X._)`${e} ${s} null`;case"array":i=(0,X._)`Array.isArray(${e})`;break;case"object":i=(0,X._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":i=o((0,X._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":i=o();break;default:return(0,X._)`typeof ${e} ${s} ${t}`}return n===yo.Correct?i:(0,X.not)(i);function o(a=X.nil){return(0,X.and)((0,X._)`typeof ${e} == "number"`,a,r?(0,X._)`isFinite(${e})`:X.nil)}}lt.checkDataType=Xb;function Qb(t,e,r,n){if(t.length===1)return Xb(t[0],e,r,n);let s,i=(0,X1.toHash)(t);if(i.array&&i.object){let o=(0,X._)`typeof ${e} != "object"`;s=i.null?o:(0,X._)`!${e} || ${o}`,delete i.null,delete i.array,delete i.object}else s=X.nil;i.number&&delete i.integer;for(let o in i)s=(0,X.and)(s,Xb(o,e,r,n));return s}lt.checkDataTypes=Qb;var SB={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,X._)`{type: ${t}}`:(0,X._)`{type: ${e}}`};function ew(t){let e=kB(t);(0,yB.reportError)(e,SB)}lt.reportTypeError=ew;function kB(t){let{gen:e,data:r,schema:n}=t,s=(0,X1.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var rO=w(vf=>{"use strict";Object.defineProperty(vf,"__esModule",{value:!0});vf.assignDefaults=void 0;var _o=te(),$B=fe();function EB(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)tO(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,i)=>tO(t,i,s.default))}vf.assignDefaults=EB;function tO(t,e,r){let{gen:n,compositeRule:s,data:i,opts:o}=t;if(r===void 0)return;let a=(0,_o._)`${i}${(0,_o.getProperty)(e)}`;if(s){(0,$B.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,_o._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,_o._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,_o._)`${a} = ${(0,_o.stringify)(r)}`)}});var Xt=w(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.validateUnion=be.validateArray=be.usePattern=be.callValidateCode=be.schemaProperties=be.allSchemaProperties=be.noPropertyInData=be.propertyInData=be.isOwnProperty=be.hasPropFunc=be.reportMissingProp=be.checkMissingProp=be.checkReportMissingProp=void 0;var Ee=te(),tw=fe(),Ln=Xr(),TB=fe();function PB(t,e){let{gen:r,data:n,it:s}=t;r.if(nw(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Ee._)`${e}`},!0),t.error()})}be.checkReportMissingProp=PB;function OB({gen:t,data:e,it:{opts:r}},n,s){return(0,Ee.or)(...n.map(i=>(0,Ee.and)(nw(t,e,i,r.ownProperties),(0,Ee._)`${s} = ${i}`)))}be.checkMissingProp=OB;function IB(t,e){t.setParams({missingProperty:e},!0),t.error()}be.reportMissingProp=IB;function nO(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ee._)`Object.prototype.hasOwnProperty`})}be.hasPropFunc=nO;function rw(t,e,r){return(0,Ee._)`${nO(t)}.call(${e}, ${r})`}be.isOwnProperty=rw;function AB(t,e,r,n){let s=(0,Ee._)`${e}${(0,Ee.getProperty)(r)} !== undefined`;return n?(0,Ee._)`${s} && ${rw(t,e,r)}`:s}be.propertyInData=AB;function nw(t,e,r,n){let s=(0,Ee._)`${e}${(0,Ee.getProperty)(r)} === undefined`;return n?(0,Ee.or)(s,(0,Ee.not)(rw(t,e,r))):s}be.noPropertyInData=nw;function sO(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}be.allSchemaProperties=sO;function NB(t,e){return sO(e).filter(r=>!(0,tw.alwaysValidSchema)(t,e[r]))}be.schemaProperties=NB;function RB({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:i},it:o},a,c,u){let l=u?(0,Ee._)`${t}, ${e}, ${n}${s}`:e,d=[[Ln.default.instancePath,(0,Ee.strConcat)(Ln.default.instancePath,i)],[Ln.default.parentData,o.parentData],[Ln.default.parentDataProperty,o.parentDataProperty],[Ln.default.rootData,Ln.default.rootData]];o.opts.dynamicRef&&d.push([Ln.default.dynamicAnchors,Ln.default.dynamicAnchors]);let f=(0,Ee._)`${l}, ${r.object(...d)}`;return c!==Ee.nil?(0,Ee._)`${a}.call(${c}, ${f})`:(0,Ee._)`${a}(${f})`}be.callValidateCode=RB;var zB=(0,Ee._)`new RegExp`;function MB({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,i=s(r,n);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Ee._)`${s.code==="new RegExp"?zB:(0,TB.useFunc)(t,s)}(${r}, ${n})`})}be.usePattern=MB;function CB(t){let{gen:e,data:r,keyword:n,it:s}=t,i=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(i,!0),o(()=>e.break()),i;function o(a){let c=e.const("len",(0,Ee._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:tw.Type.Num},i),e.if((0,Ee.not)(i),a)})}}be.validateArray=CB;function jB(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,tw.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(o,(0,Ee._)`${o} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,Ee.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}be.validateUnion=jB});var aO=w(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.validateKeywordUsage=Er.validSchemaType=Er.funcKeywordCode=Er.macroKeywordCode=void 0;var gt=te(),Hs=Xr(),LB=Xt(),qB=Ac();function DB(t,e){let{gen:r,keyword:n,schema:s,parentSchema:i,it:o}=t,a=e.macro.call(o.self,s,i,o),c=oO(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:gt.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Er.macroKeywordCode=DB;function ZB(t,e){var r;let{gen:n,keyword:s,schema:i,parentSchema:o,$data:a,it:c}=t;FB(c,e);let u=!a&&e.compile?e.compile.call(c.self,i,o,c):e.validate,l=oO(n,s,u),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&iO(t),g(()=>t.error());else{let y=e.async?p():m();e.modifying&&iO(t),g(()=>UB(t,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,gt._)`await `),_=>n.assign(d,!1).if((0,gt._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,gt._)`${_}.errors`),()=>n.throw(_))),y}function m(){let y=(0,gt._)`${l}.errors`;return n.assign(y,null),h(gt.nil),y}function h(y=e.async?(0,gt._)`await `:gt.nil){let _=c.opts.passContext?Hs.default.this:Hs.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,gt._)`${y}${(0,LB.callValidateCode)(t,l,_,v)}`,e.modifying)}function g(y){var _;n.if((0,gt.not)((_=e.valid)!==null&&_!==void 0?_:d),y)}}Er.funcKeywordCode=ZB;function iO(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,gt._)`${n.parentData}[${n.parentDataProperty}]`))}function UB(t,e){let{gen:r}=t;r.if((0,gt._)`Array.isArray(${e})`,()=>{r.assign(Hs.default.vErrors,(0,gt._)`${Hs.default.vErrors} === null ? ${e} : ${Hs.default.vErrors}.concat(${e})`).assign(Hs.default.errors,(0,gt._)`${Hs.default.vErrors}.length`),(0,qB.extendErrors)(t)},()=>t.error())}function FB({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function oO(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,gt.stringify)(r)})}function BB(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Er.validSchemaType=BB;function VB({schema:t,opts:e,self:r,errSchemaPath:n},s,i){if(Array.isArray(s.keyword)?!s.keyword.includes(i):s.keyword!==i)throw new Error("ajv implementation error");let o=s.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[i])){let c=`keyword "${i}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Er.validateKeywordUsage=VB});var uO=w(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.extendSubschemaMode=qn.extendSubschemaData=qn.getSubschema=void 0;var Tr=te(),cO=fe();function HB(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:i,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Tr._)`${t.schemaPath}${(0,Tr.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Tr._)`${t.schemaPath}${(0,Tr.getProperty)(e)}${(0,Tr.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,cO.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||i===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:o,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}qn.getSubschema=HB;function WB(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:i,propertyName:o}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,f=a.let("data",(0,Tr._)`${e.data}${(0,Tr.getProperty)(r)}`,!0);c(f),t.errorPath=(0,Tr.str)`${u}${(0,cO.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Tr._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let u=s instanceof Tr.Name?s:a.let("data",s,!0);c(u),o!==void 0&&(t.propertyName=o)}i&&(t.dataTypes=i);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}qn.extendSubschemaData=WB;function KB(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:i}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),i!==void 0&&(t.allErrors=i),t.jtdDiscriminator=e,t.jtdMetadata=r}qn.extendSubschemaMode=KB});var sw=w((tne,lO)=>{"use strict";lO.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,i;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[s]))return!1;for(s=n;s--!==0;){var o=i[s];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var fO=w((rne,dO)=>{"use strict";var Dn=dO.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};xf(e,n,s,t,"",t)};Dn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Dn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Dn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Dn.skipKeywords={default:!0,enum:!0,const:!0,required:!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};function xf(t,e,r,n,s,i,o,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,i,o,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Dn.arrayKeywords)for(var f=0;f<d.length;f++)xf(t,e,r,d[f],s+"/"+l+"/"+f,i,s,l,n,f)}else if(l in Dn.propsKeywords){if(d&&typeof d=="object")for(var p in d)xf(t,e,r,d[p],s+"/"+l+"/"+JB(p),i,s,l,n,p)}else(l in Dn.keywords||t.allKeys&&!(l in Dn.skipKeywords))&&xf(t,e,r,d,s+"/"+l,i,s,l,n)}r(n,s,i,o,a,c,u)}}function JB(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Rc=w(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.getSchemaRefs=Et.resolveUrl=Et.normalizeId=Et._getFullPath=Et.getFullPath=Et.inlineRef=void 0;var GB=fe(),YB=sw(),XB=fO(),QB=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function e9(t,e=!0){return typeof t=="boolean"?!0:e===!0?!iw(t):e?pO(t)<=e:!1}Et.inlineRef=e9;var t9=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function iw(t){for(let e in t){if(t9.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(iw)||typeof r=="object"&&iw(r))return!0}return!1}function pO(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!QB.has(r)&&(typeof t[r]=="object"&&(0,GB.eachItem)(t[r],n=>e+=pO(n)),e===1/0))return 1/0}return e}function hO(t,e="",r){r!==!1&&(e=bo(e));let n=t.parse(e);return mO(t,n)}Et.getFullPath=hO;function mO(t,e){return t.serialize(e).split("#")[0]+"#"}Et._getFullPath=mO;var r9=/#\/?$/;function bo(t){return t?t.replace(r9,""):""}Et.normalizeId=bo;function n9(t,e,r){return r=bo(r),t.resolve(e,r)}Et.resolveUrl=n9;var s9=/^[a-z_][-a-z0-9._]*$/i;function i9(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=bo(t[r]||e),i={"":s},o=hO(n,s,!1),a={},c=new Set;return XB(t,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=o+f,g=i[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),i[f]=g;function y(v){let k=this.opts.uriResolver.resolve;if(v=bo(g?k(g,v):v),c.has(v))throw l(v);c.add(v);let E=this.refs[v];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?u(d,E.schema,v):v!==bo(h)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=h),v}function _(v){if(typeof v=="string"){if(!s9.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function u(d,f,p){if(f!==void 0&&!YB(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Et.getSchemaRefs=i9});var Cc=w(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.getData=Zn.KeywordCxt=Zn.validateFunctionCode=void 0;var wO=J1(),gO=Nc(),aw=Yb(),Sf=Nc(),o9=rO(),Mc=aO(),ow=uO(),U=te(),G=Xr(),a9=Rc(),Qr=fe(),zc=Ac();function c9(t){if(SO(t)&&(kO(t),xO(t))){d9(t);return}vO(t,()=>(0,wO.topBoolOrEmptySchema)(t))}Zn.validateFunctionCode=c9;function vO({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},i){s.code.es5?t.func(e,(0,U._)`${G.default.data}, ${G.default.valCxt}`,n.$async,()=>{t.code((0,U._)`"use strict"; ${yO(r,s)}`),l9(t,s),t.code(i)}):t.func(e,(0,U._)`${G.default.data}, ${u9(s)}`,n.$async,()=>t.code(yO(r,s)).code(i))}function u9(t){return(0,U._)`{${G.default.instancePath}="", ${G.default.parentData}, ${G.default.parentDataProperty}, ${G.default.rootData}=${G.default.data}${t.dynamicRef?(0,U._)`, ${G.default.dynamicAnchors}={}`:U.nil}}={}`}function l9(t,e){t.if(G.default.valCxt,()=>{t.var(G.default.instancePath,(0,U._)`${G.default.valCxt}.${G.default.instancePath}`),t.var(G.default.parentData,(0,U._)`${G.default.valCxt}.${G.default.parentData}`),t.var(G.default.parentDataProperty,(0,U._)`${G.default.valCxt}.${G.default.parentDataProperty}`),t.var(G.default.rootData,(0,U._)`${G.default.valCxt}.${G.default.rootData}`),e.dynamicRef&&t.var(G.default.dynamicAnchors,(0,U._)`${G.default.valCxt}.${G.default.dynamicAnchors}`)},()=>{t.var(G.default.instancePath,(0,U._)`""`),t.var(G.default.parentData,(0,U._)`undefined`),t.var(G.default.parentDataProperty,(0,U._)`undefined`),t.var(G.default.rootData,G.default.data),e.dynamicRef&&t.var(G.default.dynamicAnchors,(0,U._)`{}`)})}function d9(t){let{schema:e,opts:r,gen:n}=t;vO(t,()=>{r.$comment&&e.$comment&&EO(t),g9(t),n.let(G.default.vErrors,null),n.let(G.default.errors,0),r.unevaluated&&f9(t),$O(t),b9(t)})}function f9(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,U._)`${r}.evaluated`),e.if((0,U._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,U._)`${t.evaluated}.props`,(0,U._)`undefined`)),e.if((0,U._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,U._)`${t.evaluated}.items`,(0,U._)`undefined`))}function yO(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,U._)`/*# sourceURL=${r} */`:U.nil}function p9(t,e){if(SO(t)&&(kO(t),xO(t))){h9(t,e);return}(0,wO.boolOrEmptySchema)(t,e)}function xO({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function SO(t){return typeof t.schema!="boolean"}function h9(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&EO(t),y9(t),_9(t);let i=n.const("_errs",G.default.errors);$O(t,i),n.var(e,(0,U._)`${i} === ${G.default.errors}`)}function kO(t){(0,Qr.checkUnknownRules)(t),m9(t)}function $O(t,e){if(t.opts.jtd)return _O(t,[],!1,e);let r=(0,gO.getSchemaTypes)(t.schema),n=(0,gO.coerceAndCheckDataType)(t,r);_O(t,r,!n,e)}function m9(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Qr.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function g9(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Qr.checkStrictMode)(t,"default is ignored in the schema root")}function y9(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,a9.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function _9(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function EO({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let i=r.$comment;if(s.$comment===!0)t.code((0,U._)`${G.default.self}.logger.log(${i})`);else if(typeof s.$comment=="function"){let o=(0,U.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,U._)`${G.default.self}.opts.$comment(${i}, ${o}, ${a}.schema)`)}}function b9(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:i}=t;r.$async?e.if((0,U._)`${G.default.errors} === 0`,()=>e.return(G.default.data),()=>e.throw((0,U._)`new ${s}(${G.default.vErrors})`)):(e.assign((0,U._)`${n}.errors`,G.default.vErrors),i.unevaluated&&w9(t),e.return((0,U._)`${G.default.errors} === 0`))}function w9({gen:t,evaluated:e,props:r,items:n}){r instanceof U.Name&&t.assign((0,U._)`${e}.props`,r),n instanceof U.Name&&t.assign((0,U._)`${e}.items`,n)}function _O(t,e,r,n){let{gen:s,schema:i,data:o,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Qr.schemaHasRulesButRef)(i,l))){s.block(()=>PO(t,"$ref",l.all.$ref.definition));return}c.jtd||v9(t,e),s.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,aw.shouldUseGroup)(i,f)&&(f.type?(s.if((0,Sf.checkDataType)(f.type,o,c.strictNumbers)),bO(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,Sf.reportTypeError)(t)),s.endIf()):bO(t,f),a||s.if((0,U._)`${G.default.errors} === ${n||0}`))}}function bO(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,o9.assignDefaults)(t,e.type),r.block(()=>{for(let i of e.rules)(0,aw.shouldUseRule)(n,i)&&PO(t,i.keyword,i.definition,e.type)})}function v9(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(x9(t,e),t.opts.allowUnionTypes||S9(t,e),k9(t,t.dataTypes))}function x9(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{TO(t.dataTypes,r)||cw(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),E9(t,e)}}function S9(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&cw(t,"use allowUnionTypes to allow union type keyword")}function k9(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,aw.shouldUseRule)(t.schema,s)){let{type:i}=s.definition;i.length&&!i.some(o=>$9(e,o))&&cw(t,`missing type "${i.join(",")}" for keyword "${n}"`)}}}function $9(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function TO(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function E9(t,e){let r=[];for(let n of t.dataTypes)TO(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function cw(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Qr.checkStrictMode)(t,e,t.opts.strictTypes)}var kf=class{constructor(e,r,n){if((0,Mc.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Qr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",OO(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Mc.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",G.default.errors))}result(e,r,n){this.failResult((0,U.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,U.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,U._)`${r} !== undefined && (${(0,U.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?zc.reportExtraError:zc.reportError)(this,this.def.error,r)}$dataError(){(0,zc.reportError)(this,this.def.$dataError||zc.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,zc.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=U.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=U.nil,r=U.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:i,def:o}=this;n.if((0,U.or)((0,U._)`${s} === undefined`,r)),e!==U.nil&&n.assign(e,!0),(i.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==U.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:i}=this;return(0,U.or)(o(),a());function o(){if(n.length){if(!(r instanceof U.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,U._)`${(0,Sf.checkDataTypes)(c,r,i.opts.strictNumbers,Sf.DataType.Wrong)}`}return U.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,U._)`!${c}(${r})`}return U.nil}}subschema(e,r){let n=(0,ow.getSubschema)(this.it,e);(0,ow.extendSubschemaData)(n,this.it,e),(0,ow.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return p9(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Qr.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Qr.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,U.Name)),!0}};Zn.KeywordCxt=kf;function PO(t,e,r,n){let s=new kf(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Mc.funcKeywordCode)(s,r):"macro"in r?(0,Mc.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Mc.funcKeywordCode)(s,r)}var T9=/^\/(?:[^~]|~0|~1)*$/,P9=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function OO(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,i;if(t==="")return G.default.rootData;if(t[0]==="/"){if(!T9.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,i=G.default.rootData}else{let u=P9.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(s=u[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(i=r[e-l],!s)return i}let o=i,a=s.split("/");for(let u of a)u&&(i=(0,U._)`${i}${(0,U.getProperty)((0,Qr.unescapeJsonPointer)(u))}`,o=(0,U._)`${o} && ${i}`);return o;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Zn.getData=OO});var $f=w(lw=>{"use strict";Object.defineProperty(lw,"__esModule",{value:!0});var uw=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};lw.default=uw});var jc=w(pw=>{"use strict";Object.defineProperty(pw,"__esModule",{value:!0});var dw=Rc(),fw=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,dw.resolveUrl)(e,r,n),this.missingSchema=(0,dw.normalizeId)((0,dw.getFullPath)(e,this.missingRef))}};pw.default=fw});var Tf=w(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.resolveSchema=Qt.getCompilingSchema=Qt.resolveRef=Qt.compileSchema=Qt.SchemaEnv=void 0;var lr=te(),O9=$f(),Ws=Xr(),dr=Rc(),IO=fe(),I9=Cc(),wo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,dr.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Qt.SchemaEnv=wo;function mw(t){let e=AO.call(this,t);if(e)return e;let r=(0,dr.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:i}=this.opts,o=new lr.CodeGen(this.scope,{es5:n,lines:s,ownProperties:i}),a;t.$async&&(a=o.scopeValue("Error",{ref:O9.default,code:(0,lr._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let u={gen:o,allErrors:this.opts.allErrors,data:Ws.default.data,parentData:Ws.default.parentData,parentDataProperty:Ws.default.parentDataProperty,dataNames:[Ws.default.data],dataPathArr:[lr.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,lr.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:lr.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lr._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,I9.validateFunctionCode)(u),o.optimize(this.opts.code.optimize);let d=o.toString();l=`${o.scopeRefs(Ws.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${Ws.default.self}`,`${Ws.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof lr.Name?void 0:m,items:h instanceof lr.Name?void 0:h,dynamicProps:m instanceof lr.Name,dynamicItems:h instanceof lr.Name},p.source&&(p.source.evaluated=(0,lr.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Qt.compileSchema=mw;function A9(t,e,r){var n;r=(0,dr.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let i=z9.call(this,t,r);if(i===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(i=new wo({schema:o,schemaId:a,root:t,baseId:e}))}if(i!==void 0)return t.refs[r]=N9.call(this,i)}Qt.resolveRef=A9;function N9(t){return(0,dr.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:mw.call(this,t)}function AO(t){for(let e of this._compilations)if(R9(e,t))return e}Qt.getCompilingSchema=AO;function R9(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function z9(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Ef.call(this,t,e)}function Ef(t,e){let r=this.opts.uriResolver.parse(e),n=(0,dr._getFullPath)(this.opts.uriResolver,r),s=(0,dr.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return hw.call(this,r,t);let i=(0,dr.normalizeId)(n),o=this.refs[i]||this.schemas[i];if(typeof o=="string"){let a=Ef.call(this,t,o);return typeof a?.schema!="object"?void 0:hw.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||mw.call(this,o),i===(0,dr.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,u=a[c];return u&&(s=(0,dr.resolveUrl)(this.opts.uriResolver,s,u)),new wo({schema:a,schemaId:c,root:t,baseId:s})}return hw.call(this,r,o)}}Qt.resolveSchema=Ef;var M9=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function hw(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,IO.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!M9.has(a)&&u&&(e=(0,dr.resolveUrl)(this.opts.uriResolver,e,u))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,IO.schemaHasRulesButRef)(r,this.RULES)){let a=(0,dr.resolveUrl)(this.opts.uriResolver,e,r.$ref);i=Ef.call(this,n,a)}let{schemaId:o}=this.opts;if(i=i||new wo({schema:r,schemaId:o,root:n,baseId:e}),i.schema!==i.root.schema)return i}});var NO=w((cne,C9)=>{C9.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var _w=w((une,LO)=>{"use strict";var j9=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),zO=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),gw=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),MO=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),L9=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function yw(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var q9=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function RO(t){return t.length=0,!0}function D9(t,e,r){if(t.length){let n=yw(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Z9(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],i=!1,o=!1,a=D9;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(i===!0&&(o=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(i=!0),n.push(":");continue}else if(u==="%"){if(!a(s,n,r))break;a=RO}else{s.push(u);continue}}return s.length&&(a===RO?r.zone=s.join(""):o?n.push(s.join("")):n.push(yw(s))),r.address=n.join(""),r}function CO(t){if(U9(t,":")<2)return{host:t,isIPV6:!1};let e=Z9(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function U9(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function F9(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var B9={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},V9=/[@/?#:]/g,H9=/[@/?#]/g;function jO(t,e){let r=e?H9:V9;return r.lastIndex=0,t.replace(r,n=>B9[n])}function W9(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(gw(s)){let i=s.toUpperCase(),o=String.fromCharCode(parseInt(i,16));e&&MO(o)?r+=o:r+="%"+i,n+=2;continue}}r+=t[n]}return r}function K9(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(gw(n)){let s=n.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&MO(i)?e+=i:e+="%"+s,r+=2;continue}}L9(t[r])?e+=t[r]:e+=escape(t[r])}return e}function J9(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(gw(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function G9(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!zO(r)){let n=CO(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=jO(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}LO.exports={nonSimpleDomain:q9,recomposeAuthority:G9,reescapeHostDelimiters:jO,normalizePercentEncoding:W9,normalizePathEncoding:K9,escapePreservingEscapes:J9,removeDotSegments:F9,isIPv4:zO,isUUID:j9,normalizeIPv6:CO,stringArrayToHexStripped:yw}});var FO=w((lne,UO)=>{"use strict";var{isUUID:Y9}=_w(),X9=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Q9=["http","https","ws","wss","urn","urn:uuid"];function eV(t){return Q9.indexOf(t)!==-1}function bw(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function qO(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function DO(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function tV(t){return t.secure=bw(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function rV(t){if((t.port===(bw(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function nV(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(X9);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,i=ww(s);t.path=void 0,i&&(t=i.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function sV(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,i=ww(s);i&&(t=i.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function iV(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Y9(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function oV(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ZO={scheme:"http",domainHost:!0,parse:qO,serialize:DO},aV={scheme:"https",domainHost:ZO.domainHost,parse:qO,serialize:DO},Pf={scheme:"ws",domainHost:!0,parse:tV,serialize:rV},cV={scheme:"wss",domainHost:Pf.domainHost,parse:Pf.parse,serialize:Pf.serialize},uV={scheme:"urn",parse:nV,serialize:sV,skipNormalize:!0},lV={scheme:"urn:uuid",parse:iV,serialize:oV,skipNormalize:!0},Of={http:ZO,https:aV,ws:Pf,wss:cV,urn:uV,"urn:uuid":lV};Object.setPrototypeOf(Of,null);function ww(t){return t&&(Of[t]||Of[t.toLowerCase()])||void 0}UO.exports={wsIsSecure:bw,SCHEMES:Of,isValidSchemeName:eV,getSchemeHandler:ww}});var JO=w((dne,If)=>{"use strict";var{normalizeIPv6:dV,removeDotSegments:Lc,recomposeAuthority:fV,normalizePercentEncoding:pV,normalizePathEncoding:hV,escapePreservingEscapes:mV,reescapeHostDelimiters:gV,isIPv4:yV,nonSimpleDomain:_V}=_w(),{SCHEMES:bV,getSchemeHandler:VO}=FO();function wV(t,e){return typeof t=="string"?t=$V(t,e):typeof t=="object"&&(t=vo(Ks(t,e),e)),t}function vV(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=HO(vo(t,n),vo(e,n),n,!0);return n.skipEscape=!0,Ks(s,n)}function HO(t,e,r,n){let s={};return n||(t=vo(Ks(t,r),r),e=vo(Ks(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Lc(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Lc(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=Lc(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=Lc(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function xV(t,e,r){let n=BO(t,r),s=BO(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function Ks(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],i=VO(n.scheme||r.scheme);i&&i.serialize&&i.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=pV(r.path):(r.path=mV(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let o=fV(r);if(o!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(o),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!i||!i.absolutePath)&&(a=Lc(a)),o===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var SV=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function kV(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function WO(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1,i=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let o=t.match(SV);if(o){n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]);let a=kV(n,o);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(yV(n.host)===!1){let l=dV(n.host);n.host=l.host.toLowerCase(),i=l.isIPV6}else i=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=VO(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&i===!1&&_V(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=gV(unescape(n.host),i))),n.path&&(n.path=hV(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function vo(t,e){return WO(t,e).parsed}function $V(t,e){return KO(t,e).normalized}function KO(t,e){let{parsed:r,malformedAuthorityOrPort:n}=WO(t,e);return{normalized:n?t:Ks(r,e),malformedAuthorityOrPort:n}}function BO(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=KO(t,e);return n?void 0:r}if(typeof t=="object")return Ks(t,e)}var vw={SCHEMES:bV,normalize:wV,resolve:vV,resolveComponent:HO,equal:xV,serialize:Ks,parse:vo};If.exports=vw;If.exports.default=vw;If.exports.fastUri=vw});var YO=w(xw=>{"use strict";Object.defineProperty(xw,"__esModule",{value:!0});var GO=JO();GO.code='require("ajv/dist/runtime/uri").default';xw.default=GO});var iI=w(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.CodeGen=it.Name=it.nil=it.stringify=it.str=it._=it.KeywordCxt=void 0;var EV=Cc();Object.defineProperty(it,"KeywordCxt",{enumerable:!0,get:function(){return EV.KeywordCxt}});var xo=te();Object.defineProperty(it,"_",{enumerable:!0,get:function(){return xo._}});Object.defineProperty(it,"str",{enumerable:!0,get:function(){return xo.str}});Object.defineProperty(it,"stringify",{enumerable:!0,get:function(){return xo.stringify}});Object.defineProperty(it,"nil",{enumerable:!0,get:function(){return xo.nil}});Object.defineProperty(it,"Name",{enumerable:!0,get:function(){return xo.Name}});Object.defineProperty(it,"CodeGen",{enumerable:!0,get:function(){return xo.CodeGen}});var TV=$f(),rI=jc(),PV=Gb(),qc=Tf(),OV=te(),Dc=Rc(),Af=Nc(),kw=fe(),XO=NO(),IV=YO(),nI=(t,e)=>new RegExp(t,e);nI.code="new RegExp";var AV=["removeAdditional","useDefaults","coerceTypes"],NV=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),RV={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},zV={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},QO=200;function MV(t){var e,r,n,s,i,o,a,c,u,l,d,f,p,m,h,g,y,_,v,k,E,C,B,R,ue;let I=t.strict,K=(e=t.code)===null||e===void 0?void 0:e.optimize,J=K===!0||K===void 0?1:K||0,ze=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:nI,De=(s=t.uriResolver)!==null&&s!==void 0?s:IV.default;return{strictSchema:(o=(i=t.strictSchema)!==null&&i!==void 0?i:I)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:I)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:I)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:I)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:I)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:J,regExp:ze}:{optimize:J,regExp:ze},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:QO,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:QO,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(k=t.schemaId)!==null&&k!==void 0?k:"$id",addUsedSchema:(E=t.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(C=t.validateSchema)!==null&&C!==void 0?C:!0,validateFormats:(B=t.validateFormats)!==null&&B!==void 0?B:!0,unicodeRegExp:(R=t.unicodeRegExp)!==null&&R!==void 0?R:!0,int32range:(ue=t.int32range)!==null&&ue!==void 0?ue:!0,uriResolver:De}}var Zc=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...MV(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new OV.ValueScope({scope:{},prefixes:NV,es5:r,lines:n}),this.logger=ZV(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,PV.getRules)(),eI.call(this,RV,e,"NOT SUPPORTED"),eI.call(this,zV,e,"DEPRECATED","warn"),this._metaOpts=qV.call(this),e.formats&&jV.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&LV.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),CV.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=XO;n==="id"&&(s={...XO},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(l,d){await i.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||o.call(this,f)}async function i(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},!0)}async function o(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof rI.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),o.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await i.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,s);return this}let i;if(typeof e=="object"){let{schemaId:o}=this.opts;if(i=e[o],i!==void 0&&typeof i!="string")throw new Error(`schema ${o} must be string`)}return r=(0,Dc.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return s}getSchema(e){let r;for(;typeof(r=tI.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new qc.SchemaEnv({schema:{},schemaId:n});if(r=qc.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=tI.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Dc.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(FV.call(this,n,r),!r)return(0,kw.eachItem)(n,i=>Sw.call(this,i)),this;VV.call(this,r);let s={...r,type:(0,Af.getJSONTypes)(r.type),schemaType:(0,Af.getJSONTypes)(r.schemaType)};return(0,kw.eachItem)(n,s.type.length===0?i=>Sw.call(this,i,s):i=>s.type.forEach(o=>Sw.call(this,i,s,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(i=>i.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,i)=>s+r+i)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let i=s.split("/").slice(1),o=e;for(let a of i)o=o[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=o[a];u&&l&&(o[a]=sI(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,i=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Dc.normalizeId)(o||n);let u=Dc.getSchemaRefs.call(this,e,n);return c=new qc.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):qc.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{qc.compileSchema.call(this,e)}finally{this.opts=r}}};Zc.ValidationError=TV.default;Zc.MissingRefError=rI.default;it.default=Zc;function eI(t,e,r,n="error"){for(let s in t){let i=s;i in e&&this.logger[n](`${r}: option ${s}. ${t[i]}`)}}function tI(t){return t=(0,Dc.normalizeId)(t),this.schemas[t]||this.refs[t]}function CV(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function jV(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function LV(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function qV(){let t={...this.opts};for(let e of AV)delete t[e];return t}var DV={log(){},warn(){},error(){}};function ZV(t){if(t===!1)return DV;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var UV=/^[a-z_$][a-z0-9_$:-]*$/i;function FV(t,e){let{RULES:r}=this;if((0,kw.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!UV.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Sw(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,o=s?i.post:i.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},i.rules.push(o)),i.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Af.getJSONTypes)(e.type),schemaType:(0,Af.getJSONTypes)(e.schemaType)}};e.before?BV.call(this,o,a,e.before):o.rules.push(a),i.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function BV(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function VV(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=sI(e)),t.validateSchema=this.compile(e,!0))}var HV={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function sI(t){return{anyOf:[t,HV]}}});var oI=w($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});var WV={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};$w.default=WV});var lI=w(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.callRef=Js.getValidate=void 0;var KV=jc(),aI=Xt(),Tt=te(),So=Xr(),cI=Tf(),Nf=fe(),JV={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:i,validateName:o,opts:a,self:c}=n,{root:u}=i;if((r==="#"||r==="#/")&&s===u.baseId)return d();let l=cI.resolveRef.call(c,u,s,r);if(l===void 0)throw new KV.default(n.opts.uriResolver,s,r);if(l instanceof cI.SchemaEnv)return f(l);return p(l);function d(){if(i===u)return Rf(t,o,i,i.$async);let m=e.scopeValue("root",{ref:u});return Rf(t,(0,Tt._)`${m}.validate`,u,u.$async)}function f(m){let h=uI(t,m);Rf(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Tt.stringify)(m)}:{ref:m}),g=e.name("valid"),y=t.subschema({schema:m,dataTypes:[],schemaPath:Tt.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function uI(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Tt._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Js.getValidate=uI;function Rf(t,e,r,n){let{gen:s,it:i}=t,{allErrors:o,schemaEnv:a,opts:c}=i,u=c.passContext?So.default.this:Tt.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Tt._)`await ${(0,aI.callValidateCode)(t,e,u)}`),p(e),o||s.assign(m,!0)},h=>{s.if((0,Tt._)`!(${h} instanceof ${i.ValidationError})`,()=>s.throw(h)),f(h),o||s.assign(m,!1)}),t.ok(m)}function d(){t.result((0,aI.callValidateCode)(t,e,u),()=>p(e),()=>f(e))}function f(m){let h=(0,Tt._)`${m}.errors`;s.assign(So.default.vErrors,(0,Tt._)`${So.default.vErrors} === null ? ${h} : ${So.default.vErrors}.concat(${h})`),s.assign(So.default.errors,(0,Tt._)`${So.default.vErrors}.length`)}function p(m){var h;if(!i.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(i.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(i.props=Nf.mergeEvaluated.props(s,g.props,i.props));else{let y=s.var("props",(0,Tt._)`${m}.evaluated.props`);i.props=Nf.mergeEvaluated.props(s,y,i.props,Tt.Name)}if(i.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(i.items=Nf.mergeEvaluated.items(s,g.items,i.items));else{let y=s.var("items",(0,Tt._)`${m}.evaluated.items`);i.items=Nf.mergeEvaluated.items(s,y,i.items,Tt.Name)}}}Js.callRef=Rf;Js.default=JV});var dI=w(Ew=>{"use strict";Object.defineProperty(Ew,"__esModule",{value:!0});var GV=oI(),YV=lI(),XV=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",GV.default,YV.default];Ew.default=XV});var fI=w(Tw=>{"use strict";Object.defineProperty(Tw,"__esModule",{value:!0});var zf=te(),Un=zf.operators,Mf={maximum:{okStr:"<=",ok:Un.LTE,fail:Un.GT},minimum:{okStr:">=",ok:Un.GTE,fail:Un.LT},exclusiveMaximum:{okStr:"<",ok:Un.LT,fail:Un.GTE},exclusiveMinimum:{okStr:">",ok:Un.GT,fail:Un.LTE}},QV={message:({keyword:t,schemaCode:e})=>(0,zf.str)`must be ${Mf[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,zf._)`{comparison: ${Mf[t].okStr}, limit: ${e}}`},e6={keyword:Object.keys(Mf),type:"number",schemaType:"number",$data:!0,error:QV,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,zf._)`${r} ${Mf[e].fail} ${n} || isNaN(${r})`)}};Tw.default=e6});var pI=w(Pw=>{"use strict";Object.defineProperty(Pw,"__esModule",{value:!0});var Uc=te(),t6={message:({schemaCode:t})=>(0,Uc.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Uc._)`{multipleOf: ${t}}`},r6={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:t6,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,i=s.opts.multipleOfPrecision,o=e.let("res"),a=i?(0,Uc._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:(0,Uc._)`${o} !== parseInt(${o})`;t.fail$data((0,Uc._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};Pw.default=r6});var mI=w(Ow=>{"use strict";Object.defineProperty(Ow,"__esModule",{value:!0});function hI(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}Ow.default=hI;hI.code='require("ajv/dist/runtime/ucs2length").default'});var gI=w(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});var Gs=te(),n6=fe(),s6=mI(),i6={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Gs.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Gs._)`{limit: ${t}}`},o6={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:i6,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,i=e==="maxLength"?Gs.operators.GT:Gs.operators.LT,o=s.opts.unicode===!1?(0,Gs._)`${r}.length`:(0,Gs._)`${(0,n6.useFunc)(t.gen,s6.default)}(${r})`;t.fail$data((0,Gs._)`${o} ${i} ${n}`)}};Iw.default=o6});var yI=w(Aw=>{"use strict";Object.defineProperty(Aw,"__esModule",{value:!0});var a6=Xt(),c6=fe(),ko=te(),u6={message:({schemaCode:t})=>(0,ko.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ko._)`{pattern: ${t}}`},l6={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:u6,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:i,it:o}=t,a=o.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=o.opts.code,u=c.code==="new RegExp"?(0,ko._)`new RegExp`:(0,c6.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,ko._)`${u}(${i}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,ko._)`!${l}`)}else{let c=(0,a6.usePattern)(t,s);t.fail$data((0,ko._)`!${c}.test(${r})`)}}};Aw.default=l6});var _I=w(Nw=>{"use strict";Object.defineProperty(Nw,"__esModule",{value:!0});var Fc=te(),d6={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Fc.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Fc._)`{limit: ${t}}`},f6={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:d6,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Fc.operators.GT:Fc.operators.LT;t.fail$data((0,Fc._)`Object.keys(${r}).length ${s} ${n}`)}};Nw.default=f6});var bI=w(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});var Bc=Xt(),Vc=te(),p6=fe(),h6={message:({params:{missingProperty:t}})=>(0,Vc.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Vc._)`{missingProperty: ${t}}`},m6={keyword:"required",type:"object",schemaType:"array",$data:!0,error:h6,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:i,it:o}=t,{opts:a}=o;if(!i&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?u():l(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,p6.checkStrictMode)(o,y,o.opts.strictRequired)}}function u(){if(c||i)t.block$data(Vc.nil,d);else for(let p of r)(0,Bc.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||i){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Bc.checkMissingProp)(t,r,p)),(0,Bc.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Bc.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,Bc.propertyInData)(e,s,p,a.ownProperties)),e.if((0,Vc.not)(m),()=>{t.error(),e.break()})},Vc.nil)}}};Rw.default=m6});var wI=w(zw=>{"use strict";Object.defineProperty(zw,"__esModule",{value:!0});var Hc=te(),g6={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Hc.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Hc._)`{limit: ${t}}`},y6={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:g6,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Hc.operators.GT:Hc.operators.LT;t.fail$data((0,Hc._)`${r}.length ${s} ${n}`)}};zw.default=y6});var Cf=w(Mw=>{"use strict";Object.defineProperty(Mw,"__esModule",{value:!0});var vI=sw();vI.code='require("ajv/dist/runtime/equal").default';Mw.default=vI});var xI=w(jw=>{"use strict";Object.defineProperty(jw,"__esModule",{value:!0});var Cw=Nc(),ot=te(),_6=fe(),b6=Cf(),w6={message:({params:{i:t,j:e}})=>(0,ot.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ot._)`{i: ${t}, j: ${e}}`},v6={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:w6,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:i,schemaCode:o,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),u=i.items?(0,Cw.getSchemaTypes)(i.items):[];t.block$data(c,l,(0,ot._)`${o} === false`),t.ok(c);function l(){let m=e.let("i",(0,ot._)`${r}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,ot._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=e.name("item"),y=(0,Cw.checkDataTypes)(u,g,a.opts.strictNumbers,Cw.DataType.Wrong),_=e.const("indices",(0,ot._)`{}`);e.for((0,ot._)`;${m}--;`,()=>{e.let(g,(0,ot._)`${r}[${m}]`),e.if(y,(0,ot._)`continue`),u.length>1&&e.if((0,ot._)`typeof ${g} == "string"`,(0,ot._)`${g} += "_"`),e.if((0,ot._)`typeof ${_}[${g}] == "number"`,()=>{e.assign(h,(0,ot._)`${_}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,ot._)`${_}[${g}] = ${m}`)})}function p(m,h){let g=(0,_6.useFunc)(e,b6.default),y=e.name("outer");e.label(y).for((0,ot._)`;${m}--;`,()=>e.for((0,ot._)`${h} = ${m}; ${h}--;`,()=>e.if((0,ot._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};jw.default=v6});var SI=w(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});var Lw=te(),x6=fe(),S6=Cf(),k6={message:"must be equal to constant",params:({schemaCode:t})=>(0,Lw._)`{allowedValue: ${t}}`},$6={keyword:"const",$data:!0,error:k6,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:i}=t;n||i&&typeof i=="object"?t.fail$data((0,Lw._)`!${(0,x6.useFunc)(e,S6.default)}(${r}, ${s})`):t.fail((0,Lw._)`${i} !== ${r}`)}};qw.default=$6});var kI=w(Dw=>{"use strict";Object.defineProperty(Dw,"__esModule",{value:!0});var Wc=te(),E6=fe(),T6=Cf(),P6={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Wc._)`{allowedValues: ${t}}`},O6={keyword:"enum",schemaType:"array",$data:!0,error:P6,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:i,it:o}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=o.opts.loopEnum,c,u=()=>c??(c=(0,E6.useFunc)(e,T6.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",i);l=(0,Wc.or)(...s.map((m,h)=>f(p,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",i,p=>e.if((0,Wc._)`${u()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function f(p,m){let h=s[m];return typeof h=="object"&&h!==null?(0,Wc._)`${u()}(${r}, ${p}[${m}])`:(0,Wc._)`${r} === ${h}`}}};Dw.default=O6});var $I=w(Zw=>{"use strict";Object.defineProperty(Zw,"__esModule",{value:!0});var I6=fI(),A6=pI(),N6=gI(),R6=yI(),z6=_I(),M6=bI(),C6=wI(),j6=xI(),L6=SI(),q6=kI(),D6=[I6.default,A6.default,N6.default,R6.default,z6.default,M6.default,C6.default,j6.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},L6.default,q6.default];Zw.default=D6});var Fw=w(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.validateAdditionalItems=void 0;var Ys=te(),Uw=fe(),Z6={message:({params:{len:t}})=>(0,Ys.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ys._)`{limit: ${t}}`},U6={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Z6,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Uw.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}EI(t,n)}};function EI(t,e){let{gen:r,schema:n,data:s,keyword:i,it:o}=t;o.items=!0;let a=r.const("len",(0,Ys._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Ys._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Uw.alwaysValidSchema)(o,n)){let u=r.var("valid",(0,Ys._)`${a} <= ${e.length}`);r.if((0,Ys.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:i,dataProp:l,dataPropType:Uw.Type.Num},u),o.allErrors||r.if((0,Ys.not)(u),()=>r.break())})}}Kc.validateAdditionalItems=EI;Kc.default=U6});var Bw=w(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.validateTuple=void 0;var TI=te(),jf=fe(),F6=Xt(),B6={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return PI(t,"additionalItems",e);r.items=!0,!(0,jf.alwaysValidSchema)(r,e)&&t.ok((0,F6.validateArray)(t))}};function PI(t,e,r=t.schema){let{gen:n,parentSchema:s,data:i,keyword:o,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=jf.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,TI._)`${i}.length`);r.forEach((d,f)=>{(0,jf.alwaysValidSchema)(a,d)||(n.if((0,TI._)`${u} > ${f}`,()=>t.subschema({keyword:o,schemaProp:f,dataProp:f},c)),t.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let g=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,jf.checkStrictMode)(a,g,f.strictTuples)}}}Jc.validateTuple=PI;Jc.default=B6});var OI=w(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});var V6=Bw(),H6={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,V6.validateTuple)(t,"items")};Vw.default=H6});var AI=w(Hw=>{"use strict";Object.defineProperty(Hw,"__esModule",{value:!0});var II=te(),W6=fe(),K6=Xt(),J6=Fw(),G6={message:({params:{len:t}})=>(0,II.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,II._)`{limit: ${t}}`},Y6={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:G6,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,W6.alwaysValidSchema)(n,e)&&(s?(0,J6.validateAdditionalItems)(t,s):t.ok((0,K6.validateArray)(t)))}};Hw.default=Y6});var NI=w(Ww=>{"use strict";Object.defineProperty(Ww,"__esModule",{value:!0});var er=te(),Lf=fe(),X6={message:({params:{min:t,max:e}})=>e===void 0?(0,er.str)`must contain at least ${t} valid item(s)`:(0,er.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,er._)`{minContains: ${t}}`:(0,er._)`{minContains: ${t}, maxContains: ${e}}`},Q6={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:X6,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:i}=t,o,a,{minContains:c,maxContains:u}=n;i.opts.next?(o=c===void 0?1:c,a=u):o=1;let l=e.const("len",(0,er._)`${s}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,Lf.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,Lf.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Lf.alwaysValidSchema)(i,r)){let h=(0,er._)`${l} >= ${o}`;a!==void 0&&(h=(0,er._)`${h} && ${l} <= ${a}`),t.pass(h);return}i.items=!0;let d=e.name("valid");a===void 0&&o===1?p(d,()=>e.if(d,()=>e.break())):o===0?(e.let(d,!0),a!==void 0&&e.if((0,er._)`${s}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),g=e.let("count",0);p(h,()=>e.if(h,()=>m(g)))}function p(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:Lf.Type.Num,compositeRule:!0},h),g()})}function m(h){e.code((0,er._)`${h}++`),a===void 0?e.if((0,er._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,er._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,er._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};Ww.default=Q6});var MI=w(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.validateSchemaDeps=Pr.validatePropertyDeps=Pr.error=void 0;var Kw=te(),eH=fe(),Gc=Xt();Pr.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Kw.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Kw._)`{property: ${t},
|
|
188
188
|
missingProperty: ${n},
|
|
189
189
|
depsCount: ${e},
|
|
190
|
-
deps: ${r}}`};var eH={keyword:"dependencies",type:"object",schemaType:"object",error:Tr.error,code(t){let[e,r]=tH(t);NI(t,e),RI(t,r)}};function tH({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function NI(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let i=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Jc.propertyInData)(r,n,o,s.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let u of a)(0,Jc.checkReportMissingProp)(t,u)}):(r.if((0,Ww._)`${c} && (${(0,Jc.checkMissingProp)(t,a,i)})`),(0,Jc.reportMissingProp)(t,i),r.else())}}Tr.validatePropertyDeps=NI;function RI(t,e=t.schema){let{gen:r,data:n,keyword:s,it:i}=t,o=r.name("valid");for(let a in e)(0,Q6.alwaysValidSchema)(i,e[a])||(r.if((0,Jc.propertyInData)(r,n,a,i.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}Tr.validateSchemaDeps=RI;Tr.default=eH});var CI=w(Kw=>{"use strict";Object.defineProperty(Kw,"__esModule",{value:!0});var MI=te(),rH=fe(),nH={message:"property name must be valid",params:({params:t})=>(0,MI._)`{propertyName: ${t.propertyName}}`},sH={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:nH,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,rH.alwaysValidSchema)(s,r))return;let i=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),e.if((0,MI.not)(i),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(i)}};Kw.default=sH});var Gw=w(Jw=>{"use strict";Object.defineProperty(Jw,"__esModule",{value:!0});var Lf=Yt(),dr=te(),iH=Yr(),qf=fe(),oH={message:"must NOT have additional properties",params:({params:t})=>(0,dr._)`{additionalProperty: ${t.additionalProperty}}`},aH={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:oH,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:i,it:o}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,qf.alwaysValidSchema)(o,r))return;let u=(0,Lf.allSchemaProperties)(n.properties),l=(0,Lf.allSchemaProperties)(n.patternProperties);d(),t.ok((0,dr._)`${i} === ${iH.default.errors}`);function d(){e.forIn("key",s,g=>{!u.length&&!l.length?m(g):e.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let _=(0,qf.schemaRefOrVal)(o,n.properties,"properties");y=(0,Lf.isOwnProperty)(e,_,g)}else u.length?y=(0,dr.or)(...u.map(_=>(0,dr._)`${g} === ${_}`)):y=dr.nil;return l.length&&(y=(0,dr.or)(y,...l.map(_=>(0,dr._)`${(0,Lf.usePattern)(t,_)}.test(${g})`))),(0,dr.not)(y)}function p(g){e.code((0,dr._)`delete ${s}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,qf.alwaysValidSchema)(o,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,dr.not)(y),()=>{t.reset(),p(g)})):(h(g,y),a||e.if((0,dr.not)(y),()=>e.break()))}}function h(g,y,_){let v={keyword:"additionalProperties",dataProp:g,dataPropType:qf.Type.Str};_===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,y)}}};Jw.default=aH});var qI=w(Xw=>{"use strict";Object.defineProperty(Xw,"__esModule",{value:!0});var cH=Mc(),jI=Yt(),Yw=fe(),LI=Gw(),uH={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:i}=t;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&LI.default.code(new cH.KeywordCxt(i,LI.default,"additionalProperties"));let o=(0,jI.allSchemaProperties)(r);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=Yw.mergeEvaluated.props(e,(0,Yw.toHash)(o),i.props));let a=o.filter(d=>!(0,Yw.alwaysValidSchema)(i,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,jI.propertyInData)(e,s,d,i.opts.ownProperties)),l(d),i.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Xw.default=uH});var FI=w(Qw=>{"use strict";Object.defineProperty(Qw,"__esModule",{value:!0});var DI=Yt(),Df=te(),ZI=fe(),UI=fe(),lH={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:i}=t,{opts:o}=i,a=(0,DI.allSchemaProperties)(r),c=a.filter(h=>(0,ZI.alwaysValidSchema)(i,r[h]));if(a.length===0||c.length===a.length&&(!i.opts.unevaluated||i.props===!0))return;let u=o.strictSchema&&!o.allowMatchingProperties&&s.properties,l=e.name("valid");i.props!==!0&&!(i.props instanceof Df.Name)&&(i.props=(0,UI.evaluatedPropsToName)(e,i.props));let{props:d}=i;f();function f(){for(let h of a)u&&p(h),i.allErrors?m(h):(e.var(l,!0),m(h),e.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,ZI.checkStrictMode)(i,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",n,g=>{e.if((0,Df._)`${(0,DI.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:UI.Type.Str},l),i.opts.unevaluated&&d!==!0?e.assign((0,Df._)`${d}[${g}]`,!0):!y&&!i.allErrors&&e.if((0,Df.not)(l),()=>e.break())})})}}};Qw.default=lH});var BI=w(ev=>{"use strict";Object.defineProperty(ev,"__esModule",{value:!0});var dH=fe(),fH={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,dH.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};ev.default=fH});var VI=w(tv=>{"use strict";Object.defineProperty(tv,"__esModule",{value:!0});var pH=Yt(),hH={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:pH.validateUnion,error:{message:"must match a schema in anyOf"}};tv.default=hH});var HI=w(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var Zf=te(),mH=fe(),gH={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Zf._)`{passingSchemas: ${t.passing}}`},yH={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:gH,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let i=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(o,()=>t.reset(),()=>t.error(!0));function u(){i.forEach((l,d)=>{let f;(0,mH.alwaysValidSchema)(s,l)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Zf._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Zf._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Zf.Name)})})}}};rv.default=yH});var WI=w(nv=>{"use strict";Object.defineProperty(nv,"__esModule",{value:!0});var _H=fe(),bH={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((i,o)=>{if((0,_H.alwaysValidSchema)(n,i))return;let a=t.subschema({keyword:"allOf",schemaProp:o},s);t.ok(s),t.mergeEvaluated(a)})}};nv.default=bH});var GI=w(sv=>{"use strict";Object.defineProperty(sv,"__esModule",{value:!0});var Uf=te(),JI=fe(),wH={message:({params:t})=>(0,Uf.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Uf._)`{failingKeyword: ${t.ifClause}}`},vH={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:wH,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,JI.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=KI(n,"then"),i=KI(n,"else");if(!s&&!i)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&i){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else s?e.if(a,u("then")):e.if((0,Uf.not)(a),u("else"));t.pass(o,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let f=t.subschema({keyword:l},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,Uf._)`${l}`):t.setParams({ifClause:l})}}}};function KI(t,e){let r=t.schema[e];return r!==void 0&&!(0,JI.alwaysValidSchema)(t,r)}sv.default=vH});var YI=w(iv=>{"use strict";Object.defineProperty(iv,"__esModule",{value:!0});var xH=fe(),SH={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,xH.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};iv.default=SH});var XI=w(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});var kH=Uw(),$H=PI(),EH=Fw(),TH=II(),PH=AI(),OH=zI(),IH=CI(),AH=Gw(),NH=qI(),RH=FI(),zH=BI(),MH=VI(),CH=HI(),jH=WI(),LH=GI(),qH=YI();function DH(t=!1){let e=[zH.default,MH.default,CH.default,jH.default,LH.default,qH.default,IH.default,AH.default,OH.default,NH.default,RH.default];return t?e.push($H.default,TH.default):e.push(kH.default,EH.default),e.push(PH.default),e}ov.default=DH});var QI=w(av=>{"use strict";Object.defineProperty(av,"__esModule",{value:!0});var Le=te(),ZH={message:({schemaCode:t})=>(0,Le.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Le._)`{format: ${t}}`},UH={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ZH,code(t,e){let{gen:r,data:n,$data:s,schema:i,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Le._)`${m}[${o}]`),g=r.let("fType"),y=r.let("format");r.if((0,Le._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,Le._)`${h}.type || "string"`).assign(y,(0,Le._)`${h}.validate`),()=>r.assign(g,(0,Le._)`"string"`).assign(y,h)),t.fail$data((0,Le.or)(_(),v()));function _(){return c.strictSchema===!1?Le.nil:(0,Le._)`${o} && !${y}`}function v(){let k=l.$async?(0,Le._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Le._)`${y}(${n})`,E=(0,Le._)`(typeof ${y} == "function" ? ${k} : ${y}.test(${n}))`;return(0,Le._)`${y} && ${y} !== true && ${g} === ${e} && !${E}`}}function p(){let m=d.formats[i];if(!m){_();return}if(m===!0)return;let[h,g,y]=v(m);h===e&&t.pass(k());function _(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${i}" ignored in schema at path "${u}"`}}function v(E){let C=E instanceof RegExp?(0,Le.regexpCode)(E):c.code.formats?(0,Le._)`${c.code.formats}${(0,Le.getProperty)(i)}`:void 0,B=r.scopeValue("formats",{key:i,ref:E,code:C});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Le._)`${B}.validate`]:["string",E,B]}function k(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Le._)`await ${y}(${n})`}return typeof g=="function"?(0,Le._)`${y}(${n})`:(0,Le._)`${y}.test(${n})`}}}};av.default=UH});var eA=w(cv=>{"use strict";Object.defineProperty(cv,"__esModule",{value:!0});var FH=QI(),BH=[FH.default];cv.default=BH});var tA=w(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.contentVocabulary=ko.metadataVocabulary=void 0;ko.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ko.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var nA=w(uv=>{"use strict";Object.defineProperty(uv,"__esModule",{value:!0});var VH=lI(),HH=kI(),WH=XI(),KH=eA(),rA=tA(),JH=[VH.default,HH.default,(0,WH.default)(),KH.default,rA.metadataVocabulary,rA.contentVocabulary];uv.default=JH});var iA=w(Ff=>{"use strict";Object.defineProperty(Ff,"__esModule",{value:!0});Ff.DiscrError=void 0;var sA;(function(t){t.Tag="tag",t.Mapping="mapping"})(sA||(Ff.DiscrError=sA={}))});var aA=w(dv=>{"use strict";Object.defineProperty(dv,"__esModule",{value:!0});var $o=te(),lv=iA(),oA=Ef(),GH=Cc(),YH=fe(),XH={message:({params:{discrError:t,tagName:e}})=>t===lv.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,$o._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},QH={keyword:"discriminator",type:"object",schemaType:"object",error:XH,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:i}=t,{oneOf:o}=s;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,$o._)`${r}${(0,$o.getProperty)(a)}`);e.if((0,$o._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:lv.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,$o._)`${u} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:lv.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,$o.Name),m}function f(){var p;let m={},h=y(s),g=!0;for(let k=0;k<o.length;k++){let E=o[k];if(E?.$ref&&!(0,YH.schemaHasRulesButRef)(E,i.self.RULES)){let B=E.$ref;if(E=oA.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,B),E instanceof oA.SchemaEnv&&(E=E.schema),E===void 0)throw new GH.default(i.opts.uriResolver,i.baseId,B)}let C=(p=E?.properties)===null||p===void 0?void 0:p[a];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(E)),_(C,k)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:k}){return Array.isArray(k)&&k.includes(a)}function _(k,E){if(k.const)v(k.const,E);else if(k.enum)for(let C of k.enum)v(C,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(k,E){if(typeof k!="string"||k in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[k]=E}}}};dv.default=QH});var cA=w((Yne,eW)=>{eW.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var pv=w((Te,fv)=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.MissingRefError=Te.ValidationError=Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=Te.Ajv=void 0;var tW=sI(),rW=nA(),nW=aA(),uA=cA(),sW=["/properties"],Bf="http://json-schema.org/draft-07/schema",Eo=class extends tW.default{_addVocabularies(){super._addVocabularies(),rW.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(nW.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(uA,sW):uA;this.addMetaSchema(e,Bf,!1),this.refs["http://json-schema.org/schema"]=Bf}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Bf)?Bf:void 0)}};Te.Ajv=Eo;fv.exports=Te=Eo;fv.exports.Ajv=Eo;Object.defineProperty(Te,"__esModule",{value:!0});Te.default=Eo;var iW=Mc();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return iW.KeywordCxt}});var To=te();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return To._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return To.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return To.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return To.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return To.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return To.CodeGen}});var oW=kf();Object.defineProperty(Te,"ValidationError",{enumerable:!0,get:function(){return oW.default}});var aW=Cc();Object.defineProperty(Te,"MissingRefError",{enumerable:!0,get:function(){return aW.default}})});var yA=w(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.formatNames=Or.fastFormats=Or.fullFormats=void 0;function Pr(t,e){return{validate:t,compare:e}}Or.fullFormats={date:Pr(pA,yv),time:Pr(mv(!0),_v),"date-time":Pr(lA(!0),mA),"iso-time":Pr(mv(),hA),"iso-date-time":Pr(lA(),gA),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:pW,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|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-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:wW,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:hW,int32:{type:"number",validate:yW},int64:{type:"number",validate:_W},float:{type:"number",validate:fA},double:{type:"number",validate:fA},password:!0,binary:!0};Or.fastFormats={...Or.fullFormats,date:Pr(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,yv),time:Pr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_v),"date-time":Pr(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,mA),"iso-time":Pr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,hA),"iso-date-time":Pr(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,gA),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Or.formatNames=Object.keys(Or.fullFormats);function cW(t){return t%4===0&&(t%100!==0||t%400===0)}var uW=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,lW=[0,31,28,31,30,31,30,31,31,30,31,30,31];function pA(t){let e=uW.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&cW(r)?29:lW[n])}function yv(t,e){if(t&&e)return t>e?1:t<e?-1:0}var hv=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function mv(t){return function(r){let n=hv.exec(r);if(!n)return!1;let s=+n[1],i=+n[2],o=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(s<=23&&i<=59&&o<60)return!0;let d=i-l*c,f=s-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&o<61}}function _v(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function hA(t,e){if(!(t&&e))return;let r=hv.exec(t),n=hv.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var gv=/t|\s/i;function lA(t){let e=mv(t);return function(n){let s=n.split(gv);return s.length===2&&pA(s[0])&&e(s[1])}}function mA(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function gA(t,e){if(!(t&&e))return;let[r,n]=t.split(gv),[s,i]=e.split(gv),o=yv(r,s);if(o!==void 0)return o||_v(n,i)}var dW=/\/|:/,fW=/^(?:[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 pW(t){return dW.test(t)&&fW.test(t)}var dA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function hW(t){return dA.lastIndex=0,dA.test(t)}var mW=-(2**31),gW=2**31-1;function yW(t){return Number.isInteger(t)&&t<=gW&&t>=mW}function _W(t){return Number.isInteger(t)}function fA(){return!0}var bW=/[^\\]\\Z/;function wW(t){if(bW.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var _A=w(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.formatLimitDefinition=void 0;var vW=pv(),fr=te(),Un=fr.operators,Vf={formatMaximum:{okStr:"<=",ok:Un.LTE,fail:Un.GT},formatMinimum:{okStr:">=",ok:Un.GTE,fail:Un.LT},formatExclusiveMaximum:{okStr:"<",ok:Un.LT,fail:Un.GTE},formatExclusiveMinimum:{okStr:">",ok:Un.GT,fail:Un.LTE}},xW={message:({keyword:t,schemaCode:e})=>(0,fr.str)`should be ${Vf[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,fr._)`{comparison: ${Vf[t].okStr}, limit: ${e}}`};Po.formatLimitDefinition={keyword:Object.keys(Vf),type:"string",schemaType:"string",$data:!0,error:xW,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:i}=t,{opts:o,self:a}=i;if(!o.validateFormats)return;let c=new vW.KeywordCxt(i,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=e.scopeValue("formats",{ref:a.formats,code:o.code.formats}),p=e.const("fmt",(0,fr._)`${f}[${c.schemaCode}]`);t.fail$data((0,fr.or)((0,fr._)`typeof ${p} != "object"`,(0,fr._)`${p} instanceof RegExp`,(0,fr._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let m=e.scopeValue("formats",{key:f,ref:p,code:o.code.formats?(0,fr._)`${o.code.formats}${(0,fr.getProperty)(f)}`:void 0});t.fail$data(d(m))}function d(f){return(0,fr._)`${f}.compare(${r}, ${n}) ${Vf[s].fail} 0`}},dependencies:["format"]};var SW=t=>(t.addKeyword(Po.formatLimitDefinition),t);Po.default=SW});var xA=w((Gc,vA)=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});var Oo=yA(),kW=_A(),bv=te(),bA=new bv.Name("fullFormats"),$W=new bv.Name("fastFormats"),wv=(t,e={keywords:!0})=>{if(Array.isArray(e))return wA(t,e,Oo.fullFormats,bA),t;let[r,n]=e.mode==="fast"?[Oo.fastFormats,$W]:[Oo.fullFormats,bA],s=e.formats||Oo.formatNames;return wA(t,s,r,n),e.keywords&&(0,kW.default)(t),t};wv.get=(t,e="full")=>{let n=(e==="fast"?Oo.fastFormats:Oo.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function wA(t,e,r,n){var s,i;(s=(i=t.opts.code).formats)!==null&&s!==void 0||(i.formats=(0,bv._)`require("ajv-formats/dist/formats").${n}`);for(let o of e)t.addFormat(o,r[o])}vA.exports=Gc=wv;Object.defineProperty(Gc,"__esModule",{value:!0});Gc.default=wv});function EW(){let t=new SA.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,kA.default)(t),t}var SA,kA,Hf,$A=$(()=>{SA=Mt(pv(),1),kA=Mt(xA(),1);Hf=class{constructor(e){this._ajv=e??EW()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}});var Wf,EA=$(()=>{lo();Wf=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],i=Array.isArray(s.content)?s.content:[s.content],o=i.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(o){if(i.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(i.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},wc,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),s=e.mode??"form";switch(s){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=s==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:i},uo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}});function TA(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function PA(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var OA=$(()=>{});var Kf,IA=$(()=>{N1();lo();$A();cc();EA();OA();Kf=class extends df{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(bc.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{let i=this._loggingLevels.get(s);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Hf,this.setRequestHandler(z_,n=>this._oninitialize(n)),this.setNotificationHandler(M_,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(U_,async(n,s)=>{let i=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,a=bc.safeParse(o);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Wf(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=A1(this._capabilities,e)}setRequestHandler(e,r){let s=An(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let i;if(Ht(s)){let a=s;i=a._zod?.def?.value??a.value}else{let a=s;i=a._def?.value??a.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let a=async(c,u)=>{let l=In(co,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new D(F.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=In(oo,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new D(F.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=In(Xd,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new D(F.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){PA(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&TA(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:AP.includes(r)?r:O_,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Cd)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],i=s.some(u=>u.type==="tool_result"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=o?Array.isArray(o.content)?o.content:[o.content]:[],c=a.some(u=>u.type==="tool_use");if(i){if(s.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(s.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},F_,r):this.request({method:"sampling/createMessage",params:e},wc,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let s=e;return this.request({method:"elicitation/create",params:s},uo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let s=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:s},uo,r);if(i.action==="accept"&&i.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(i.content);if(!a.valid)throw new D(F.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(o){throw o instanceof D?o:new D(F.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return i}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},B_,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});function vv(t){return!!t&&typeof t=="object"&&NA in t}function RA(t){return t[NA]?.complete}var NA,AA,zA=$(()=>{NA=Symbol.for("mcp.completable");(function(t){t.Completable="McpCompletable"})(AA||(AA={}))});var MA=$(()=>{});function PW(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!TW.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,i)=>i.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function OW(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function xv(t){let e=PW(t);return OW(t,e.warnings),e.isValid}var TW,CA=$(()=>{TW=/^[A-Za-z0-9._-]{1,128}$/});var Jf,jA=$(()=>{Jf=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}}});var Sv=$(()=>{od();od()});function DA(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function ZA(t){return"_def"in t||"_zod"in t||DA(t)}function kv(t){return typeof t!="object"||t===null||ZA(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(DA)}function LA(t){if(t){if(kv(t))return qs(t);if(!ZA(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function AW(t){let e=An(t);return e?Object.entries(e).map(([r,n])=>{let s=rP(n),i=nP(n);return{name:r,description:s,required:!i}}):[]}function Fn(t){let r=An(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Id(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function qA(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Gf,IW,Yc,UA=$(()=>{IA();cc();Tb();lo();zA();MA();CA();jA();Sv();Gf=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Kf(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Jf(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Fn(Yd)),this.server.assertCanSetRequestHandler(Fn(co)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Yd,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let s=so(r.inputSchema);return s?kb(s,{strictUnions:!0,pipeStrategy:"input"}):IW})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=so(r.outputSchema);s&&(n.outputSchema=kb(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(co,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new D(F.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Tool ${e.params.name} disabled`);let s=!!e.params.task,i=n.execution?.taskSupport,o="createTask"in n.handler;if((i==="required"||i==="optional")&&!o)throw new D(F.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!s)throw new D(F.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!s&&o)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof D&&n.code===F.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let i=so(e.inputSchema)??e.inputSchema,o=await Pd(i,r);if(!o.success){let a="error"in o?o.error:"Unknown error",c=Od(a);throw new D(F.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return o.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new D(F.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=so(e.outputSchema),i=await Pd(s,r.structuredContent);if(!i.success){let o="error"in i?i.error:"Unknown error",a=Od(o);throw new D(F.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");let o={...n,taskStore:n.taskStore};if(e.inputSchema){let a=s;return await Promise.resolve(a.createTask(r,o))}else{let a=s;return await Promise.resolve(a.createTask(o))}}if(e.inputSchema){let o=s;return await Promise.resolve(o(r,n))}else{let o=s;return await Promise.resolve(o(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let s=await this.validateToolInput(e,r.params.arguments,r.params.name),i=e.handler,o={...n,taskStore:n.taskStore},a=s?await Promise.resolve(i.createTask(s,o)):await Promise.resolve(i.createTask(o)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(f=>setTimeout(f,l));let d=await n.taskStore.getTask(c);if(!d)throw new D(F.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Fn(Qd)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Qd,async e=>{switch(e.params.ref.type){case"ref/prompt":return WP(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return KP(e),this.handleResourceCompletion(e,e.params.ref);default:throw new D(F.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new D(F.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Yc;let i=An(n.argsSchema)?.[e.params.argument.name];if(!vv(i))return Yc;let o=RA(i);if(!o)return Yc;let a=await o(e.params.argument.value,e.params.context);return qA(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Yc;throw new D(F.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Yc;let i=await s(e.params.argument.value,e.params.context);return qA(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Fn(Hd)),this.server.assertCanSetRequestHandler(Fn(Wd)),this.server.assertCanSetRequestHandler(Fn(Kd)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Hd,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([i,o])=>o.enabled).map(([i,o])=>({uri:i,name:o.name,...o.metadata})),s=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let o=await i.resourceTemplate.listCallback(r);for(let a of o.resources)s.push({...i.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Wd,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Kd,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new D(F.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(let i of Object.values(this._registeredResourceTemplates)){let o=i.resourceTemplate.uriTemplate.match(n.toString());if(o)return i.readCallback(n,o,r)}throw new D(F.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Fn(Jd)),this.server.assertCanSetRequestHandler(Fn(Gd)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Jd,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?AW(r.argsSchema):void 0}))})),this.server.setRequestHandler(Gd,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new D(F.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=so(n.argsSchema),i=await Pd(s,e.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",u=Od(c);throw new D(F.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let o=i.data,a=n.callback;return await Promise.resolve(a(o,r))}else{let s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());let i=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,void 0,r,s,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,void 0,r,s,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,r,n,s,i){let o={name:e,title:r,metadata:s,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=o)),typeof a.name<"u"&&(o.name=a.name),typeof a.title<"u"&&(o.title=a.title),typeof a.metadata<"u"&&(o.metadata=a.metadata),typeof a.callback<"u"&&(o.readCallback=a.callback),typeof a.enabled<"u"&&(o.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,r,n,s,i){let o={resourceTemplate:n,title:r,metadata:s,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=o)),typeof u.title<"u"&&(o.title=u.title),typeof u.template<"u"&&(o.resourceTemplate=u.template),typeof u.metadata<"u"&&(o.metadata=u.metadata),typeof u.callback<"u"&&(o.readCallback=u.callback),typeof u.enabled<"u"&&(o.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,r,n,s,i){let o={title:r,description:n,argsSchema:s===void 0?void 0:qs(s),callback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=o)),typeof a.title<"u"&&(o.title=a.title),typeof a.description<"u"&&(o.description=a.description),typeof a.argsSchema<"u"&&(o.argsSchema=qs(a.argsSchema)),typeof a.callback<"u"&&(o.callback=a.callback),typeof a.enabled<"u"&&(o.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=o,s&&Object.values(s).some(c=>{let u=c instanceof wt?c._def?.innerType:c;return vv(u)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,r,n,s,i,o,a,c,u){xv(e);let l={title:r,description:n,inputSchema:LA(s),outputSchema:LA(i),annotations:o,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&xv(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=qs(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=qs(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,i,o;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(kv(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!kv(r[0])&&(o=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);o=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,s,i,o,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:s,description:i,inputSchema:o,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,i,o,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());let i=r[0],o=this._createRegisteredPrompt(e,void 0,n,s,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:s,description:i,argsSchema:o}=r,a=this._createRegisteredPrompt(e,s,i,o,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},IW={type:"object",properties:{}};Yc={completion:{values:[],hasMore:!1}}});function NW(t){return qP.parse(JSON.parse(t))}function FA(t){return JSON.stringify(t)+`
|
|
191
|
-
`}var
|
|
192
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),
|
|
193
|
-
`,"utf8"),o}async function
|
|
190
|
+
deps: ${r}}`};var tH={keyword:"dependencies",type:"object",schemaType:"object",error:Pr.error,code(t){let[e,r]=rH(t);RI(t,e),zI(t,r)}};function rH({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function RI(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let i=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Gc.propertyInData)(r,n,o,s.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let u of a)(0,Gc.checkReportMissingProp)(t,u)}):(r.if((0,Kw._)`${c} && (${(0,Gc.checkMissingProp)(t,a,i)})`),(0,Gc.reportMissingProp)(t,i),r.else())}}Pr.validatePropertyDeps=RI;function zI(t,e=t.schema){let{gen:r,data:n,keyword:s,it:i}=t,o=r.name("valid");for(let a in e)(0,eH.alwaysValidSchema)(i,e[a])||(r.if((0,Gc.propertyInData)(r,n,a,i.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}Pr.validateSchemaDeps=zI;Pr.default=tH});var jI=w(Jw=>{"use strict";Object.defineProperty(Jw,"__esModule",{value:!0});var CI=te(),nH=fe(),sH={message:"property name must be valid",params:({params:t})=>(0,CI._)`{propertyName: ${t.propertyName}}`},iH={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:sH,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,nH.alwaysValidSchema)(s,r))return;let i=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),e.if((0,CI.not)(i),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(i)}};Jw.default=iH});var Yw=w(Gw=>{"use strict";Object.defineProperty(Gw,"__esModule",{value:!0});var qf=Xt(),fr=te(),oH=Xr(),Df=fe(),aH={message:"must NOT have additional properties",params:({params:t})=>(0,fr._)`{additionalProperty: ${t.additionalProperty}}`},cH={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:aH,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:i,it:o}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,Df.alwaysValidSchema)(o,r))return;let u=(0,qf.allSchemaProperties)(n.properties),l=(0,qf.allSchemaProperties)(n.patternProperties);d(),t.ok((0,fr._)`${i} === ${oH.default.errors}`);function d(){e.forIn("key",s,g=>{!u.length&&!l.length?m(g):e.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let _=(0,Df.schemaRefOrVal)(o,n.properties,"properties");y=(0,qf.isOwnProperty)(e,_,g)}else u.length?y=(0,fr.or)(...u.map(_=>(0,fr._)`${g} === ${_}`)):y=fr.nil;return l.length&&(y=(0,fr.or)(y,...l.map(_=>(0,fr._)`${(0,qf.usePattern)(t,_)}.test(${g})`))),(0,fr.not)(y)}function p(g){e.code((0,fr._)`delete ${s}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Df.alwaysValidSchema)(o,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,fr.not)(y),()=>{t.reset(),p(g)})):(h(g,y),a||e.if((0,fr.not)(y),()=>e.break()))}}function h(g,y,_){let v={keyword:"additionalProperties",dataProp:g,dataPropType:Df.Type.Str};_===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,y)}}};Gw.default=cH});var DI=w(Qw=>{"use strict";Object.defineProperty(Qw,"__esModule",{value:!0});var uH=Cc(),LI=Xt(),Xw=fe(),qI=Yw(),lH={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:i}=t;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&qI.default.code(new uH.KeywordCxt(i,qI.default,"additionalProperties"));let o=(0,LI.allSchemaProperties)(r);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=Xw.mergeEvaluated.props(e,(0,Xw.toHash)(o),i.props));let a=o.filter(d=>!(0,Xw.alwaysValidSchema)(i,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,LI.propertyInData)(e,s,d,i.opts.ownProperties)),l(d),i.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Qw.default=lH});var BI=w(ev=>{"use strict";Object.defineProperty(ev,"__esModule",{value:!0});var ZI=Xt(),Zf=te(),UI=fe(),FI=fe(),dH={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:i}=t,{opts:o}=i,a=(0,ZI.allSchemaProperties)(r),c=a.filter(h=>(0,UI.alwaysValidSchema)(i,r[h]));if(a.length===0||c.length===a.length&&(!i.opts.unevaluated||i.props===!0))return;let u=o.strictSchema&&!o.allowMatchingProperties&&s.properties,l=e.name("valid");i.props!==!0&&!(i.props instanceof Zf.Name)&&(i.props=(0,FI.evaluatedPropsToName)(e,i.props));let{props:d}=i;f();function f(){for(let h of a)u&&p(h),i.allErrors?m(h):(e.var(l,!0),m(h),e.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,UI.checkStrictMode)(i,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",n,g=>{e.if((0,Zf._)`${(0,ZI.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:FI.Type.Str},l),i.opts.unevaluated&&d!==!0?e.assign((0,Zf._)`${d}[${g}]`,!0):!y&&!i.allErrors&&e.if((0,Zf.not)(l),()=>e.break())})})}}};ev.default=dH});var VI=w(tv=>{"use strict";Object.defineProperty(tv,"__esModule",{value:!0});var fH=fe(),pH={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,fH.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};tv.default=pH});var HI=w(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var hH=Xt(),mH={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:hH.validateUnion,error:{message:"must match a schema in anyOf"}};rv.default=mH});var WI=w(nv=>{"use strict";Object.defineProperty(nv,"__esModule",{value:!0});var Uf=te(),gH=fe(),yH={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Uf._)`{passingSchemas: ${t.passing}}`},_H={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:yH,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let i=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(o,()=>t.reset(),()=>t.error(!0));function u(){i.forEach((l,d)=>{let f;(0,gH.alwaysValidSchema)(s,l)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Uf._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Uf._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Uf.Name)})})}}};nv.default=_H});var KI=w(sv=>{"use strict";Object.defineProperty(sv,"__esModule",{value:!0});var bH=fe(),wH={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((i,o)=>{if((0,bH.alwaysValidSchema)(n,i))return;let a=t.subschema({keyword:"allOf",schemaProp:o},s);t.ok(s),t.mergeEvaluated(a)})}};sv.default=wH});var YI=w(iv=>{"use strict";Object.defineProperty(iv,"__esModule",{value:!0});var Ff=te(),GI=fe(),vH={message:({params:t})=>(0,Ff.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ff._)`{failingKeyword: ${t.ifClause}}`},xH={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:vH,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,GI.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=JI(n,"then"),i=JI(n,"else");if(!s&&!i)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&i){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else s?e.if(a,u("then")):e.if((0,Ff.not)(a),u("else"));t.pass(o,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let f=t.subschema({keyword:l},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,Ff._)`${l}`):t.setParams({ifClause:l})}}}};function JI(t,e){let r=t.schema[e];return r!==void 0&&!(0,GI.alwaysValidSchema)(t,r)}iv.default=xH});var XI=w(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});var SH=fe(),kH={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,SH.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};ov.default=kH});var QI=w(av=>{"use strict";Object.defineProperty(av,"__esModule",{value:!0});var $H=Fw(),EH=OI(),TH=Bw(),PH=AI(),OH=NI(),IH=MI(),AH=jI(),NH=Yw(),RH=DI(),zH=BI(),MH=VI(),CH=HI(),jH=WI(),LH=KI(),qH=YI(),DH=XI();function ZH(t=!1){let e=[MH.default,CH.default,jH.default,LH.default,qH.default,DH.default,AH.default,NH.default,IH.default,RH.default,zH.default];return t?e.push(EH.default,PH.default):e.push($H.default,TH.default),e.push(OH.default),e}av.default=ZH});var eA=w(cv=>{"use strict";Object.defineProperty(cv,"__esModule",{value:!0});var qe=te(),UH={message:({schemaCode:t})=>(0,qe.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,qe._)`{format: ${t}}`},FH={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:UH,code(t,e){let{gen:r,data:n,$data:s,schema:i,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,qe._)`${m}[${o}]`),g=r.let("fType"),y=r.let("format");r.if((0,qe._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,qe._)`${h}.type || "string"`).assign(y,(0,qe._)`${h}.validate`),()=>r.assign(g,(0,qe._)`"string"`).assign(y,h)),t.fail$data((0,qe.or)(_(),v()));function _(){return c.strictSchema===!1?qe.nil:(0,qe._)`${o} && !${y}`}function v(){let k=l.$async?(0,qe._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,qe._)`${y}(${n})`,E=(0,qe._)`(typeof ${y} == "function" ? ${k} : ${y}.test(${n}))`;return(0,qe._)`${y} && ${y} !== true && ${g} === ${e} && !${E}`}}function p(){let m=d.formats[i];if(!m){_();return}if(m===!0)return;let[h,g,y]=v(m);h===e&&t.pass(k());function _(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${i}" ignored in schema at path "${u}"`}}function v(E){let C=E instanceof RegExp?(0,qe.regexpCode)(E):c.code.formats?(0,qe._)`${c.code.formats}${(0,qe.getProperty)(i)}`:void 0,B=r.scopeValue("formats",{key:i,ref:E,code:C});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,qe._)`${B}.validate`]:["string",E,B]}function k(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,qe._)`await ${y}(${n})`}return typeof g=="function"?(0,qe._)`${y}(${n})`:(0,qe._)`${y}.test(${n})`}}}};cv.default=FH});var tA=w(uv=>{"use strict";Object.defineProperty(uv,"__esModule",{value:!0});var BH=eA(),VH=[BH.default];uv.default=VH});var rA=w($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.contentVocabulary=$o.metadataVocabulary=void 0;$o.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];$o.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var sA=w(lv=>{"use strict";Object.defineProperty(lv,"__esModule",{value:!0});var HH=dI(),WH=$I(),KH=QI(),JH=tA(),nA=rA(),GH=[HH.default,WH.default,(0,KH.default)(),JH.default,nA.metadataVocabulary,nA.contentVocabulary];lv.default=GH});var oA=w(Bf=>{"use strict";Object.defineProperty(Bf,"__esModule",{value:!0});Bf.DiscrError=void 0;var iA;(function(t){t.Tag="tag",t.Mapping="mapping"})(iA||(Bf.DiscrError=iA={}))});var cA=w(fv=>{"use strict";Object.defineProperty(fv,"__esModule",{value:!0});var Eo=te(),dv=oA(),aA=Tf(),YH=jc(),XH=fe(),QH={message:({params:{discrError:t,tagName:e}})=>t===dv.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Eo._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},eW={keyword:"discriminator",type:"object",schemaType:"object",error:QH,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:i}=t,{oneOf:o}=s;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Eo._)`${r}${(0,Eo.getProperty)(a)}`);e.if((0,Eo._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:dv.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,Eo._)`${u} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:dv.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,Eo.Name),m}function f(){var p;let m={},h=y(s),g=!0;for(let k=0;k<o.length;k++){let E=o[k];if(E?.$ref&&!(0,XH.schemaHasRulesButRef)(E,i.self.RULES)){let B=E.$ref;if(E=aA.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,B),E instanceof aA.SchemaEnv&&(E=E.schema),E===void 0)throw new YH.default(i.opts.uriResolver,i.baseId,B)}let C=(p=E?.properties)===null||p===void 0?void 0:p[a];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(E)),_(C,k)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:k}){return Array.isArray(k)&&k.includes(a)}function _(k,E){if(k.const)v(k.const,E);else if(k.enum)for(let C of k.enum)v(C,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(k,E){if(typeof k!="string"||k in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[k]=E}}}};fv.default=eW});var uA=w((Qne,tW)=>{tW.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var hv=w((Te,pv)=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.MissingRefError=Te.ValidationError=Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=Te.Ajv=void 0;var rW=iI(),nW=sA(),sW=cA(),lA=uA(),iW=["/properties"],Vf="http://json-schema.org/draft-07/schema",To=class extends rW.default{_addVocabularies(){super._addVocabularies(),nW.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(sW.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(lA,iW):lA;this.addMetaSchema(e,Vf,!1),this.refs["http://json-schema.org/schema"]=Vf}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Vf)?Vf:void 0)}};Te.Ajv=To;pv.exports=Te=To;pv.exports.Ajv=To;Object.defineProperty(Te,"__esModule",{value:!0});Te.default=To;var oW=Cc();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return oW.KeywordCxt}});var Po=te();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return Po._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return Po.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return Po.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return Po.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return Po.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return Po.CodeGen}});var aW=$f();Object.defineProperty(Te,"ValidationError",{enumerable:!0,get:function(){return aW.default}});var cW=jc();Object.defineProperty(Te,"MissingRefError",{enumerable:!0,get:function(){return cW.default}})});var _A=w(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.formatNames=Ir.fastFormats=Ir.fullFormats=void 0;function Or(t,e){return{validate:t,compare:e}}Ir.fullFormats={date:Or(hA,_v),time:Or(gv(!0),bv),"date-time":Or(dA(!0),gA),"iso-time":Or(gv(),mA),"iso-date-time":Or(dA(),yA),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:hW,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|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-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:vW,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:mW,int32:{type:"number",validate:_W},int64:{type:"number",validate:bW},float:{type:"number",validate:pA},double:{type:"number",validate:pA},password:!0,binary:!0};Ir.fastFormats={...Ir.fullFormats,date:Or(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,_v),time:Or(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,bv),"date-time":Or(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,gA),"iso-time":Or(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,mA),"iso-date-time":Or(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,yA),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Ir.formatNames=Object.keys(Ir.fullFormats);function uW(t){return t%4===0&&(t%100!==0||t%400===0)}var lW=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,dW=[0,31,28,31,30,31,30,31,31,30,31,30,31];function hA(t){let e=lW.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&uW(r)?29:dW[n])}function _v(t,e){if(t&&e)return t>e?1:t<e?-1:0}var mv=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function gv(t){return function(r){let n=mv.exec(r);if(!n)return!1;let s=+n[1],i=+n[2],o=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(s<=23&&i<=59&&o<60)return!0;let d=i-l*c,f=s-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&o<61}}function bv(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function mA(t,e){if(!(t&&e))return;let r=mv.exec(t),n=mv.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var yv=/t|\s/i;function dA(t){let e=gv(t);return function(n){let s=n.split(yv);return s.length===2&&hA(s[0])&&e(s[1])}}function gA(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function yA(t,e){if(!(t&&e))return;let[r,n]=t.split(yv),[s,i]=e.split(yv),o=_v(r,s);if(o!==void 0)return o||bv(n,i)}var fW=/\/|:/,pW=/^(?:[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 hW(t){return fW.test(t)&&pW.test(t)}var fA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function mW(t){return fA.lastIndex=0,fA.test(t)}var gW=-(2**31),yW=2**31-1;function _W(t){return Number.isInteger(t)&&t<=yW&&t>=gW}function bW(t){return Number.isInteger(t)}function pA(){return!0}var wW=/[^\\]\\Z/;function vW(t){if(wW.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var bA=w(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.formatLimitDefinition=void 0;var xW=hv(),pr=te(),Fn=pr.operators,Hf={formatMaximum:{okStr:"<=",ok:Fn.LTE,fail:Fn.GT},formatMinimum:{okStr:">=",ok:Fn.GTE,fail:Fn.LT},formatExclusiveMaximum:{okStr:"<",ok:Fn.LT,fail:Fn.GTE},formatExclusiveMinimum:{okStr:">",ok:Fn.GT,fail:Fn.LTE}},SW={message:({keyword:t,schemaCode:e})=>(0,pr.str)`should be ${Hf[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,pr._)`{comparison: ${Hf[t].okStr}, limit: ${e}}`};Oo.formatLimitDefinition={keyword:Object.keys(Hf),type:"string",schemaType:"string",$data:!0,error:SW,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:i}=t,{opts:o,self:a}=i;if(!o.validateFormats)return;let c=new xW.KeywordCxt(i,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=e.scopeValue("formats",{ref:a.formats,code:o.code.formats}),p=e.const("fmt",(0,pr._)`${f}[${c.schemaCode}]`);t.fail$data((0,pr.or)((0,pr._)`typeof ${p} != "object"`,(0,pr._)`${p} instanceof RegExp`,(0,pr._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let m=e.scopeValue("formats",{key:f,ref:p,code:o.code.formats?(0,pr._)`${o.code.formats}${(0,pr.getProperty)(f)}`:void 0});t.fail$data(d(m))}function d(f){return(0,pr._)`${f}.compare(${r}, ${n}) ${Hf[s].fail} 0`}},dependencies:["format"]};var kW=t=>(t.addKeyword(Oo.formatLimitDefinition),t);Oo.default=kW});var SA=w((Yc,xA)=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var Io=_A(),$W=bA(),wv=te(),wA=new wv.Name("fullFormats"),EW=new wv.Name("fastFormats"),vv=(t,e={keywords:!0})=>{if(Array.isArray(e))return vA(t,e,Io.fullFormats,wA),t;let[r,n]=e.mode==="fast"?[Io.fastFormats,EW]:[Io.fullFormats,wA],s=e.formats||Io.formatNames;return vA(t,s,r,n),e.keywords&&(0,$W.default)(t),t};vv.get=(t,e="full")=>{let n=(e==="fast"?Io.fastFormats:Io.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function vA(t,e,r,n){var s,i;(s=(i=t.opts.code).formats)!==null&&s!==void 0||(i.formats=(0,wv._)`require("ajv-formats/dist/formats").${n}`);for(let o of e)t.addFormat(o,r[o])}xA.exports=Yc=vv;Object.defineProperty(Yc,"__esModule",{value:!0});Yc.default=vv});function TW(){let t=new kA.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,$A.default)(t),t}var kA,$A,Wf,EA=$(()=>{kA=Ct(hv(),1),$A=Ct(SA(),1);Wf=class{constructor(e){this._ajv=e??TW()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}});var Kf,TA=$(()=>{fo();Kf=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],i=Array.isArray(s.content)?s.content:[s.content],o=i.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(o){if(i.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(i.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},vc,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),s=e.mode??"form";switch(s){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=s==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:i},lo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}});function PA(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function OA(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var IA=$(()=>{});var Jf,AA=$(()=>{R1();fo();EA();uc();TA();IA();Jf=class extends ff{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(wc.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{let i=this._loggingLevels.get(s);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Wf,this.setRequestHandler(M_,n=>this._oninitialize(n)),this.setNotificationHandler(C_,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(F_,async(n,s)=>{let i=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,a=wc.safeParse(o);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Kf(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=N1(this._capabilities,e)}setRequestHandler(e,r){let s=Nn(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let i;if(Wt(s)){let a=s;i=a._zod?.def?.value??a.value}else{let a=s;i=a._def?.value??a.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let a=async(c,u)=>{let l=An(uo,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new D(F.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=An(ao,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new D(F.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=An(Qd,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new D(F.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){OA(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&PA(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:NP.includes(r)?r:I_,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},jd)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],i=s.some(u=>u.type==="tool_result"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=o?Array.isArray(o.content)?o.content:[o.content]:[],c=a.some(u=>u.type==="tool_use");if(i){if(s.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(s.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},B_,r):this.request({method:"sampling/createMessage",params:e},vc,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let s=e;return this.request({method:"elicitation/create",params:s},lo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let s=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:s},lo,r);if(i.action==="accept"&&i.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(i.content);if(!a.valid)throw new D(F.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(o){throw o instanceof D?o:new D(F.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return i}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},V_,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});function xv(t){return!!t&&typeof t=="object"&&RA in t}function zA(t){return t[RA]?.complete}var RA,NA,MA=$(()=>{RA=Symbol.for("mcp.completable");(function(t){t.Completable="McpCompletable"})(NA||(NA={}))});var CA=$(()=>{});function OW(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!PW.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,i)=>i.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function IW(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Sv(t){let e=OW(t);return IW(t,e.warnings),e.isValid}var PW,jA=$(()=>{PW=/^[A-Za-z0-9._-]{1,128}$/});var Gf,LA=$(()=>{Gf=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}}});var kv=$(()=>{ad();ad()});function ZA(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function UA(t){return"_def"in t||"_zod"in t||ZA(t)}function $v(t){return typeof t!="object"||t===null||UA(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(ZA)}function qA(t){if(t){if($v(t))return Ds(t);if(!UA(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function NW(t){let e=Nn(t);return e?Object.entries(e).map(([r,n])=>{let s=nP(n),i=sP(n);return{name:r,description:s,required:!i}}):[]}function Bn(t){let r=Nn(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ad(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function DA(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Yf,AW,Xc,FA=$(()=>{AA();uc();Pb();fo();MA();CA();jA();LA();kv();Yf=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Jf(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Gf(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Bn(Xd)),this.server.assertCanSetRequestHandler(Bn(uo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Xd,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let s=io(r.inputSchema);return s?$b(s,{strictUnions:!0,pipeStrategy:"input"}):AW})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=io(r.outputSchema);s&&(n.outputSchema=$b(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(uo,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new D(F.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Tool ${e.params.name} disabled`);let s=!!e.params.task,i=n.execution?.taskSupport,o="createTask"in n.handler;if((i==="required"||i==="optional")&&!o)throw new D(F.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!s)throw new D(F.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!s&&o)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof D&&n.code===F.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let i=io(e.inputSchema)??e.inputSchema,o=await Od(i,r);if(!o.success){let a="error"in o?o.error:"Unknown error",c=Id(a);throw new D(F.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return o.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new D(F.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=io(e.outputSchema),i=await Od(s,r.structuredContent);if(!i.success){let o="error"in i?i.error:"Unknown error",a=Id(o);throw new D(F.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");let o={...n,taskStore:n.taskStore};if(e.inputSchema){let a=s;return await Promise.resolve(a.createTask(r,o))}else{let a=s;return await Promise.resolve(a.createTask(o))}}if(e.inputSchema){let o=s;return await Promise.resolve(o(r,n))}else{let o=s;return await Promise.resolve(o(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let s=await this.validateToolInput(e,r.params.arguments,r.params.name),i=e.handler,o={...n,taskStore:n.taskStore},a=s?await Promise.resolve(i.createTask(s,o)):await Promise.resolve(i.createTask(o)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(f=>setTimeout(f,l));let d=await n.taskStore.getTask(c);if(!d)throw new D(F.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Bn(ef)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(ef,async e=>{switch(e.params.ref.type){case"ref/prompt":return KP(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return JP(e),this.handleResourceCompletion(e,e.params.ref);default:throw new D(F.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new D(F.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Xc;let i=Nn(n.argsSchema)?.[e.params.argument.name];if(!xv(i))return Xc;let o=zA(i);if(!o)return Xc;let a=await o(e.params.argument.value,e.params.context);return DA(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Xc;throw new D(F.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Xc;let i=await s(e.params.argument.value,e.params.context);return DA(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Bn(Wd)),this.server.assertCanSetRequestHandler(Bn(Kd)),this.server.assertCanSetRequestHandler(Bn(Jd)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Wd,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([i,o])=>o.enabled).map(([i,o])=>({uri:i,name:o.name,...o.metadata})),s=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let o=await i.resourceTemplate.listCallback(r);for(let a of o.resources)s.push({...i.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Kd,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Jd,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new D(F.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(let i of Object.values(this._registeredResourceTemplates)){let o=i.resourceTemplate.uriTemplate.match(n.toString());if(o)return i.readCallback(n,o,r)}throw new D(F.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Bn(Gd)),this.server.assertCanSetRequestHandler(Bn(Yd)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Gd,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?NW(r.argsSchema):void 0}))})),this.server.setRequestHandler(Yd,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new D(F.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new D(F.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=io(n.argsSchema),i=await Od(s,e.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",u=Id(c);throw new D(F.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let o=i.data,a=n.callback;return await Promise.resolve(a(o,r))}else{let s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());let i=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,void 0,r,s,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,void 0,r,s,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,r,n,s,i){let o={name:e,title:r,metadata:s,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=o)),typeof a.name<"u"&&(o.name=a.name),typeof a.title<"u"&&(o.title=a.title),typeof a.metadata<"u"&&(o.metadata=a.metadata),typeof a.callback<"u"&&(o.readCallback=a.callback),typeof a.enabled<"u"&&(o.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,r,n,s,i){let o={resourceTemplate:n,title:r,metadata:s,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=o)),typeof u.title<"u"&&(o.title=u.title),typeof u.template<"u"&&(o.resourceTemplate=u.template),typeof u.metadata<"u"&&(o.metadata=u.metadata),typeof u.callback<"u"&&(o.readCallback=u.callback),typeof u.enabled<"u"&&(o.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,r,n,s,i){let o={title:r,description:n,argsSchema:s===void 0?void 0:Ds(s),callback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=o)),typeof a.title<"u"&&(o.title=a.title),typeof a.description<"u"&&(o.description=a.description),typeof a.argsSchema<"u"&&(o.argsSchema=Ds(a.argsSchema)),typeof a.callback<"u"&&(o.callback=a.callback),typeof a.enabled<"u"&&(o.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=o,s&&Object.values(s).some(c=>{let u=c instanceof vt?c._def?.innerType:c;return xv(u)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,r,n,s,i,o,a,c,u){Sv(e);let l={title:r,description:n,inputSchema:qA(s),outputSchema:qA(i),annotations:o,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Sv(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Ds(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Ds(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,i,o;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if($v(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!$v(r[0])&&(o=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);o=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,s,i,o,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:s,description:i,inputSchema:o,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,i,o,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());let i=r[0],o=this._createRegisteredPrompt(e,void 0,n,s,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:s,description:i,argsSchema:o}=r,a=this._createRegisteredPrompt(e,s,i,o,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},AW={type:"object",properties:{}};Xc={completion:{values:[],hasMore:!1}}});function RW(t){return DP.parse(JSON.parse(t))}function BA(t){return JSON.stringify(t)+`
|
|
191
|
+
`}var Xf,VA=$(()=>{fo();Xf=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
192
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),RW(r)}clear(){this._buffer=void 0}}});import HA from"node:process";var Qf,WA=$(()=>{VA();Qf=class{constructor(e=HA.stdin,r=HA.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Xf,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=BA(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}}});var QA={};Vn(QA,{discardRecording:()=>CW,readMarker:()=>ep,startRecording:()=>Ev,stopRecording:()=>Tv});import{mkdir as KA,readFile as zW,rm as JA,writeFile as GA}from"node:fs/promises";import{dirname as YA,join as XA,resolve as MW}from"node:path";async function ep(){try{return JSON.parse(await zW(Qc,"utf8"))}catch{return null}}async function Ev(t,e,r){let n=await ep();if(n)throw new Error(`recording "${n.name}" already active (started ${n.startedAt}) \u2014 stop it first (record stop)`);let i=(await t.events(r)).at(-1)?.seq??0,o={name:e,udid:r,fromSeq:i,startedAt:new Date().toISOString(),daemonUrl:t.baseUrl};return await KA(YA(Qc),{recursive:!0}),await GA(Qc,JSON.stringify(o,null,2)+`
|
|
193
|
+
`,"utf8"),o}async function Tv(t,e){let r=await ep();if(!r)throw new Error("no active recording \u2014 start one first (record start <name>)");let n=(await t.events(r.udid,r.fromSeq)).filter(o=>o.deviceId===r.udid);if(n.length===0)throw new Error("no events recorded since `record start` (was the daemon restarted in between?)");let s=wi(n,{name:r.name,...e?.appId?{appId:e.appId}:{},recordedBy:`record:${r.startedAt}`,recordedAt:new Date().toISOString()}),i=MW(e?.savePath??XA(".simon","flows",`${r.name}.yaml`));return await KA(YA(i),{recursive:!0}),await GA(i,s,"utf8"),await JA(Qc,{force:!0}),{marker:r,outPath:i,yaml:s,eventCount:n.length}}async function CW(){let t=await ep();return await JA(Qc,{force:!0}),t}var Qc,Pv=$(()=>{"use strict";va();Qc=XA(".simon","recording.json")});var eN={};Vn(eN,{runMcpServer:()=>qW});import{writeFile as jW}from"node:fs/promises";import{dirname as LW,resolve as Ov}from"node:path";async function qW(t){let e=new Yf({name:"simon",version:"0.1.0"}),r,n=async()=>r??=await t(),s=async l=>{let d=await n(),f=await d.listDevices();if(l){let h=f.find(g=>g.udid===l||g.name===l);if(!h)throw new Error(`device not found: ${l}`);return h.state!=="Booted"&&await d.bootDevice(h.udid),h.udid}let p=f.find(h=>h.state==="Booted");if(p)return p.udid;let m=f.find(h=>h.name.startsWith("iPhone"));if(!m)throw new Error("no iOS simulator available");return await d.bootDevice(m.udid),m.udid},i=l=>({content:[{type:"text",text:l}]}),o=async(l,d)=>{let p=await(await n()).action(l,Iv,d);if(!p.ok)throw new Error(p.error??"action failed");return p},a=async l=>{let f=await(await n()).uiSnapshot(l),p=es(f,{interactiveOnly:!0});return p.sparse?p.text+`
|
|
194
194
|
|
|
195
|
-
(sparse tree \u2014 the screen may be custom-drawn; use simon_screenshot to see it)`:p.text},c=l=>{if(!l.text&&!l.id)throw new Error("provide text or id");let d={};return l.id&&(d.id=l.id),l.text&&(d.text=l.text),l.index!==void 0&&(d.index=l.index),d},u={device:
|
|
196
|
-
`))}),e.tool("simon_snapshot","Compact accessibility tree of the CURRENT screen \u2014 call this before acting, and again after the screen changes. Each line: role, label, id (React Native testID), normalized (x,y w\xD7h). Prefer tapping by id, then by label text.",u,async l=>i(await a(await s(l.device)))),e.tool("simon_screenshot","PNG screenshot of the simulator. Expensive in tokens \u2014 use only when the accessibility tree is sparse (custom-drawn UI) or you need to verify visual appearance.",u,async l=>({content:[{type:"image",data:(await(await n()).screenshotPng(await s(l.device),
|
|
195
|
+
(sparse tree \u2014 the screen may be custom-drawn; use simon_screenshot to see it)`:p.text},c=l=>{if(!l.text&&!l.id)throw new Error("provide text or id");let d={};return l.id&&(d.id=l.id),l.text&&(d.text=l.text),l.index!==void 0&&(d.index=l.index),d},u={device:Ce.string().optional().describe("device name or UDID; defaults to the booted simulator")};e.tool("simon_devices","List iOS simulators (name, UDID, state).",{},async()=>{let d=await(await n()).listDevices();return i(d.map(f=>`${f.state==="Booted"?"\u25CF":"\u25CB"} ${f.name} ${f.udid} ${f.runtime}`).join(`
|
|
196
|
+
`))}),e.tool("simon_snapshot","Compact accessibility tree of the CURRENT screen \u2014 call this before acting, and again after the screen changes. Each line: role, label, id (React Native testID), normalized (x,y w\xD7h). Prefer tapping by id, then by label text.",u,async l=>i(await a(await s(l.device)))),e.tool("simon_screenshot","PNG screenshot of the simulator. Expensive in tokens \u2014 use only when the accessibility tree is sparse (custom-drawn UI) or you need to verify visual appearance.",u,async l=>({content:[{type:"image",data:(await(await n()).screenshotPng(await s(l.device),Iv)).toString("base64"),mimeType:"image/png"}]})),e.tool("simon_tap","Tap an element by id (preferred, exact) or text (label/value; exact match or full-match regex like 'Name.*'). Take simon_snapshot first to see what is on screen.",{...u,text:Ce.string().optional(),id:Ce.string().optional(),index:Ce.number().int().optional().describe("0-based pick when several match"),longPress:Ce.boolean().optional()},async l=>{let d=await s(l.device),p=(await o(d,{type:"tap",selector:c(l),...l.longPress?{longPressMs:600}:{}})).element;return i(`tapped ${p?.label??p?.id??"element"}
|
|
197
197
|
|
|
198
198
|
CURRENT SCREEN:
|
|
199
|
-
${await a(d)}`)}),e.tool("simon_type_text","Type text into the focused field (tap the field first).",{...u,text:
|
|
199
|
+
${await a(d)}`)}),e.tool("simon_type_text","Type text into the focused field (tap the field first).",{...u,text:Ce.string()},async l=>{let d=await s(l.device);return await o(d,{type:"inputText",text:l.text}),i("typed")}),e.tool("simon_press_key","Press a hardware/keyboard key.",{...u,key:Ce.enum(["enter","escape","backspace","tab","space","delete","arrowup","arrowdown","arrowleft","arrowright"])},async l=>(await o(await s(l.device),{type:"key",key:l.key}),i(`pressed ${l.key}`))),e.tool("simon_swipe","Swipe/scroll the screen in a direction (swipe up = scroll content down).",{...u,direction:Ce.enum(["up","down","left","right"])},async l=>{let d=await s(l.device);return await o(d,{type:"swipe",direction:l.direction}),i(`swiped ${l.direction}
|
|
200
200
|
|
|
201
201
|
CURRENT SCREEN:
|
|
202
|
-
${await a(d)}`)}),e.tool("simon_launch_app","Launch an app by bundle id (relaunches if already running).",{...u,appId:
|
|
202
|
+
${await a(d)}`)}),e.tool("simon_launch_app","Launch an app by bundle id (relaunches if already running).",{...u,appId:Ce.string(),relaunch:Ce.boolean().optional()},async l=>{let d=await s(l.device);return await o(d,{type:"launchApp",appId:l.appId,relaunch:l.relaunch??!0}),i(`launched ${l.appId}
|
|
203
203
|
|
|
204
204
|
CURRENT SCREEN:
|
|
205
|
-
${await a(d)}`)}),e.tool("simon_open_url","Open a URL / deep link (e.g. exp://, https://, myapp://).",{...u,url:
|
|
205
|
+
${await a(d)}`)}),e.tool("simon_open_url","Open a URL / deep link (e.g. exp://, https://, myapp://).",{...u,url:Ce.string()},async l=>{let d=await s(l.device);return await o(d,{type:"openUrl",url:l.url}),i(`opened ${l.url}`)}),e.tool("simon_wait_for","Wait until an element appears (or disappears with gone=true). Use this to assert outcomes \u2014 satisfied waits become assertVisible steps when the session is compiled to a flow.",{...u,text:Ce.string().optional(),id:Ce.string().optional(),gone:Ce.boolean().optional(),timeoutSeconds:Ce.number().optional()},async l=>{let d=await s(l.device),p=await(await n()).action(d,Iv,{type:"waitFor",selector:c(l),...l.gone!==void 0?{gone:l.gone}:{},timeoutMs:(l.timeoutSeconds??10)*1e3});return i(p.ok?"satisfied":`NOT satisfied: ${p.error}`)}),e.tool("simon_record_start","Start recording the session into a deterministic flow. Everything you (and anyone else) do on the device after this \u2014 taps, typing, waits \u2014 is captured in the unified event log. Call simon_record_stop when the scenario is complete.",{...u,name:Ce.string().describe("flow name, e.g. 'login'")},async l=>{let d=await s(l.device),f=await Ev(await n(),l.name,d);return i(`recording "${f.name}" started (from seq ${f.fromSeq}). Drive the scenario, assert outcomes with simon_wait_for, then call simon_record_stop.`)}),e.tool("simon_record_stop","Stop recording and compile the captured events into a Maestro-style YAML flow with self-healing anchors. Re-run it for free with simon_run_flow.",{savePath:Ce.string().optional().describe("default .simon/flows/<name>.yaml")},async l=>{let d=await Tv(await n(),{savePath:l.savePath});return i(`saved ${d.eventCount} events \u2192 ${d.outPath}
|
|
206
206
|
|
|
207
|
-
${d.yaml}`)}),e.tool("simon_run_flow","Run a deterministic flow YAML file (zero LLM tokens). Returns per-step results.",{...u,path:
|
|
207
|
+
${d.yaml}`)}),e.tool("simon_run_flow","Run a deterministic flow YAML file (zero LLM tokens). Returns per-step results.",{...u,path:Ce.string()},async l=>{let d=await s(l.device),f=Ov(l.path),p=await br(f),h=await new gn({client:await n(),udid:d,flowDir:LW(f)}).run(p),g=h.steps.map(y=>`${y.ok?"\u2713":"\u2717"} ${y.index+1}. ${y.step.kind}${y.resolvedBy?` (by ${y.resolvedBy})`:""}${y.error?` \u2014 ${y.error}`:""}`);return i(`${h.pass?"PASS":"FAIL"} ${p.config.name??l.path} (${h.finishedAt-h.startedAt}ms)
|
|
208
208
|
${g.join(`
|
|
209
|
-
`)}`)}),e.tool("simon_export_maestro","Export a simon flow as plain Maestro YAML runnable by the upstream `maestro test` CLI (strips simon-only anchors/meta, converts points to percent strings). Returns the output path and YAML.",{path:
|
|
209
|
+
`)}`)}),e.tool("simon_export_maestro","Export a simon flow as plain Maestro YAML runnable by the upstream `maestro test` CLI (strips simon-only anchors/meta, converts points to percent strings). Returns the output path and YAML.",{path:Ce.string().describe("simon flow file"),outPath:Ce.string().optional().describe("default: <path>.maestro.yaml")},async l=>{let d=await br(Ov(l.path)),f=kl(d),p=Ov(l.outPath??l.path.replace(/\.ya?ml$/,"")+".maestro.yaml");return await jW(p,f,"utf8"),i(`exported \u2192 ${p}
|
|
210
210
|
|
|
211
211
|
${f}
|
|
212
212
|
|
|
213
|
-
Run with: maestro test ${p}`)}),await e.connect(new
|
|
214
|
-
`;this.writeQueue=this.writeQueue.then(async()=>{await qR(DR(i),{recursive:!0}),await LR(i,o,"utf8")}).catch(()=>{})}return s}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}recent(e=0,r){return this.ring.filter(n=>n.seq>e&&(!r||n.deviceId===r))}async flush(){await this.writeQueue}};import{execFile as ZR}from"node:child_process";import{promisify as UR}from"node:util";var FR=UR(ZR);async function rn(t,e){return FR("xcrun",["simctl",...t],{timeout:e?.timeoutMs??6e4,maxBuffer:64*1024*1024})}async function qo(){let{stdout:t}=await rn(["list","devices","--json"]),e=JSON.parse(t),r=[];for(let[n,s]of Object.entries(e.devices))for(let i of s)i.isAvailable&&r.push({udid:i.udid,name:i.name,state:i.state,runtime:n.replace("com.apple.CoreSimulator.SimRuntime.","")});return r}async function M0(t){try{await rn(["boot",t])}catch(e){if(!(e instanceof Error?e.message:String(e)).includes("current state: Booted"))throw e}await rn(["bootstatus",t],{timeoutMs:12e4})}async function C0(t,e){await rn(["install",t,e],{timeoutMs:18e4})}async function j0(t,e,r){r?.relaunch&&await $p(t,e).catch(()=>{}),await rn(["launch",t,e,...r?.args??[]])}async function $p(t,e){await rn(["terminate",t,e])}async function L0(t,e){await rn(["openurl",t,e])}async function q0(t){let{readFile:e,rm:r}=await import("node:fs/promises"),{tmpdir:n}=await import("node:os"),{join:s}=await import("node:path"),{randomUUID:i}=await import("node:crypto"),o=s(n(),`simon-shot-${i()}.png`);try{return await rn(["io",t,"screenshot","--type","png",o],{timeoutMs:3e4}),await e(o)}finally{await r(o,{force:!0}).catch(()=>{})}}async function D0(t){let e=await qo();if(t){let s=e.find(i=>i.udid===t||i.name===t);if(!s)throw new Error(`Device not found: ${t}`);return s}let r=e.find(s=>s.state==="Booted");if(r)return r;let n=e.filter(s=>s.name.startsWith("iPhone")).sort((s,i)=>i.runtime.localeCompare(s.runtime)).at(0);if(!n)throw new Error("No available iOS simulator found");return n}import{spawn as VR}from"node:child_process";import{once as Z0}from"node:events";import{existsSync as HR}from"node:fs";import{createServer as WR}from"node:net";import{homedir as U0}from"node:os";import{join as Yn}from"node:path";import{fileURLToPath as F0}from"node:url";var KR=[process.env.SIMON_HELPER_BIN,()=>Yn(F0(new URL(".",import.meta.url)),"..","vendor","helper","simon-helper"),()=>Yn(Ep(),"bin","simon-helper"),()=>Yn(Ep(),".build","release","simon-helper"),()=>Yn(Ep(),".build","arm64-apple-macosx","release","simon-helper"),Yn(U0(),"expo/serve-sim/packages/serve-sim/.build/release/serve-sim-bin"),Yn(U0(),"expo/serve-sim/packages/serve-sim/.build/arm64-apple-macosx/release/serve-sim-bin")];function Ep(){return Yn(F0(new URL(".",import.meta.url)),"..","..","helper")}function JR(){for(let t of KR){let e=typeof t=="function"?t():t;if(e&&HR(e))return e}return null}async function GR(t){for(let e=t;e<t+200;e++)if(await new Promise(n=>{let s=WR();s.once("error",()=>n(!1)),s.listen(e,"127.0.0.1",()=>s.close(()=>n(!0)))}))return e;throw new Error(`No free port found from ${t}`)}var mu=class{udid;port=0;proc;ws;wsReady;options;onBinaryMessage;onExit;constructor(e){this.udid=e.udid,this.options=e}get alive(){return this.proc!==void 0&&this.proc.exitCode===null}async start(){let e=this.options.binaryPath??JR();if(!e)throw new Error("simon-helper binary not found. Build it with `bun run build:helper` or set SIMON_HELPER_BIN.");this.port=this.options.port??await GR(3100);let r=[this.udid,"--port",String(this.port),"--codec",this.options.codec??"webrtc","--max-fps",String(this.options.maxFps??60)];this.proc=VR(e,r,{stdio:["ignore","pipe","pipe"]}),this.proc.on("exit",n=>this.onExit?.(n)),await this.waitForHttp()}async waitForHttp(e=15e3){let r=Date.now()+e;for(;Date.now()<r;){try{let n=await fetch(`http://127.0.0.1:${this.port}/health`,{signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===404)return}catch{}if(this.proc&&this.proc.exitCode!==null)throw new Error(`helper exited with code ${this.proc.exitCode}`);await new Promise(n=>setTimeout(n,200))}throw new Error("helper did not start listening in time")}async ensureWs(){if(this.ws&&this.ws.readyState===Lo.OPEN)return this.ws;let e=new Lo(`ws://127.0.0.1:${this.port}/ws`);return e.binaryType="nodebuffer",e.on("message",(r,n)=>{n&&this.onBinaryMessage?.(r)}),this.ws=e,this.wsReady=Z0(e,"open").then(()=>{}),await this.wsReady,e}async sendJson(e,r){let n=await this.ensureWs(),s=Buffer.from(JSON.stringify(r),"utf8");n.send(Buffer.concat([Buffer.from([e]),s]))}async sendRaw(e){(await this.ensureWs()).send(e)}async touch(e,r,n,s){await this.sendJson(3,{type:e,x:r,y:n,...s?{edge:s}:{}})}async button(e){await this.sendJson(4,{button:e})}async key(e,r){await this.sendJson(6,{type:e,usage:r})}async orientation(e){await this.sendJson(7,{orientation:e})}async describeUi(){let e=await fetch(`http://127.0.0.1:${this.port}/ax`,{signal:AbortSignal.timeout(2e4)});if(!e.ok)throw new Error(`helper /ax failed: ${e.status} ${await e.text()}`);return await e.json()}async stop(){this.ws?.close(),this.ws=void 0,this.proc&&this.proc.exitCode===null&&(this.proc.kill("SIGTERM"),await Promise.race([Z0(this.proc,"exit"),new Promise(e=>setTimeout(e,3e3))]),this.proc.exitCode===null&&this.proc.kill("SIGKILL")),this.proc=void 0}};var B0={1:30,2:31,3:32,4:33,5:34,6:35,7:36,8:37,9:38,0:39},V0={"\n":40," ":43," ":44,"-":45,"=":46,"[":47,"]":48,"\\":49,";":51,"'":52,"`":53,",":54,".":55,"/":56},H0={"!":30,"@":31,"#":32,$:33,"%":34,"^":35,"&":36,"*":37,"(":38,")":39,_:45,"+":46,"{":47,"}":48,"|":49,":":51,'"':52,"~":53,"<":54,">":55,"?":56},W0={enter:40,escape:41,backspace:42,tab:43,space:44,delete:76,home:74,end:77,arrowright:79,arrowleft:80,arrowdown:81,arrowup:82},Tp=225;function YR(t){return t>="a"&&t<="z"?{usage:4+(t.charCodeAt(0)-97)}:t>="A"&&t<="Z"?{usage:4+(t.charCodeAt(0)-65),shift:!0}:t in B0?{usage:B0[t]}:t in V0?{usage:V0[t]}:t in H0?{usage:H0[t],shift:!0}:null}function K0(t){return[...t].map(YR)}function J0(t,e){let r=t,n=r[0]?.frame??{x:0,y:0,width:1,height:1},s=0,i=a=>{let c=a.frame??{x:0,y:0,width:0,height:0},u={i:s++,enabled:a.enabled!==!1,frame:{x:c.x-n.x,y:c.y-n.y,width:c.width,height:c.height}};a.AXUniqueId&&(u.id=a.AXUniqueId),a.AXLabel&&(u.label=a.AXLabel),a.AXValue!=null&&a.AXValue!==""&&(u.value=String(a.AXValue)),a.type&&(u.role=a.type);let l=a.children??[];return l.length>0&&(u.children=l.map(i)),u},o=r.length===1?i(r[0]):{i:s++,enabled:!0,frame:{x:0,y:0,width:n.width,height:n.height},children:r.map(i)};return{deviceId:e,ts:Date.now(),screen:{width:n.width,height:n.height},root:o}}nn();function ez(t,e){let r=Xn(t.root).filter(i=>i.frame.width>0&&i.frame.height>0),n=(i,o)=>{let a=[i.label,i.value,i.id].filter(Boolean);if(e.regex){let u=new RegExp(o);return a.some(l=>u.test(l))}let c=null;try{c=new RegExp(`^(?:${o})$`)}catch{}return a.some(u=>u===o||c!==null&&c.test(u))},s=r.filter(i=>e.id!==void 0&&i.id!==e.id||e.text!==void 0&&!n(i,e.text)||e.role!==void 0&&i.role!==e.role?!1:e.id!==void 0||e.text!==void 0||e.role!==void 0);if(s.sort((i,o)=>i.frame.y-o.frame.y||i.frame.x-o.frame.x),e.index===void 0&&s.length>1){let i=[...s].sort((c,u)=>c.frame.width*c.frame.height-u.frame.width*u.frame.height)[0],o=i.frame.width*i.frame.height,a=s.filter(c=>c.frame.width*c.frame.height<=o*4);a.length>=1&&(s=a)}if(e.index!==void 0){let i=s[e.index];return i?[i]:[]}return s}function tx(t,e){return ez(t,typeof e=="string"?{text:e}:e)[0]??null}function yu(t){if(typeof t=="string")return JSON.stringify(t);let e=[];return t.id&&e.push(`id=${JSON.stringify(t.id)}`),t.text&&e.push(`text=${JSON.stringify(t.text)}${t.regex?" (regex)":""}`),t.role&&e.push(`role=${t.role}`),t.index!==void 0&&e.push(`index=${t.index}`),e.join(" ")||"<empty selector>"}nn();var tz=60,rx=300,rz=6,nx=18;var _u=class{info;bus;helper;codec;snapshotCache;screen;constructor(e){this.info=e.info,this.bus=e.bus,this.helper=e.helper,this.codec=e.codec??"webrtc"}get udid(){return this.info.udid}get helperPort(){return this.helper?.port}async ensureHelper(){return this.helper&&!this.helper.alive&&(await this.helper.stop().catch(()=>{}),this.helper=void 0),this.helper||(this.helper=new mu({udid:this.udid,codec:this.codec}),await this.helper.start()),this.helper}lastHelperRestartAt=0;async restartHelper(){return Date.now()-this.lastHelperRestartAt<1e4?!1:(this.lastHelperRestartAt=Date.now(),await this.helper?.stop().catch(()=>{}),this.helper=void 0,this.snapshotCache=void 0,this.screen=void 0,!0)}async screenSize(){if(this.screen)return this.screen;let e=await this.uiSnapshot({system:!0});return this.screen=e.screen,this.screen}invalidateSnapshot(){this.snapshotCache=void 0}async uiSnapshot(e){let r=e?.maxAgeMs??0;if(this.snapshotCache&&r>0&&Date.now()-this.snapshotCache.at<r)return this.snapshotCache.snapshot;let n=await this.fetchSnapshot();return this.snapshotCache={snapshot:n,at:Date.now()},n.screen.width>1&&(this.screen=n.screen),n}lastWedgeWarnAt=0;async fetchSnapshot(){let e;for(let r=0;r<2;r++)try{let s=await(await this.ensureHelper()).describeUi(),i=J0(s,this.udid);if(!((i.root.children?.length??0)===0||i.screen.width<=1)||(e=i,r===0&&!await this.restartHelper()))return i;r===1&&this.warnWedged()}catch(n){if(r===0&&await this.restartHelper())continue;throw n}return e}warnWedged(){Date.now()-this.lastWedgeWarnAt<3e4||(this.lastWedgeWarnAt=Date.now(),this.bus.emit(this.udid,{kind:"system"},{type:"note",text:`accessibility tree is empty even from a fresh helper \u2014 the simulator's AX is likely wedged; reboot it: xcrun simctl shutdown ${this.udid} && xcrun simctl boot ${this.udid}`}))}async screenshotPng(e,r){let n=await q0(this.udid);return r?.silent||this.bus.emit(this.udid,e,{type:"screenshot"}),n}async rawTouch(e,r,n){await(await this.ensureHelper()).touch(e,sx(r),sx(n))}async tap(e,r,n){await this.rawTouch("begin",r.x,r.y),await Zo(n?.longPressMs??tz),await this.rawTouch("end",r.x,r.y),this.invalidateSnapshot(),n?.longPressMs?this.bus.emit(this.udid,e,{type:"longPress",point:r,durationMs:n.longPressMs,...n?.element?{element:n.element}:{}}):this.bus.emit(this.udid,e,{type:"tap",point:r,...n?.element?{element:n.element}:{}})}async swipe(e,r,n,s=rx){let i=Math.max(3,Math.round(s/100*rz)),o=s/i;await this.rawTouch("begin",r.x,r.y);for(let a=1;a<=i;a++){let c=a/i;await this.rawTouch("move",r.x+(n.x-r.x)*c,r.y+(n.y-r.y)*c),await Zo(o)}await this.rawTouch("end",n.x,n.y),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"swipe",from:r,to:n,durationMs:s})}async keyTap(e,r){let n=await this.ensureHelper();r&&await n.key("down",Tp),await n.key("down",e),await Zo(nx),await n.key("up",e),r&&await n.key("up",Tp),await Zo(nx)}async inputText(e,r){let n=K0(r);if(n.some(s=>s===null))await this.pasteText(r);else for(let s of n)await this.keyTap(s.usage,s.shift);this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"inputText",text:r})}async pasteText(e){let{spawn:r}=await import("node:child_process");await new Promise((o,a)=>{let c=r("xcrun",["simctl","pbcopy",this.udid],{stdio:["pipe","ignore","pipe"]});c.on("error",a),c.on("exit",u=>u===0?o():a(new Error(`pbcopy exited ${u}`))),c.stdin.write(e),c.stdin.end()});let n=await this.ensureHelper(),s=227,i=25;await n.key("down",s),await this.keyTap(i),await n.key("up",s)}async eraseText(e,r){for(let n=0;n<r;n++)await this.keyTap(42);this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"eraseText",chars:r})}async pressKey(e,r){let n=W0[r.toLowerCase()];if(n===void 0)throw new Error(`Unknown key: ${r}`);await this.keyTap(n),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"key",key:r})}async button(e,r){await(await this.ensureHelper()).button(r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"button",button:r})}async setOrientation(e,r){await(await this.ensureHelper()).orientation(r),this.screen=void 0,this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"orientation",orientation:r})}async launchApp(e,r,n){await j0(this.udid,r,{relaunch:n?.relaunch??!0,args:n?.args}),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"launchApp",appId:r,...n?.args?{args:n.args}:{}})}async stopApp(e,r){await $p(this.udid,r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"stopApp",appId:r})}async openUrl(e,r){await L0(this.udid,r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"openUrl",url:r})}async installApp(e,r){await C0(this.udid,r),this.bus.emit(this.udid,e,{type:"installApp",path:r})}async waitForSelector(e,r){let n=r?.timeoutMs??17e3,s=Date.now(),i=50;for(;;){let o=await this.uiSnapshot(),a=tx(o,e);if(r?.gone?a===null:a!==null)return{node:a,waitedMs:Date.now()-s};if(Date.now()-s>=n)return{node:null,waitedMs:Date.now()-s};await Zo(i),i=Math.min(i*2,250)}}async tapOnSelector(e,r,n){let{node:s}=await this.waitForSelector(r,{timeoutMs:n?.timeoutMs});if(!s)throw new Error(`Element not found: ${yu(r)}`);let i=await this.screenSize(),o=Do(s);return await this.tap(e,{x:o.x/i.width,y:o.y/i.height},{...n?.longPressMs?{longPressMs:n.longPressMs}:{},element:Ip(s)}),s}async execute(e,r){try{switch(r.type){case"tap":{if(r.selector){let n=await this.tapOnSelector(e,r.selector,{...r.longPressMs?{longPressMs:r.longPressMs}:{}});return{ok:!0,element:Ip(n)}}return r.point?(await this.tap(e,r.point,r.longPressMs?{longPressMs:r.longPressMs}:{}),{ok:!0}):{ok:!1,error:"tap requires point or selector"}}case"swipe":{let{from:n,to:s}=r;return r.direction&&({from:n,to:s}=nz(r.direction)),!n||!s?{ok:!1,error:"swipe requires direction or from/to"}:(await this.swipe(e,n,s,r.durationMs??rx),{ok:!0})}case"inputText":return await this.inputText(e,r.text),{ok:!0};case"eraseText":return await this.eraseText(e,r.chars??50),{ok:!0};case"key":return await this.pressKey(e,r.key),{ok:!0};case"button":return await this.button(e,r.button),{ok:!0};case"orientation":return await this.setOrientation(e,r.orientation),{ok:!0};case"launchApp":return await this.launchApp(e,r.appId,{...r.relaunch!==void 0?{relaunch:r.relaunch}:{},...r.args?{args:r.args}:{}}),{ok:!0};case"stopApp":return await this.stopApp(e,r.appId),{ok:!0};case"openUrl":return await this.openUrl(e,r.url),{ok:!0};case"installApp":return await this.installApp(e,r.path),{ok:!0};case"screenshot":return{ok:!0,screenshotBase64:(await this.screenshotPng(e)).toString("base64")};case"uiSnapshot":{let n=await this.uiSnapshot();return this.bus.emit(this.udid,e,{type:"uiSnapshot",elementCount:ix(n.root)}),{ok:!0,snapshot:n}}case"waitFor":{let{node:n,waitedMs:s}=await this.waitForSelector(r.selector,{...r.timeoutMs!==void 0?{timeoutMs:r.timeoutMs}:{},...r.gone!==void 0?{gone:r.gone}:{}}),i=r.gone?n===null:n!==null;return this.bus.emit(this.udid,e,{type:"waitFor",condition:yu(r.selector)+(r.gone?" gone":""),satisfied:i,waitedMs:s}),i?{ok:!0,...n?{element:Ip(n)}:{}}:{ok:!1,error:`waitFor timed out: ${yu(r.selector)}`}}default:return{ok:!1,error:`Unknown action: ${r.type}`}}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}async dispose(){await this.helper?.stop(),this.helper=void 0}};function Ip(t){let e={frame:t.frame};return t.id&&(e.id=t.id),t.label&&(e.label=t.label),t.value&&(e.text=t.value),t.role&&(e.role=t.role),e}function nz(t){switch(t){case"up":return{from:{x:.5,y:.7},to:{x:.5,y:.25}};case"down":return{from:{x:.5,y:.3},to:{x:.5,y:.75}};case"left":return{from:{x:.8,y:.5},to:{x:.2,y:.5}};case"right":return{from:{x:.2,y:.5},to:{x:.8,y:.5}}}}function ix(t){let e=1;for(let r of t.children??[])e+=ix(r);return e}function sx(t){return Math.min(1,Math.max(0,t))}function Zo(t){return new Promise(e=>setTimeout(e,t))}import{randomUUID as cz}from"node:crypto";import{mkdir as uz,readFile as lz,rm as dz,writeFile as fz}from"node:fs/promises";import{createServer as pz}from"node:http";import{homedir as Ap}from"node:os";import{join as wu}from"node:path";var bu=class{onGesture;start;last;constructor(e){this.onGesture=e}feed(e,r,n){let s={x:ox(r),y:ox(n)};switch(e){case"begin":this.start={point:s,at:Date.now()},this.last=s;break;case"move":this.last=s;break;case"end":{if(!this.start)return;let i=this.start.point,o=this.last??s,a=Date.now()-this.start.at;Math.hypot(o.x-i.x,o.y-i.y)<=.02?a>=450?this.onGesture({type:"longPress",point:i,durationMs:a}):this.onGesture({type:"tap",point:i}):this.onGesture({type:"swipe",from:i,to:o,durationMs:a}),this.start=void 0,this.last=void 0;break}}}};function ox(t){return Math.round(t*1e3)/1e3}import{createReadStream as sz}from"node:fs";import{stat as ax}from"node:fs/promises";import{extname as iz,join as cx,normalize as oz}from"node:path";var az={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json",".png":"image/png",".svg":"image/svg+xml",".ico":"image/x-icon",".map":"application/json",".woff2":"font/woff2"};async function ux(t,e,r){let n=oz(decodeURIComponent(e)).replace(/^([/\\.])+/,"");(n===""||n==="/")&&(n="index.html");let s=cx(t,n),i=await ax(s).catch(()=>null);if(!i?.isFile()&&(s=cx(t,"index.html"),i=await ax(s).catch(()=>null),!i?.isFile())){r.writeHead(404,{"content-type":"text/plain"}),r.end("not found");return}r.writeHead(200,{"content-type":az[iz(s)]??"application/octet-stream","content-length":i.size,"cache-control":"no-cache"}),sz(s).pipe(r)}var lx="0.1.0",hz={40:"enter",41:"escape",42:"backspace",43:"tab",44:"space",76:"delete",79:"arrowright",80:"arrowleft",81:"arrowdown",82:"arrowup"},Uo=class{bus;devices=new Map;server;wssEvents=new pu.default({noServer:!0});wssDevice=new pu.default({noServer:!0});options;port;constructor(e={}){this.options=e,this.port=e.port??3300,this.bus=new hu({logFile:e.logFile??wu(Ap(),".simon","logs",`events-${process.pid}.jsonl`)})}get token(){return this.options.token}url(){let e=this.options.host??"127.0.0.1";return`http://${e==="0.0.0.0"?"127.0.0.1":e}:${this.port}`}async device(e){let r=this.devices.get(e);if(!r){let s=(await qo()).find(i=>i.udid===e);if(!s)throw new Error(`Device not found: ${e}`);r=new _u({info:s,bus:this.bus,...this.options.codec?{codec:this.options.codec}:{}}),this.devices.set(e,r)}return r}async start(){if(this.server=pz((e,r)=>{this.handleHttp(e,r).catch(n=>{r.headersSent||r.writeHead(500,{"content-type":"application/json"}),r.end(JSON.stringify({error:n instanceof Error?n.message:String(n)}))})}),this.server.on("upgrade",(e,r,n)=>{let s=new URL(e.url??"/","http://localhost");if(!this.authorized(e,s)){r.write(`HTTP/1.1 401 Unauthorized\r
|
|
213
|
+
Run with: maestro test ${p}`)}),await e.connect(new Qf)}var Iv,tN=$(()=>{"use strict";FA();WA();kv();sn();va();Pv();Iv={kind:"mcp",client:"mcp"}});import{randomBytes as DW}from"node:crypto";import{existsSync as ZW}from"node:fs";import{mkdir as UW,writeFile as Nv}from"node:fs/promises";import{basename as FW,dirname as sN,join as tp,resolve as Ao}from"node:path";import{parseArgs as Ar}from"node:util";import{fileURLToPath as BW}from"node:url";var NR=Ct(T0(),1),RR=Ct(cu(),1),zR=Ct(ti(),1),MR=Ct(hp(),1),CR=Ct(yp(),1),jR=Ct(Sp(),1),Yn=Ct(fu(),1),hu=Ct(M0(),1);var qo=Yn.default;async function $p(t){if(t?.url)return{url:t.url,...t.token?{token:t.token}:{}};let e=process.env.SIMON_REMOTE_URL;if(e){let r=process.env.SIMON_REMOTE_TOKEN;return{url:e,...r?{token:r}:{}}}try{let{readFile:r}=await import("node:fs/promises"),{homedir:n}=await import("node:os"),s=await r(`${n()}/.simon/daemon.json`,"utf8"),i=JSON.parse(s);return{url:`http://127.0.0.1:${i.httpPort}`,...i.token?{token:i.token}:{}}}catch{return null}}var ai=class{baseUrl;token;constructor(e){this.baseUrl=e.url.replace(/\/+$/,""),this.token=e.token}headers(){return{"content-type":"application/json",...this.token?{authorization:`Bearer ${this.token}`}:{}}}async request(e,r,n){let s=await fetch(`${this.baseUrl}${r}`,{method:e,headers:this.headers(),...n!==void 0?{body:JSON.stringify(n)}:{}});if(!s.ok){let i=await s.text().catch(()=>"");throw new Error(`${e} ${r} \u2192 ${s.status}: ${i.slice(0,500)}`)}return await s.json()}async ping(){try{return await this.request("GET","/api/health"),!0}catch{return!1}}listDevices(){return this.request("GET","/api/devices")}bootDevice(e){return this.request("POST",`/api/devices/${e}/boot`)}action(e,r,n){return this.request("POST",`/api/devices/${e}/action`,{source:r,action:n})}uiSnapshot(e){return this.request("GET",`/api/devices/${e}/ui`)}async screenshotPng(e,r){let n=r?`?source=${encodeURIComponent(JSON.stringify(r))}`:"",s=await fetch(`${this.baseUrl}/api/devices/${e}/screenshot.png${n}`,{headers:this.headers()});if(!s.ok)throw new Error(`screenshot \u2192 ${s.status}`);return Buffer.from(await s.arrayBuffer())}events(e,r=0){let n=new URLSearchParams;return e&&n.set("device",e),r&&n.set("since",String(r)),this.request("GET",`/api/events?${n}`)}streamEvents(e,r){let n=this.baseUrl.replace(/^http/,"ws")+`/ws/events?${this.token?`token=${this.token}&`:""}since=${r?.sinceSeq??0}`,s=new qo(n);return s.on("message",i=>{try{let o=JSON.parse(String(i));o.type==="event"&&o.event&&e(o.event)}catch{}}),()=>s.close()}};import{randomUUID as LR}from"node:crypto";import{appendFile as qR,mkdir as DR}from"node:fs/promises";import{dirname as ZR}from"node:path";var mu=class{seq=0;listeners=new Set;ring=[];ringCapacity;logFile;writeQueue=Promise.resolve();constructor(e){this.logFile=e?.logFile,this.ringCapacity=e?.ringCapacity??2e3}emit(e,r,n){let s={seq:++this.seq,id:LR(),ts:Date.now(),deviceId:e,source:r,event:n};this.ring.push(s),this.ring.length>this.ringCapacity&&this.ring.shift();for(let i of this.listeners)try{i(s)}catch{}if(this.logFile){let i=this.logFile,o=JSON.stringify(s)+`
|
|
214
|
+
`;this.writeQueue=this.writeQueue.then(async()=>{await DR(ZR(i),{recursive:!0}),await qR(i,o,"utf8")}).catch(()=>{})}return s}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}recent(e=0,r){return this.ring.filter(n=>n.seq>e&&(!r||n.deviceId===r))}async flush(){await this.writeQueue}};import{execFile as UR}from"node:child_process";import{promisify as FR}from"node:util";var BR=FR(UR);async function nn(t,e){return BR("xcrun",["simctl",...t],{timeout:e?.timeoutMs??6e4,maxBuffer:64*1024*1024})}async function Do(){let{stdout:t}=await nn(["list","devices","--json"]),e=JSON.parse(t),r=[];for(let[n,s]of Object.entries(e.devices))for(let i of s)i.isAvailable&&r.push({udid:i.udid,name:i.name,state:i.state,runtime:n.replace("com.apple.CoreSimulator.SimRuntime.","")});return r}async function C0(t){try{await nn(["boot",t])}catch(e){if(!(e instanceof Error?e.message:String(e)).includes("current state: Booted"))throw e}await nn(["bootstatus",t],{timeoutMs:12e4})}async function j0(t,e){await nn(["install",t,e],{timeoutMs:18e4})}async function L0(t,e,r){r?.relaunch&&await Ep(t,e).catch(()=>{}),await nn(["launch",t,e,...r?.args??[]])}async function Ep(t,e){await nn(["terminate",t,e])}async function q0(t,e){await nn(["openurl",t,e])}async function D0(t){let{readFile:e,rm:r}=await import("node:fs/promises"),{tmpdir:n}=await import("node:os"),{join:s}=await import("node:path"),{randomUUID:i}=await import("node:crypto"),o=s(n(),`simon-shot-${i()}.png`);try{return await nn(["io",t,"screenshot","--type","png",o],{timeoutMs:3e4}),await e(o)}finally{await r(o,{force:!0}).catch(()=>{})}}async function Z0(t){let e=await Do();if(t){let s=e.find(i=>i.udid===t||i.name===t);if(!s)throw new Error(`Device not found: ${t}`);return s}let r=e.find(s=>s.state==="Booted");if(r)return r;let n=e.filter(s=>s.name.startsWith("iPhone")).sort((s,i)=>i.runtime.localeCompare(s.runtime)).at(0);if(!n)throw new Error("No available iOS simulator found");return n}import{spawn as HR}from"node:child_process";import{once as U0}from"node:events";import{existsSync as WR}from"node:fs";import{createServer as KR}from"node:net";import{homedir as F0}from"node:os";import{join as Xn}from"node:path";import{fileURLToPath as B0}from"node:url";var JR=[process.env.SIMON_HELPER_BIN,()=>Xn(B0(new URL(".",import.meta.url)),"..","vendor","helper","simon-helper"),()=>Xn(Tp(),"bin","simon-helper"),()=>Xn(Tp(),".build","release","simon-helper"),()=>Xn(Tp(),".build","arm64-apple-macosx","release","simon-helper"),Xn(F0(),"expo/serve-sim/packages/serve-sim/.build/release/serve-sim-bin"),Xn(F0(),"expo/serve-sim/packages/serve-sim/.build/arm64-apple-macosx/release/serve-sim-bin")];function Tp(){return Xn(B0(new URL(".",import.meta.url)),"..","..","helper")}function GR(){for(let t of JR){let e=typeof t=="function"?t():t;if(e&&WR(e))return e}return null}async function YR(t){for(let e=t;e<t+200;e++)if(await new Promise(n=>{let s=KR();s.once("error",()=>n(!1)),s.listen(e,"127.0.0.1",()=>s.close(()=>n(!0)))}))return e;throw new Error(`No free port found from ${t}`)}var gu=class{udid;port=0;proc;ws;wsReady;options;onBinaryMessage;onExit;constructor(e){this.udid=e.udid,this.options=e}get alive(){return this.proc!==void 0&&this.proc.exitCode===null}async start(){let e=this.options.binaryPath??GR();if(!e)throw new Error("simon-helper binary not found. Build it with `bun run build:helper` or set SIMON_HELPER_BIN.");this.port=this.options.port??await YR(3100);let r=[this.udid,"--port",String(this.port),"--codec",this.options.codec??"webrtc","--max-fps",String(this.options.maxFps??60)];this.proc=HR(e,r,{stdio:["ignore","pipe","pipe"]}),this.proc.on("exit",n=>this.onExit?.(n)),await this.waitForHttp()}async waitForHttp(e=15e3){let r=Date.now()+e;for(;Date.now()<r;){try{let n=await fetch(`http://127.0.0.1:${this.port}/health`,{signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===404)return}catch{}if(this.proc&&this.proc.exitCode!==null)throw new Error(`helper exited with code ${this.proc.exitCode}`);await new Promise(n=>setTimeout(n,200))}throw new Error("helper did not start listening in time")}async ensureWs(){if(this.ws&&this.ws.readyState===qo.OPEN)return this.ws;let e=new qo(`ws://127.0.0.1:${this.port}/ws`);return e.binaryType="nodebuffer",e.on("message",(r,n)=>{n&&this.onBinaryMessage?.(r)}),this.ws=e,this.wsReady=U0(e,"open").then(()=>{}),await this.wsReady,e}async sendJson(e,r){let n=await this.ensureWs(),s=Buffer.from(JSON.stringify(r),"utf8");n.send(Buffer.concat([Buffer.from([e]),s]))}async sendRaw(e){(await this.ensureWs()).send(e)}async touch(e,r,n,s){await this.sendJson(3,{type:e,x:r,y:n,...s?{edge:s}:{}})}async button(e){await this.sendJson(4,{button:e})}async key(e,r){await this.sendJson(6,{type:e,usage:r})}async orientation(e){await this.sendJson(7,{orientation:e})}async describeUi(){let e=await fetch(`http://127.0.0.1:${this.port}/ax`,{signal:AbortSignal.timeout(2e4)});if(!e.ok)throw new Error(`helper /ax failed: ${e.status} ${await e.text()}`);return await e.json()}async stop(){this.ws?.close(),this.ws=void 0,this.proc&&this.proc.exitCode===null&&(this.proc.kill("SIGTERM"),await Promise.race([U0(this.proc,"exit"),new Promise(e=>setTimeout(e,3e3))]),this.proc.exitCode===null&&this.proc.kill("SIGKILL")),this.proc=void 0}};var V0={1:30,2:31,3:32,4:33,5:34,6:35,7:36,8:37,9:38,0:39},H0={"\n":40," ":43," ":44,"-":45,"=":46,"[":47,"]":48,"\\":49,";":51,"'":52,"`":53,",":54,".":55,"/":56},W0={"!":30,"@":31,"#":32,$:33,"%":34,"^":35,"&":36,"*":37,"(":38,")":39,_:45,"+":46,"{":47,"}":48,"|":49,":":51,'"':52,"~":53,"<":54,">":55,"?":56},K0={enter:40,escape:41,backspace:42,tab:43,space:44,delete:76,home:74,end:77,arrowright:79,arrowleft:80,arrowdown:81,arrowup:82},Pp=225;function XR(t){return t>="a"&&t<="z"?{usage:4+(t.charCodeAt(0)-97)}:t>="A"&&t<="Z"?{usage:4+(t.charCodeAt(0)-65),shift:!0}:t in V0?{usage:V0[t]}:t in H0?{usage:H0[t]}:t in W0?{usage:W0[t],shift:!0}:null}function J0(t){return[...t].map(XR)}function G0(t,e){let r=t,n=r[0]?.frame??{x:0,y:0,width:1,height:1},s=0,i=a=>{let c=a.frame??{x:0,y:0,width:0,height:0},u={i:s++,enabled:a.enabled!==!1,frame:{x:c.x-n.x,y:c.y-n.y,width:c.width,height:c.height}};a.AXUniqueId&&(u.id=a.AXUniqueId),a.AXLabel&&(u.label=a.AXLabel),a.AXValue!=null&&a.AXValue!==""&&(u.value=String(a.AXValue)),a.type&&(u.role=a.type);let l=a.children??[];return l.length>0&&(u.children=l.map(i)),u},o=r.length===1?i(r[0]):{i:s++,enabled:!0,frame:{x:0,y:0,width:n.width,height:n.height},children:r.map(i)};return{deviceId:e,ts:Date.now(),screen:{width:n.width,height:n.height},root:o}}sn();function tz(t,e){let r=Qn(t.root).filter(i=>i.frame.width>0&&i.frame.height>0),n=(i,o)=>{let a=[i.label,i.value,i.id].filter(Boolean);if(e.regex){let u=new RegExp(o);return a.some(l=>u.test(l))}let c=null;try{c=new RegExp(`^(?:${o})$`)}catch{}return a.some(u=>u===o||c!==null&&c.test(u))},s=r.filter(i=>e.id!==void 0&&i.id!==e.id||e.text!==void 0&&!n(i,e.text)||e.role!==void 0&&i.role!==e.role?!1:e.id!==void 0||e.text!==void 0||e.role!==void 0);if(s.sort((i,o)=>i.frame.y-o.frame.y||i.frame.x-o.frame.x),e.index===void 0&&s.length>1){let i=[...s].sort((c,u)=>c.frame.width*c.frame.height-u.frame.width*u.frame.height)[0],o=i.frame.width*i.frame.height,a=s.filter(c=>c.frame.width*c.frame.height<=o*4);a.length>=1&&(s=a)}if(e.index!==void 0){let i=s[e.index];return i?[i]:[]}return s}function rx(t,e){return tz(t,typeof e=="string"?{text:e}:e)[0]??null}function _u(t){if(typeof t=="string")return JSON.stringify(t);let e=[];return t.id&&e.push(`id=${JSON.stringify(t.id)}`),t.text&&e.push(`text=${JSON.stringify(t.text)}${t.regex?" (regex)":""}`),t.role&&e.push(`role=${t.role}`),t.index!==void 0&&e.push(`index=${t.index}`),e.join(" ")||"<empty selector>"}sn();var rz=60,nx=300,nz=6,sx=18;var bu=class{info;bus;helper;codec;snapshotCache;screen;constructor(e){this.info=e.info,this.bus=e.bus,this.helper=e.helper,this.codec=e.codec??"webrtc"}get udid(){return this.info.udid}get helperPort(){return this.helper?.port}async ensureHelper(){return this.helper&&!this.helper.alive&&(await this.helper.stop().catch(()=>{}),this.helper=void 0),this.helper||(this.helper=new gu({udid:this.udid,codec:this.codec}),await this.helper.start()),this.helper}lastHelperRestartAt=0;async restartHelper(){return Date.now()-this.lastHelperRestartAt<1e4?!1:(this.lastHelperRestartAt=Date.now(),await this.helper?.stop().catch(()=>{}),this.helper=void 0,this.snapshotCache=void 0,this.screen=void 0,!0)}async screenSize(){if(this.screen)return this.screen;let e=await this.uiSnapshot({system:!0});return this.screen=e.screen,this.screen}invalidateSnapshot(){this.snapshotCache=void 0}async uiSnapshot(e){let r=e?.maxAgeMs??0;if(this.snapshotCache&&r>0&&Date.now()-this.snapshotCache.at<r)return this.snapshotCache.snapshot;let n=await this.fetchSnapshot();return this.snapshotCache={snapshot:n,at:Date.now()},n.screen.width>1&&(this.screen=n.screen),n}lastWedgeWarnAt=0;async fetchSnapshot(){let e;for(let r=0;r<2;r++)try{let s=await(await this.ensureHelper()).describeUi(),i=G0(s,this.udid);if(!((i.root.children?.length??0)===0||i.screen.width<=1)||(e=i,r===0&&!await this.restartHelper()))return i;r===1&&this.warnWedged()}catch(n){if(r===0&&await this.restartHelper())continue;throw n}return e}warnWedged(){Date.now()-this.lastWedgeWarnAt<3e4||(this.lastWedgeWarnAt=Date.now(),this.bus.emit(this.udid,{kind:"system"},{type:"note",text:`accessibility tree is empty even from a fresh helper \u2014 the simulator's AX is likely wedged; reboot it: xcrun simctl shutdown ${this.udid} && xcrun simctl boot ${this.udid}`}))}async screenshotPng(e,r){let n=await D0(this.udid);return r?.silent||this.bus.emit(this.udid,e,{type:"screenshot"}),n}async rawTouch(e,r,n){await(await this.ensureHelper()).touch(e,ix(r),ix(n))}async tap(e,r,n){await this.rawTouch("begin",r.x,r.y),await Uo(n?.longPressMs??rz),await this.rawTouch("end",r.x,r.y),this.invalidateSnapshot(),n?.longPressMs?this.bus.emit(this.udid,e,{type:"longPress",point:r,durationMs:n.longPressMs,...n?.element?{element:n.element}:{}}):this.bus.emit(this.udid,e,{type:"tap",point:r,...n?.element?{element:n.element}:{}})}async swipe(e,r,n,s=nx){let i=Math.max(3,Math.round(s/100*nz)),o=s/i;await this.rawTouch("begin",r.x,r.y);for(let a=1;a<=i;a++){let c=a/i;await this.rawTouch("move",r.x+(n.x-r.x)*c,r.y+(n.y-r.y)*c),await Uo(o)}await this.rawTouch("end",n.x,n.y),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"swipe",from:r,to:n,durationMs:s})}async keyTap(e,r){let n=await this.ensureHelper();r&&await n.key("down",Pp),await n.key("down",e),await Uo(sx),await n.key("up",e),r&&await n.key("up",Pp),await Uo(sx)}async inputText(e,r){let n=J0(r);if(n.some(s=>s===null))await this.pasteText(r);else for(let s of n)await this.keyTap(s.usage,s.shift);this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"inputText",text:r})}async pasteText(e){let{spawn:r}=await import("node:child_process");await new Promise((o,a)=>{let c=r("xcrun",["simctl","pbcopy",this.udid],{stdio:["pipe","ignore","pipe"]});c.on("error",a),c.on("exit",u=>u===0?o():a(new Error(`pbcopy exited ${u}`))),c.stdin.write(e),c.stdin.end()});let n=await this.ensureHelper(),s=227,i=25;await n.key("down",s),await this.keyTap(i),await n.key("up",s)}async eraseText(e,r){for(let n=0;n<r;n++)await this.keyTap(42);this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"eraseText",chars:r})}async pressKey(e,r){let n=K0[r.toLowerCase()];if(n===void 0)throw new Error(`Unknown key: ${r}`);await this.keyTap(n),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"key",key:r})}async button(e,r){await(await this.ensureHelper()).button(r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"button",button:r})}async setOrientation(e,r){await(await this.ensureHelper()).orientation(r),this.screen=void 0,this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"orientation",orientation:r})}async launchApp(e,r,n){await L0(this.udid,r,{relaunch:n?.relaunch??!0,args:n?.args}),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"launchApp",appId:r,...n?.args?{args:n.args}:{}})}async stopApp(e,r){await Ep(this.udid,r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"stopApp",appId:r})}async openUrl(e,r){await q0(this.udid,r),this.invalidateSnapshot(),this.bus.emit(this.udid,e,{type:"openUrl",url:r})}async installApp(e,r){await j0(this.udid,r),this.bus.emit(this.udid,e,{type:"installApp",path:r})}async waitForSelector(e,r){let n=r?.timeoutMs??17e3,s=Date.now(),i=50;for(;;){let o=await this.uiSnapshot(),a=rx(o,e);if(r?.gone?a===null:a!==null)return{node:a,waitedMs:Date.now()-s};if(Date.now()-s>=n)return{node:null,waitedMs:Date.now()-s};await Uo(i),i=Math.min(i*2,250)}}async tapOnSelector(e,r,n){let{node:s}=await this.waitForSelector(r,{timeoutMs:n?.timeoutMs});if(!s)throw new Error(`Element not found: ${_u(r)}`);let i=await this.screenSize(),o=Zo(s);return await this.tap(e,{x:o.x/i.width,y:o.y/i.height},{...n?.longPressMs?{longPressMs:n.longPressMs}:{},element:Ap(s)}),s}async execute(e,r){try{switch(r.type){case"tap":{if(r.selector){let n=await this.tapOnSelector(e,r.selector,{...r.longPressMs?{longPressMs:r.longPressMs}:{}});return{ok:!0,element:Ap(n)}}return r.point?(await this.tap(e,r.point,r.longPressMs?{longPressMs:r.longPressMs}:{}),{ok:!0}):{ok:!1,error:"tap requires point or selector"}}case"swipe":{let{from:n,to:s}=r;return r.direction&&({from:n,to:s}=sz(r.direction)),!n||!s?{ok:!1,error:"swipe requires direction or from/to"}:(await this.swipe(e,n,s,r.durationMs??nx),{ok:!0})}case"inputText":return await this.inputText(e,r.text),{ok:!0};case"eraseText":return await this.eraseText(e,r.chars??50),{ok:!0};case"key":return await this.pressKey(e,r.key),{ok:!0};case"button":return await this.button(e,r.button),{ok:!0};case"orientation":return await this.setOrientation(e,r.orientation),{ok:!0};case"launchApp":return await this.launchApp(e,r.appId,{...r.relaunch!==void 0?{relaunch:r.relaunch}:{},...r.args?{args:r.args}:{}}),{ok:!0};case"stopApp":return await this.stopApp(e,r.appId),{ok:!0};case"openUrl":return await this.openUrl(e,r.url),{ok:!0};case"installApp":return await this.installApp(e,r.path),{ok:!0};case"screenshot":return{ok:!0,screenshotBase64:(await this.screenshotPng(e)).toString("base64")};case"uiSnapshot":{let n=await this.uiSnapshot();return this.bus.emit(this.udid,e,{type:"uiSnapshot",elementCount:ox(n.root)}),{ok:!0,snapshot:n}}case"waitFor":{let{node:n,waitedMs:s}=await this.waitForSelector(r.selector,{...r.timeoutMs!==void 0?{timeoutMs:r.timeoutMs}:{},...r.gone!==void 0?{gone:r.gone}:{}}),i=r.gone?n===null:n!==null;return this.bus.emit(this.udid,e,{type:"waitFor",condition:_u(r.selector)+(r.gone?" gone":""),satisfied:i,waitedMs:s}),i?{ok:!0,...n?{element:Ap(n)}:{}}:{ok:!1,error:`waitFor timed out: ${_u(r.selector)}`}}default:return{ok:!1,error:`Unknown action: ${r.type}`}}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}async dispose(){await this.helper?.stop(),this.helper=void 0}};function Ap(t){let e={frame:t.frame};return t.id&&(e.id=t.id),t.label&&(e.label=t.label),t.value&&(e.text=t.value),t.role&&(e.role=t.role),e}function sz(t){switch(t){case"up":return{from:{x:.5,y:.7},to:{x:.5,y:.25}};case"down":return{from:{x:.5,y:.3},to:{x:.5,y:.75}};case"left":return{from:{x:.8,y:.5},to:{x:.2,y:.5}};case"right":return{from:{x:.2,y:.5},to:{x:.8,y:.5}}}}function ox(t){let e=1;for(let r of t.children??[])e+=ox(r);return e}function ix(t){return Math.min(1,Math.max(0,t))}function Uo(t){return new Promise(e=>setTimeout(e,t))}import{randomUUID as uz}from"node:crypto";import{mkdir as lz,readFile as dz,rm as fz,writeFile as pz}from"node:fs/promises";import{createServer as hz}from"node:http";import{homedir as Np}from"node:os";import{join as vu}from"node:path";var wu=class{onGesture;start;last;constructor(e){this.onGesture=e}feed(e,r,n){let s={x:ax(r),y:ax(n)};switch(e){case"begin":this.start={point:s,at:Date.now()},this.last=s;break;case"move":this.last=s;break;case"end":{if(!this.start)return;let i=this.start.point,o=this.last??s,a=Date.now()-this.start.at;Math.hypot(o.x-i.x,o.y-i.y)<=.02?a>=450?this.onGesture({type:"longPress",point:i,durationMs:a}):this.onGesture({type:"tap",point:i}):this.onGesture({type:"swipe",from:i,to:o,durationMs:a}),this.start=void 0,this.last=void 0;break}}}};function ax(t){return Math.round(t*1e3)/1e3}import{createReadStream as iz}from"node:fs";import{stat as cx}from"node:fs/promises";import{extname as oz,join as ux,normalize as az}from"node:path";var cz={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json",".png":"image/png",".svg":"image/svg+xml",".ico":"image/x-icon",".map":"application/json",".woff2":"font/woff2"};async function lx(t,e,r){let n=az(decodeURIComponent(e)).replace(/^([/\\.])+/,"");(n===""||n==="/")&&(n="index.html");let s=ux(t,n),i=await cx(s).catch(()=>null);if(!i?.isFile()&&(s=ux(t,"index.html"),i=await cx(s).catch(()=>null),!i?.isFile())){r.writeHead(404,{"content-type":"text/plain"}),r.end("not found");return}r.writeHead(200,{"content-type":cz[oz(s)]??"application/octet-stream","content-length":i.size,"cache-control":"no-cache"}),iz(s).pipe(r)}var dx="0.1.0",mz={40:"enter",41:"escape",42:"backspace",43:"tab",44:"space",76:"delete",79:"arrowright",80:"arrowleft",81:"arrowdown",82:"arrowup"},Fo=class{bus;devices=new Map;server;wssEvents=new hu.default({noServer:!0});wssDevice=new hu.default({noServer:!0});options;port;constructor(e={}){this.options=e,this.port=e.port??3300,this.bus=new mu({logFile:e.logFile??vu(Np(),".simon","logs",`events-${process.pid}.jsonl`)})}get token(){return this.options.token}url(){let e=this.options.host??"127.0.0.1";return`http://${e==="0.0.0.0"?"127.0.0.1":e}:${this.port}`}async device(e){let r=this.devices.get(e);if(!r){let s=(await Do()).find(i=>i.udid===e);if(!s)throw new Error(`Device not found: ${e}`);r=new bu({info:s,bus:this.bus,...this.options.codec?{codec:this.options.codec}:{}}),this.devices.set(e,r)}return r}async start(){if(this.server=hz((e,r)=>{this.handleHttp(e,r).catch(n=>{r.headersSent||r.writeHead(500,{"content-type":"application/json"}),r.end(JSON.stringify({error:n instanceof Error?n.message:String(n)}))})}),this.server.on("upgrade",(e,r,n)=>{let s=new URL(e.url??"/","http://localhost");if(!this.authorized(e,s)){r.write(`HTTP/1.1 401 Unauthorized\r
|
|
215
215
|
\r
|
|
216
|
-
`),r.destroy();return}if(s.pathname==="/ws/events")this.wssEvents.handleUpgrade(e,r,n,i=>{this.handleEventsWs(i,s)});else if(s.pathname.startsWith("/ws/device/")){let i=decodeURIComponent(s.pathname.slice(11));this.wssDevice.handleUpgrade(e,r,n,o=>{this.handleDeviceWs(o,i,s).catch(()=>o.close(1011,"device error"))})}else r.destroy()}),await new Promise((e,r)=>{this.server.once("error",r),this.server.listen(this.port,this.options.host??"127.0.0.1",()=>e())}),this.options.writeDaemonFile!==!1){let e=wu(Ap(),".simon");await uz(e,{recursive:!0}),await fz(wu(e,"daemon.json"),JSON.stringify({httpPort:this.port,token:this.options.token,pid:process.pid,version:lx}),"utf8")}}async stop(){for(let e of this.devices.values())await e.dispose().catch(()=>{});this.devices.clear();try{let e=wu(Ap(),".simon","daemon.json");JSON.parse(await lz(e,"utf8")).pid===process.pid&&await dz(e,{force:!0})}catch{}await new Promise(e=>this.server?.close(()=>e())),await this.bus.flush()}authorized(e,r){let n=this.options.token;return!n||e.headers.authorization===`Bearer ${n}`||r.searchParams.get("token")===n}async handleHttp(e,r){let n=new URL(e.url??"/","http://localhost"),s=n.pathname;if(s.startsWith("/api/"))return this.authorized(e,n)?this.handleApi(e,r,n):mr(r,401,{error:"unauthorized"});if(this.options.webDist)return ux(this.options.webDist,s,r);mr(r,404,{error:"web UI not bundled; use the /api endpoints"})}async handleApi(e,r,n){let s=n.pathname,i=e.method??"GET";if(s==="/api/health")return mr(r,200,{ok:!0,version:lx});if(s==="/api/devices"&&i==="GET"){let c=(await qo()).map(u=>{let d=this.devices.get(u.udid)?.helperPort;return d?{...u,helperPort:d}:u});return mr(r,200,c)}if(s==="/api/events"&&i==="GET"){let a=Number(n.searchParams.get("since")??0),c=n.searchParams.get("device")??void 0;return mr(r,200,this.bus.recent(a,c))}let o=s.match(/^\/api\/devices\/([^/]+)\/(\w+(?:\.\w+)?)$/);if(o){let a=decodeURIComponent(o[1]),c=o[2];if(c==="boot"&&i==="POST"){await M0(a),this.bus.emit(a,{kind:"system"},{type:"deviceBooted"});let u=await qo();return mr(r,200,u.find(l=>l.udid===a))}if(c==="action"&&i==="POST"){let u=await mz(e);if(!u?.action?.type||!u?.source?.kind)return mr(r,400,{error:"body must be {source, action}"});let d=await(await this.device(a)).execute(u.source,u.action);return mr(r,d.ok?200:422,d)}if(c==="ui"&&i==="GET"){let u=await this.device(a);return mr(r,200,await u.uiSnapshot())}if(c==="screenshot.png"&&i==="GET"){let u=n.searchParams.get("source"),l=u?JSON.parse(u):{kind:"system"},f=await(await this.device(a)).screenshotPng(l,{silent:l.kind==="system"});r.writeHead(200,{"content-type":"image/png","content-length":f.length}),r.end(f);return}}mr(r,404,{error:`no route: ${i} ${s}`})}handleEventsWs(e,r){let n=Number(r.searchParams.get("since")??0);for(let i of this.bus.recent(n))e.send(JSON.stringify({type:"event",event:i}));let s=this.bus.subscribe(i=>{e.readyState===Gn.default.OPEN&&e.send(JSON.stringify({type:"event",event:i}))});e.on("close",s)}async handleDeviceWs(e,r,n){let i={kind:"browser",sessionId:n.searchParams.get("session")??cz().slice(0,8)},o=await this.device(r),a=await o.ensureHelper(),c=new Gn.default(`ws://127.0.0.1:${a.port}/ws`);c.binaryType="nodebuffer";let u=new bu(d=>{o.invalidateSnapshot(),this.bus.emit(r,i,d)}),l=[];c.on("open",()=>{for(let d of l.splice(0))c.send(d)}),c.on("message",(d,f)=>{e.readyState===Gn.default.OPEN&&e.send(d,{binary:f})}),c.on("close",()=>e.close()),c.on("error",()=>e.close()),e.on("message",(d,f)=>{!f||d.length<1||(this.observeBrowserInput(d,r,i,u),c.readyState===Gn.default.OPEN?c.send(d):l.push(d))}),e.on("close",()=>c.close()),e.on("error",()=>c.close())}observeBrowserInput(e,r,n,s){let i=e[0],o=()=>{try{return JSON.parse(e.subarray(1).toString("utf8"))}catch{return null}};switch(i){case 3:{let a=o();a&&typeof a.x=="number"&&typeof a.y=="number"&&s.feed(a.type,a.x,a.y);break}case 4:{let a=o();a?.button&&this.bus.emit(r,n,{type:"button",button:a.button});break}case 6:{let a=o();if(a?.type==="down"&&typeof a.usage=="number"){let c=hz[a.usage];c&&this.bus.emit(r,n,{type:"key",key:c})}break}case 7:{let a=o();a?.orientation&&this.bus.emit(r,n,{type:"orientation",orientation:a.orientation});break}default:break}}};function mr(t,e,r){let n=JSON.stringify(r??null);t.writeHead(e,{"content-type":"application/json","cache-control":"no-store"}),t.end(n)}async function mz(t){let e=[];for await(let n of t)e.push(n);let r=Buffer.concat(e).toString("utf8");return r?JSON.parse(r):void 0}wa();var pL=["enter","escape","backspace","tab","space","delete","arrow_up","arrow_down","arrow_left","arrow_right"],hL=["up","down","left","right"];function v$(t){return{tool:t.name,...t.input}}var w$="Refs (@eN) are only valid for the MOST RECENT tree \u2014 either the last snapshot or the CURRENT SCREEN block in the last tool result. They go stale after every action.",x$=[{name:"snapshot",description:'Read the current screen as a compact accessibility tree, one element per line: `@e12 Button "Sign In" id="sign-in" (0.38,0.71 0.23\xD70.05)` \u2014 normalized [0,1] center and size. Call this BEFORE your first interaction and whenever you have no fresh tree. Every mutating tool already returns a fresh CURRENT SCREEN tree, so do not call snapshot right after an action \u2014 that wastes a step. '+w$,input_schema:{type:"object",properties:{},additionalProperties:!1}},{name:"screenshot",description:"Take a PNG screenshot of the device. EXPENSIVE \u2014 use sparingly, only when: the tree is sparse (custom-drawn surface like a map, game or chart), you must verify something visual (image content, color, layout glitch), or an assertion needs pixels. For everything else the snapshot tree is cheaper and more precise.",input_schema:{type:"object",properties:{},additionalProperties:!1}},{name:"tap",description:"Tap (or long-press) an element by its @e ref from the latest tree. If you do not have a fresh tree, call snapshot first. "+w$+" Never invent refs and never aim at coordinates \u2014 only refs are accepted. Prefer elements that carry an id= (accessibility id); they are the most stable targets.",input_schema:{type:"object",properties:{ref:{type:"string",description:'Element ref from the latest tree, e.g. "@e12".'},longPress:{type:"boolean",description:"Long-press instead of tap (context menus, drag handles)."}},required:["ref"],additionalProperties:!1}},{name:"type_text",description:"Type text into the currently focused element. Tap a text field first to focus it. Unicode and long strings are fine (pasteboard fallback is automatic).",input_schema:{type:"object",properties:{text:{type:"string",description:"Text to type."}},required:["text"],additionalProperties:!1}},{name:"erase_text",description:"Erase characters from the focused text field (backspace presses). Focus the field first.",input_schema:{type:"object",properties:{chars:{type:"integer",description:"How many characters to erase. Defaults to clearing a sensible amount (50)."}},required:[],additionalProperties:!1}},{name:"press_key",description:"Press a hardware/keyboard key. Use enter to submit forms, escape to dismiss, tab/arrows to move focus.",input_schema:{type:"object",properties:{key:{type:"string",enum:[...pL],description:"Key to press."}},required:["key"],additionalProperties:!1}},{name:"swipe",description:"Swipe across the screen center in a direction. `up` scrolls content down (reveals content below), `down` scrolls up. Use to scroll lists or dismiss sheets; the result tree shows what became visible.",input_schema:{type:"object",properties:{direction:{type:"string",enum:[...hL],description:"Swipe direction."}},required:["direction"],additionalProperties:!1}},{name:"launch_app",description:"Launch an app by bundle id. Set relaunch=true to terminate it first for a clean foreground state. Call this at the start when the app under test is not already on screen.",input_schema:{type:"object",properties:{appId:{type:"string",description:"Bundle identifier, e.g. com.example.app."},relaunch:{type:"boolean",description:"Terminate the app first if it is running."}},required:["appId"],additionalProperties:!1}},{name:"stop_app",description:"Terminate a running app by bundle id.",input_schema:{type:"object",properties:{appId:{type:"string",description:"Bundle identifier of the app to stop."}},required:["appId"],additionalProperties:!1}},{name:"open_url",description:"Open a URL on the device \u2014 deep links (myapp://...), universal links, or web URLs. Use for navigating directly to a screen under test.",input_schema:{type:"object",properties:{url:{type:"string",description:"URL or deep link to open."}},required:["url"],additionalProperties:!1}},{name:"wait_for",description:"Poll until an element appears (or disappears with gone=true). Use this after actions that trigger loading, navigation or animation instead of taking repeated snapshots \u2014 it is one call and it settles exactly when the UI does. Match by exact visible text and/or accessibility id (id preferred).",input_schema:{type:"object",properties:{text:{type:"string",description:"Exact text/label/value to wait for."},id:{type:"string",description:"Accessibility id (React Native testID) to wait for."},gone:{type:"boolean",description:"Wait for the element to DISAPPEAR instead (spinners, dismissed sheets)."},timeoutSeconds:{type:"number",description:"Max seconds to wait. Default 10."}},required:[],additionalProperties:!1}},{name:"assert",description:`Record a verdict about something you observed. Call this for EVERY observation that matters to the goal \u2014 assertions become the compiled flow's checks. Format the assertion as "visible:<exact text>" or "notVisible:<exact text>" whenever possible: those are verified live against the device and compile to deterministic flow asserts. Free-form assertions are recorded but not device-verified. Set pass to your honest verdict; a failing assert does not end the run (use done for that).`,input_schema:{type:"object",properties:{assertion:{type:"string",description:'What is being asserted, e.g. "visible:Welcome back" or "notVisible:Error".'},pass:{type:"boolean",description:"Whether the assertion holds."},detail:{type:"string",description:"Optional context, especially for failures."}},required:["assertion","pass"],additionalProperties:!1}},{name:"checkpoint",description:'Mark a milestone in the run, e.g. "logged in" or "cart populated". Checkpoints structure the compiled flow and the evidence report. Use a short, stable, kebab-or-plain name.',input_schema:{type:"object",properties:{name:{type:"string",description:"Milestone name."}},required:["name"],additionalProperties:!1}},{name:"done",description:"End the run with the final verdict. Call exactly once, when the goal is verified (pass=true) or you have established it cannot be (pass=false). The summary should state what was verified and how \u2014 it becomes the run's record.",input_schema:{type:"object",properties:{pass:{type:"boolean",description:"Final verdict for the goal."},summary:{type:"string",description:"Concise account of what was verified or why it failed."}},required:["pass","summary"],additionalProperties:!1}}];import{randomUUID as cq}from"node:crypto";function A(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}function b(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}var Em=function(){let{crypto:t}=globalThis;if(t?.randomUUID)return Em=t.randomUUID.bind(t),t.randomUUID();let e=new Uint8Array(1),r=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function jr(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}var va=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){let 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)};var j=class extends Error{},Je=class t extends j{constructor(e,r,n,s,i){super(`${t.makeMessage(e,r,n)}`),this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.error=r,this.type=i??null}static makeMessage(e,r,n){let s=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,r,n,s){if(!e||!s)return new yn({message:n,cause:va(r)});let i=r,o=i?.error?.type;return e===400?new vi(e,i,n,s,o):e===401?new xi(e,i,n,s,o):e===403?new Si(e,i,n,s,o):e===404?new ki(e,i,n,s,o):e===409?new $i(e,i,n,s,o):e===422?new Ei(e,i,n,s,o):e===429?new Ti(e,i,n,s,o):e>=500?new Pi(e,i,n,s,o):new t(e,i,n,s,o)}},Qe=class extends Je{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},yn=class extends Je{constructor({message:e,cause:r}){super(void 0,void 0,e||"Connection error.",void 0),r&&(this.cause=r)}},wi=class extends yn{constructor({message:e}={}){super({message:e??"Request timed out."})}},vi=class extends Je{},xi=class extends Je{},Si=class extends Je{},ki=class extends Je{},$i=class extends Je{},Ei=class extends Je{},Ti=class extends Je{},Pi=class extends Je{};var gL=/^[a-z][a-z0-9+.-]*:/i,S$=t=>gL.test(t),Tm=t=>(Tm=Array.isArray,Tm(t)),Pm=Tm;function kl(t){return typeof t!="object"?{}:t??{}}function Om(t){if(!t)return!0;for(let e in t)return!1;return!0}function k$(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var $$=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new j(`${t} must be an integer`);if(e<0)throw new j(`${t} must be a positive integer`);return e};var $l=t=>{try{return JSON.parse(t)}catch{return}};var E$=t=>new Promise(e=>setTimeout(e,t));var _n="0.88.0";var I$=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function yL(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var _L=()=>{let t=yL();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_n,"X-Stainless-OS":P$(Deno.build.os),"X-Stainless-Arch":T$(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_n,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_n,"X-Stainless-OS":P$(globalThis.process.platform??"unknown"),"X-Stainless-Arch":T$(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=bL();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_n,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_n,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function bL(){if(typeof navigator>"u"||!navigator)return null;let t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:r}of t){let n=r.exec(navigator.userAgent);if(n){let s=n[1]||0,i=n[2]||0,o=n[3]||0;return{browser:e,version:`${s}.${i}.${o}`}}}return null}var T$=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",P$=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),O$,A$=()=>O$??(O$=_L());function N$(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Im(...t){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function El(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return Im({start(){},async pull(r){let{done:n,value:s}=await e.next();n?r.close():r.enqueue(s)},async cancel(){await e.return?.()}})}function xa(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let r=await e.read();return r?.done&&e.releaseLock(),r}catch(r){throw e.releaseLock(),r}},async return(){let r=e.cancel();return e.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function R$(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}let e=t.getReader(),r=e.cancel();e.releaseLock(),await r}var z$=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function M$(t){return Object.entries(t).filter(([e,r])=>typeof r<"u").map(([e,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return`${encodeURIComponent(e)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(e)}=`;throw new j(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function L$(t){let e=0;for(let s of t)e+=s.length;let r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var C$;function Sa(t){let e;return(C$??(e=new globalThis.TextEncoder,C$=e.encode.bind(e)))(t)}var j$;function Am(t){let e;return(j$??(e=new globalThis.TextDecoder,j$=e.decode.bind(e)))(t)}var Ot,It,Lr=class{constructor(){Ot.set(this,void 0),It.set(this,void 0),A(this,Ot,new Uint8Array,"f"),A(this,It,null,"f")}decode(e){if(e==null)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Sa(e):e;A(this,Ot,L$([b(this,Ot,"f"),r]),"f");let n=[],s;for(;(s=xL(b(this,Ot,"f"),b(this,It,"f")))!=null;){if(s.carriage&&b(this,It,"f")==null){A(this,It,s.index,"f");continue}if(b(this,It,"f")!=null&&(s.index!==b(this,It,"f")+1||s.carriage)){n.push(Am(b(this,Ot,"f").subarray(0,b(this,It,"f")-1))),A(this,Ot,b(this,Ot,"f").subarray(b(this,It,"f")),"f"),A(this,It,null,"f");continue}let i=b(this,It,"f")!==null?s.preceding-1:s.preceding,o=Am(b(this,Ot,"f").subarray(0,i));n.push(o),A(this,Ot,b(this,Ot,"f").subarray(s.index),"f"),A(this,It,null,"f")}return n}flush(){return b(this,Ot,"f").length?this.decode(`
|
|
217
|
-
`):[]}};
|
|
218
|
-
`,"\r"]);
|
|
219
|
-
`);n.enqueue(o)}catch(s){n.error(s)}},async cancel(){await r.return?.()}})}};async function
|
|
220
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,n,s]=
|
|
216
|
+
`),r.destroy();return}if(s.pathname==="/ws/events")this.wssEvents.handleUpgrade(e,r,n,i=>{this.handleEventsWs(i,s)});else if(s.pathname.startsWith("/ws/device/")){let i=decodeURIComponent(s.pathname.slice(11));this.wssDevice.handleUpgrade(e,r,n,o=>{this.handleDeviceWs(o,i,s).catch(()=>o.close(1011,"device error"))})}else r.destroy()}),await new Promise((e,r)=>{this.server.once("error",r),this.server.listen(this.port,this.options.host??"127.0.0.1",()=>e())}),this.options.writeDaemonFile!==!1){let e=vu(Np(),".simon");await lz(e,{recursive:!0}),await pz(vu(e,"daemon.json"),JSON.stringify({httpPort:this.port,token:this.options.token,pid:process.pid,version:dx}),"utf8")}}async stop(){for(let e of this.devices.values())await e.dispose().catch(()=>{});this.devices.clear();try{let e=vu(Np(),".simon","daemon.json");JSON.parse(await dz(e,"utf8")).pid===process.pid&&await fz(e,{force:!0})}catch{}await new Promise(e=>this.server?.close(()=>e())),await this.bus.flush()}authorized(e,r){let n=this.options.token;return!n||e.headers.authorization===`Bearer ${n}`||r.searchParams.get("token")===n}async handleHttp(e,r){let n=new URL(e.url??"/","http://localhost"),s=n.pathname;if(s.startsWith("/api/"))return this.authorized(e,n)?this.handleApi(e,r,n):gr(r,401,{error:"unauthorized"});if(this.options.webDist)return lx(this.options.webDist,s,r);gr(r,404,{error:"web UI not bundled; use the /api endpoints"})}async handleApi(e,r,n){let s=n.pathname,i=e.method??"GET";if(s==="/api/health")return gr(r,200,{ok:!0,version:dx});if(s==="/api/devices"&&i==="GET"){let c=(await Do()).map(u=>{let d=this.devices.get(u.udid)?.helperPort;return d?{...u,helperPort:d}:u});return gr(r,200,c)}if(s==="/api/events"&&i==="GET"){let a=Number(n.searchParams.get("since")??0),c=n.searchParams.get("device")??void 0;return gr(r,200,this.bus.recent(a,c))}let o=s.match(/^\/api\/devices\/([^/]+)\/(\w+(?:\.\w+)?)$/);if(o){let a=decodeURIComponent(o[1]),c=o[2];if(c==="boot"&&i==="POST"){await C0(a),this.bus.emit(a,{kind:"system"},{type:"deviceBooted"});let u=await Do();return gr(r,200,u.find(l=>l.udid===a))}if(c==="action"&&i==="POST"){let u=await gz(e);if(!u?.action?.type||!u?.source?.kind)return gr(r,400,{error:"body must be {source, action}"});let d=await(await this.device(a)).execute(u.source,u.action);return gr(r,d.ok?200:422,d)}if(c==="ui"&&i==="GET"){let u=await this.device(a);return gr(r,200,await u.uiSnapshot())}if(c==="screenshot.png"&&i==="GET"){let u=n.searchParams.get("source"),l=u?JSON.parse(u):{kind:"system"},f=await(await this.device(a)).screenshotPng(l,{silent:l.kind==="system"});r.writeHead(200,{"content-type":"image/png","content-length":f.length}),r.end(f);return}}gr(r,404,{error:`no route: ${i} ${s}`})}handleEventsWs(e,r){let n=Number(r.searchParams.get("since")??0);for(let i of this.bus.recent(n))e.send(JSON.stringify({type:"event",event:i}));let s=this.bus.subscribe(i=>{e.readyState===Yn.default.OPEN&&e.send(JSON.stringify({type:"event",event:i}))});e.on("close",s)}async handleDeviceWs(e,r,n){let i={kind:"browser",sessionId:n.searchParams.get("session")??uz().slice(0,8)},o=await this.device(r),a=await o.ensureHelper(),c=new Yn.default(`ws://127.0.0.1:${a.port}/ws`);c.binaryType="nodebuffer";let u=new wu(d=>{o.invalidateSnapshot(),this.bus.emit(r,i,d)}),l=[];c.on("open",()=>{for(let d of l.splice(0))c.send(d)}),c.on("message",(d,f)=>{e.readyState===Yn.default.OPEN&&e.send(d,{binary:f})}),c.on("close",()=>e.close()),c.on("error",()=>e.close()),e.on("message",(d,f)=>{!f||d.length<1||(this.observeBrowserInput(d,r,i,u),c.readyState===Yn.default.OPEN?c.send(d):l.push(d))}),e.on("close",()=>c.close()),e.on("error",()=>c.close())}observeBrowserInput(e,r,n,s){let i=e[0],o=()=>{try{return JSON.parse(e.subarray(1).toString("utf8"))}catch{return null}};switch(i){case 3:{let a=o();a&&typeof a.x=="number"&&typeof a.y=="number"&&s.feed(a.type,a.x,a.y);break}case 4:{let a=o();a?.button&&this.bus.emit(r,n,{type:"button",button:a.button});break}case 6:{let a=o();if(a?.type==="down"&&typeof a.usage=="number"){let c=mz[a.usage];c&&this.bus.emit(r,n,{type:"key",key:c})}break}case 7:{let a=o();a?.orientation&&this.bus.emit(r,n,{type:"orientation",orientation:a.orientation});break}default:break}}};function gr(t,e,r){let n=JSON.stringify(r??null);t.writeHead(e,{"content-type":"application/json","cache-control":"no-store"}),t.end(n)}async function gz(t){let e=[];for await(let n of t)e.push(n);let r=Buffer.concat(e).toString("utf8");return r?JSON.parse(r):void 0}va();var hL=["enter","escape","backspace","tab","space","delete","arrow_up","arrow_down","arrow_left","arrow_right"],mL=["up","down","left","right"];function x$(t){return{tool:t.name,...t.input}}var v$="Refs (@eN) are only valid for the MOST RECENT tree \u2014 either the last snapshot or the CURRENT SCREEN block in the last tool result. They go stale after every action.",S$=[{name:"snapshot",description:'Read the current screen as a compact accessibility tree, one element per line: `@e12 Button "Sign In" id="sign-in" (0.38,0.71 0.23\xD70.05)` \u2014 normalized [0,1] center and size. Call this BEFORE your first interaction and whenever you have no fresh tree. Every mutating tool already returns a fresh CURRENT SCREEN tree, so do not call snapshot right after an action \u2014 that wastes a step. '+v$,input_schema:{type:"object",properties:{},additionalProperties:!1}},{name:"screenshot",description:"Take a PNG screenshot of the device. EXPENSIVE \u2014 use sparingly, only when: the tree is sparse (custom-drawn surface like a map, game or chart), you must verify something visual (image content, color, layout glitch), or an assertion needs pixels. For everything else the snapshot tree is cheaper and more precise.",input_schema:{type:"object",properties:{},additionalProperties:!1}},{name:"tap",description:"Tap (or long-press) an element by its @e ref from the latest tree. If you do not have a fresh tree, call snapshot first. "+v$+" Never invent refs and never aim at coordinates \u2014 only refs are accepted. Prefer elements that carry an id= (accessibility id); they are the most stable targets.",input_schema:{type:"object",properties:{ref:{type:"string",description:'Element ref from the latest tree, e.g. "@e12".'},longPress:{type:"boolean",description:"Long-press instead of tap (context menus, drag handles)."}},required:["ref"],additionalProperties:!1}},{name:"type_text",description:"Type text into the currently focused element. Tap a text field first to focus it. Unicode and long strings are fine (pasteboard fallback is automatic).",input_schema:{type:"object",properties:{text:{type:"string",description:"Text to type."}},required:["text"],additionalProperties:!1}},{name:"erase_text",description:"Erase characters from the focused text field (backspace presses). Focus the field first.",input_schema:{type:"object",properties:{chars:{type:"integer",description:"How many characters to erase. Defaults to clearing a sensible amount (50)."}},required:[],additionalProperties:!1}},{name:"press_key",description:"Press a hardware/keyboard key. Use enter to submit forms, escape to dismiss, tab/arrows to move focus.",input_schema:{type:"object",properties:{key:{type:"string",enum:[...hL],description:"Key to press."}},required:["key"],additionalProperties:!1}},{name:"swipe",description:"Swipe across the screen center in a direction. `up` scrolls content down (reveals content below), `down` scrolls up. Use to scroll lists or dismiss sheets; the result tree shows what became visible.",input_schema:{type:"object",properties:{direction:{type:"string",enum:[...mL],description:"Swipe direction."}},required:["direction"],additionalProperties:!1}},{name:"launch_app",description:"Launch an app by bundle id. Set relaunch=true to terminate it first for a clean foreground state. Call this at the start when the app under test is not already on screen.",input_schema:{type:"object",properties:{appId:{type:"string",description:"Bundle identifier, e.g. com.example.app."},relaunch:{type:"boolean",description:"Terminate the app first if it is running."}},required:["appId"],additionalProperties:!1}},{name:"stop_app",description:"Terminate a running app by bundle id.",input_schema:{type:"object",properties:{appId:{type:"string",description:"Bundle identifier of the app to stop."}},required:["appId"],additionalProperties:!1}},{name:"open_url",description:"Open a URL on the device \u2014 deep links (myapp://...), universal links, or web URLs. Use for navigating directly to a screen under test.",input_schema:{type:"object",properties:{url:{type:"string",description:"URL or deep link to open."}},required:["url"],additionalProperties:!1}},{name:"wait_for",description:"Poll until an element appears (or disappears with gone=true). Use this after actions that trigger loading, navigation or animation instead of taking repeated snapshots \u2014 it is one call and it settles exactly when the UI does. Match by exact visible text and/or accessibility id (id preferred).",input_schema:{type:"object",properties:{text:{type:"string",description:"Exact text/label/value to wait for."},id:{type:"string",description:"Accessibility id (React Native testID) to wait for."},gone:{type:"boolean",description:"Wait for the element to DISAPPEAR instead (spinners, dismissed sheets)."},timeoutSeconds:{type:"number",description:"Max seconds to wait. Default 10."}},required:[],additionalProperties:!1}},{name:"assert",description:`Record a verdict about something you observed. Call this for EVERY observation that matters to the goal \u2014 assertions become the compiled flow's checks. Format the assertion as "visible:<exact text>" or "notVisible:<exact text>" whenever possible: those are verified live against the device and compile to deterministic flow asserts. Free-form assertions are recorded but not device-verified. Set pass to your honest verdict; a failing assert does not end the run (use done for that).`,input_schema:{type:"object",properties:{assertion:{type:"string",description:'What is being asserted, e.g. "visible:Welcome back" or "notVisible:Error".'},pass:{type:"boolean",description:"Whether the assertion holds."},detail:{type:"string",description:"Optional context, especially for failures."}},required:["assertion","pass"],additionalProperties:!1}},{name:"checkpoint",description:'Mark a milestone in the run, e.g. "logged in" or "cart populated". Checkpoints structure the compiled flow and the evidence report. Use a short, stable, kebab-or-plain name.',input_schema:{type:"object",properties:{name:{type:"string",description:"Milestone name."}},required:["name"],additionalProperties:!1}},{name:"done",description:"End the run with the final verdict. Call exactly once, when the goal is verified (pass=true) or you have established it cannot be (pass=false). The summary should state what was verified and how \u2014 it becomes the run's record.",input_schema:{type:"object",properties:{pass:{type:"boolean",description:"Final verdict for the goal."},summary:{type:"string",description:"Concise account of what was verified or why it failed."}},required:["pass","summary"],additionalProperties:!1}}];import{randomUUID as uq}from"node:crypto";function A(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}function b(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}var Tm=function(){let{crypto:t}=globalThis;if(t?.randomUUID)return Tm=t.randomUUID.bind(t),t.randomUUID();let e=new Uint8Array(1),r=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function Lr(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}var xa=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){let 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)};var j=class extends Error{},Ge=class t extends j{constructor(e,r,n,s,i){super(`${t.makeMessage(e,r,n)}`),this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.error=r,this.type=i??null}static makeMessage(e,r,n){let s=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,r,n,s){if(!e||!s)return new _n({message:n,cause:xa(r)});let i=r,o=i?.error?.type;return e===400?new xi(e,i,n,s,o):e===401?new Si(e,i,n,s,o):e===403?new ki(e,i,n,s,o):e===404?new $i(e,i,n,s,o):e===409?new Ei(e,i,n,s,o):e===422?new Ti(e,i,n,s,o):e===429?new Pi(e,i,n,s,o):e>=500?new Oi(e,i,n,s,o):new t(e,i,n,s,o)}},et=class extends Ge{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},_n=class extends Ge{constructor({message:e,cause:r}){super(void 0,void 0,e||"Connection error.",void 0),r&&(this.cause=r)}},vi=class extends _n{constructor({message:e}={}){super({message:e??"Request timed out."})}},xi=class extends Ge{},Si=class extends Ge{},ki=class extends Ge{},$i=class extends Ge{},Ei=class extends Ge{},Ti=class extends Ge{},Pi=class extends Ge{},Oi=class extends Ge{};var yL=/^[a-z][a-z0-9+.-]*:/i,k$=t=>yL.test(t),Pm=t=>(Pm=Array.isArray,Pm(t)),Om=Pm;function $l(t){return typeof t!="object"?{}:t??{}}function Im(t){if(!t)return!0;for(let e in t)return!1;return!0}function $$(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var E$=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new j(`${t} must be an integer`);if(e<0)throw new j(`${t} must be a positive integer`);return e};var El=t=>{try{return JSON.parse(t)}catch{return}};var T$=t=>new Promise(e=>setTimeout(e,t));var bn="0.88.0";var A$=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function _L(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var bL=()=>{let t=_L();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bn,"X-Stainless-OS":O$(Deno.build.os),"X-Stainless-Arch":P$(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bn,"X-Stainless-OS":O$(globalThis.process.platform??"unknown"),"X-Stainless-Arch":P$(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=wL();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function wL(){if(typeof navigator>"u"||!navigator)return null;let t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:r}of t){let n=r.exec(navigator.userAgent);if(n){let s=n[1]||0,i=n[2]||0,o=n[3]||0;return{browser:e,version:`${s}.${i}.${o}`}}}return null}var P$=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",O$=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),I$,N$=()=>I$??(I$=bL());function R$(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Am(...t){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function Tl(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return Am({start(){},async pull(r){let{done:n,value:s}=await e.next();n?r.close():r.enqueue(s)},async cancel(){await e.return?.()}})}function Sa(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let r=await e.read();return r?.done&&e.releaseLock(),r}catch(r){throw e.releaseLock(),r}},async return(){let r=e.cancel();return e.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function z$(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}let e=t.getReader(),r=e.cancel();e.releaseLock(),await r}var M$=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function C$(t){return Object.entries(t).filter(([e,r])=>typeof r<"u").map(([e,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return`${encodeURIComponent(e)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(e)}=`;throw new j(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function q$(t){let e=0;for(let s of t)e+=s.length;let r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var j$;function ka(t){let e;return(j$??(e=new globalThis.TextEncoder,j$=e.encode.bind(e)))(t)}var L$;function Nm(t){let e;return(L$??(e=new globalThis.TextDecoder,L$=e.decode.bind(e)))(t)}var It,At,qr=class{constructor(){It.set(this,void 0),At.set(this,void 0),A(this,It,new Uint8Array,"f"),A(this,At,null,"f")}decode(e){if(e==null)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ka(e):e;A(this,It,q$([b(this,It,"f"),r]),"f");let n=[],s;for(;(s=SL(b(this,It,"f"),b(this,At,"f")))!=null;){if(s.carriage&&b(this,At,"f")==null){A(this,At,s.index,"f");continue}if(b(this,At,"f")!=null&&(s.index!==b(this,At,"f")+1||s.carriage)){n.push(Nm(b(this,It,"f").subarray(0,b(this,At,"f")-1))),A(this,It,b(this,It,"f").subarray(b(this,At,"f")),"f"),A(this,At,null,"f");continue}let i=b(this,At,"f")!==null?s.preceding-1:s.preceding,o=Nm(b(this,It,"f").subarray(0,i));n.push(o),A(this,It,b(this,It,"f").subarray(s.index),"f"),A(this,At,null,"f")}return n}flush(){return b(this,It,"f").length?this.decode(`
|
|
217
|
+
`):[]}};It=new WeakMap,At=new WeakMap;qr.NEWLINE_CHARS=new Set([`
|
|
218
|
+
`,"\r"]);qr.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function SL(t,e){for(let s=e??0;s<t.length;s++){if(t[s]===10)return{preceding:s,index:s+1,carriage:!1};if(t[s]===13)return{preceding:s,index:s+1,carriage:!0}}return null}function D$(t){for(let n=0;n<t.length-1;n++){if(t[n]===10&&t[n+1]===10||t[n]===13&&t[n+1]===13)return n+2;if(t[n]===13&&t[n+1]===10&&n+3<t.length&&t[n+2]===13&&t[n+3]===10)return n+4}return-1}var Ol={off:0,error:200,warn:300,info:400,debug:500},Rm=(t,e,r)=>{if(t){if($$(Ol,t))return t;Ye(r).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(Ol))}`)}};function $a(){}function Pl(t,e,r){return!e||Ol[t]>Ol[r]?$a:e[t].bind(e)}var kL={error:$a,warn:$a,info:$a,debug:$a},Z$=new WeakMap;function Ye(t){let e=t.logger,r=t.logLevel??"off";if(!e)return kL;let n=Z$.get(e);if(n&&n[0]===r)return n[1];let s={error:Pl("error",e,r),warn:Pl("warn",e,r),info:Pl("info",e,r),debug:Pl("debug",e,r)};return Z$.set(e,[r,s]),s}var Dr=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,r])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":r]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);var Ea,wr=class t{constructor(e,r,n){this.iterator=e,Ea.set(this,void 0),this.controller=r,A(this,Ea,n,"f")}static fromSSEResponse(e,r,n){let s=!1,i=n?Ye(n):console;async function*o(){if(s)throw new j("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let a=!1;try{for await(let c of $L(e,r)){if(c.event==="completion")try{yield JSON.parse(c.data)}catch(u){throw i.error("Could not parse message into JSON:",c.data),i.error("From chunk:",c.raw),u}if(c.event==="message_start"||c.event==="message_delta"||c.event==="message_stop"||c.event==="content_block_start"||c.event==="content_block_delta"||c.event==="content_block_stop"||c.event==="message")try{yield JSON.parse(c.data)}catch(u){throw i.error("Could not parse message into JSON:",c.data),i.error("From chunk:",c.raw),u}if(c.event!=="ping"&&c.event==="error"){let u=El(c.data)??c.data,l=u?.error?.type;throw new Ge(void 0,u,void 0,e.headers,l)}}a=!0}catch(c){if(Lr(c))return;throw c}finally{a||r.abort()}}return new t(o,r,n)}static fromReadableStream(e,r,n){let s=!1;async function*i(){let a=new qr,c=Sa(e);for await(let u of c)for(let l of a.decode(u))yield l;for(let u of a.flush())yield u}async function*o(){if(s)throw new j("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let a=!1;try{for await(let c of i())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(Lr(c))return;throw c}finally{a||r.abort()}}return new t(o,r,n)}[(Ea=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],r=[],n=this.iterator(),s=i=>({next:()=>{if(i.length===0){let o=n.next();e.push(o),r.push(o)}return i.shift()}});return[new t(()=>s(e),this.controller,b(this,Ea,"f")),new t(()=>s(r),this.controller,b(this,Ea,"f"))]}toReadableStream(){let e=this,r;return Am({async start(){r=e[Symbol.asyncIterator]()},async pull(n){try{let{value:s,done:i}=await r.next();if(i)return n.close();let o=ka(JSON.stringify(s)+`
|
|
219
|
+
`);n.enqueue(o)}catch(s){n.error(s)}},async cancel(){await r.return?.()}})}};async function*$L(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new j("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new j("Attempted to iterate over a response with no body");let r=new zm,n=new qr,s=Sa(t.body);for await(let i of EL(s))for(let o of n.decode(i)){let a=r.decode(o);a&&(yield a)}for(let i of n.flush()){let o=r.decode(i);o&&(yield o)}}async function*EL(t){let e=new Uint8Array;for await(let r of t){if(r==null)continue;let n=r instanceof ArrayBuffer?new Uint8Array(r):typeof r=="string"?ka(r):r,s=new Uint8Array(e.length+n.length);s.set(e),s.set(n,e.length),e=s;let i;for(;(i=D$(e))!==-1;)yield e.slice(0,i),e=e.slice(i)}e.length>0&&(yield e)}var zm=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let i={event:this.event,data:this.data.join(`
|
|
220
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,n,s]=TL(e,":");return s.startsWith(" ")&&(s=s.substring(1)),r==="event"?this.event=s:r==="data"&&this.data.push(s),null}};function TL(t,e){let r=t.indexOf(e);return r!==-1?[t.substring(0,r),e,t.substring(r+e.length)]:[t,"",""]}async function Il(t,e){let{response:r,requestLogID:n,retryOfRequestLogID:s,startTime:i}=e,o=await(async()=>{if(e.options.stream)return Ye(t).debug("response",r.status,r.url,r.headers,r.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(r,e.controller):wr.fromSSEResponse(r,e.controller);if(r.status===204)return null;if(e.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(r.headers.get("content-length")==="0")return;let f=await r.json();return Mm(f,r)}return await r.text()})();return Ye(t).debug(`[${n}] response parsed`,Dr({retryOfRequestLogID:s,url:r.url,status:r.status,body:o,durationMs:Date.now()-i})),o}function Mm(t,e){return!t||typeof t!="object"||Array.isArray(t)?t:Object.defineProperty(t,"_request_id",{value:e.headers.get("request-id"),enumerable:!1})}var Ta,as=class t extends Promise{constructor(e,r,n=Il){super(s=>{s(null)}),this.responsePromise=r,this.parseResponse=n,Ta.set(this,void 0),A(this,Ta,e,"f")}_thenUnwrap(e){return new t(b(this,Ta,"f"),this.responsePromise,async(r,n)=>Mm(e(await this.parseResponse(r,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:r,request_id:r.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(b(this,Ta,"f"),e))),this.parsedPromise}then(e,r){return this.parse().then(e,r)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Ta=new WeakMap;var Al,Nl=class{constructor(e,r,n,s){Al.set(this,void 0),A(this,Al,e,"f"),this.options=s,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new j("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await b(this,Al,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Al=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let r of e.getPaginatedItems())yield r}},Pa=class extends as{constructor(e,r,n){super(e,r,async(s,i)=>new n(s,i.response,await Il(s,i),i.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let r of e)yield r}},Zt=class extends Nl{constructor(e,r,n,s){super(e,r,n,s),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let r=this.first_id;return r?{...this.options,query:{...$l(this.options.query),before_id:r}}:null}let e=this.last_id;return e?{...this.options,query:{...$l(this.options.query),after_id:e}}:null}};var Le=class extends Nl{constructor(e,r,n,s){super(e,r,n,s),this.data=n.data||[],this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...$l(this.options.query),page:e}}:null}};var jm=()=>{if(typeof File>"u"){let{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function cs(t,e,r){return jm(),new File(t,e??"unknown_file",r)}function Oa(t,e){let r=typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"";return e?r.split(/[\\/]/).pop()||void 0:r}var Lm=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function";var Ii=async(t,e,r=!0)=>({...t,body:await IL(t.body,e,r)}),U$=new WeakMap;function OL(t){let e=typeof t=="function"?t:t.fetch,r=U$.get(e);if(r)return r;let n=(async()=>{try{let s="Response"in e?e.Response:(await e("data:,")).constructor,i=new FormData;return i.toString()!==await new s(i).text()}catch{return!0}})();return U$.set(e,n),n}var IL=async(t,e,r=!0)=>{if(!await OL(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let n=new FormData;return await Promise.all(Object.entries(t||{}).map(([s,i])=>Cm(n,s,i,r))),n},AL=t=>t instanceof Blob&&"name"in t;var Cm=async(t,e,r,n)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")t.append(e,String(r));else if(r instanceof Response){let s={},i=r.headers.get("Content-Type");i&&(s={type:i}),t.append(e,cs([await r.blob()],Oa(r,n),s))}else if(Lm(r))t.append(e,cs([await new Response(Tl(r)).blob()],Oa(r,n)));else if(AL(r))t.append(e,cs([r],Oa(r,n),{type:r.type}));else if(Array.isArray(r))await Promise.all(r.map(s=>Cm(t,e+"[]",s,n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([s,i])=>Cm(t,`${e}[${s}]`,i,n)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var F$=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",NL=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&F$(t),RL=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function Rl(t,e,r){if(jm(),t=await t,e||(e=Oa(t,!0)),NL(t))return t instanceof File&&e==null&&r==null?t:cs([await t.arrayBuffer()],e??t.name,{type:t.type,lastModified:t.lastModified,...r});if(RL(t)){let s=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),cs(await qm(s),e,r)}let n=await qm(t);if(!r?.type){let s=n.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof s=="string"&&(r={...r,type:s})}return cs(n,e,r)}async function qm(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(F$(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(Lm(t))for await(let r of t)e.push(...await qm(r));else{let r=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${r?`; constructor: ${r}`:""}${zL(t)}`)}return e}function zL(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(r=>`"${r}"`).join(", ")}]`}var Q=class{constructor(e){this._client=e}};var B$=Symbol.for("brand.privateNullableHeaders");function*CL(t){if(!t)return;if(B$ in t){let{values:n,nulls:s}=t;yield*n.entries();for(let i of s)yield[i,null];return}let e=!1,r;t instanceof Headers?r=t.entries():Om(t)?r=t:(e=!0,r=Object.entries(t??{}));for(let n of r){let s=n[0];if(typeof s!="string")throw new TypeError("expected header name to be a string");let i=Om(n[1])?n[1]:[n[1]],o=!1;for(let a of i)a!==void 0&&(e&&!o&&(o=!0,yield[s,null]),yield[s,a])}}var P=t=>{let e=new Headers,r=new Set;for(let n of t){let s=new Set;for(let[i,o]of CL(n)){let a=i.toLowerCase();s.has(a)||(e.delete(i),s.add(a)),o===null?(e.delete(i),r.add(a)):(e.append(i,o),r.delete(a))}}return{[B$]:!0,values:e,nulls:r}};function H$(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var V$=Object.freeze(Object.create(null)),jL=(t=H$)=>function(r,...n){if(r.length===1)return r[0];let s=!1,i=[],o=r.reduce((l,d,f)=>{/[?#]/.test(d)&&(s=!0);let p=n[f],m=(s?encodeURIComponent:t)(""+p);return f!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??V$)??V$)?.toString)&&(m=p+"",i.push({start:l.length+d.length,length:m.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),l+d+(f===n.length?"":m)},""),a=o.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(a))!==null;)i.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(i.sort((l,d)=>l.start-d.start),i.length>0){let l=0,d=i.reduce((f,p)=>{let m=" ".repeat(p.start-l),h="^".repeat(p.length);return l=p.start+p.length,f+m+h},"");throw new j(`Path parameters result in path with invalid segments:
|
|
221
221
|
${i.map(f=>f.error).join(`
|
|
222
222
|
`)}
|
|
223
223
|
${o}
|
|
224
|
-
${d}`)}return o},L=CL(V$);var Ii=class extends Q{create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/environments?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/environments/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/environments/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/environments?beta=true",je,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/environments/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/environments/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var Oa=Symbol("anthropic.sdk.stainlessHelper");function Rl(t){return typeof t=="object"&&t!==null&&Oa in t}function qm(t,e){let r=new Set;if(t)for(let n of t)Rl(n)&&r.add(n[Oa]);if(e){for(let n of e)if(Rl(n)&&r.add(n[Oa]),Array.isArray(n.content))for(let s of n.content)Rl(s)&&r.add(s[Oa])}return Array.from(r)}function zl(t,e){let r=qm(t,e);return r.length===0?{}:{"x-stainless-helper":r.join(", ")}}function H$(t){return Rl(t)?{"x-stainless-helper":t[Oa]}:{}}var Ai=class extends Q{list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/files",Dt,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/files/${e}`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},n?.headers])})}download(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/files/${e}/content`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/files/${e}`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},n?.headers])})}upload(e,r){let{betas:n,...s}=e;return this._client.post("/v1/files",Oi({body:s,...r,headers:P([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},H$(s.file),r?.headers])},this._client))}};var Ni=class extends Q{retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/models/${e}?beta=true`,{...n,headers:P([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/models?beta=true",Dt,{query:s,...r,headers:P([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}};var Ri=class extends Q{list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/agents/${e}/versions?beta=true`,je,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var cs=class extends Q{constructor(){super(...arguments),this.versions=new Ri(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/agents?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s,...i}=r??{};return this._client.get(L`/v1/agents/${e}?beta=true`,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/agents/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/agents?beta=true",je,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/agents/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};cs.Versions=Ri;var Ml={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function W$(t){return t?.output_format??t?.output_config?.format}function Dm(t,e,r){let n=W$(e);return!e||!("parse"in(n??{}))?{...t,content:t.content.map(s=>{if(s.type==="text"){let i=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(i,"parsed",{get(){return r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return s}),parsed_output:null}:Zm(t,e,r)}function Zm(t,e,r){let n=null,s=t.content.map(i=>{if(i.type==="text"){let o=UL(e,i.text);n===null&&(n=o);let a=Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),o},enumerable:!1})}return i});return{...t,content:s,parsed_output:n}}function UL(t,e){let r=W$(t);if(r?.type!=="json_schema")return null;try{return"parse"in r?r.parse(e):JSON.parse(e)}catch(n){throw new j(`Failed to parse structured output: ${n}`)}}var FL=t=>{let e=0,r=[];for(;e<t.length;){let n=t[e];if(n==="\\"){e++;continue}if(n==="{"){r.push({type:"brace",value:"{"}),e++;continue}if(n==="}"){r.push({type:"brace",value:"}"}),e++;continue}if(n==="["){r.push({type:"paren",value:"["}),e++;continue}if(n==="]"){r.push({type:"paren",value:"]"}),e++;continue}if(n===":"){r.push({type:"separator",value:":"}),e++;continue}if(n===","){r.push({type:"delimiter",value:","}),e++;continue}if(n==='"'){let a="",c=!1;for(n=t[++e];n!=='"';){if(e===t.length){c=!0;break}if(n==="\\"){if(e++,e===t.length){c=!0;break}a+=n+t[e],n=t[++e]}else a+=n,n=t[++e]}n=t[++e],c||r.push({type:"string",value:a});continue}if(n&&/\s/.test(n)){e++;continue}let i=/[0-9]/;if(n&&i.test(n)||n==="-"||n==="."){let a="";for(n==="-"&&(a+=n,n=t[++e]);n&&i.test(n)||n===".";)a+=n,n=t[++e];r.push({type:"number",value:a});continue}let o=/[a-z]/i;if(n&&o.test(n)){let a="";for(;n&&o.test(n)&&e!==t.length;)a+=n,n=t[++e];if(a=="true"||a=="false"||a==="null")r.push({type:"name",value:a});else{e++;continue}continue}e++}return r},zi=t=>{if(t.length===0)return t;let e=t[t.length-1];switch(e.type){case"separator":return t=t.slice(0,t.length-1),zi(t);break;case"number":let r=e.value[e.value.length-1];if(r==="."||r==="-")return t=t.slice(0,t.length-1),zi(t);case"string":let n=t[t.length-2];if(n?.type==="delimiter")return t=t.slice(0,t.length-1),zi(t);if(n?.type==="brace"&&n.value==="{")return t=t.slice(0,t.length-1),zi(t);break;case"delimiter":return t=t.slice(0,t.length-1),zi(t);break}return t},BL=t=>{let e=[];return t.map(r=>{r.type==="brace"&&(r.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),r.type==="paren"&&(r.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(r=>{r==="}"?t.push({type:"brace",value:"}"}):r==="]"&&t.push({type:"paren",value:"]"})}),t},VL=t=>{let e="";return t.map(r=>{switch(r.type){case"string":e+='"'+r.value+'"';break;default:e+=r.value;break}}),e},Cl=t=>JSON.parse(VL(BL(zi(FL(t)))));var Zt,bn,Mi,Ia,jl,Aa,Na,Ll,Ra,Dr,za,ql,Dl,us,Zl,Ul,Ma,Um,K$,Fl,Fm,Bm,Vm,J$,G$="__json_buf";function Y$(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}var Bl=class t{constructor(e,r){Zt.add(this),this.messages=[],this.receivedMessages=[],bn.set(this,void 0),Mi.set(this,null),this.controller=new AbortController,Ia.set(this,void 0),jl.set(this,()=>{}),Aa.set(this,()=>{}),Na.set(this,void 0),Ll.set(this,()=>{}),Ra.set(this,()=>{}),Dr.set(this,{}),za.set(this,!1),ql.set(this,!1),Dl.set(this,!1),us.set(this,!1),Zl.set(this,void 0),Ul.set(this,void 0),Ma.set(this,void 0),Fl.set(this,n=>{if(A(this,ql,!0,"f"),jr(n)&&(n=new Qe),n instanceof Qe)return A(this,Dl,!0,"f"),this._emit("abort",n);if(n instanceof j)return this._emit("error",n);if(n instanceof Error){let s=new j(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new j(String(n)))}),A(this,Ia,new Promise((n,s)=>{A(this,jl,n,"f"),A(this,Aa,s,"f")}),"f"),A(this,Na,new Promise((n,s)=>{A(this,Ll,n,"f"),A(this,Ra,s,"f")}),"f"),b(this,Ia,"f").catch(()=>{}),b(this,Na,"f").catch(()=>{}),A(this,Mi,e,"f"),A(this,Ma,r?.logger??console,"f")}get response(){return b(this,Zl,"f")}get request_id(){return b(this,Ul,"f")}async withResponse(){A(this,us,!0,"f");let e=await b(this,Ia,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,n,{logger:s}={}){let i=new t(r,{logger:s});for(let o of r.messages)i._addMessageParam(o);return A(i,Mi,{...r,stream:!0},"f"),i._run(()=>i._createMessage(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},b(this,Fl,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,n){let s=n?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{b(this,Zt,"m",Fm).call(this);let{response:o,data:a}=await e.create({...r,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(let c of a)b(this,Zt,"m",Bm).call(this,c);if(a.controller.signal?.aborted)throw new Qe;b(this,Zt,"m",Vm).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}_connected(e){this.ended||(A(this,Zl,e,"f"),A(this,Ul,e?.headers.get("request-id"),"f"),b(this,jl,"f").call(this,e),this._emit("connect"))}get ended(){return b(this,za,"f")}get errored(){return b(this,ql,"f")}get aborted(){return b(this,Dl,"f")}abort(){this.controller.abort()}on(e,r){return(b(this,Dr,"f")[e]||(b(this,Dr,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=b(this,Dr,"f")[e];if(!n)return this;let s=n.findIndex(i=>i.listener===r);return s>=0&&n.splice(s,1),this}once(e,r){return(b(this,Dr,"f")[e]||(b(this,Dr,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{A(this,us,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){A(this,us,!0,"f"),await b(this,Na,"f")}get currentMessage(){return b(this,bn,"f")}async finalMessage(){return await this.done(),b(this,Zt,"m",Um).call(this)}async finalText(){return await this.done(),b(this,Zt,"m",K$).call(this)}_emit(e,...r){if(b(this,za,"f"))return;e==="end"&&(A(this,za,!0,"f"),b(this,Ll,"f").call(this));let n=b(this,Dr,"f")[e];if(n&&(b(this,Dr,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...r))),e==="abort"){let s=r[0];!b(this,us,"f")&&!n?.length&&Promise.reject(s),b(this,Aa,"f").call(this,s),b(this,Ra,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=r[0];!b(this,us,"f")&&!n?.length&&Promise.reject(s),b(this,Aa,"f").call(this,s),b(this,Ra,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",b(this,Zt,"m",Um).call(this))}async _fromReadableStream(e,r){let n=r?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{b(this,Zt,"m",Fm).call(this),this._connected(null);let i=br.fromReadableStream(e,this.controller);for await(let o of i)b(this,Zt,"m",Bm).call(this,o);if(i.controller.signal?.aborted)throw new Qe;b(this,Zt,"m",Vm).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(bn=new WeakMap,Mi=new WeakMap,Ia=new WeakMap,jl=new WeakMap,Aa=new WeakMap,Na=new WeakMap,Ll=new WeakMap,Ra=new WeakMap,Dr=new WeakMap,za=new WeakMap,ql=new WeakMap,Dl=new WeakMap,us=new WeakMap,Zl=new WeakMap,Ul=new WeakMap,Ma=new WeakMap,Fl=new WeakMap,Zt=new WeakSet,Um=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},K$=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let r=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(r.length===0)throw new j("stream ended without producing a content block with type=text");return r.join(" ")},Fm=function(){this.ended||A(this,bn,void 0,"f")},Bm=function(r){if(this.ended)return;let n=b(this,Zt,"m",J$).call(this,r);switch(this._emit("streamEvent",r,n),r.type){case"content_block_delta":{let s=n.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{Y$(s)&&s.input&&this._emit("inputJson",r.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}case"compaction_delta":{s.type==="compaction"&&s.content&&this._emit("compaction",s.content);break}default:r.delta}break}case"message_stop":{this._addMessageParam(n),this._addMessage(Dm(n,b(this,Mi,"f"),{logger:b(this,Ma,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{A(this,bn,n,"f");break}case"content_block_start":case"message_delta":break}},Vm=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let r=b(this,bn,"f");if(!r)throw new j("request ended without sending any chunks");return A(this,bn,void 0,"f"),Dm(r,b(this,Mi,"f"),{logger:b(this,Ma,"f")})},J$=function(r){let n=b(this,bn,"f");if(r.type==="message_start"){if(n)throw new j(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(!n)throw new j(`Unexpected event order, got ${r.type} before "message_start"`);switch(r.type){case"message_stop":return n;case"message_delta":return n.container=r.delta.container,n.stop_reason=r.delta.stop_reason,n.stop_sequence=r.delta.stop_sequence,n.usage.output_tokens=r.usage.output_tokens,n.context_management=r.context_management,r.usage.input_tokens!=null&&(n.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(n.usage.server_tool_use=r.usage.server_tool_use),r.usage.iterations!=null&&(n.usage.iterations=r.usage.iterations),n;case"content_block_start":return n.content.push(r.content_block),n;case"content_block_delta":{let s=n.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(n.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&Y$(s)){let i=s[G$]||"";i+=r.delta.partial_json;let o={...s};if(Object.defineProperty(o,G$,{value:i,enumerable:!1,writable:!0}),i)try{o.input=Cl(i)}catch(a){let c=new j(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${a}. JSON: ${i}`);b(this,Fl,"f").call(this,c)}n.content[r.index]=o}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,signature:r.delta.signature});break}case"compaction_delta":{s?.type==="compaction"&&(n.content[r.index]={...s,content:(s.content||"")+r.delta.content});break}default:r.delta}return n}case"content_block_stop":return n}},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("streamEvent",s=>{let i=r.shift();i?i.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),this.on("error",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,o)=>r.push({resolve:i,reject:o})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new br(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var ls=class extends Error{constructor(e){let r=typeof e=="string"?e:e.map(n=>n.type==="text"?n.text:`[${n.type}]`).join(" ");super(r),this.name="ToolError",this.content=e}};var X$=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
224
|
+
${d}`)}return o},L=jL(H$);var Ai=class extends Q{create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/environments?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/environments/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/environments/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/environments?beta=true",Le,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/environments/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/environments/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var Ia=Symbol("anthropic.sdk.stainlessHelper");function zl(t){return typeof t=="object"&&t!==null&&Ia in t}function Dm(t,e){let r=new Set;if(t)for(let n of t)zl(n)&&r.add(n[Ia]);if(e){for(let n of e)if(zl(n)&&r.add(n[Ia]),Array.isArray(n.content))for(let s of n.content)zl(s)&&r.add(s[Ia])}return Array.from(r)}function Ml(t,e){let r=Dm(t,e);return r.length===0?{}:{"x-stainless-helper":r.join(", ")}}function W$(t){return zl(t)?{"x-stainless-helper":t[Ia]}:{}}var Ni=class extends Q{list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/files",Zt,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/files/${e}`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},n?.headers])})}download(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/files/${e}/content`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/files/${e}`,{...n,headers:P([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},n?.headers])})}upload(e,r){let{betas:n,...s}=e;return this._client.post("/v1/files",Ii({body:s,...r,headers:P([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},W$(s.file),r?.headers])},this._client))}};var Ri=class extends Q{retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/models/${e}?beta=true`,{...n,headers:P([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/models?beta=true",Zt,{query:s,...r,headers:P([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}};var zi=class extends Q{list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/agents/${e}/versions?beta=true`,Le,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var us=class extends Q{constructor(){super(...arguments),this.versions=new zi(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/agents?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s,...i}=r??{};return this._client.get(L`/v1/agents/${e}?beta=true`,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/agents/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/agents?beta=true",Le,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/agents/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};us.Versions=zi;var Cl={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function K$(t){return t?.output_format??t?.output_config?.format}function Zm(t,e,r){let n=K$(e);return!e||!("parse"in(n??{}))?{...t,content:t.content.map(s=>{if(s.type==="text"){let i=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(i,"parsed",{get(){return r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return s}),parsed_output:null}:Um(t,e,r)}function Um(t,e,r){let n=null,s=t.content.map(i=>{if(i.type==="text"){let o=FL(e,i.text);n===null&&(n=o);let a=Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),o},enumerable:!1})}return i});return{...t,content:s,parsed_output:n}}function FL(t,e){let r=K$(t);if(r?.type!=="json_schema")return null;try{return"parse"in r?r.parse(e):JSON.parse(e)}catch(n){throw new j(`Failed to parse structured output: ${n}`)}}var BL=t=>{let e=0,r=[];for(;e<t.length;){let n=t[e];if(n==="\\"){e++;continue}if(n==="{"){r.push({type:"brace",value:"{"}),e++;continue}if(n==="}"){r.push({type:"brace",value:"}"}),e++;continue}if(n==="["){r.push({type:"paren",value:"["}),e++;continue}if(n==="]"){r.push({type:"paren",value:"]"}),e++;continue}if(n===":"){r.push({type:"separator",value:":"}),e++;continue}if(n===","){r.push({type:"delimiter",value:","}),e++;continue}if(n==='"'){let a="",c=!1;for(n=t[++e];n!=='"';){if(e===t.length){c=!0;break}if(n==="\\"){if(e++,e===t.length){c=!0;break}a+=n+t[e],n=t[++e]}else a+=n,n=t[++e]}n=t[++e],c||r.push({type:"string",value:a});continue}if(n&&/\s/.test(n)){e++;continue}let i=/[0-9]/;if(n&&i.test(n)||n==="-"||n==="."){let a="";for(n==="-"&&(a+=n,n=t[++e]);n&&i.test(n)||n===".";)a+=n,n=t[++e];r.push({type:"number",value:a});continue}let o=/[a-z]/i;if(n&&o.test(n)){let a="";for(;n&&o.test(n)&&e!==t.length;)a+=n,n=t[++e];if(a=="true"||a=="false"||a==="null")r.push({type:"name",value:a});else{e++;continue}continue}e++}return r},Mi=t=>{if(t.length===0)return t;let e=t[t.length-1];switch(e.type){case"separator":return t=t.slice(0,t.length-1),Mi(t);break;case"number":let r=e.value[e.value.length-1];if(r==="."||r==="-")return t=t.slice(0,t.length-1),Mi(t);case"string":let n=t[t.length-2];if(n?.type==="delimiter")return t=t.slice(0,t.length-1),Mi(t);if(n?.type==="brace"&&n.value==="{")return t=t.slice(0,t.length-1),Mi(t);break;case"delimiter":return t=t.slice(0,t.length-1),Mi(t);break}return t},VL=t=>{let e=[];return t.map(r=>{r.type==="brace"&&(r.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),r.type==="paren"&&(r.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(r=>{r==="}"?t.push({type:"brace",value:"}"}):r==="]"&&t.push({type:"paren",value:"]"})}),t},HL=t=>{let e="";return t.map(r=>{switch(r.type){case"string":e+='"'+r.value+'"';break;default:e+=r.value;break}}),e},jl=t=>JSON.parse(HL(VL(Mi(BL(t)))));var Ut,wn,Ci,Aa,Ll,Na,Ra,ql,za,Zr,Ma,Dl,Zl,ls,Ul,Fl,Ca,Fm,J$,Bl,Bm,Vm,Hm,G$,Y$="__json_buf";function X$(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}var Vl=class t{constructor(e,r){Ut.add(this),this.messages=[],this.receivedMessages=[],wn.set(this,void 0),Ci.set(this,null),this.controller=new AbortController,Aa.set(this,void 0),Ll.set(this,()=>{}),Na.set(this,()=>{}),Ra.set(this,void 0),ql.set(this,()=>{}),za.set(this,()=>{}),Zr.set(this,{}),Ma.set(this,!1),Dl.set(this,!1),Zl.set(this,!1),ls.set(this,!1),Ul.set(this,void 0),Fl.set(this,void 0),Ca.set(this,void 0),Bl.set(this,n=>{if(A(this,Dl,!0,"f"),Lr(n)&&(n=new et),n instanceof et)return A(this,Zl,!0,"f"),this._emit("abort",n);if(n instanceof j)return this._emit("error",n);if(n instanceof Error){let s=new j(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new j(String(n)))}),A(this,Aa,new Promise((n,s)=>{A(this,Ll,n,"f"),A(this,Na,s,"f")}),"f"),A(this,Ra,new Promise((n,s)=>{A(this,ql,n,"f"),A(this,za,s,"f")}),"f"),b(this,Aa,"f").catch(()=>{}),b(this,Ra,"f").catch(()=>{}),A(this,Ci,e,"f"),A(this,Ca,r?.logger??console,"f")}get response(){return b(this,Ul,"f")}get request_id(){return b(this,Fl,"f")}async withResponse(){A(this,ls,!0,"f");let e=await b(this,Aa,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,n,{logger:s}={}){let i=new t(r,{logger:s});for(let o of r.messages)i._addMessageParam(o);return A(i,Ci,{...r,stream:!0},"f"),i._run(()=>i._createMessage(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},b(this,Bl,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,n){let s=n?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{b(this,Ut,"m",Bm).call(this);let{response:o,data:a}=await e.create({...r,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(let c of a)b(this,Ut,"m",Vm).call(this,c);if(a.controller.signal?.aborted)throw new et;b(this,Ut,"m",Hm).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}_connected(e){this.ended||(A(this,Ul,e,"f"),A(this,Fl,e?.headers.get("request-id"),"f"),b(this,Ll,"f").call(this,e),this._emit("connect"))}get ended(){return b(this,Ma,"f")}get errored(){return b(this,Dl,"f")}get aborted(){return b(this,Zl,"f")}abort(){this.controller.abort()}on(e,r){return(b(this,Zr,"f")[e]||(b(this,Zr,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=b(this,Zr,"f")[e];if(!n)return this;let s=n.findIndex(i=>i.listener===r);return s>=0&&n.splice(s,1),this}once(e,r){return(b(this,Zr,"f")[e]||(b(this,Zr,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{A(this,ls,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){A(this,ls,!0,"f"),await b(this,Ra,"f")}get currentMessage(){return b(this,wn,"f")}async finalMessage(){return await this.done(),b(this,Ut,"m",Fm).call(this)}async finalText(){return await this.done(),b(this,Ut,"m",J$).call(this)}_emit(e,...r){if(b(this,Ma,"f"))return;e==="end"&&(A(this,Ma,!0,"f"),b(this,ql,"f").call(this));let n=b(this,Zr,"f")[e];if(n&&(b(this,Zr,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...r))),e==="abort"){let s=r[0];!b(this,ls,"f")&&!n?.length&&Promise.reject(s),b(this,Na,"f").call(this,s),b(this,za,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=r[0];!b(this,ls,"f")&&!n?.length&&Promise.reject(s),b(this,Na,"f").call(this,s),b(this,za,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",b(this,Ut,"m",Fm).call(this))}async _fromReadableStream(e,r){let n=r?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{b(this,Ut,"m",Bm).call(this),this._connected(null);let i=wr.fromReadableStream(e,this.controller);for await(let o of i)b(this,Ut,"m",Vm).call(this,o);if(i.controller.signal?.aborted)throw new et;b(this,Ut,"m",Hm).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(wn=new WeakMap,Ci=new WeakMap,Aa=new WeakMap,Ll=new WeakMap,Na=new WeakMap,Ra=new WeakMap,ql=new WeakMap,za=new WeakMap,Zr=new WeakMap,Ma=new WeakMap,Dl=new WeakMap,Zl=new WeakMap,ls=new WeakMap,Ul=new WeakMap,Fl=new WeakMap,Ca=new WeakMap,Bl=new WeakMap,Ut=new WeakSet,Fm=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},J$=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let r=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(r.length===0)throw new j("stream ended without producing a content block with type=text");return r.join(" ")},Bm=function(){this.ended||A(this,wn,void 0,"f")},Vm=function(r){if(this.ended)return;let n=b(this,Ut,"m",G$).call(this,r);switch(this._emit("streamEvent",r,n),r.type){case"content_block_delta":{let s=n.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{X$(s)&&s.input&&this._emit("inputJson",r.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}case"compaction_delta":{s.type==="compaction"&&s.content&&this._emit("compaction",s.content);break}default:r.delta}break}case"message_stop":{this._addMessageParam(n),this._addMessage(Zm(n,b(this,Ci,"f"),{logger:b(this,Ca,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{A(this,wn,n,"f");break}case"content_block_start":case"message_delta":break}},Hm=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let r=b(this,wn,"f");if(!r)throw new j("request ended without sending any chunks");return A(this,wn,void 0,"f"),Zm(r,b(this,Ci,"f"),{logger:b(this,Ca,"f")})},G$=function(r){let n=b(this,wn,"f");if(r.type==="message_start"){if(n)throw new j(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(!n)throw new j(`Unexpected event order, got ${r.type} before "message_start"`);switch(r.type){case"message_stop":return n;case"message_delta":return n.container=r.delta.container,n.stop_reason=r.delta.stop_reason,n.stop_sequence=r.delta.stop_sequence,n.usage.output_tokens=r.usage.output_tokens,n.context_management=r.context_management,r.usage.input_tokens!=null&&(n.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(n.usage.server_tool_use=r.usage.server_tool_use),r.usage.iterations!=null&&(n.usage.iterations=r.usage.iterations),n;case"content_block_start":return n.content.push(r.content_block),n;case"content_block_delta":{let s=n.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(n.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&X$(s)){let i=s[Y$]||"";i+=r.delta.partial_json;let o={...s};if(Object.defineProperty(o,Y$,{value:i,enumerable:!1,writable:!0}),i)try{o.input=jl(i)}catch(a){let c=new j(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${a}. JSON: ${i}`);b(this,Bl,"f").call(this,c)}n.content[r.index]=o}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,signature:r.delta.signature});break}case"compaction_delta":{s?.type==="compaction"&&(n.content[r.index]={...s,content:(s.content||"")+r.delta.content});break}default:r.delta}return n}case"content_block_stop":return n}},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("streamEvent",s=>{let i=r.shift();i?i.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),this.on("error",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,o)=>r.push({resolve:i,reject:o})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new wr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var ds=class extends Error{constructor(e){let r=typeof e=="string"?e:e.map(n=>n.type==="text"?n.text:`[${n.type}]`).join(" ");super(r),this.name="ToolError",this.content=e}};var Q$=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
225
225
|
1. Task Overview
|
|
226
226
|
The user's core request and success criteria
|
|
227
227
|
Any clarifications or constraints they specified
|
|
@@ -243,16 +243,16 @@ User preferences or style requirements
|
|
|
243
243
|
Domain-specific details that aren't obvious
|
|
244
244
|
Any promises made to the user
|
|
245
245
|
Be concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
246
|
-
Wrap your summary in <summary></summary> tags.`;var
|
|
247
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),i.model in JL&&i.thinking&&i.thinking.type==="enabled"&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let o=this._client._options.timeout;if(!i.stream&&o==null){let c=Ml[i.model]??void 0;o=this._client.calculateNonstreamingTimeout(i.max_tokens,c)}let a=zl(i.tools,i.messages);return this._client.post("/v1/messages?beta=true",{body:i,timeout:o??6e5,...r,headers:P([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},a,r?.headers]),stream:n.stream??!1})}parse(e,r){return r={...r,headers:P([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},r?.headers])},this.create(e,r).then(n=>Zm(n,e,{logger:this._client.logger??console}))}stream(e,r){return Bl.createMessage(this,e,r)}countTokens(e,r){let n=rE(e),{betas:s,...i}=n;return this._client.post("/v1/messages/count_tokens?beta=true",{body:i,...r,headers:P([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString()},r?.headers])})}toolRunner(e,r){return new ji(this._client,e,r)}};function rE(t){if(!t.output_format)return t;if(t.output_config?.format)throw new j("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:e,...r}=t;return{...r,output_config:{...t.output_config,format:e}}}Ur.Batches=qi;Ur.BetaToolRunner=ji;Ur.ToolError=ls;var Di=class extends Q{list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/sessions/${e}/events?beta=true`,je,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}send(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}/events?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}stream(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/sessions/${e}/events/stream?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers]),stream:!0})}};var Zi=class extends Q{retrieve(e,r,n){let{session_id:s,betas:i}=r;return this._client.get(L`/v1/sessions/${s}/resources/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{session_id:s,betas:i,...o}=r;return this._client.post(L`/v1/sessions/${s}/resources/${e}?beta=true`,{body:o,...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/sessions/${e}/resources?beta=true`,je,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}delete(e,r,n){let{session_id:s,betas:i}=r;return this._client.delete(L`/v1/sessions/${s}/resources/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}add(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}/resources?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var vn=class extends Q{constructor(){super(...arguments),this.events=new Di(this._client),this.resources=new Zi(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/sessions?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/sessions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/sessions?beta=true",je,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/sessions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/sessions/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};vn.Events=Di;vn.Resources=Zi;var Ui=class extends Q{create(e,r={},n){let{betas:s,...i}=r??{};return this._client.post(L`/v1/skills/${e}/versions?beta=true`,Oi({body:i,...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])},this._client))}retrieve(e,r,n){let{skill_id:s,betas:i}=r;return this._client.get(L`/v1/skills/${s}/versions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/skills/${e}/versions?beta=true`,je,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}delete(e,r,n){let{skill_id:s,betas:i}=r;return this._client.delete(L`/v1/skills/${s}/versions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"skills-2025-10-02"].toString()},n?.headers])})}};var fs=class extends Q{constructor(){super(...arguments),this.versions=new Ui(this._client)}create(e={},r){let{betas:n,...s}=e??{};return this._client.post("/v1/skills?beta=true",Oi({body:s,...r,headers:P([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])},this._client,!1))}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/skills/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/skills?beta=true",je,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/skills/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}};fs.Versions=Ui;var Fi=class extends Q{create(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/vaults/${e}/credentials?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}retrieve(e,r,n){let{vault_id:s,betas:i}=r;return this._client.get(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{vault_id:s,betas:i,...o}=r;return this._client.post(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{body:o,...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/vaults/${e}/credentials?beta=true`,je,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}delete(e,r,n){let{vault_id:s,betas:i}=r;return this._client.delete(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r,n){let{vault_id:s,betas:i}=r;return this._client.post(L`/v1/vaults/${s}/credentials/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var ps=class extends Q{constructor(){super(...arguments),this.credentials=new Fi(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/vaults?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/vaults/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/vaults/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/vaults?beta=true",je,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/vaults/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/vaults/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};ps.Credentials=Fi;var lt=class extends Q{constructor(){super(...arguments),this.models=new Ni(this._client),this.messages=new Ur(this._client),this.agents=new cs(this._client),this.environments=new Ii(this._client),this.sessions=new vn(this._client),this.vaults=new ps(this._client),this.files=new Ai(this._client),this.skills=new fs(this._client)}};lt.Models=Ni;lt.Messages=Ur;lt.Agents=cs;lt.Environments=Ii;lt.Sessions=vn;lt.Vaults=ps;lt.Files=Ai;lt.Skills=fs;var hs=class extends Q{create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/complete",{body:s,timeout:this._client._options.timeout??6e5,...r,headers:P([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers]),stream:e.stream??!1})}};function nE(t){return t?.output_config?.format}function Wm(t,e,r){let n=nE(e);return!e||!("parse"in(n??{}))?{...t,content:t.content.map(s=>s.type==="text"?Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1}):s),parsed_output:null}:Km(t,e,r)}function Km(t,e,r){let n=null,s=t.content.map(i=>{if(i.type==="text"){let o=sq(e,i.text);return n===null&&(n=o),Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1})}return i});return{...t,content:s,parsed_output:n}}function sq(t,e){let r=nE(t);if(r?.type!=="json_schema")return null;try{return"parse"in r?r.parse(e):JSON.parse(e)}catch(n){throw new j(`Failed to parse structured output: ${n}`)}}var Ut,xn,Bi,La,Vl,qa,Da,Hl,Za,Fr,Ua,Wl,Kl,ms,Jl,Gl,Fa,Jm,sE,Gm,Ym,Xm,Qm,iE,oE="__json_buf";function aE(t){return t.type==="tool_use"||t.type==="server_tool_use"}var Yl=class t{constructor(e,r){Ut.add(this),this.messages=[],this.receivedMessages=[],xn.set(this,void 0),Bi.set(this,null),this.controller=new AbortController,La.set(this,void 0),Vl.set(this,()=>{}),qa.set(this,()=>{}),Da.set(this,void 0),Hl.set(this,()=>{}),Za.set(this,()=>{}),Fr.set(this,{}),Ua.set(this,!1),Wl.set(this,!1),Kl.set(this,!1),ms.set(this,!1),Jl.set(this,void 0),Gl.set(this,void 0),Fa.set(this,void 0),Gm.set(this,n=>{if(A(this,Wl,!0,"f"),jr(n)&&(n=new Qe),n instanceof Qe)return A(this,Kl,!0,"f"),this._emit("abort",n);if(n instanceof j)return this._emit("error",n);if(n instanceof Error){let s=new j(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new j(String(n)))}),A(this,La,new Promise((n,s)=>{A(this,Vl,n,"f"),A(this,qa,s,"f")}),"f"),A(this,Da,new Promise((n,s)=>{A(this,Hl,n,"f"),A(this,Za,s,"f")}),"f"),b(this,La,"f").catch(()=>{}),b(this,Da,"f").catch(()=>{}),A(this,Bi,e,"f"),A(this,Fa,r?.logger??console,"f")}get response(){return b(this,Jl,"f")}get request_id(){return b(this,Gl,"f")}async withResponse(){A(this,ms,!0,"f");let e=await b(this,La,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,n,{logger:s}={}){let i=new t(r,{logger:s});for(let o of r.messages)i._addMessageParam(o);return A(i,Bi,{...r,stream:!0},"f"),i._run(()=>i._createMessage(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},b(this,Gm,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,n){let s=n?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{b(this,Ut,"m",Ym).call(this);let{response:o,data:a}=await e.create({...r,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(let c of a)b(this,Ut,"m",Xm).call(this,c);if(a.controller.signal?.aborted)throw new Qe;b(this,Ut,"m",Qm).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}_connected(e){this.ended||(A(this,Jl,e,"f"),A(this,Gl,e?.headers.get("request-id"),"f"),b(this,Vl,"f").call(this,e),this._emit("connect"))}get ended(){return b(this,Ua,"f")}get errored(){return b(this,Wl,"f")}get aborted(){return b(this,Kl,"f")}abort(){this.controller.abort()}on(e,r){return(b(this,Fr,"f")[e]||(b(this,Fr,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=b(this,Fr,"f")[e];if(!n)return this;let s=n.findIndex(i=>i.listener===r);return s>=0&&n.splice(s,1),this}once(e,r){return(b(this,Fr,"f")[e]||(b(this,Fr,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{A(this,ms,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){A(this,ms,!0,"f"),await b(this,Da,"f")}get currentMessage(){return b(this,xn,"f")}async finalMessage(){return await this.done(),b(this,Ut,"m",Jm).call(this)}async finalText(){return await this.done(),b(this,Ut,"m",sE).call(this)}_emit(e,...r){if(b(this,Ua,"f"))return;e==="end"&&(A(this,Ua,!0,"f"),b(this,Hl,"f").call(this));let n=b(this,Fr,"f")[e];if(n&&(b(this,Fr,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...r))),e==="abort"){let s=r[0];!b(this,ms,"f")&&!n?.length&&Promise.reject(s),b(this,qa,"f").call(this,s),b(this,Za,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=r[0];!b(this,ms,"f")&&!n?.length&&Promise.reject(s),b(this,qa,"f").call(this,s),b(this,Za,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",b(this,Ut,"m",Jm).call(this))}async _fromReadableStream(e,r){let n=r?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{b(this,Ut,"m",Ym).call(this),this._connected(null);let i=br.fromReadableStream(e,this.controller);for await(let o of i)b(this,Ut,"m",Xm).call(this,o);if(i.controller.signal?.aborted)throw new Qe;b(this,Ut,"m",Qm).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(xn=new WeakMap,Bi=new WeakMap,La=new WeakMap,Vl=new WeakMap,qa=new WeakMap,Da=new WeakMap,Hl=new WeakMap,Za=new WeakMap,Fr=new WeakMap,Ua=new WeakMap,Wl=new WeakMap,Kl=new WeakMap,ms=new WeakMap,Jl=new WeakMap,Gl=new WeakMap,Fa=new WeakMap,Gm=new WeakMap,Ut=new WeakSet,Jm=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},sE=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let r=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(r.length===0)throw new j("stream ended without producing a content block with type=text");return r.join(" ")},Ym=function(){this.ended||A(this,xn,void 0,"f")},Xm=function(r){if(this.ended)return;let n=b(this,Ut,"m",iE).call(this,r);switch(this._emit("streamEvent",r,n),r.type){case"content_block_delta":{let s=n.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{aE(s)&&s.input&&this._emit("inputJson",r.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}default:r.delta}break}case"message_stop":{this._addMessageParam(n),this._addMessage(Wm(n,b(this,Bi,"f"),{logger:b(this,Fa,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{A(this,xn,n,"f");break}case"content_block_start":case"message_delta":break}},Qm=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let r=b(this,xn,"f");if(!r)throw new j("request ended without sending any chunks");return A(this,xn,void 0,"f"),Wm(r,b(this,Bi,"f"),{logger:b(this,Fa,"f")})},iE=function(r){let n=b(this,xn,"f");if(r.type==="message_start"){if(n)throw new j(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(!n)throw new j(`Unexpected event order, got ${r.type} before "message_start"`);switch(r.type){case"message_stop":return n;case"message_delta":return n.stop_reason=r.delta.stop_reason,n.stop_sequence=r.delta.stop_sequence,n.usage.output_tokens=r.usage.output_tokens,r.usage.input_tokens!=null&&(n.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(n.usage.server_tool_use=r.usage.server_tool_use),n;case"content_block_start":return n.content.push({...r.content_block}),n;case"content_block_delta":{let s=n.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(n.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&aE(s)){let i=s[oE]||"";i+=r.delta.partial_json;let o={...s};Object.defineProperty(o,oE,{value:i,enumerable:!1,writable:!0}),i&&(o.input=Cl(i)),n.content[r.index]=o}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,signature:r.delta.signature});break}default:r.delta}return n}case"content_block_stop":return n}},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("streamEvent",s=>{let i=r.shift();i?i.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),this.on("error",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,o)=>r.push({resolve:i,reject:o})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new br(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var Vi=class extends Q{create(e,r){return this._client.post("/v1/messages/batches",{body:e,...r})}retrieve(e,r){return this._client.get(L`/v1/messages/batches/${e}`,r)}list(e={},r){return this._client.getAPIList("/v1/messages/batches",Dt,{query:e,...r})}delete(e,r){return this._client.delete(L`/v1/messages/batches/${e}`,r)}cancel(e,r){return this._client.post(L`/v1/messages/batches/${e}/cancel`,r)}async results(e,r){let n=await this.retrieve(e);if(!n.results_url)throw new j(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...r,headers:P([{Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((s,i)=>Li.fromResponse(i.response,i.controller))}};var Sn=class extends Q{constructor(){super(...arguments),this.batches=new Vi(this._client)}create(e,r){e.model in cE&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${cE[e.model]}
|
|
248
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in
|
|
246
|
+
Wrap your summary in <summary></summary> tags.`;var ja,ji,fs,Be,bt,Nt,Ur,vn,La,eE,Wm;function tE(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}var Li=class{constructor(e,r,n){ja.add(this),this.client=e,ji.set(this,!1),fs.set(this,!1),Be.set(this,void 0),bt.set(this,void 0),Nt.set(this,void 0),Ur.set(this,void 0),vn.set(this,void 0),La.set(this,0),A(this,Be,{params:{...r,messages:structuredClone(r.messages)}},"f");let i=["BetaToolRunner",...Dm(r.tools,r.messages)].join(", ");A(this,bt,{...n,headers:P([{"x-stainless-helper":i},n?.headers])},"f"),A(this,vn,tE(),"f"),r.compactionControl?.enabled&&console.warn('Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction')}async*[(ji=new WeakMap,fs=new WeakMap,Be=new WeakMap,bt=new WeakMap,Nt=new WeakMap,Ur=new WeakMap,vn=new WeakMap,La=new WeakMap,ja=new WeakSet,eE=async function(){let r=b(this,Be,"f").params.compactionControl;if(!r||!r.enabled)return!1;let n=0;if(b(this,Nt,"f")!==void 0)try{let u=await b(this,Nt,"f");n=u.usage.input_tokens+(u.usage.cache_creation_input_tokens??0)+(u.usage.cache_read_input_tokens??0)+u.usage.output_tokens}catch{return!1}let s=r.contextTokenThreshold??1e5;if(n<s)return!1;let i=r.model??b(this,Be,"f").params.model,o=r.summaryPrompt??Q$,a=b(this,Be,"f").params.messages;if(a[a.length-1].role==="assistant"){let u=a[a.length-1];if(Array.isArray(u.content)){let l=u.content.filter(d=>d.type!=="tool_use");l.length===0?a.pop():u.content=l}}let c=await this.client.beta.messages.create({model:i,messages:[...a,{role:"user",content:[{type:"text",text:o}]}],max_tokens:b(this,Be,"f").params.max_tokens},{signal:b(this,bt,"f").signal,headers:P([b(this,bt,"f").headers,{"x-stainless-helper":"compaction"}])});if(c.content[0]?.type!=="text")throw new j("Expected text response for compaction");return b(this,Be,"f").params.messages=[{role:"user",content:c.content}],!0},Symbol.asyncIterator)](){var e;if(b(this,ji,"f"))throw new j("Cannot iterate over a consumed stream");A(this,ji,!0,"f"),A(this,fs,!0,"f"),A(this,Ur,void 0,"f");try{for(;;){let r;try{if(b(this,Be,"f").params.max_iterations&&b(this,La,"f")>=b(this,Be,"f").params.max_iterations)break;A(this,fs,!1,"f"),A(this,Ur,void 0,"f"),A(this,La,(e=b(this,La,"f"),e++,e),"f"),A(this,Nt,void 0,"f");let{max_iterations:n,compactionControl:s,...i}=b(this,Be,"f").params;if(i.stream?(r=this.client.beta.messages.stream({...i},b(this,bt,"f")),A(this,Nt,r.finalMessage(),"f"),b(this,Nt,"f").catch(()=>{}),yield r):(A(this,Nt,this.client.beta.messages.create({...i,stream:!1},b(this,bt,"f")),"f"),yield b(this,Nt,"f")),!await b(this,ja,"m",eE).call(this)){if(!b(this,fs,"f")){let{role:c,content:u}=await b(this,Nt,"f");b(this,Be,"f").params.messages.push({role:c,content:u})}let a=await b(this,ja,"m",Wm).call(this,b(this,Be,"f").params.messages.at(-1));if(a)b(this,Be,"f").params.messages.push(a);else if(!b(this,fs,"f"))break}}finally{r&&r.abort()}}if(!b(this,Nt,"f"))throw new j("ToolRunner concluded without a message from the server");b(this,vn,"f").resolve(await b(this,Nt,"f"))}catch(r){throw A(this,ji,!1,"f"),b(this,vn,"f").promise.catch(()=>{}),b(this,vn,"f").reject(r),A(this,vn,tE(),"f"),r}}setMessagesParams(e){typeof e=="function"?b(this,Be,"f").params=e(b(this,Be,"f").params):b(this,Be,"f").params=e,A(this,fs,!0,"f"),A(this,Ur,void 0,"f")}setRequestOptions(e){typeof e=="function"?A(this,bt,e(b(this,bt,"f")),"f"):A(this,bt,{...b(this,bt,"f"),...e},"f")}async generateToolResponse(e=b(this,bt,"f").signal){let r=await b(this,Nt,"f")??this.params.messages.at(-1);return r?b(this,ja,"m",Wm).call(this,r,e):null}done(){return b(this,vn,"f").promise}async runUntilDone(){if(!b(this,ji,"f"))for await(let e of this);return this.done()}get params(){return b(this,Be,"f").params}pushMessages(...e){this.setMessagesParams(r=>({...r,messages:[...r.messages,...e]}))}then(e,r){return this.runUntilDone().then(e,r)}};Wm=async function(e,r=b(this,bt,"f").signal){return b(this,Ur,"f")!==void 0?b(this,Ur,"f"):(A(this,Ur,KL(b(this,Be,"f").params,e,{...b(this,bt,"f"),signal:r}),"f"),b(this,Ur,"f"))};async function KL(t,e=t.messages.at(-1),r){if(!e||e.role!=="assistant"||!e.content||typeof e.content=="string")return null;let n=e.content.filter(i=>i.type==="tool_use");return n.length===0?null:{role:"user",content:await Promise.all(n.map(async i=>{let o=t.tools.find(a=>("name"in a?a.name:a.mcp_server_name)===i.name);if(!o||!("run"in o))return{type:"tool_result",tool_use_id:i.id,content:`Error: Tool '${i.name}' not found`,is_error:!0};try{let a=i.input;"parse"in o&&o.parse&&(a=o.parse(a));let c=await o.run(a,{toolUseBlock:i,signal:r?.signal});return{type:"tool_result",tool_use_id:i.id,content:c}}catch(a){return{type:"tool_result",tool_use_id:i.id,content:a instanceof ds?a.content:`Error: ${a instanceof Error?a.message:String(a)}`,is_error:!0}}}))}}var qi=class t{constructor(e,r){this.iterator=e,this.controller=r}async*decoder(){let e=new qr;for await(let r of this.iterator)for(let n of e.decode(r))yield JSON.parse(n);for(let r of e.flush())yield JSON.parse(r)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,r){if(!e.body)throw r.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new j("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new j("Attempted to iterate over a response with no body");return new t(Sa(e.body),r)}};var Di=class extends Q{create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/messages/batches?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",Zt,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},n?.headers])})}cancel(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},n?.headers])})}async results(e,r={},n){let s=await this.retrieve(e);if(!s.results_url)throw new j(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`);let{betas:i}=r??{};return this._client.get(s.results_url,{...n,headers:P([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((o,a)=>qi.fromResponse(a.response,a.controller))}};var rE={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},GL=["claude-opus-4-6"],Fr=class extends Q{constructor(){super(...arguments),this.batches=new Di(this._client)}create(e,r){let n=nE(e),{betas:s,...i}=n;i.model in rE&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${rE[i.model]}
|
|
247
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),i.model in GL&&i.thinking&&i.thinking.type==="enabled"&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let o=this._client._options.timeout;if(!i.stream&&o==null){let c=Cl[i.model]??void 0;o=this._client.calculateNonstreamingTimeout(i.max_tokens,c)}let a=Ml(i.tools,i.messages);return this._client.post("/v1/messages?beta=true",{body:i,timeout:o??6e5,...r,headers:P([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},a,r?.headers]),stream:n.stream??!1})}parse(e,r){return r={...r,headers:P([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},r?.headers])},this.create(e,r).then(n=>Um(n,e,{logger:this._client.logger??console}))}stream(e,r){return Vl.createMessage(this,e,r)}countTokens(e,r){let n=nE(e),{betas:s,...i}=n;return this._client.post("/v1/messages/count_tokens?beta=true",{body:i,...r,headers:P([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString()},r?.headers])})}toolRunner(e,r){return new Li(this._client,e,r)}};function nE(t){if(!t.output_format)return t;if(t.output_config?.format)throw new j("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:e,...r}=t;return{...r,output_config:{...t.output_config,format:e}}}Fr.Batches=Di;Fr.BetaToolRunner=Li;Fr.ToolError=ds;var Zi=class extends Q{list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/sessions/${e}/events?beta=true`,Le,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}send(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}/events?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}stream(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/sessions/${e}/events/stream?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers]),stream:!0})}};var Ui=class extends Q{retrieve(e,r,n){let{session_id:s,betas:i}=r;return this._client.get(L`/v1/sessions/${s}/resources/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{session_id:s,betas:i,...o}=r;return this._client.post(L`/v1/sessions/${s}/resources/${e}?beta=true`,{body:o,...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/sessions/${e}/resources?beta=true`,Le,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}delete(e,r,n){let{session_id:s,betas:i}=r;return this._client.delete(L`/v1/sessions/${s}/resources/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}add(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}/resources?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var xn=class extends Q{constructor(){super(...arguments),this.events=new Zi(this._client),this.resources=new Ui(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/sessions?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/sessions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/sessions/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/sessions?beta=true",Le,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/sessions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/sessions/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};xn.Events=Zi;xn.Resources=Ui;var Fi=class extends Q{create(e,r={},n){let{betas:s,...i}=r??{};return this._client.post(L`/v1/skills/${e}/versions?beta=true`,Ii({body:i,...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])},this._client))}retrieve(e,r,n){let{skill_id:s,betas:i}=r;return this._client.get(L`/v1/skills/${s}/versions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/skills/${e}/versions?beta=true`,Le,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}delete(e,r,n){let{skill_id:s,betas:i}=r;return this._client.delete(L`/v1/skills/${s}/versions/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"skills-2025-10-02"].toString()},n?.headers])})}};var ps=class extends Q{constructor(){super(...arguments),this.versions=new Fi(this._client)}create(e={},r){let{betas:n,...s}=e??{};return this._client.post("/v1/skills?beta=true",Ii({body:s,...r,headers:P([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])},this._client,!1))}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/skills/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/skills?beta=true",Le,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/skills/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},n?.headers])})}};ps.Versions=Fi;var Bi=class extends Q{create(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/vaults/${e}/credentials?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}retrieve(e,r,n){let{vault_id:s,betas:i}=r;return this._client.get(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{vault_id:s,betas:i,...o}=r;return this._client.post(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{body:o,...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e,r={},n){let{betas:s,...i}=r??{};return this._client.getAPIList(L`/v1/vaults/${e}/credentials?beta=true`,Le,{query:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}delete(e,r,n){let{vault_id:s,betas:i}=r;return this._client.delete(L`/v1/vaults/${s}/credentials/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r,n){let{vault_id:s,betas:i}=r;return this._client.post(L`/v1/vaults/${s}/credentials/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};var hs=class extends Q{constructor(){super(...arguments),this.credentials=new Bi(this._client)}create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/vaults?beta=true",{body:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/vaults/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}update(e,r,n){let{betas:s,...i}=r;return this._client.post(L`/v1/vaults/${e}?beta=true`,{body:i,...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/vaults?beta=true",Le,{query:s,...r,headers:P([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,r={},n){let{betas:s}=r??{};return this._client.delete(L`/v1/vaults/${e}?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}archive(e,r={},n){let{betas:s}=r??{};return this._client.post(L`/v1/vaults/${e}/archive?beta=true`,{...n,headers:P([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers])})}};hs.Credentials=Bi;var dt=class extends Q{constructor(){super(...arguments),this.models=new Ri(this._client),this.messages=new Fr(this._client),this.agents=new us(this._client),this.environments=new Ai(this._client),this.sessions=new xn(this._client),this.vaults=new hs(this._client),this.files=new Ni(this._client),this.skills=new ps(this._client)}};dt.Models=Ri;dt.Messages=Fr;dt.Agents=us;dt.Environments=Ai;dt.Sessions=xn;dt.Vaults=hs;dt.Files=Ni;dt.Skills=ps;var ms=class extends Q{create(e,r){let{betas:n,...s}=e;return this._client.post("/v1/complete",{body:s,timeout:this._client._options.timeout??6e5,...r,headers:P([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers]),stream:e.stream??!1})}};function sE(t){return t?.output_config?.format}function Km(t,e,r){let n=sE(e);return!e||!("parse"in(n??{}))?{...t,content:t.content.map(s=>s.type==="text"?Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1}):s),parsed_output:null}:Jm(t,e,r)}function Jm(t,e,r){let n=null,s=t.content.map(i=>{if(i.type==="text"){let o=iq(e,i.text);return n===null&&(n=o),Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1})}return i});return{...t,content:s,parsed_output:n}}function iq(t,e){let r=sE(t);if(r?.type!=="json_schema")return null;try{return"parse"in r?r.parse(e):JSON.parse(e)}catch(n){throw new j(`Failed to parse structured output: ${n}`)}}var Ft,Sn,Vi,qa,Hl,Da,Za,Wl,Ua,Br,Fa,Kl,Jl,gs,Gl,Yl,Ba,Gm,iE,Ym,Xm,Qm,eg,oE,aE="__json_buf";function cE(t){return t.type==="tool_use"||t.type==="server_tool_use"}var Xl=class t{constructor(e,r){Ft.add(this),this.messages=[],this.receivedMessages=[],Sn.set(this,void 0),Vi.set(this,null),this.controller=new AbortController,qa.set(this,void 0),Hl.set(this,()=>{}),Da.set(this,()=>{}),Za.set(this,void 0),Wl.set(this,()=>{}),Ua.set(this,()=>{}),Br.set(this,{}),Fa.set(this,!1),Kl.set(this,!1),Jl.set(this,!1),gs.set(this,!1),Gl.set(this,void 0),Yl.set(this,void 0),Ba.set(this,void 0),Ym.set(this,n=>{if(A(this,Kl,!0,"f"),Lr(n)&&(n=new et),n instanceof et)return A(this,Jl,!0,"f"),this._emit("abort",n);if(n instanceof j)return this._emit("error",n);if(n instanceof Error){let s=new j(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new j(String(n)))}),A(this,qa,new Promise((n,s)=>{A(this,Hl,n,"f"),A(this,Da,s,"f")}),"f"),A(this,Za,new Promise((n,s)=>{A(this,Wl,n,"f"),A(this,Ua,s,"f")}),"f"),b(this,qa,"f").catch(()=>{}),b(this,Za,"f").catch(()=>{}),A(this,Vi,e,"f"),A(this,Ba,r?.logger??console,"f")}get response(){return b(this,Gl,"f")}get request_id(){return b(this,Yl,"f")}async withResponse(){A(this,gs,!0,"f");let e=await b(this,qa,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,n,{logger:s}={}){let i=new t(r,{logger:s});for(let o of r.messages)i._addMessageParam(o);return A(i,Vi,{...r,stream:!0},"f"),i._run(()=>i._createMessage(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},b(this,Ym,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,n){let s=n?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{b(this,Ft,"m",Xm).call(this);let{response:o,data:a}=await e.create({...r,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(let c of a)b(this,Ft,"m",Qm).call(this,c);if(a.controller.signal?.aborted)throw new et;b(this,Ft,"m",eg).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}_connected(e){this.ended||(A(this,Gl,e,"f"),A(this,Yl,e?.headers.get("request-id"),"f"),b(this,Hl,"f").call(this,e),this._emit("connect"))}get ended(){return b(this,Fa,"f")}get errored(){return b(this,Kl,"f")}get aborted(){return b(this,Jl,"f")}abort(){this.controller.abort()}on(e,r){return(b(this,Br,"f")[e]||(b(this,Br,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=b(this,Br,"f")[e];if(!n)return this;let s=n.findIndex(i=>i.listener===r);return s>=0&&n.splice(s,1),this}once(e,r){return(b(this,Br,"f")[e]||(b(this,Br,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{A(this,gs,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){A(this,gs,!0,"f"),await b(this,Za,"f")}get currentMessage(){return b(this,Sn,"f")}async finalMessage(){return await this.done(),b(this,Ft,"m",Gm).call(this)}async finalText(){return await this.done(),b(this,Ft,"m",iE).call(this)}_emit(e,...r){if(b(this,Fa,"f"))return;e==="end"&&(A(this,Fa,!0,"f"),b(this,Wl,"f").call(this));let n=b(this,Br,"f")[e];if(n&&(b(this,Br,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...r))),e==="abort"){let s=r[0];!b(this,gs,"f")&&!n?.length&&Promise.reject(s),b(this,Da,"f").call(this,s),b(this,Ua,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=r[0];!b(this,gs,"f")&&!n?.length&&Promise.reject(s),b(this,Da,"f").call(this,s),b(this,Ua,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",b(this,Ft,"m",Gm).call(this))}async _fromReadableStream(e,r){let n=r?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{b(this,Ft,"m",Xm).call(this),this._connected(null);let i=wr.fromReadableStream(e,this.controller);for await(let o of i)b(this,Ft,"m",Qm).call(this,o);if(i.controller.signal?.aborted)throw new et;b(this,Ft,"m",eg).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(Sn=new WeakMap,Vi=new WeakMap,qa=new WeakMap,Hl=new WeakMap,Da=new WeakMap,Za=new WeakMap,Wl=new WeakMap,Ua=new WeakMap,Br=new WeakMap,Fa=new WeakMap,Kl=new WeakMap,Jl=new WeakMap,gs=new WeakMap,Gl=new WeakMap,Yl=new WeakMap,Ba=new WeakMap,Ym=new WeakMap,Ft=new WeakSet,Gm=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},iE=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let r=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(r.length===0)throw new j("stream ended without producing a content block with type=text");return r.join(" ")},Xm=function(){this.ended||A(this,Sn,void 0,"f")},Qm=function(r){if(this.ended)return;let n=b(this,Ft,"m",oE).call(this,r);switch(this._emit("streamEvent",r,n),r.type){case"content_block_delta":{let s=n.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{cE(s)&&s.input&&this._emit("inputJson",r.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}default:r.delta}break}case"message_stop":{this._addMessageParam(n),this._addMessage(Km(n,b(this,Vi,"f"),{logger:b(this,Ba,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{A(this,Sn,n,"f");break}case"content_block_start":case"message_delta":break}},eg=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let r=b(this,Sn,"f");if(!r)throw new j("request ended without sending any chunks");return A(this,Sn,void 0,"f"),Km(r,b(this,Vi,"f"),{logger:b(this,Ba,"f")})},oE=function(r){let n=b(this,Sn,"f");if(r.type==="message_start"){if(n)throw new j(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(!n)throw new j(`Unexpected event order, got ${r.type} before "message_start"`);switch(r.type){case"message_stop":return n;case"message_delta":return n.stop_reason=r.delta.stop_reason,n.stop_sequence=r.delta.stop_sequence,n.usage.output_tokens=r.usage.output_tokens,r.usage.input_tokens!=null&&(n.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(n.usage.server_tool_use=r.usage.server_tool_use),n;case"content_block_start":return n.content.push({...r.content_block}),n;case"content_block_delta":{let s=n.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(n.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&cE(s)){let i=s[aE]||"";i+=r.delta.partial_json;let o={...s};Object.defineProperty(o,aE,{value:i,enumerable:!1,writable:!0}),i&&(o.input=jl(i)),n.content[r.index]=o}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[r.index]={...s,signature:r.delta.signature});break}default:r.delta}return n}case"content_block_stop":return n}},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("streamEvent",s=>{let i=r.shift();i?i.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),this.on("error",s=>{n=!0;for(let i of r)i.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,o)=>r.push({resolve:i,reject:o})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new wr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var Hi=class extends Q{create(e,r){return this._client.post("/v1/messages/batches",{body:e,...r})}retrieve(e,r){return this._client.get(L`/v1/messages/batches/${e}`,r)}list(e={},r){return this._client.getAPIList("/v1/messages/batches",Zt,{query:e,...r})}delete(e,r){return this._client.delete(L`/v1/messages/batches/${e}`,r)}cancel(e,r){return this._client.post(L`/v1/messages/batches/${e}/cancel`,r)}async results(e,r){let n=await this.retrieve(e);if(!n.results_url)throw new j(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...r,headers:P([{Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((s,i)=>qi.fromResponse(i.response,i.controller))}};var kn=class extends Q{constructor(){super(...arguments),this.batches=new Hi(this._client)}create(e,r){e.model in uE&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${uE[e.model]}
|
|
248
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in aq&&e.thinking&&e.thinking.type==="enabled"&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let n=this._client._options.timeout;if(!e.stream&&n==null){let i=Cl[e.model]??void 0;n=this._client.calculateNonstreamingTimeout(e.max_tokens,i)}let s=Ml(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:n??6e5,...r,headers:P([s,r?.headers]),stream:e.stream??!1})}parse(e,r){return this.create(e,r).then(n=>Jm(n,e,{logger:this._client.logger??console}))}stream(e,r){return Xl.createMessage(this,e,r,{logger:this._client.logger??console})}countTokens(e,r){return this._client.post("/v1/messages/count_tokens",{body:e,...r})}},uE={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},aq=["claude-opus-4-6"];kn.Batches=Hi;var ys=class extends Q{retrieve(e,r={},n){let{betas:s}=r??{};return this._client.get(L`/v1/models/${e}`,{...n,headers:P([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers])})}list(e={},r){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/models",Zt,{query:s,...r,headers:P([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}};var Va=t=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[t]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()||void 0};var tg,rg,Ql,lE,dE="\\n\\nHuman:",fE="\\n\\nAssistant:",Me=class{constructor({baseURL:e=Va("ANTHROPIC_BASE_URL"),apiKey:r=Va("ANTHROPIC_API_KEY")??null,authToken:n=Va("ANTHROPIC_AUTH_TOKEN")??null,...s}={}){tg.add(this),Ql.set(this,void 0);let i={apiKey:r,authToken:n,...s,baseURL:e||"https://api.anthropic.com"};if(!i.dangerouslyAllowBrowser&&A$())throw new j(`It looks like you're running in a browser-like environment.
|
|
249
249
|
|
|
250
250
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
251
251
|
If you understand the risks and have appropriate mitigations in place,
|
|
252
252
|
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
253
253
|
|
|
254
254
|
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
255
|
-
`);this.baseURL=i.baseURL,this.timeout=i.timeout??
|
|
255
|
+
`);this.baseURL=i.baseURL,this.timeout=i.timeout??rg.DEFAULT_TIMEOUT,this.logger=i.logger??console;let o="warn";this.logLevel=o,this.logLevel=Rm(i.logLevel,"ClientOptions.logLevel",this)??Rm(Va("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??R$(),A(this,Ql,M$,"f"),this._options=i,this.apiKey=typeof r=="string"?r:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){if(!(e.get("x-api-key")||e.get("authorization"))&&!(this.apiKey&&e.get("x-api-key"))&&!r.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!r.has("authorization"))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return P([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return P([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return P([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return C$(e)}getUserAgent(){return`${this.constructor.name}/JS ${bn}`}defaultIdempotencyKey(){return`stainless-node-retry-${Tm()}`}makeStatusError(e,r,n,s){return Ge.generate(e,r,n,s)}buildURL(e,r,n){let s=!b(this,tg,"m",lE).call(this)&&n||this.baseURL,i=k$(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!Im(o)||!Im(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(i.search=this.stringifyQuery(r)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new j("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(s=>({method:e,path:r,...s})))}request(e,r=null){return new as(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let s=await e,i=s.maxRetries??this.maxRetries;r==null&&(r=i),await this.prepareOptions(s);let{req:o,url:a,timeout:c}=await this.buildRequest(s,{retryCount:i-r});await this.prepareRequest(o,{url:a,options:s});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),l=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Ye(this).debug(`[${u}] sending request`,Dr({retryOfRequestLogID:n,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new et;let f=new AbortController,p=await this.fetchWithTimeout(a,o,c,f).catch(xa),m=Date.now();if(p instanceof globalThis.Error){let y=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new et;let _=Lr(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Ye(this).info(`[${u}] connection ${_?"timed out":"failed"} - ${y}`),Ye(this).debug(`[${u}] connection ${_?"timed out":"failed"} (${y})`,Dr({retryOfRequestLogID:n,url:a,durationMs:m-d,message:p.message})),this.retryRequest(s,r,n??u);throw Ye(this).info(`[${u}] connection ${_?"timed out":"failed"} - error; no more retries left`),Ye(this).debug(`[${u}] connection ${_?"timed out":"failed"} (error; no more retries left)`,Dr({retryOfRequestLogID:n,url:a,durationMs:m-d,message:p.message})),_?new vi:new _n({cause:p})}let h=[...p.headers.entries()].filter(([y])=>y==="request-id").map(([y,_])=>", "+y+": "+JSON.stringify(_)).join(""),g=`[${u}${l}${h}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${m-d}ms`;if(!p.ok){let y=await this.shouldRetry(p);if(r&&y){let B=`retrying, ${r} attempts remaining`;return await z$(p.body),Ye(this).info(`${g} - ${B}`),Ye(this).debug(`[${u}] response error (${B})`,Dr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),this.retryRequest(s,r,n??u,p.headers)}let _=y?"error; no more retries left":"error; not retryable";Ye(this).info(`${g} - ${_}`);let v=await p.text().catch(B=>xa(B).message),k=El(v),E=k?void 0:v;throw Ye(this).debug(`[${u}] response error (${_})`,Dr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:E,durationMs:Date.now()-d})),this.makeStatusError(p.status,k,E,p.headers)}return Ye(this).info(g),Ye(this).debug(`[${u}] response start`,Dr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),{response:p,options:s,controller:f,requestLogID:u,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Pa(this,n,e)}async fetchWithTimeout(e,r,n,s){let{signal:i,method:o,...a}=r||{},c=this._makeAbort(s);i&&i.addEventListener("abort",c,{once:!0});let u=setTimeout(c,n),l=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:s.signal,...l?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(u)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,s){let i,o=s?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(i=c)}let a=s?.get("retry-after");if(a&&!i){let c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(i===void 0){let c=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(r,c)}return await T$(i),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,o=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return o*a*1e3}calculateNonstreamingTimeout(e,r){if(36e5*e/128e3>6e5||r!=null&&e>r)throw new j("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:s,path:i,query:o,defaultBaseURL:a}=n,c=this.buildURL(i,o,a);"timeout"in n&&E$("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:u,body:l}=this.buildBody({options:n}),d=await this.buildHeaders({options:e,method:s,bodyHeaders:u,retryCount:r});return{req:{method:s,headers:d,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:s}){let i={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let o=P([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...N$(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=P([r]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:Tl(e)}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:b(this,Ql,"f").call(this,{body:e,headers:n})}};rg=Me,Ql=new WeakMap,tg=new WeakSet,lE=function(){return this.baseURL!=="https://api.anthropic.com"};Me.Anthropic=rg;Me.HUMAN_PROMPT=dE;Me.AI_PROMPT=fE;Me.DEFAULT_TIMEOUT=6e5;Me.AnthropicError=j;Me.APIError=Ge;Me.APIConnectionError=_n;Me.APIConnectionTimeoutError=vi;Me.APIUserAbortError=et;Me.NotFoundError=$i;Me.ConflictError=Ei;Me.RateLimitError=Pi;Me.BadRequestError=xi;Me.AuthenticationError=Si;Me.InternalServerError=Oi;Me.PermissionDeniedError=ki;Me.UnprocessableEntityError=Ti;Me.toFile=Rl;var Bt=class extends Me{constructor(){super(...arguments),this.completions=new ms(this),this.messages=new kn(this),this.models=new ys(this),this.beta=new dt(this)}};Bt.Completions=ms;Bt.Messages=kn;Bt.Models=ys;Bt.Beta=dt;sn();var sg="claude-opus-4-8",lq=16e3,dq=800,fq=10,pq=5e3,hq=50,mq={enter:"enter",escape:"escape",backspace:"backspace",tab:"tab",space:"space",delete:"delete",arrow_up:"arrowup",arrow_down:"arrowdown",arrow_left:"arrowleft",arrow_right:"arrowright"},gq=`You are an expert mobile app tester driving an iOS simulator toward a GOAL.
|
|
256
256
|
|
|
257
257
|
Method:
|
|
258
258
|
1. Discovery before action: call snapshot before your first interaction; after that, trust the CURRENT SCREEN tree that every action result carries. Element refs (@eN) go stale after every action \u2014 only use refs from the most recent tree.
|
|
@@ -262,46 +262,48 @@ Method:
|
|
|
262
262
|
5. Screenshots are expensive; take one only when the tree is sparse or pixels matter.
|
|
263
263
|
6. When the goal is verified \u2014 or you have established it cannot be \u2014 call done with your pass/fail verdict and a concise summary. Always end with done.
|
|
264
264
|
|
|
265
|
-
Be efficient: no redundant snapshots, no wandering beyond the goal.`;async function
|
|
266
|
-
(sparse tree \u2014 likely a custom-drawn surface; a screenshot may help)`:K.text},g=async(I,K)=>{p=null;let J=await f(I);if(d(J),!J.ok)return{content:`${K} FAILED: ${J.error??"unknown error"}`,isError:!0};let
|
|
265
|
+
Be efficient: no redundant snapshots, no wandering beyond the goal.`;async function pE(t){let{client:e,udid:r,goal:n}=t,s=t.model??process.env.SIMON_AGENT_MODEL??sg,i=t.maxSteps??40,o=`agent-run-${uq().slice(0,8)}`,a={kind:"agent",runId:o,goal:n},c=new Bt(t.apiKey?{apiKey:t.apiKey}:{}),u=0;try{let I=await e.events(r);u=I[I.length-1]?.seq??0}catch{}let l=u+1,d=I=>{I.seq!==void 0&&I.seq>u&&(u=I.seq)},f=I=>e.action(r,a,I),p=null,m=null,h=async()=>{let I=await e.uiSnapshot(r),K=es(I,{interactiveOnly:!0});return p=K.byRef,m=I.screen,K.sparse?`${K.text}
|
|
266
|
+
(sparse tree \u2014 likely a custom-drawn surface; a screenshot may help)`:K.text},g=async(I,K)=>{p=null;let J=await f(I);if(d(J),!J.ok)return{content:`${K} FAILED: ${J.error??"unknown error"}`,isError:!0};let ze;try{ze=await h()}catch(De){return{content:`ACTION RESULT: ${K}. (could not refresh UI tree: ${ng(De)})`}}return{content:`ACTION RESULT: ${K}.
|
|
267
267
|
|
|
268
268
|
CURRENT SCREEN:
|
|
269
|
-
${
|
|
270
|
-
${await h()}`};case"screenshot":{let K=await f({type:"screenshot"});return d(K),!K.ok||!K.screenshotBase64?{content:`screenshot FAILED: ${K.error??"no image returned"}`,isError:!0}:{content:[{type:"image",source:{type:"base64",media_type:"image/png",data:K.screenshotBase64}}]}}case"tap":{if(!p||!m)return{content:"No current tree \u2014 call snapshot first; refs go stale after every action.",isError:!0};let K=p.get(I.ref);if(!K)return{content:`Unknown ref ${JSON.stringify(I.ref)} \u2014 not in the latest tree. Use a ref from the most recent CURRENT SCREEN, or call snapshot.`,isError:!0};let J=y(K,m),
|
|
269
|
+
${ze}`}},y=(I,K)=>{if(I.id)return{selector:{id:I.id},via:`id=${JSON.stringify(I.id)}`};if(I.label)return{selector:{text:I.label},via:`text=${JSON.stringify(I.label)}`};let J=Zo(I),ze={x:J.x/K.width,y:J.y/K.height};return{point:ze,via:`point (${ze.x.toFixed(2)},${ze.y.toFixed(2)})`}},_=async I=>{switch(I.tool){case"snapshot":return{content:`CURRENT SCREEN:
|
|
270
|
+
${await h()}`};case"screenshot":{let K=await f({type:"screenshot"});return d(K),!K.ok||!K.screenshotBase64?{content:`screenshot FAILED: ${K.error??"no image returned"}`,isError:!0}:{content:[{type:"image",source:{type:"base64",media_type:"image/png",data:K.screenshotBase64}}]}}case"tap":{if(!p||!m)return{content:"No current tree \u2014 call snapshot first; refs go stale after every action.",isError:!0};let K=p.get(I.ref);if(!K)return{content:`Unknown ref ${JSON.stringify(I.ref)} \u2014 not in the latest tree. Use a ref from the most recent CURRENT SCREEN, or call snapshot.`,isError:!0};let J=y(K,m),ze={type:"tap",..."selector"in J?{selector:J.selector}:{point:J.point},...I.longPress?{longPressMs:dq}:{}},De=I.longPress?"long-pressed":"tapped";return g(ze,`${De} ${I.ref} ${K.role??"View"} via ${J.via}`)}case"type_text":return g({type:"inputText",text:I.text},`typed ${JSON.stringify(I.text)}`);case"erase_text":{let K=I.chars??hq;return g({type:"eraseText",chars:K},`erased ${K} characters`)}case"press_key":return g({type:"key",key:mq[I.key]??I.key},`pressed ${I.key}`);case"swipe":return g({type:"swipe",direction:I.direction},`swiped ${I.direction}`);case"launch_app":return g({type:"launchApp",appId:I.appId,...I.relaunch!==void 0?{relaunch:I.relaunch}:{}},`launched ${I.appId}`);case"stop_app":return g({type:"stopApp",appId:I.appId},`stopped ${I.appId}`);case"open_url":return g({type:"openUrl",url:I.url},`opened ${I.url}`);case"wait_for":{if(!I.text&&!I.id)return{content:"wait_for needs text and/or id.",isError:!0};let K={...I.id!==void 0?{id:I.id}:{},...I.text!==void 0?{text:I.text}:{}},J=I.gone??!1,ze=Math.round((I.timeoutSeconds??fq)*1e3),De=yq(K);p=null;let tr=await f({type:"waitFor",selector:K,timeoutMs:ze,...J?{gone:J}:{}});if(d(tr),!tr.ok)return{content:`wait_for timed out after ${ze}ms \u2014 ${De} ${J?"is still present":"did not appear"}.`,isError:!0};let hr;try{hr=await h()}catch(rp){return{content:`ACTION RESULT: ${De} ${J?"is gone":"appeared"}. (could not refresh UI tree: ${ng(rp)})`}}return{content:`ACTION RESULT: ${De} ${J?"is gone":"appeared"}.
|
|
271
271
|
|
|
272
272
|
CURRENT SCREEN:
|
|
273
|
-
${
|
|
274
|
-
`)}],E=0,C=0,B=0,R="",ue=null;for(;B<i&&!ue;){B++;let I=await c.messages.create({model:s,max_tokens:
|
|
273
|
+
${hr}`}}case"assert":{let K=I.pass?"PASS":"FAIL",J=/^(visible|notVisible):\s*(.+)$/.exec(I.assertion);if(!J)return{content:`Assertion recorded: ${JSON.stringify(I.assertion)} \u2192 ${K}. (free-form \u2014 not device-verified; prefer "visible:<text>" / "notVisible:<text>")`};let ze=J[1]==="notVisible",De={text:J[2].trim()},tr=await f({type:"waitFor",selector:De,timeoutMs:pq,...ze?{gone:ze}:{}});d(tr);let hr=tr.ok;return hr===I.pass?{content:`Assertion recorded: ${JSON.stringify(I.assertion)} \u2192 ${K} (device check agrees).`}:{content:`ASSERT MISMATCH: you recorded ${K}, but the device says ${JSON.stringify(I.assertion)} is ${hr?"satisfied":"NOT satisfied"}. Re-examine the screen before proceeding.`,isError:!0}}case"checkpoint":return{content:`Checkpoint recorded: ${JSON.stringify(I.name)}.`};case"done":return{content:"done is handled by the runner.",isError:!0};default:return{content:`Unknown tool ${JSON.stringify(I.tool)}.`,isError:!0}}},k=[{role:"user",content:[`GOAL: ${n}`,...t.appId?[`App under test: ${t.appId} (use launch_app if it is not already in the foreground).`]:[],`Device: iOS simulator ${r}.`,"Start with snapshot to see the current screen."].join(`
|
|
274
|
+
`)}],E=0,C=0,B=0,R="",ue=null;for(;B<i&&!ue;){B++;let I=await c.messages.create({model:s,max_tokens:lq,thinking:{type:"adaptive"},system:[{type:"text",text:gq,cache_control:{type:"ephemeral"}}],tools:S$,messages:k}),K=I.usage;E+=K.input_tokens+(K.cache_creation_input_tokens??0)+(K.cache_read_input_tokens??0),C+=K.output_tokens;for(let De of I.content)De.type==="text"&&De.text.trim()&&(R=De.text.trim(),t.onThought?.(R));let J=I.content.filter(De=>De.type==="tool_use");if(J.length===0){ue={pass:!1,summary:R||"Agent ended its turn without a verdict."};break}k.push({role:"assistant",content:I.content});let ze=[];for(let De of J){let tr=x$(De);if(tr.tool==="done"){ue={pass:tr.pass===!0,summary:tr.summary??""};break}let hr;try{hr=await _(tr)}catch(rp){hr={content:`${tr.tool} failed: ${ng(rp)}`,isError:!0}}ze.push({type:"tool_result",tool_use_id:De.id,content:hr.content,...hr.isError?{is_error:!0}:{}})}if(ue)break;k.push({role:"user",content:ze})}return{pass:ue?.pass??!1,summary:ue?.summary??`Run hit the ${i}-step limit before reaching a verdict.${R?` Last thought: ${R}`:""}`,runId:o,firstSeq:l,lastSeq:u,steps:B,inputTokens:E,outputTokens:C}}function yq(t){let e=[];return t.id&&e.push(`id=${JSON.stringify(t.id)}`),t.text&&e.push(`text=${JSON.stringify(t.text)}`),e.join(" ")||"<empty selector>"}function ng(t){return t instanceof Error?t.message:String(t)}sn();var _q=`You are the self-healing tier of a deterministic mobile UI test runner.
|
|
275
275
|
A recorded flow step failed and local re-grounding could not resolve it. Decide from the live UI tree:
|
|
276
276
|
- "patched": the intended element still exists (renamed, moved, relabelled) \u2014 propose the most stable selector for it. Prefer accessibility id, then exact text; add index only to disambiguate. Never invent elements that are not in the tree.
|
|
277
|
-
- "regression": the capability the step exercised is gone or broken \u2014 the failure is real and must be reported, not papered over.`,
|
|
278
|
-
`),a=(await e.messages.create({model:r,max_tokens:16e3,system:
|
|
277
|
+
- "regression": the capability the step exercised is gone or broken \u2014 the failure is real and must be reported, not papered over.`,bq={name:"propose_fix",description:"Deliver the healing verdict: a re-grounded selector for the failing step, or a regression call.",input_schema:{type:"object",properties:{verdict:{type:"string",enum:["patched","regression"],description:'"patched" when the element still exists under a new selector; otherwise "regression".'},patchedSelector:{type:"object",description:'Required when verdict is "patched": the new selector, taken from the live tree.',properties:{id:{type:"string",description:"Accessibility id (most stable \u2014 prefer this)."},text:{type:"string",description:"Exact label/text/value match."},index:{type:"integer",description:"0-based pick when several elements match."}},additionalProperties:!1},reasoning:{type:"string",description:"One or two sentences: what changed in the UI and why this verdict."}},required:["verdict","reasoning"],additionalProperties:!1}};async function hE(t){let e=new Bt(t.apiKey?{apiKey:t.apiKey}:{}),r=t.model??process.env.SIMON_AGENT_MODEL??sg,n=await t.client.uiSnapshot(t.udid),s=es(n),i=[`Flow: ${t.flowName}`,`Failing step (JSON): ${JSON.stringify(t.step)}`,`Step intent: ${t.intent}`,`Runner error: ${t.error}`,"","CURRENT SCREEN (one element per line, normalized [0,1] center and size):",s.text||"(no elements \u2014 the tree is empty)"].join(`
|
|
278
|
+
`),a=(await e.messages.create({model:r,max_tokens:16e3,system:_q,tools:[bq],tool_choice:{type:"tool",name:"propose_fix"},messages:[{role:"user",content:i}]})).content.find(l=>l.type==="tool_use"&&l.name==="propose_fix");if(!a)throw new Error("healStep: model returned no propose_fix tool call");let c=a.input,u=c.reasoning??"";if(c.verdict==="patched"){let l=wq(c.patchedSelector),d=l?vq(t.step,l):null;return d?{kind:"patched",step:d,reasoning:u}:{kind:"regression",reasoning:`${u} (model proposed a patch, but it could not be applied to a "${t.step.kind}" step)`.trim()}}return{kind:"regression",reasoning:u}}function wq(t){if(!t)return null;let e={...t.id!==void 0?{id:t.id}:{},...t.text!==void 0?{text:t.text}:{},...t.index!==void 0?{index:t.index}:{}};return e.id!==void 0||e.text!==void 0?e:null}function vq(t,e){switch(t.kind){case"tapOn":return{...t,selector:{...e}};case"assertVisible":case"assertNotVisible":case"scrollUntilVisible":return{...t,selector:e};default:return null}}var Pe=(()=>{let t=process.argv[1]??"";if(t.includes("_npx"))return"npx @szdziedzic/sim-on";let e=FW(t).replace(/\.(c|m)?(js|ts)$/,"");return e&&e!=="index"?e:"sim-on"})(),rN=`sim-on \u2014 agentic mobile testing + simulator service (Expo)
|
|
279
279
|
|
|
280
280
|
Usage:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
281
|
+
${Pe} # = ${Pe} serve
|
|
282
|
+
${Pe} serve [--port 3300] [--host 127.0.0.1] [--remote] [--token T]
|
|
283
|
+
[--codec webrtc|mjpeg|h264] [--json]
|
|
284
|
+
${Pe} devices [--json]
|
|
285
|
+
${Pe} boot [device]
|
|
286
|
+
${Pe} run <flow.yaml...> [--device D] [--heal]
|
|
287
|
+
${Pe} explore "<goal>" [--app <bundleId>] [--device D] [--save <flow.yaml>]
|
|
288
|
+
[--max-steps 40] [--model <id>]
|
|
289
|
+
${Pe} tap <text|--id ID> [--device D]
|
|
290
|
+
${Pe} screenshot [out.png] [--device D]
|
|
291
|
+
${Pe} snapshot [--device D] # compact UI tree
|
|
292
|
+
${Pe} events [--follow] [--device D] # unified event log
|
|
293
|
+
${Pe} record start <name> [--device D]
|
|
294
|
+
# bracket a session in the event log
|
|
295
|
+
${Pe} record stop [--save out.yaml] # compile it to a deterministic flow
|
|
296
|
+
${Pe} record status|discard
|
|
297
|
+
${Pe} export <flow.yaml> [--out f] # plain Maestro YAML (maestro test)
|
|
298
|
+
${Pe} mcp # MCP server for Claude Code/Cursor:
|
|
299
|
+
# claude mcp add sim-on -- ${Pe} mcp
|
|
298
300
|
|
|
299
301
|
Remote daemon: set SIMON_REMOTE_URL + SIMON_REMOTE_TOKEN, or pass
|
|
300
302
|
--url/--token-auth \u2014 every command then targets that daemon.
|
|
301
|
-
`,
|
|
302
|
-
`),console.log(
|
|
303
|
-
|
|
304
|
-
`),
|
|
303
|
+
`,iN={kind:"cli"};async function nie(t=process.argv.slice(2)){let e=t[0],r=t.slice(1);switch(e){case"serve":return nN(r);case"devices":return VW(r);case"boot":return HW(r);case"run":return WW(r);case"explore":return JW(r);case"tap":return GW(r);case"screenshot":return YW(r);case"snapshot":return XW(r);case"events":return tK(r);case"record":return eK(r);case"export":return QW(r);case"mcp":{let{runMcpServer:n}=await Promise.resolve().then(()=>(tN(),eN));return await n(()=>en()),new Promise(()=>{})}case void 0:return nN([]);case"help":case"--help":case"-h":console.log(rN);return;default:console.error(`Unknown command: ${e}
|
|
304
|
+
`),console.log(rN),process.exitCode=1}}function Av(){let t=BW(new URL(".",import.meta.url));return[tp(t,"..","vendor","web"),tp(t,"..","..","web","dist"),tp(t,"..","..","..","web","dist")].find(r=>ZW(tp(r,"index.html")))}async function en(t){let e=await $p(t?.url?{url:t.url,token:t.token}:void 0);if(e){let s=new ai(e);if(await s.ping())return s}let r;for(let s=0;s<5&&!r;s++){let i=new Fo({port:3300+Math.floor(Math.random()*500),webDist:Av(),writeDaemonFile:!1});try{await i.start(),r=i}catch{}}if(!r)throw new Error("could not start an ephemeral daemon");let n=r;return process.on("exit",()=>void n.stop()),new ai({url:n.url()})}async function Xs(t,e){let r=await t.listDevices();if(e){let i=r.find(o=>o.udid===e||o.name===e);if(!i)throw new Error(`Device not found: ${e}`);return i.state!=="Booted"&&await t.bootDevice(i.udid),i.udid}let n=r.find(i=>i.state==="Booted");if(n)return n.udid;let s=await Z0();return console.error(`Booting ${s.name}\u2026`),await t.bootDevice(s.udid),s.udid}async function nN(t){let{values:e}=Ar({args:t,options:{port:{type:"string",default:"3300"},host:{type:"string",default:"127.0.0.1"},remote:{type:"boolean",default:!1},token:{type:"string"},codec:{type:"string",default:"webrtc"},json:{type:"boolean",default:!1}}}),r=e.token??(e.remote?DW(24).toString("hex"):void 0),n=new Fo({port:Number(e.port),host:e.host,token:r,codec:e.codec,webDist:Av()});await n.start();let s=n.url()+(r?`/?token=${r}`:"/");e.json?console.log(JSON.stringify({url:n.url(),token:r,previewUrl:s})):(console.log(`
|
|
305
|
+
sim-on daemon \u2192 ${s}
|
|
306
|
+
`),Av()||console.log(" (web UI not built \u2014 run `bun run --filter @simon/web build`)\n"));let i=()=>{n.stop().finally(()=>process.exit(0))};process.on("SIGINT",i),process.on("SIGTERM",i),await new Promise(()=>{})}async function VW(t){let{values:e}=Ar({args:t,options:{json:{type:"boolean",default:!1},url:{type:"string"},"token-auth":{type:"string"}}}),n=await(await en({url:e.url,token:e["token-auth"]})).listDevices();if(e.json)console.log(JSON.stringify(n,null,2));else for(let s of n)console.log(`${s.state==="Booted"?"\u25CF":"\u25CB"} ${s.name} ${s.udid} ${s.runtime}${s.helperPort?` helper:${s.helperPort}`:""}`)}async function HW(t){let e=await en(),r=await Xs(e,t[0]);console.log(`Booted ${r}`)}async function WW(t){let{values:e,positionals:r}=Ar({args:t,options:{device:{type:"string"},heal:{type:"boolean",default:!1},url:{type:"string"},"token-auth":{type:"string"}},allowPositionals:!0});if(r.length===0)throw new Error(`${Pe} run <flow.yaml...>`);let n=await en({url:e.url,token:e["token-auth"]}),s=await Xs(n,e.device),i=0;for(let o of r){let a=Ao(o),c=await br(a),u=new gn({client:n,udid:s,flowDir:sN(a)}),l=await u.run(c);if(!l.pass&&e.heal){let f=l.steps.find(p=>!p.ok);if(f){console.log(`\u2717 step ${f.index+1} failed \u2014 invoking healer\u2026`);let p=await hE({client:n,udid:s,step:f.step,flowName:c.config.name??o,intent:c.config.name??"flow",error:f.error??"unknown"});p.kind==="patched"?(console.log(` healer: ${p.reasoning}`),c.steps[f.index]=p.step,l=await u.run(c),l.pass&&(console.log(" healed flow passes \u2014 review & commit the patched step:"),console.log(` ${JSON.stringify(p.step)}`))):console.log(` healer verdict: regression \u2014 ${p.reasoning}`)}}let d=l.pass?"\u2713":"\u2717";console.log(`${d} ${o} (${l.steps.length} steps, ${l.finishedAt-l.startedAt}ms)`);for(let f of l.steps){let p=KW(f.step);f.ok?f.resolvedBy&&f.resolvedBy!=="selector"?console.log(` \u26A1 ${f.index+1}. ${p} \u2014 healed via anchors.${f.resolvedBy}`):console.log(` \u2713 ${f.index+1}. ${p} (${f.durationMs}ms)`):console.log(` \u2717 ${f.index+1}. ${p}: ${f.error}`)}l.pass||i++}process.exitCode=i>0?1:0}function KW(t){switch(t.kind){case"tapOn":return`tapOn ${t.selector.id??t.selector.text??"point"}`;case"assertVisible":case"assertNotVisible":return`${t.kind} ${t.selector.id??t.selector.text??""}`;case"launchApp":return`launchApp${t.appId?` ${t.appId}`:""}`;case"inputText":return`inputText "${t.text.length>24?t.text.slice(0,23)+"\u2026":t.text}"`;default:return t.kind}}async function JW(t){let{values:e,positionals:r}=Ar({args:t,options:{app:{type:"string"},device:{type:"string"},save:{type:"string"},model:{type:"string"},"max-steps":{type:"string",default:"40"},url:{type:"string"},"token-auth":{type:"string"}},allowPositionals:!0}),n=r.join(" ").trim();if(!n)throw new Error('simon explore "<goal>"');let s=await en({url:e.url,token:e["token-auth"]}),i=await Xs(s,e.device);console.log(`\u25C6 exploring: ${n}`);let o=await pE({client:s,udid:i,goal:n,appId:e.app,model:e.model,maxSteps:Number(e["max-steps"]),onThought:a=>console.log(` ${a.split(`
|
|
305
307
|
`)[0]}`)});if(console.log(`
|
|
306
|
-
${o.pass?"\u2713 PASS":"\u2717 FAIL"} \u2014 ${o.summary}`),console.log(` ${o.steps} steps \xB7 ${o.inputTokens}in/${o.outputTokens}out tokens`),e.save&&o.pass){let c=(await s.events(i,o.firstSeq-1)).filter(l=>l.seq>=o.firstSeq&&l.seq<=o.lastSeq),u=
|
|
307
|
-
drive the scenario any way you like \u2014 browser UI, MCP, CLI \u2014 then:
|
|
308
|
+
${o.pass?"\u2713 PASS":"\u2717 FAIL"} \u2014 ${o.summary}`),console.log(` ${o.steps} steps \xB7 ${o.inputTokens}in/${o.outputTokens}out tokens`),e.save&&o.pass){let c=(await s.events(i,o.firstSeq-1)).filter(l=>l.seq>=o.firstSeq&&l.seq<=o.lastSeq),u=wi(c,{name:e.save.replace(/^.*\//,"").replace(/\.ya?ml$/,""),appId:e.app,recordedBy:`agent:${o.runId}`,recordedAt:new Date().toISOString()});await UW(sN(Ao(e.save)),{recursive:!0}),await Nv(Ao(e.save),u,"utf8"),console.log(` saved deterministic flow \u2192 ${e.save} (re-runs are free: ${Pe} run ${e.save})`)}process.exitCode=o.pass?0:1}async function GW(t){let{values:e,positionals:r}=Ar({args:t,options:{id:{type:"string"},device:{type:"string"}},allowPositionals:!0}),n=await en(),s=await Xs(n,e.device),i=e.id?{id:e.id}:{text:r.join(" ")},o=await n.action(s,iN,{type:"tap",selector:i});if(!o.ok)throw new Error(o.error);console.log(`\u2713 tapped ${JSON.stringify(i)}`)}async function YW(t){let{values:e,positionals:r}=Ar({args:t,options:{device:{type:"string"}},allowPositionals:!0}),n=await en(),s=await Xs(n,e.device),i=await n.screenshotPng(s,iN),o=Ao(r[0]??`screenshot-${Date.now()}.png`);await Nv(o,i),console.log(o)}async function XW(t){let{values:e}=Ar({args:t,options:{device:{type:"string"}}}),r=await en(),n=await Xs(r,e.device),{renderUiTree:s}=await Promise.resolve().then(()=>(sn(),tx)),i=await r.uiSnapshot(n);console.log(s(i,{interactiveOnly:!0}).text)}async function QW(t){let{values:e,positionals:r}=Ar({args:t,options:{out:{type:"string"}},allowPositionals:!0}),n=r[0];if(!n)throw new Error("simon export <flow.yaml> [--out file]");let{exportMaestroYaml:s}=await Promise.resolve().then(()=>(va(),w$)),i=await br(Ao(n)),o=s(i),a=Ao(e.out??n.replace(/\.ya?ml$/,"")+".maestro.yaml");await Nv(a,o,"utf8"),console.log(a),console.log(`run it with upstream maestro: maestro test ${a}`)}async function eK(t){let e=t[0],{values:r,positionals:n}=Ar({args:t.slice(1),options:{device:{type:"string"},save:{type:"string"},app:{type:"string"}},allowPositionals:!0}),{startRecording:s,stopRecording:i,readMarker:o,discardRecording:a}=await Promise.resolve().then(()=>(Pv(),QA)),c=await $p(),u=c?new ai(c):null;if(!u||!await u.ping())throw new Error(`\`${Pe} record\` needs a running daemon \u2014 start \`${Pe} serve\` first`);switch(e){case"start":{let l=n[0];if(!l)throw new Error(`${Pe} record start <name>`);let d=await Xs(u,r.device),f=await s(u,l,d);console.log(`\u25CF recording "${f.name}" (device ${d.slice(0,8)}\u2026, from seq ${f.fromSeq})
|
|
309
|
+
drive the scenario any way you like \u2014 browser UI, MCP, CLI \u2014 then: ${Pe} record stop`);return}case"stop":{let l=await i(u,{...r.save?{savePath:r.save}:{},...r.app?{appId:r.app}:{}});console.log(`\u25A0 recorded ${l.eventCount} events \u2192 ${l.outPath}`),console.log(` replay (zero tokens): ${Pe} run ${l.outPath}`);return}case"status":{let l=await o();console.log(l?`\u25CF recording "${l.name}" since ${l.startedAt} (from seq ${l.fromSeq})`:"no active recording");return}case"discard":{let l=await a();console.log(l?`discarded recording "${l.name}"`:"no active recording");return}default:throw new Error(`${Pe} record start|stop|status|discard`)}}async function tK(t){let{values:e}=Ar({args:t,options:{follow:{type:"boolean",short:"f",default:!1},device:{type:"string"}}}),r=await en(),n=s=>{let i=new Date(s.ts).toISOString().slice(11,23);console.log(`${i} [${s.source.kind}] ${s.deviceId.slice(0,8)} ${JSON.stringify(s.event)}`)};for(let s of await r.events(e.device))n(s);e.follow&&(r.streamEvents(n),await new Promise(()=>{}))}export{nie as main};
|